-
-
Notifications
You must be signed in to change notification settings - Fork 188
test: add Playwright #694
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
Merged
Merged
test: add Playwright #694
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
af52453
test: add Playwright to local provider
phoenix-ru 694dd90
Merge branch 'main' into feature/add-playwright-tests
zoey-kaiser ddd5036
test: improve local provider spec to check for page reload, refresh aβ¦
phoenix-ru 46474e3
test: add basic tests for refresh provider
phoenix-ru c0b2c27
chore: update github actions versions
phoenix-ru 3ebc0be
test: remove timeout check for refresh provider
phoenix-ru f13f45b
Merge branch 'main' into feature/add-playwright-tests
phoenix-ru 9256246
test: use a better name
phoenix-ru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,5 @@ | ||
| node_modules/ | ||
| /test-results/ | ||
| /playwright-report/ | ||
| /blob-report/ | ||
| /playwright/.cache/ |
This file contains hidden or 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 hidden or 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 hidden or 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,77 @@ | ||
| import { defineConfig, devices } from '@playwright/test' | ||
|
|
||
| /** | ||
| * Read environment variables from file. | ||
| * https://github.com/motdotla/dotenv | ||
| */ | ||
| // require('dotenv').config(); | ||
|
|
||
| /** | ||
| * See https://playwright.dev/docs/test-configuration. | ||
| */ | ||
| export default defineConfig({ | ||
| testDir: './tests', | ||
| /* Run tests in files in parallel */ | ||
| fullyParallel: true, | ||
| /* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
| forbidOnly: !!process.env.CI, | ||
| /* Retry on CI only */ | ||
| retries: process.env.CI ? 2 : 0, | ||
zoey-kaiser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /* Opt out of parallel tests on CI. */ | ||
| workers: process.env.CI ? 1 : undefined, | ||
| /* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
| reporter: 'html', | ||
| /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
| use: { | ||
| /* Base URL to use in actions like `await page.goto('/')`. */ | ||
| // baseURL: 'http://127.0.0.1:3000', | ||
|
|
||
| /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
| trace: 'on-first-retry' | ||
| }, | ||
|
|
||
| /* Configure projects for major browsers */ | ||
| projects: [ | ||
| { | ||
| name: 'chromium', | ||
| use: { ...devices['Desktop Chrome'] } | ||
| }, | ||
|
|
||
| { | ||
| name: 'firefox', | ||
| use: { ...devices['Desktop Firefox'] } | ||
| } | ||
|
|
||
| // { | ||
| // name: 'webkit', | ||
| // use: { ...devices['Desktop Safari'] } | ||
| // } | ||
|
|
||
| /* Test against mobile viewports. */ | ||
| // { | ||
| // name: 'Mobile Chrome', | ||
| // use: { ...devices['Pixel 5'] }, | ||
| // }, | ||
| // { | ||
| // name: 'Mobile Safari', | ||
| // use: { ...devices['iPhone 12'] }, | ||
| // }, | ||
|
|
||
| /* Test against branded browsers. */ | ||
| // { | ||
| // name: 'Microsoft Edge', | ||
| // use: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
| // }, | ||
| // { | ||
| // name: 'Google Chrome', | ||
| // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, | ||
| // }, | ||
| ] | ||
|
|
||
| /* Run your local dev server before starting the tests */ | ||
| // webServer: { | ||
| // command: 'npm run start', | ||
| // url: 'http://127.0.0.1:3000', | ||
| // reuseExistingServer: !process.env.CI, | ||
| // }, | ||
| }) | ||
This file contains hidden or 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,62 @@ | ||
| import { describe, test } from 'vitest' | ||
| import { setup, createPage } from '@nuxt/test-utils/e2e' | ||
| import { expect as playwrightExpect } from '@playwright/test' | ||
|
|
||
| const STATUS_AUTHENTICATED = 'authenticated' | ||
| const STATUS_UNAUTHENTICATED = 'unauthenticated' | ||
|
|
||
| describe('Local Provider', async () => { | ||
| await setup({ | ||
| runner: 'vitest', | ||
| browser: true | ||
| }) | ||
|
|
||
| test('load, sign in, reload, refresh, sign out', async () => { | ||
| const page = await createPage('/') | ||
| const [ | ||
| usernameInput, | ||
| passwordInput, | ||
| submitButton, | ||
| status, | ||
| signoutButton, | ||
| refreshRequiredFalseButton, | ||
| refreshRequiredTrueButton | ||
| ] = await Promise.all([ | ||
| page.getByTestId('username'), | ||
| page.getByTestId('password'), | ||
| page.getByTestId('submit'), | ||
| page.getByTestId('status'), | ||
| page.getByTestId('signout'), | ||
| page.getByTestId('refresh-required-false'), | ||
| page.getByTestId('refresh-required-true') | ||
| ]) | ||
|
|
||
| await playwrightExpect(status).toHaveText(STATUS_UNAUTHENTICATED) | ||
|
|
||
| await usernameInput.fill('hunter') | ||
| await passwordInput.fill('hunter2') | ||
|
|
||
| // Click button and wait for API to finish | ||
| const responsePromise = page.waitForResponse(/\/api\/auth\/login/) | ||
| await submitButton.click() | ||
| await responsePromise | ||
|
|
||
| await playwrightExpect(status).toHaveText(STATUS_AUTHENTICATED) | ||
|
|
||
| // Ensure that we are still authenticated after page refresh | ||
| await page.reload() | ||
| await playwrightExpect(status).toHaveText(STATUS_AUTHENTICATED) | ||
|
|
||
| // Refresh (required: false), status should not change | ||
| await refreshRequiredFalseButton.click() | ||
| await playwrightExpect(status).toHaveText(STATUS_AUTHENTICATED) | ||
|
|
||
| // Refresh (required: true), status should not change | ||
| await refreshRequiredTrueButton.click() | ||
| await playwrightExpect(status).toHaveText(STATUS_AUTHENTICATED) | ||
|
|
||
| // Sign out, status should change | ||
| await signoutButton.click() | ||
| await playwrightExpect(status).toHaveText(STATUS_UNAUTHENTICATED) | ||
| }) | ||
| }) |
This file contains hidden or 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,7 @@ | ||
| import { defineConfig } from 'vitest/config' | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| include: ['tests/*.spec.ts'] | ||
| } | ||
| }) |
This file contains hidden or 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,5 @@ | ||
| node_modules/ | ||
| /test-results/ | ||
| /playwright-report/ | ||
| /blob-report/ | ||
| /playwright/.cache/ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.