-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { Page } from "@playwright/test"; | ||
|
||
declare global { | ||
interface Window { | ||
E2E_CLIPBOARD_VALUE?: string; | ||
} | ||
} | ||
|
||
export type Window = typeof window; | ||
// creates the single server fixture | ||
export const createClipboardFixture = (page: Page) => { | ||
return { | ||
reset: async () => { | ||
await page.evaluate(() => { | ||
delete window.E2E_CLIPBOARD_VALUE; | ||
}); | ||
}, | ||
get: async () => { | ||
return getClipboardValue({ page }); | ||
}, | ||
}; | ||
}; | ||
|
||
function getClipboardValue({ page }: { page: Page }) { | ||
return page.evaluate(() => { | ||
return new Promise<string>((resolve, reject) => { | ||
setInterval(() => { | ||
if (!window.E2E_CLIPBOARD_VALUE) return; | ||
resolve(window.E2E_CLIPBOARD_VALUE); | ||
}, 500); | ||
setTimeout(() => reject(new Error("Timeout")), 1000); | ||
}); | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { Page } from "@playwright/test"; | ||
import { expect } from "@playwright/test"; | ||
import { JSDOM } from "jsdom"; | ||
// eslint-disable-next-line no-restricted-imports | ||
import type { API, Messages } from "mailhog"; | ||
|
||
import { getEmailsReceivedByUser } from "../lib/testUtils"; | ||
|
||
export async function expectInvitationEmailToBeReceived( | ||
page: Page, | ||
emails: API | undefined, | ||
userEmail: string, | ||
subject: string, | ||
returnLink?: string | ||
) { | ||
if (!emails) return null; | ||
// We need to wait for the email to go through, otherwise it will fail | ||
// eslint-disable-next-line playwright/no-wait-for-timeout | ||
await page.waitForTimeout(2000); | ||
const receivedEmails = await getEmailsReceivedByUser({ emails, userEmail }); | ||
expect(receivedEmails?.total).toBe(1); | ||
Check failure on line 21 in apps/web/playwright/organization/expects.ts GitHub Actions / E2E tests / E2E tests (4/5)[@calcom/web] › apps/web/playwright/organization/organization-creation.e2e.ts:21:7 › Organization › should be able to create an organization and complete onboarding
Check failure on line 21 in apps/web/playwright/organization/expects.ts GitHub Actions / E2E tests / E2E tests (4/5)[@calcom/web] › apps/web/playwright/organization/organization-creation.e2e.ts:21:7 › Organization › should be able to create an organization and complete onboarding
Check failure on line 21 in apps/web/playwright/organization/expects.ts GitHub Actions / E2E tests / E2E tests (4/5)[@calcom/web] › apps/web/playwright/organization/organization-creation.e2e.ts:21:7 › Organization › should be able to create an organization and complete onboarding
Check failure on line 21 in apps/web/playwright/organization/expects.ts GitHub Actions / E2E tests / E2E tests (4/5)[@calcom/web] › apps/web/playwright/organization/organization-invitation.e2e.ts:15:7 › Organization › Invitation (non verified)
Check failure on line 21 in apps/web/playwright/organization/expects.ts GitHub Actions / E2E tests / E2E tests (4/5)[@calcom/web] › apps/web/playwright/organization/organization-invitation.e2e.ts:15:7 › Organization › Invitation (non verified)
|
||
const [firstReceivedEmail] = (receivedEmails as Messages).items; | ||
expect(firstReceivedEmail.subject).toBe(subject); | ||
if (!returnLink) return; | ||
const dom = new JSDOM(firstReceivedEmail.html); | ||
const anchor = dom.window.document.querySelector(`a[href*="${returnLink}"]`); | ||
return anchor?.getAttribute("href"); | ||
} |