generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add console e2e testing with playwright (#2462)
Fixes #2416
- Loading branch information
1 parent
3da112c
commit f2686f9
Showing
13 changed files
with
232 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -153,6 +153,9 @@ test-scripts: | |
GIT_AUTHOR_EMAIL="[email protected]" \ | ||
scripts/tests/test-ensure-frozen-migrations.sh | ||
|
||
test-frontend: build-frontend | ||
@cd frontend && npx playwright install --with-deps && npm run test | ||
|
||
# Lint the frontend | ||
lint-frontend: build-frontend | ||
@cd frontend && npm run lint && tsc | ||
|
@@ -233,4 +236,4 @@ grafana-stop: | |
|
||
storybook: | ||
#!/bin/bash | ||
cd frontend && npm run storybook | ||
cd frontend && npm run storybook |
This file contains 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './tests', | ||
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: 'html', | ||
use: { | ||
baseURL: 'http://localhost:8892', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
|
||
{ | ||
name: 'firefox', | ||
use: { ...devices['Desktop Firefox'] }, | ||
}, | ||
|
||
{ | ||
name: 'webkit', | ||
use: { ...devices['Desktop Safari'] }, | ||
}, | ||
], | ||
webServer: { | ||
command: 'ftl dev --recreate', | ||
url: 'http://localhost:8892', | ||
reuseExistingServer: true, | ||
}, | ||
}); |
This file contains 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 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,14 @@ | ||
import { expect, ftlTest } from './ftl-test' | ||
|
||
ftlTest('shows verbs for deployment', async ({ page }) => { | ||
const deploymentsNavItem = page.getByRole('link', { name: 'Deployments' }) | ||
await deploymentsNavItem.click() | ||
|
||
const deploymentEcho = page.getByText('dpl-echo') | ||
await deploymentEcho.click() | ||
|
||
await expect(page).toHaveURL(/\/deployments\/dpl-echo-.*/) | ||
|
||
await expect(page.getByText('echo', { exact: true })).toBeVisible() | ||
await expect(page.getByText('exported', { exact: true })).toBeVisible() | ||
}) |
This file contains 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,10 @@ | ||
import { expect, ftlTest } from './ftl-test' | ||
|
||
ftlTest('shows active deployments', async ({ page }) => { | ||
const deploymentsNavItem = page.getByRole('link', { name: 'Deployments' }) | ||
await deploymentsNavItem.click() | ||
await expect(page).toHaveURL(/\/deployments$/) | ||
|
||
await expect(page.getByText('dpl-time')).toBeVisible() | ||
await expect(page.getByText('dpl-echo')).toBeVisible() | ||
}) |
This file contains 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 { expect, ftlTest } from './ftl-test' | ||
|
||
ftlTest('defaults to the events page', async ({ page }) => { | ||
const eventsNavItem = page.getByRole('link', { name: 'Events' }) | ||
|
||
await expect(eventsNavItem).toHaveClass(/bg-indigo-600 text-white/) | ||
}) |
This file contains 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,17 @@ | ||
import { test as base, expect } from '@playwright/test' | ||
|
||
const ftlTest = base.extend<{ | ||
// biome-ignore lint/suspicious/noExplicitAny: <explanation> | ||
page: any | ||
}>({ | ||
page: async ({ page }, use) => { | ||
await page.goto('http://localhost:8892') | ||
await page.waitForFunction(() => { | ||
const element = document.querySelector('#deployments-count') | ||
return element && element.textContent?.trim() === '2' | ||
}) | ||
await use(page) | ||
}, | ||
}) | ||
|
||
export { ftlTest, expect } |
This file contains 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 { expect, ftlTest } from './ftl-test' | ||
|
||
ftlTest.beforeEach(async ({ page }) => { | ||
const deploymentsNavItem = page.getByRole('link', { name: 'Deployments' }) | ||
await deploymentsNavItem.click() | ||
|
||
const deploymentEcho = page.getByText('dpl-echo') | ||
await deploymentEcho.click() | ||
|
||
const verbEcho = page.getByText('echo', { exact: true }) | ||
await verbEcho.click() | ||
|
||
await expect(page).toHaveURL(/\/deployments\/dpl-echo-[^/]+\/verbs\/echo/) | ||
}) | ||
|
||
ftlTest('shows verb form', async ({ page }) => { | ||
await expect(page.getByText('CALL', { exact: true })).toBeVisible() | ||
await expect(page.locator('input#request-path')).toHaveValue('echo.echo') | ||
|
||
await expect(page.getByText('Body', { exact: true })).toBeVisible() | ||
await expect(page.getByText('Verb Schema', { exact: true })).toBeVisible() | ||
await expect(page.getByText('JSONSchema', { exact: true })).toBeVisible() | ||
}) |