-
Notifications
You must be signed in to change notification settings - Fork 0
added playwright fixture to reset db #98
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a3b0df6
added playwright fixture to reset db
benjaminstrasser b676469
added transactional context to up migrations
benjaminstrasser bf0f4fb
added local testing to playwright setup
benjaminstrasser 3d64c38
sped up migrations inside e2e tests
benjaminstrasser 7b28bb6
minor changes
benjaminstrasser 49c4b34
added programatic way to setup user and barebone projects e2e test
benjaminstrasser 25850d0
renamed projects test
benjaminstrasser 9dd4312
added support for e2e database and added feedback for minor stuff
benjaminstrasser 06882c0
synced versions of playwright inside github actions
benjaminstrasser 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,7 @@ npm-debug.log* | |
| /playwright/.cache/ | ||
| /playwright-report | ||
|
|
||
| db.sqlite | ||
| db*.sqlite | ||
|
|
||
| /build | ||
| /.svelte-kit | ||
|
|
||
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,8 @@ | ||
| import { testWithUser as test } from './fixtures' | ||
|
|
||
| test.describe('create project', { tag: ['@foo-bar'] }, () => { | ||
| test('projects', async ({ page }) => { | ||
| await page.goto('/projects') | ||
| // TODO add test | ||
| }) | ||
| }) | ||
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,23 @@ | ||
| import { test as base } from '@playwright/test' | ||
| import { migrate, undoMigration } from 'services/kysely/migrator.util' | ||
| import { setupUser } from './util' | ||
|
|
||
| export const test = base.extend({ | ||
| page: async ({ page }, use) => { | ||
| // clean up the database | ||
| await undoMigration() | ||
|
|
||
| // set up the database | ||
| await migrate() | ||
benjaminstrasser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| await use(page) | ||
| } | ||
| }) | ||
|
|
||
| export const testWithUser = test.extend({ | ||
| page: async ({ page }, use) => { | ||
| await setupUser(page.request) | ||
|
|
||
| await use(page) | ||
| } | ||
| }) | ||
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,39 @@ | ||
| import { type APIRequestContext, type Page, expect } from '@playwright/test' | ||
|
|
||
| export async function waitForHydration(page: Page) { | ||
| await page.locator('.hydrated').waitFor({ state: 'visible' }) | ||
| } | ||
|
|
||
| export async function setupUser(request: APIRequestContext) { | ||
| await register(request) | ||
| await login(request) | ||
| } | ||
|
|
||
| export async function register(request: APIRequestContext) { | ||
| const signup = await request.post('/signup', { | ||
| headers: { | ||
| origin: 'http://localhost:3000' | ||
| }, | ||
| form: { | ||
| first_name: 'test', | ||
| last_name: 'test', | ||
| email: 'test@test.com', | ||
| password: 'password', | ||
| confirmPassword: 'password', | ||
| termsOfService: 'true' | ||
| } | ||
| }) | ||
|
|
||
| expect(signup.ok()).toBeTruthy() | ||
| } | ||
|
|
||
| export async function login(request: APIRequestContext) { | ||
| const login = await request.post('/login', { | ||
| headers: { | ||
| origin: 'http://localhost:3000' | ||
| }, | ||
| form: { email: 'test@test.com', password: 'password' } | ||
| }) | ||
|
|
||
| expect(login.ok()).toBeTruthy() | ||
| } |
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,27 @@ | ||
| import { type PlaywrightTestConfig, devices } from '@playwright/test' | ||
|
|
||
| const WEB_SERVER_PORT = 3000 | ||
| const config: PlaywrightTestConfig = { | ||
| testDir: './e2e/specs', | ||
| outputDir: './e2e/results', | ||
| projects: [ | ||
| { | ||
| name: 'Chrome', | ||
| testMatch: /.*\.spec\.ts/, | ||
| use: { | ||
| ...devices['Desktop Chrome'] | ||
| } | ||
| } | ||
| ], | ||
| use: { | ||
| baseURL: `http://localhost:${WEB_SERVER_PORT}`, | ||
| bypassCSP: true | ||
| }, | ||
| webServer: { | ||
| command: 'pnpm run dev:e2e', | ||
| port: WEB_SERVER_PORT | ||
| }, | ||
| reporter: [['list']] | ||
| } | ||
|
|
||
| export default config | ||
benjaminstrasser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
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.