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
cbe0841
commit 520e553
Showing
6 changed files
with
42 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
NODE_ENV=test | ||
|
||
PUBLIC_SUPABASE_URL=https://your-project.supabase.co | ||
PUBLIC_SUPABASE_ANON_KEY=your-anon-key | ||
|
||
MAILSLURP_APIKEY=your-mailslurp-api-key | ||
MAILSLURP_MAILBOX_ID=your-mailslurp-mailbox-id | ||
MAILSLURP_EMAIL_ADDRESS=your-mailslurp-email-address | ||
MAILBOX_ID=your-mailbox-id | ||
EMAIL_ADDRESS=your-email-address | ||
INBUCKET_URL=http://127.0.0.1:54324 |
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 |
---|---|---|
@@ -1,21 +1,19 @@ | ||
import type { PlaywrightTestConfig } from '@playwright/test'; | ||
import * as dotenv from "dotenv"; | ||
import * as dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
|
||
process.env['NODE_ENV'] = 'test'; | ||
|
||
const config: PlaywrightTestConfig = { | ||
use: { | ||
baseURL: 'http://localhost:4173', | ||
storageState: 'storage-state.json', | ||
storageState: 'storage-state.json' | ||
}, | ||
webServer: { | ||
command: 'npm run build && npm run preview', | ||
url: 'http://localhost:4173' | ||
}, | ||
testDir: 'tests/e2e', | ||
globalSetup: './tests/helper/global-setup.ts', | ||
globalSetup: './tests/helper/global-setup.ts' | ||
}; | ||
|
||
export default config; |
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 |
---|---|---|
@@ -1,15 +1,9 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test.describe('devices', () => { | ||
|
||
test('authenticated', async ({ page }) => { | ||
await page.goto("/devices"); | ||
|
||
// Print page content to console | ||
//console.log(await page.textContent('body')); | ||
|
||
await expect( | ||
page.getByRole('heading', { name: 'Device List' }) | ||
).toBeVisible(); | ||
await page.goto('/devices'); | ||
|
||
await expect(page.getByRole('heading', { name: 'Device List' })).toBeVisible(); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,37 +1,35 @@ | ||
import { chromium, type FullConfig } from '@playwright/test' | ||
import { chromium, type FullConfig } from '@playwright/test'; | ||
import { InbucketAPIClient } from 'inbucket-js-client'; | ||
|
||
const emailAddress = process.env.MAILSLURP_EMAIL_ADDRESS as string; | ||
const mailboxId = process.env.MAILSLURP_MAILBOX_ID as string; | ||
const client = new InbucketAPIClient('http://127.0.0.1:54324'); | ||
const emailAddress = process.env.EMAIL_ADDRESS as string; | ||
const mailboxId = process.env.MAILBOX_ID as string; | ||
const client = new InbucketAPIClient(process.env.INBUCKET_URL as string); | ||
|
||
async function globalSetup(config: FullConfig) { | ||
const browser = await chromium.launch() | ||
const page = await browser.newPage() | ||
|
||
await page.goto(`${config.webServer?.url}/login`) | ||
|
||
await page | ||
.locator('input[name="email"]') | ||
.type(emailAddress, { delay: 100 }); | ||
|
||
await page | ||
.locator('button[type="submit"]') | ||
.click({ delay: 100 }); | ||
|
||
await page.waitForSelector( | ||
`text=An email was sent with a magic link. Please check your mailbox.` | ||
); | ||
|
||
const inbox = await client.mailbox(mailboxId) | ||
const email = await client.message(mailboxId, inbox[0].id) | ||
const matches = email.body?.html.match(/href="([^"]*)"/); | ||
const href = matches?.[1] as string; | ||
|
||
await page.goto(href); | ||
await page.context().storageState({ path: 'storage-state.json' }) | ||
await browser.close(); | ||
await client.prugeMailbox(mailboxId); | ||
const browser = await chromium.launch(); | ||
const page = await browser.newPage(); | ||
|
||
await page.goto(`${config.webServer?.url}/login`); | ||
|
||
await page.locator('input[name="email"]').type(emailAddress, { delay: 100 }); | ||
|
||
await page.locator('button[type="submit"]').click({ delay: 100 }); | ||
|
||
await page.waitForSelector( | ||
`text=An email was sent with a magic link. Please check your mailbox.` | ||
); | ||
|
||
const inbox = await client.mailbox(mailboxId); | ||
|
||
const email = await client.message(mailboxId, inbox[inbox.length - 1].id); | ||
const matches = email.body?.html.match(/href="([^"]*)"/); | ||
const href = (matches?.[1] as string).replace(/&/g, '&'); | ||
|
||
await page.goto(href); | ||
await page.screenshot({ path: 'shit.png' }); | ||
await page.context().storageState({ path: 'storage-state.json' }); | ||
await browser.close(); | ||
await client.prugeMailbox(mailboxId); | ||
} | ||
|
||
export default globalSetup | ||
export default globalSetup; |