-
-
Notifications
You must be signed in to change notification settings - Fork 252
feat: add simple e2e tests #1014
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
steveiliop56
wants to merge
13
commits into
main
Choose a base branch
from
feat/e2e
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.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
226df14
feat: add simple e2e tests
steveiliop56 423ad7b
fix: rabbit fixes
steveiliop56 d8ee3e7
feat: add netcheck command for debugging
steveiliop56 4eeede6
chore: run dev server in background to see why actions can't reach sslip
steveiliop56 90ff78b
chore: add sslip to hosts
steveiliop56 6b77777
chore: try a newer nodejs version
steveiliop56 b327dd1
chore: try a different traefik version
steveiliop56 86c6c71
fix: use correct docker socket path
steveiliop56 afacc5c
fix: strip out unix prefix from docker socket
steveiliop56 bf83708
chore: try to omit playwright
steveiliop56 2138902
fix: remove custom socket stuff
steveiliop56 9f9a87e
idk: use docker ps
steveiliop56 bb1aa72
refactor: replace traefik with caddy
steveiliop56 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: Run e2e tests | ||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| test: | ||
| timeout-minutes: 30 | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # ratchet:actions/checkout@v7 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # ratchet:pnpm/action-setup@v6 | ||
| with: | ||
| package_json_file: ./e2e/package.json | ||
|
|
||
| - name: Set up Docker | ||
| uses: docker/setup-docker-action@6d7cfa65f60a9dda7b46e5513fa982536f3c9877 # ratchet:docker/setup-docker-action@v5 | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm ci | ||
| working-directory: e2e | ||
|
|
||
| - name: Install Playwright Browsers | ||
| run: pnpm exec playwright install --with-deps | ||
| working-directory: e2e | ||
|
|
||
| - name: Run Playwright tests | ||
| run: pnpm test | ||
| working-directory: e2e | ||
|
|
||
| - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # ratchet:actions/upload-artifact@v4 | ||
| if: ${{ !cancelled() }} | ||
| with: | ||
| name: playwright-report | ||
| path: e2e/playwright-report/ | ||
| retention-days: 5 | ||
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 @@ | ||
| # playwright files | ||
| /node_modules/ | ||
| /test-results/ | ||
| /playwright-report/ | ||
| /blob-report/ | ||
| /playwright/.cache/ | ||
| /playwright/.auth/ |
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,15 @@ | ||
| { | ||
| auto_https off | ||
| } | ||
|
|
||
| http://whoami.127.0.0.1.sslip.io { | ||
| forward_auth tinyauth:3000 { | ||
| uri /api/auth/caddy | ||
| copy_headers Remote-User Remote-Name Remote-Email Remote-Groups | ||
| } | ||
| reverse_proxy whoami:80 | ||
| } | ||
|
|
||
| http://tinyauth.127.0.0.1.sslip.io { | ||
| reverse_proxy tinyauth:3000 | ||
| } |
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,22 @@ | ||
| appUrl: http://tinyauth.127.0.0.1.sslip.io | ||
|
|
||
| log: | ||
| level: debug | ||
|
|
||
| auth: | ||
| users: | ||
| # user1:password,user2:password,user3:password:token | ||
| - user1:$2a$10$h1laww4k5a4bJcG5KwE3nO45YKSC4mOKHxbcccgxr3Y7H9zHlQe8e | ||
| - user2:$2a$10$h1laww4k5a4bJcG5KwE3nO45YKSC4mOKHxbcccgxr3Y7H9zHlQe8e | ||
| - user3:$2a$10$h1laww4k5a4bJcG5KwE3nO45YKSC4mOKHxbcccgxr3Y7H9zHlQe8e:MVR4JQWNXYKNM6HHJEYEFP2O74QIIEJE | ||
| # disable rate limits for multiple workers to work | ||
| loginMaxRetries: 0 | ||
|
|
||
| apps: | ||
| whoami: | ||
| config: | ||
| domain: whoami.127.0.0.1.sslip.io | ||
| path: | ||
| allow: /foo | ||
| users: | ||
| allow: user1 |
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,24 @@ | ||
| services: | ||
| caddy: | ||
| image: caddy:2.11.4 | ||
| pull_policy: missing | ||
| ports: | ||
| - 80:80 | ||
| volumes: | ||
| - ./conf:/etc/caddy | ||
|
|
||
| whoami: | ||
| image: traefik/whoami:v1.11.0 | ||
| pull_policy: missing | ||
|
|
||
| tinyauth: | ||
| build: | ||
| context: ../ | ||
| dockerfile: Dockerfile | ||
| args: | ||
| - VERSION=e2e | ||
| - BUILD_TAGS=nomsgpack | ||
| - LDFLAGS=-s -w | ||
| command: ["--configfile", "/app/config.yaml"] | ||
| volumes: | ||
| - ./config.e2e.yaml:/app/config.yaml:ro |
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,47 @@ | ||
| import {expect, Page} from '@playwright/test'; | ||
| import { OTP } from 'otplib'; | ||
|
|
||
| export class LoginFixture { | ||
| constructor(public readonly page: Page) {} | ||
|
|
||
| async run(username: string, password: string) { | ||
| await expect(this.page.getByText('Welcome back, please login')).toBeVisible(); | ||
| await this.page.getByLabel('Username').fill(username); | ||
| await this.page.getByLabel('Password').fill(password); | ||
| await this.page.getByRole('button', { name: 'Login' }).click(); | ||
| } | ||
|
|
||
| async expectSuccess(username: string) { | ||
| await expect(this.page.getByText(`You are currently logged in as ${username}.`)).toBeVisible() | ||
| } | ||
| } | ||
|
|
||
| export class LogoutFixture { | ||
| constructor(public readonly page: Page) {} | ||
|
|
||
| async run() { | ||
| await expect(this.page.getByText('Click the button below to logout.')).toBeVisible(); | ||
| await this.page.getByRole('button', { name: 'Logout' }).click(); | ||
| } | ||
|
|
||
| async expectSuccess() { | ||
| await expect(this.page.getByText('Welcome back, please login')).toBeVisible(); | ||
| } | ||
| } | ||
|
|
||
| export class TOTPFixture { | ||
| constructor(public readonly page: Page) {} | ||
|
|
||
| async run(secret: string) { | ||
| await expect(this.page.getByText('Enter your TOTP code')).toBeVisible(); | ||
| const otp = new OTP(); | ||
| const token = await otp.generate({ secret }); | ||
| await this.page.getByPlaceholder('XXXXXX').fill(token); | ||
| // we shouldn't need to click continue, it will auto submit | ||
| // await this.page.getByRole('button', { name: 'Continue' }).click(); | ||
| } | ||
|
|
||
| async expectSuccess(username: string) { | ||
| await expect(this.page.getByText(`You are currently logged in as ${username}.`)).toBeVisible() | ||
| } | ||
| } |
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,30 @@ | ||
| { | ||
| "name": "e2e", | ||
| "version": "1.0.0", | ||
| "description": "", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "down": "docker compose -f docker-compose.e2e.yml down", | ||
| "up": "docker compose -f docker-compose.e2e.yml up --build --force-recreate --remove-orphans", | ||
| "test": "playwright test", | ||
| "report": "playwright show-report" | ||
| }, | ||
| "keywords": [], | ||
| "author": "", | ||
| "license": "ISC", | ||
| "devEngines": { | ||
| "packageManager": { | ||
| "name": "pnpm", | ||
| "version": "^11.1.2", | ||
| "onFail": "download" | ||
| } | ||
| }, | ||
| "type": "module", | ||
| "devDependencies": { | ||
| "@playwright/test": "^1.61.1", | ||
| "@types/node": "^26.1.1" | ||
| }, | ||
| "dependencies": { | ||
| "otplib": "^13.4.1" | ||
| } | ||
| } |
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,49 @@ | ||
| import { defineConfig, devices } from '@playwright/test'; | ||
|
|
||
| export default defineConfig({ | ||
| testDir: './specs', | ||
| fullyParallel: true, | ||
| forbidOnly: false, | ||
| retries: 0, | ||
| workers: 4, | ||
| reporter: 'html', | ||
| use: { | ||
| trace: 'on-first-retry', | ||
| video: 'on', | ||
| }, | ||
| projects: [ | ||
| { | ||
| name: 'chromium', | ||
| use: { ...devices['Desktop Chrome'] }, | ||
| }, | ||
| { | ||
| name: 'firefox', | ||
| use: { ...devices['Desktop Firefox'] }, | ||
| }, | ||
|
|
||
| { | ||
| name: 'webkit', | ||
| use: { ...devices['Desktop Safari'] }, | ||
| }, | ||
| { | ||
| name: 'Mobile Chrome', | ||
| use: { ...devices['Pixel 5'] }, | ||
| }, | ||
| { | ||
| name: 'Mobile Safari', | ||
| use: { ...devices['iPhone 12'] }, | ||
| }, | ||
| ], | ||
| webServer: { | ||
| command: 'pnpm run up', | ||
| url: 'http://tinyauth.127.0.0.1.sslip.io/api/healthz', | ||
| reuseExistingServer: true, | ||
| timeout: 5 * 60 * 1000, | ||
| gracefulShutdown: { | ||
| signal: 'SIGINT', | ||
| timeout: 1000, | ||
| }, | ||
| stderr: 'pipe', | ||
| stdout: 'pipe', | ||
| }, | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| }); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.