File tree Expand file tree Collapse file tree 6 files changed +99
-7
lines changed Expand file tree Collapse file tree 6 files changed +99
-7
lines changed Original file line number Diff line number Diff line change 22node_modules
33/dist
44
5+ /tests /_storagestate
56
67# local env files
78.env
Original file line number Diff line number Diff line change 11// playwright.config.js
22// @ts -check
33/** @type {import('@playwright/test').PlaywrightTestConfig } */
4+
5+ if (
6+ ! process . env . TWO_WEEKS_READY_E2E_TEST_USERNAME ||
7+ ! process . env . TWO_WEEKS_READY_E2E_TEST_PASSWORD
8+ ) {
9+ console . error (
10+ "TWO_WEEKS_READY_E2E_TEST_USERNAME and TWO_WEEKS_READY_E2E_TEST_PASSWORD environment variables must be set for end-to-end tests to run."
11+ ) ;
12+ process . exit ( - 1 ) ;
13+ }
14+
415const config = {
16+ timeout : 120 * 1000 ,
17+ webServer : {
18+ command : "npm run serve" ,
19+ port : 8080 ,
520 timeout : 120 * 1000 ,
6- webServer : {
7- command : 'npm run serve' ,
8- port : 8080 ,
9- timeout : 120 * 1000 ,
10- } ,
21+ reuseExistingServer : ! process . env . CI
22+ } ,
23+ globalSetup : require . resolve ( "./tests/global-setup" ) ,
24+ use : {
25+ // Tell all tests to load signed-in state from 'storageState.json'.
26+ storageState : "./tests/_storagestate/storageState.json"
27+ }
1128} ;
12- module . exports = config ;
29+ module . exports = config ;
Original file line number Diff line number Diff line change 4141 </v-row >
4242 <v-fab-transition >
4343 <v-btn
44+ data-testid =" welcome-next-button"
4445 color =" green"
4546 dark
4647 absolute
4748 bottom
4849 right
4950 fab
50- class =" mb-12"
51+ class =" mb-12 welcome-next-button "
5152 @click =" next()"
5253 aria-label =" Next"
5354 >
@@ -75,3 +76,8 @@ export default {
7576 },
7677};
7778 </script >
79+ <style >
80+ .v-btn--fab.welcome-next-button {
81+ z-index : 10
82+ }
83+ </style >
Original file line number Diff line number Diff line change 1+ // global-setup.js
2+ const { chromium, expect } = require ( "@playwright/test" ) ;
3+
4+ module . exports = async ( ) => {
5+ const browser = await chromium . launch ( ) ;
6+ const page = await browser . newPage ( ) ;
7+ await page . goto ( "http://localhost:8080/" ) ;
8+
9+ // Save not signed-in state to 'newuser-storageState.json'.
10+ await page
11+ . context ( )
12+ . storageState ( { path : "./tests/_storagestate/newuser-storageState.json" } ) ;
13+
14+ await page . getByTestId ( "welcome-next-button" ) . click ( ) ;
15+ await expect (
16+ page . getByRole ( "heading" , { name : "You and earthquake risk" } )
17+ ) . toBeVisible ( ) ;
18+ await page . getByTestId ( "welcome-next-button" ) . click ( ) ;
19+ await expect (
20+ page . getByRole ( "heading" , { name : "Let's get started!" } )
21+ ) . toBeVisible ( ) ;
22+ await page . getByTestId ( "welcome-next-button" ) . click ( ) ;
23+
24+ await page
25+ . getByLabel ( "Email address" )
26+ . fill ( process . env . TWO_WEEKS_READY_E2E_TEST_USERNAME ) ;
27+ await page
28+ . getByLabel ( "Password" )
29+ . fill ( process . env . TWO_WEEKS_READY_E2E_TEST_PASSWORD ) ;
30+ await Promise . all ( [
31+ page . waitForNavigation ( { url : "http://localhost:8080/prepare" } ) ,
32+ page . locator ( 'button[name="action"]' ) . click ( )
33+ ] ) ;
34+
35+ // Save signed-in state to 'storageState.json'.
36+ await page
37+ . context ( )
38+ . storageState ( { path : "./tests/_storagestate/storageState.json" } ) ;
39+ await browser . close ( ) ;
40+ } ;
Original file line number Diff line number Diff line change 1+ import { expect , test } from "@playwright/test" ;
2+
3+ test ( "Navigate to Hazard Info shows Earthquake Harzard info" , async ( {
4+ page
5+ } ) => {
6+ await page . goto ( "http://localhost:8080/" ) ;
7+
8+ await page
9+ . getByRole ( "link" , {
10+ name : "Learn Your Hazards Learn all about common hazards."
11+ } )
12+ . click ( ) ;
13+
14+ await page . getByText ( "Earthquake" ) . click ( ) ;
15+ await page . getByRole ( "button" , { name : "Before" } ) . click ( ) ;
16+ await expect (
17+ page . getByText ( "Practice how to drop, cover, and hold on" )
18+ ) . toBeVisible ( ) ;
19+ await page
20+ . getByRole ( "banner" )
21+ . getByRole ( "button" )
22+ . click ( ) ;
23+ await expect (
24+ page . getByText ( "Practice how to drop, cover, and hold on" )
25+ ) . not . toBeVisible ( ) ;
26+ } ) ;
Original file line number Diff line number Diff line change 11const { expect, test, chromium } = require ( "@playwright/test" ) ;
22const { injectAxe, checkA11y } = require ( "axe-playwright" ) ;
33
4+ test . use ( { storageState : "./tests/_storagestate/newuser-storageState.json" } ) ;
5+
46test . describe ( "Welcome page accessibility test" , ( ) => {
57 let browser ;
68 let page ;
You can’t perform that action at this time.
0 commit comments