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

fix(e2e): Runs email-link tests #4873

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/lazy-mice-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
14 changes: 13 additions & 1 deletion integration/testUtils/emailService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ type Message = {
subject: string;
};

interface ErrorResponse {
message: string;
error: string;
}

type InboxFilterResponse = { messages: Message[] } | ErrorResponse;

export const createEmailService = () => {
const cleanEmail = (email: string) => {
return email.replace(/\+.*@/, '@');
Expand All @@ -27,7 +34,12 @@ export const createEmailService = () => {
return runWithExponentialBackOff(
async () => {
const res = await fetcher(url);
const json = (await res.json()) as unknown as { messages: Message[] };
const json = (await res.json()) as InboxFilterResponse;
if ('message' in json) {
throw new Error(`Mailsac API Error: ${json.error} - ${json.message}`);
}
throw new Error(Object.keys(json).join(', '));

const message = json.messages[0];
if (!message) {
throw new Error('message not found');
Expand Down
8 changes: 4 additions & 4 deletions integration/tests/email-link.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { Application } from '../models/application';
import { appConfigs } from '../presets';
import { createTestUtils } from '../testUtils';

test.describe('sign up and sign in using email link', () => {
const configs = [];
test.describe('sign up and sign in using email link @generic', () => {
const configs = [appConfigs.next.appRouter, appConfigs.react.vite];

configs.forEach(config => {
test.describe(`${config.name}`, () => {
Expand Down Expand Up @@ -81,7 +81,7 @@ const performSignUpVerificationLinkSameDevice = async (
searchParams?: URLSearchParams,
) => {
const u = createTestUtils({ app, page, context });
const fakeUser = u.services.users.createFakeUser();
const fakeUser = u.services.users.createFakeUser({ fictionalEmail: false, withPassword: true });
await u.po.signUp.goTo({ searchParams });
await u.po.signUp.signUpWithEmailAndPassword({ email: fakeUser.email, password: fakeUser.password });
await u.po.signUp.waitForEmailVerificationScreen();
Expand All @@ -103,7 +103,7 @@ const performSignUpVerificationLinkDifferentDevice = async (
searchParams?: URLSearchParams,
) => {
const u = createTestUtils({ app, page, context, browser });
const fakeUser = u.services.users.createFakeUser();
const fakeUser = u.services.users.createFakeUser({ fictionalEmail: false, withPassword: true });
await u.po.signUp.goTo({ searchParams });
await u.po.signUp.signUpWithEmailAndPassword({ email: fakeUser.email, password: fakeUser.password });
await u.po.signUp.waitForEmailVerificationScreen();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"test:integration:elements": "E2E_APP_ID=elements.* pnpm test:integration:base --grep @elements",
"test:integration:expo-web": "E2E_APP_ID=expo.expo-web pnpm test:integration:base --grep @expo-web",
"test:integration:express": "E2E_APP_ID=express.* pnpm test:integration:base --grep @express",
"test:integration:generic": "E2E_APP_ID=react.vite.*,next.appRouter.withEmailCodes* pnpm test:integration:base --grep @generic",
"test:integration:generic": "E2E_APP_ID=react.vite.*,next.appRouter.* pnpm test:integration:base --grep @generic",
"test:integration:nextjs": "E2E_APP_ID=next.appRouter.* pnpm test:integration:base --grep @nextjs",
"test:integration:nuxt": "E2E_APP_ID=nuxt.node npm run test:integration:base -- --grep @nuxt",
"test:integration:quickstart": "E2E_APP_ID=quickstart.* pnpm test:integration:base --grep @quickstart",
Expand Down
Loading