-
-
Notifications
You must be signed in to change notification settings - Fork 190
test: add authjs tests and bump dependencies #1088
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
Open
phoenix-ru
wants to merge
4
commits into
main
Choose a base branch
from
test/add-authjs-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,667
β1,423
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
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, | ||
| /* 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,73 @@ | ||
| import { createPage, setup } from '@nuxt/test-utils/e2e' | ||
| import { expect as playwrightExpect } from '@nuxt/test-utils/playwright' | ||
| import { describe, it } from 'vitest' | ||
|
|
||
| const STATUS_AUTHENTICATED = 'authenticated' | ||
| const STATUS_UNAUTHENTICATED = 'unauthenticated' | ||
|
|
||
| const BASE_URL = 'http://127.0.0.1:3000' | ||
|
|
||
| describe('authjs Provider', async () => { | ||
| await setup({ | ||
| runner: 'vitest', | ||
| browser: true, | ||
| port: 3000, | ||
| env: { | ||
| AUTH_ORIGIN: `${BASE_URL}/api/auth`, | ||
| }, | ||
| }) | ||
|
|
||
| it('load, sign in, reload, refresh, sign out', async () => { | ||
| const page = await createPage('/', { baseURL: BASE_URL }) | ||
|
|
||
| // Locators | ||
| const [ | ||
| signInButton, | ||
| status, | ||
| signoutButton, | ||
| refreshRequiredFalseButton, | ||
| refreshRequiredTrueButton | ||
| ] = await Promise.all([ | ||
| page.getByTestId('signin'), | ||
| page.getByTestId('status'), | ||
| page.getByTestId('signout'), | ||
| page.getByTestId('refresh-required-false'), | ||
| page.getByTestId('refresh-required-true') | ||
| ]) | ||
|
|
||
| // Unauthenticated at first | ||
| await playwrightExpect(status).toHaveText(STATUS_UNAUTHENTICATED) | ||
|
|
||
| // Trigger normal signin page | ||
| await signInButton.click() | ||
| await playwrightExpect(page).toHaveURL(toUrl('/api/auth/signin?callbackUrl=%2F')) | ||
|
|
||
| // Fill username and password, submit | ||
| await page.getByPlaceholder('(hint: jsmith)').fill('jsmith') | ||
| await page.getByPlaceholder('(hint: hunter2)').fill('hunter2') | ||
| await page.getByRole('button', { name: 'Sign in with Credentials' }).click() | ||
|
|
||
| await playwrightExpect(page).toHaveURL(toUrl('/')) | ||
| 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) | ||
| }, 30000) | ||
| }) | ||
|
|
||
| function toUrl(path: string): string { | ||
| return new URL(path, BASE_URL).href | ||
| } |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pretty big bump to
vue-tsc. Are there any other packages that make sense to update too (e.g. jump totypescript6?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Soooo? π