-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: playwright tests for genotype presets (#1831)
tests are executed within Storybook to re-use the backend mocking
- Loading branch information
Showing
11 changed files
with
300 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Playwright Tests | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./frontend | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Install Playwright Browsers | ||
run: npx playwright install --with-deps | ||
- name: Run Playwright tests | ||
run: npx playwright test | ||
- uses: actions/upload-artifact@v4 | ||
if: ${{ !cancelled() }} | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 |
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 |
---|---|---|
|
@@ -334,3 +334,7 @@ Session.vim | |
tags | ||
|
||
.DS_Store | ||
/test-results/ | ||
playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
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,75 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto( | ||
'http://localhost:6006/iframe.html?globals=backgrounds.grid:!false;backgrounds.value:!hex(F8F8F8)&id=seqvars-seqvars-filtration--example', | ||
) | ||
}) | ||
|
||
test('modified genotype preset is marked', async ({ page }) => { | ||
page.locator('button[aria-label="Create query based on dominant"]').click() | ||
|
||
const selectedGenotypePreset = page.locator( | ||
'[aria-selected="true"]:below(:text("Genotype")):has-text("dominant")', | ||
) | ||
await expect(selectedGenotypePreset.first()).toBeVisible() | ||
|
||
const modifiedPreset = selectedGenotypePreset.locator('[data-test-modified]') | ||
await expect(modifiedPreset).toBeHidden() | ||
await page.getByRole('button', { name: '1/0' }).first().click() | ||
await expect(modifiedPreset).toBeVisible() | ||
}) | ||
|
||
test.describe('genotype', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page | ||
.locator('button[aria-label="Create query based on de novo"]') | ||
.click() | ||
}) | ||
|
||
test('any is checked when all types are checked', async ({ page }) => { | ||
const firstAnyButton = page | ||
.getByRole('button', { name: 'any' }) | ||
.and(page.locator('[aria-selected]')) | ||
.first() | ||
await expect(firstAnyButton).toHaveAttribute('aria-selected', 'false') | ||
for (const name of ['0/0', '1/0', '1/1']) { | ||
const button = page.getByRole('button', { name }).first() | ||
if ((await button.getAttribute('aria-selected')) === 'false') { | ||
await button.click() | ||
} | ||
} | ||
await expect(firstAnyButton).toHaveAttribute('aria-selected', 'true') | ||
}) | ||
}) | ||
|
||
test.describe('genotype (recessive)', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page | ||
.locator('button[aria-label="Create query based on recessive"]') | ||
.click() | ||
}) | ||
|
||
test('index radios are mutually exclusive', async ({ page }) => { | ||
await page | ||
.locator('input[type="radio"][aria-label="Index"]:not(:checked)') | ||
.first() | ||
.click() | ||
await expect( | ||
page.locator('input[type="radio"][aria-label="Index"]:checked'), | ||
).toHaveCount(1) | ||
}) | ||
|
||
test('only two parent radios can be selected', async ({ page }) => { | ||
const parentRadios = page.locator( | ||
'input[type="radio"][aria-label="Parent"]', | ||
) | ||
expect(await parentRadios.count()).toBe(3) | ||
for (const parent of await parentRadios.all()) { | ||
await parent.click() | ||
} | ||
await expect(await parentRadios.and(page.locator(':checked'))).toHaveCount( | ||
2, | ||
) | ||
}) | ||
}) |
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,36 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
|
||
export default defineConfig({ | ||
testDir: './end-to-end-tests', | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: process.env.CI ? 1 : undefined, | ||
reporter: 'html', | ||
use: { | ||
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: 'npm run storybook', | ||
url: 'http://127.0.0.1:6006', | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
}) |
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
Oops, something went wrong.