-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31fd536
commit 7c03444
Showing
13 changed files
with
136 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
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"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.