Skip to content

Commit

Permalink
fix comments, add err catches
Browse files Browse the repository at this point in the history
  • Loading branch information
vincanger committed Apr 12, 2024
1 parent 11bc2c6 commit 392e9fa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ jobs:
- name: Run Playwright tests
env:
# The e2e tests are testing parts of the app that need OPENAI_API_KEY, so we need to set it here.
# The e2e tests are testing parts of the app that need certain env vars, so we need to access them here.
# These secretes can be set in your GitHub repo settings, e.g. https://github.com/<account>/<repo>/settings/secrets/actions
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
STRIPE_KEY: ${{ secrets.STRIPE_KEY }}
STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_SECRET }}
Expand Down
10 changes: 3 additions & 7 deletions e2e-tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default defineConfig({
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
Expand All @@ -32,20 +32,16 @@ export default defineConfig({
},
],

// globalSetup: require.resolve('./global-setup'), // TODO add dummy env vars here
// globalTeardown: require.resolve('./global-teardown'),

// TODO: change this comment for local testing --
/**
* There seems to be a bug that keeps the webserver open after running tests locally https://github.com/microsoft/playwright/issues/11907
* causing errors when trying to run `wasp start` afterwards. To avoid this, we can run the webserver only on CI.
* For local development, we start the app manually with `wasp start` and then run `npx playwright test` to run the tests.
* For local development, we start the app manually with `wasp db start` and `wasp start` and then `npm run local:e2e:start`.
*/
webServer: {
command: 'npm run ci:e2e:start',
// Wait for the backend to start
url: 'http://localhost:3001',
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
}
},
});
21 changes: 13 additions & 8 deletions e2e-tests/tests/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test as base, type Page } from '@playwright/test';
import { type Page } from '@playwright/test';
import { randomUUID } from 'crypto';

export type User = {
Expand All @@ -13,7 +13,7 @@ export const logUserIn = async ({ page, user }: { page: Page; user: User }) => {
await page.goto('/');

await page.getByRole('link', { name: 'Log in' }).click();

await page.waitForURL('**/login', {
waitUntil: 'domcontentloaded',
});
Expand All @@ -25,9 +25,12 @@ export const logUserIn = async ({ page, user }: { page: Page; user: User }) => {
const clickLogin = page.click('button:has-text("Log in")');

await Promise.all([
page.waitForResponse((response) => {
return response.url().includes('login') && response.status() === 200;
}),
page
.waitForResponse((response) => {
return response.url().includes('login') && response.status() === 200;
})
.catch((err) => console.error(err.message)),
,
clickLogin,
]);

Expand All @@ -47,9 +50,11 @@ export const signUserUp = async ({ page, user }: { page: Page; user: User }) =>

await page.click('button:has-text("Sign up")');

await page.waitForResponse((response) => {
return response.url().includes('signup') && response.status() === 200;
});
await page
.waitForResponse((response) => {
return response.url().includes('signup') && response.status() === 200;
})
.catch((err) => console.error(err.message));
};

export const createRandomUser = () => {
Expand Down

0 comments on commit 392e9fa

Please sign in to comment.