@@ -2,6 +2,7 @@ import AxeBuilder from '@axe-core/playwright';
2
2
import { expect , test } from '@playwright/test' ;
3
3
import { seedSessionData } from 'e2e/__supports/session-supports' ;
4
4
import { formatHtml } from 'e2e/__supports/string-utils' ;
5
+ import { PlaywrightEstimatorPage } from 'e2e/models/PlaywrightEstimatorPage' ;
5
6
6
7
const stagedSession = {
7
8
estimator : {
@@ -11,46 +12,49 @@ const stagedSession = {
11
12
} ;
12
13
13
14
test ( 'Navigating to /en/income renders the english income page' , async ( { page } ) => {
15
+ const estimator = new PlaywrightEstimatorPage ( page ) ;
14
16
const resp = await seedSessionData ( page , stagedSession ) ;
15
17
expect ( resp . status ( ) ) . toBe ( 200 ) ;
16
18
17
19
await page . goto ( '/en/income' ) ;
18
- expect ( page . url ( ) ) . toContain ( '/en/ income') ;
20
+ await estimator . isLoaded ( ' income') ;
19
21
20
22
expect ( await formatHtml ( await page . locator ( 'main' ) . innerHTML ( ) ) ) . toMatchSnapshot ( ) ;
21
23
} ) ;
22
24
23
25
test ( 'Navigating to /fr/revenus renders the french income page' , async ( { page } ) => {
26
+ const estimator = new PlaywrightEstimatorPage ( page ) ;
24
27
const resp = await seedSessionData ( page , stagedSession ) ;
25
28
expect ( resp . status ( ) ) . toBe ( 200 ) ;
26
29
27
30
await page . goto ( '/fr/revenus' ) ;
28
- expect ( page . url ( ) ) . toContain ( '/fr/revenus' ) ;
31
+ await estimator . isLoaded ( 'income' , 'fr' ) ;
32
+
29
33
expect ( await formatHtml ( await page . locator ( 'main' ) . innerHTML ( ) ) ) . toMatchSnapshot ( ) ;
30
34
} ) ;
31
35
32
36
test ( '/en/income passes a11y checks' , async ( { page } ) => {
37
+ const estimator = new PlaywrightEstimatorPage ( page ) ;
33
38
const resp = await seedSessionData ( page , stagedSession ) ;
34
39
expect ( resp . status ( ) ) . toBe ( 200 ) ;
35
40
36
41
await page . goto ( '/en/income' ) ;
37
- expect ( page . url ( ) ) . toContain ( '/en/income' ) ;
38
- await page . locator ( 'main' ) . waitFor ( ) ;
42
+ await estimator . isLoaded ( 'income' ) ;
39
43
40
- const accessibilityScanResults = await new AxeBuilder ( { page } ) . include ( 'main' ) . analyze ( ) ;
44
+ const accessibilityScanResults = await new AxeBuilder ( { page } ) . analyze ( ) ;
41
45
42
46
expect ( accessibilityScanResults . violations ) . toEqual ( [ ] ) ;
43
47
} ) ;
44
48
45
49
test ( '/fr/revenus passes a11y checks' , async ( { page } ) => {
50
+ const estimator = new PlaywrightEstimatorPage ( page ) ;
46
51
const resp = await seedSessionData ( page , stagedSession ) ;
47
52
expect ( resp . status ( ) ) . toBe ( 200 ) ;
48
53
49
54
await page . goto ( '/fr/revenus' ) ;
50
- expect ( page . url ( ) ) . toContain ( '/fr/revenus' ) ;
51
- await page . locator ( 'main' ) . waitFor ( ) ;
55
+ await estimator . isLoaded ( 'income' , 'fr' ) ;
52
56
53
- const accessibilityScanResults = await new AxeBuilder ( { page } ) . include ( 'main' ) . analyze ( ) ;
57
+ const accessibilityScanResults = await new AxeBuilder ( { page } ) . analyze ( ) ;
54
58
55
59
expect ( accessibilityScanResults . violations ) . toEqual ( [ ] ) ;
56
60
} ) ;
0 commit comments