-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(devtools): add e2e tests for devtools
- Loading branch information
1 parent
6759f9d
commit 76665f3
Showing
9 changed files
with
141 additions
and
37 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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { Action } from '@ngrx/store'; | ||
|
||
test('has title', async ({ page }) => { | ||
await page.goto(''); | ||
|
||
await page.evaluate(() => { | ||
window['devtoolsSpy'] = []; | ||
|
||
window['__REDUX_DEVTOOLS_EXTENSION__'] = { | ||
connect: () => { | ||
return { | ||
send: (data: Action) => { | ||
window['devtoolsSpy'].push(data); | ||
}, | ||
}; | ||
}, | ||
}; | ||
}); | ||
await page.getByRole('link', { name: 'DevTools' }).click(); | ||
await page | ||
.getByRole('row', { name: 'Go for a walk' }) | ||
.getByRole('checkbox') | ||
.click(); | ||
await page | ||
.getByRole('row', { name: 'Exercise' }) | ||
.getByRole('checkbox') | ||
.click(); | ||
|
||
await expect( | ||
page.getByRole('region', { name: 'Go for a walk' }) | ||
).toBeVisible(); | ||
await expect(page.getByRole('region', { name: 'Exercise' })).toBeVisible(); | ||
|
||
await page | ||
.getByRole('row', { name: 'Go for a walk' }) | ||
.getByRole('checkbox') | ||
.click(); | ||
await page | ||
.getByRole('row', { name: 'Exercise' }) | ||
.getByRole('checkbox') | ||
.click(); | ||
|
||
await expect( | ||
page.getByRole('region', { name: 'Go for a walk' }) | ||
).toBeHidden(); | ||
await expect(page.getByRole('region', { name: 'Exercise' })).toBeHidden(); | ||
|
||
const devtoolsActions = await page.evaluate(() => window['devtoolsSpy']); | ||
|
||
expect(devtoolsActions).toEqual([ | ||
{ type: 'add todo' }, | ||
{ type: 'select todo 1' }, | ||
{ type: 'Store Update' }, | ||
{ type: 'select todo 4' }, | ||
{ type: 'Store Update' }, | ||
{ type: 'select todo 1' }, | ||
{ type: 'Store Update' }, | ||
{ type: 'select todo 4' }, | ||
{ type: 'Store Update' }, | ||
]); | ||
}); |
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
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,35 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
import * as path from 'node:path'; | ||
|
||
// For CI, you may want to set BASE_URL to the deployed application. | ||
const baseURL = process.env['BASE_URL'] || 'http://localhost:4200'; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
use: { | ||
baseURL, | ||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
/* Run your local dev server before starting the tests */ | ||
webServer: { | ||
command: 'pnpm start', | ||
url: 'http://localhost:4200', | ||
reuseExistingServer: true, | ||
cwd: path.join(__dirname, '../..'), | ||
}, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
], | ||
}); |
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
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.