Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2900 returning user flow #2948

Merged
merged 11 commits into from
Oct 9, 2024
6 changes: 4 additions & 2 deletions app/.env-example.env
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,7 @@ NEXT_PUBLIC_GA_ID=id


# Env vars for the scroll campaign
NEXT_PUBLIC_SCROLL_CAMPAIGN_SELECTED_PROVIDERS=["DeveloperList#PassportCommiterLevel1#7f421a19","DeveloperList#PassportCommiterLevel2#0d74972f","DeveloperList#PassportCommiterLevel3#8c6b910f","DeveloperList#PassportCommiterLevel4#9381f80a"]

NEXT_PUBLIC_SCROLL_CAMPAIGN_SELECTED_PROVIDERS='["DeveloperList#PassportCommiterLevel1#7f421a19","DeveloperList#PassportCommiterLevel2#0d74972f","DeveloperList#PassportCommiterLevel3#8c6b910f","DeveloperList#PassportCommiterLevel4#9381f80a"]'
NEXT_PUBLIC_SCROLL_CAMPAIGN_RPC_URL=https://scroll.drpc.org
NEXT_PUBLIC_SCROLL_CAMPAIGN_CONTRACT_ADDRESSES='["0x0000000000", "..."]'
NEXT_PUBLIC_SCROLL_CAMPAIGN_RPC_URL=https://scroll.drpc.org
37 changes: 37 additions & 0 deletions app/__tests__/components/ScrollCampaign.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useParams } from "react-router-dom";
import { CredentialResponseBody } from "@gitcoin/passport-types";
import { googleStampFixture } from "../../__test-fixtures__/databaseStorageFixtures";
import * as passportIdentity from "@gitcoin/passport-identity";
import { useScrollBadge } from "../../hooks/useScrollBadge";
import { PassportDatabase } from "@gitcoin/passport-database-client";

const navigateMock = jest.fn();
Expand Down Expand Up @@ -90,6 +91,19 @@ jest.mock("@gitcoin/passport-identity", () => {
};
});

jest.mock("../../hooks/useScrollBadge", () => {
return {
useScrollBadge: jest.fn().mockImplementation(() => {
return {
badges: [],
errors: {},
areBadgesLoading: false,
hasAtLeastOneBadge: false,
};
}),
};
});

describe("Landing page tests", () => {
it("goes to next page when login successful", async () => {
const mockUseLoginFlow = jest.fn().mockReturnValue({
Expand Down Expand Up @@ -247,4 +261,27 @@ describe("Github Connect page tests", () => {

expect(screen.getByText(/sorry/)).toBeInTheDocument();
});

it("navigates to the last step when the user already has at least a badge", async () => {
// Mocking the necessary context and hooks
(useScrollBadge as jest.Mock).mockReturnValue({
hasAtLeastOneBadge: true,
badges: [{ contract: "0X000", hasBadge: true, badgeLevel: 1, badgeUri: "https://example.com" }],
errors: {},
areBadgesLoading: false,
error: null,
});

renderWithContext(
mockCeramicContext,
<MemoryRouter initialEntries={["/campaign/scroll-developer/1"]}>
<AppRoutes />
</MemoryRouter>
);

// const canvasRedirectButton = screen.queryByTestId("canvasRedirectButton");
// expect(canvasRedirectButton).toBeInTheDocument();

expect(navigateMock).toHaveBeenCalledTimes(1);
});
});
Loading
Loading