File tree Expand file tree Collapse file tree 24 files changed +848
-14
lines changed
02.problem.pending-ui/tests
02.solution.pending-ui/tests
03.problem.race-conditions/tests
03.solution.race-conditions/tests
04.solution.history/tests
01.problem.action-reference/tests
01.solution.action-reference/tests
04.problem.revalidation/tests
04.solution.revalidation/tests
05.problem.history-revalidation/tests
05.solution.history-revalidation/tests Expand file tree Collapse file tree 24 files changed +848
-14
lines changed Original file line number Diff line number Diff line change
1
+ import { test , expect } from '@playwright/test'
2
+
3
+ test ( 'should display the home page and perform client-side routing' , async ( {
4
+ page,
5
+ } ) => {
6
+ await page . goto ( '/' )
7
+ let reloadCount = 0
8
+
9
+ // Listen for 'load' event which triggers on page reload
10
+ page . on ( 'load' , ( ) => {
11
+ reloadCount ++
12
+ } )
13
+
14
+ // Wait for the page to load
15
+ await page . waitForSelector ( 'a' )
16
+
17
+ // Get the first link
18
+ const firstLink = await page . locator ( 'a' ) . first ( )
19
+
20
+ // Get the href attribute of the first link
21
+ const href = await firstLink . getAttribute ( 'href' )
22
+
23
+ // Click the first link
24
+ await firstLink . click ( )
25
+
26
+ // Wait for the URL to change
27
+ await page . waitForURL ( `**${ href } ` )
28
+
29
+ // Verify the URL has updated
30
+ expect ( page . url ( ) ) . toContain ( href )
31
+
32
+ // Verify no reloads occurred
33
+ expect ( reloadCount ) . toBe ( 0 )
34
+ } )
Original file line number Diff line number Diff line change
1
+ import { test , expect } from '@playwright/test'
2
+
3
+ test ( 'should display the home page and perform search' , async ( { page } ) => {
4
+ await page . goto ( '/' )
5
+ await expect ( page ) . toHaveTitle ( 'Starship Deets' )
6
+
7
+ // Check for the filter input
8
+ const filterInput = page . getByPlaceholder ( 'filter ships' )
9
+ await expect ( filterInput ) . toBeVisible ( )
10
+
11
+ // Perform a search
12
+ await filterInput . fill ( 'hopper' )
13
+ await filterInput . press ( 'Enter' )
14
+
15
+ // Verify URL change with search params
16
+ await expect ( page ) . toHaveURL ( '/?search=hopper' )
17
+
18
+ // Verify filtered results
19
+ const shipLinks = page
20
+ . getByRole ( 'list' )
21
+ . first ( )
22
+ . getByRole ( 'listitem' )
23
+ . getByRole ( 'link' )
24
+ for ( const link of await shipLinks . all ( ) ) {
25
+ await expect ( link ) . toContainText ( 'hopper' , { ignoreCase : true } )
26
+ }
27
+
28
+ // Find and click on a ship in the filtered list
29
+ const shipLink = shipLinks . first ( )
30
+ const shipName = await shipLink . textContent ( )
31
+ await shipLink . click ( )
32
+
33
+ // Verify URL change
34
+ await expect ( page ) . toHaveURL ( / \/ [ a - z A - Z 0 - 9 - ] + / )
35
+
36
+ // Verify ship detail view
37
+ const shipTitle = page . getByRole ( 'heading' , { level : 2 } )
38
+ await expect ( shipTitle ) . toHaveText ( shipName )
39
+ } )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import { test , expect } from '@playwright/test'
2
+
3
+ test ( 'should display the home page and perform client-side routing' , async ( {
4
+ page,
5
+ } ) => {
6
+ await page . goto ( '/' )
7
+ let reloadCount = 0
8
+
9
+ // Listen for 'load' event which triggers on page reload
10
+ page . on ( 'load' , ( ) => {
11
+ reloadCount ++
12
+ } )
13
+
14
+ // Wait for the page to load
15
+ await page . waitForSelector ( 'a' )
16
+
17
+ // Get the first link
18
+ const firstLink = await page . locator ( 'a' ) . first ( )
19
+
20
+ // Get the href attribute of the first link
21
+ const href = await firstLink . getAttribute ( 'href' )
22
+
23
+ // Click the first link
24
+ await firstLink . click ( )
25
+
26
+ // Wait for the URL to change
27
+ await page . waitForURL ( `**${ href } ` )
28
+
29
+ // Verify the URL has updated
30
+ expect ( page . url ( ) ) . toContain ( href )
31
+
32
+ // Verify no reloads occurred
33
+ expect ( reloadCount ) . toBe ( 0 )
34
+ } )
Original file line number Diff line number Diff line change
1
+ import { test , expect } from '@playwright/test'
2
+
3
+ test ( 'should display the home page and perform search' , async ( { page } ) => {
4
+ await page . goto ( '/' )
5
+ await expect ( page ) . toHaveTitle ( 'Starship Deets' )
6
+
7
+ // Check for the filter input
8
+ const filterInput = page . getByPlaceholder ( 'filter ships' )
9
+ await expect ( filterInput ) . toBeVisible ( )
10
+
11
+ // Perform a search
12
+ await filterInput . fill ( 'hopper' )
13
+ await filterInput . press ( 'Enter' )
14
+
15
+ // Verify URL change with search params
16
+ await expect ( page ) . toHaveURL ( '/?search=hopper' )
17
+
18
+ // Verify filtered results
19
+ const shipLinks = page
20
+ . getByRole ( 'list' )
21
+ . first ( )
22
+ . getByRole ( 'listitem' )
23
+ . getByRole ( 'link' )
24
+ for ( const link of await shipLinks . all ( ) ) {
25
+ await expect ( link ) . toContainText ( 'hopper' , { ignoreCase : true } )
26
+ }
27
+
28
+ // Find and click on a ship in the filtered list
29
+ const shipLink = shipLinks . first ( )
30
+ const shipName = await shipLink . textContent ( )
31
+ await shipLink . click ( )
32
+
33
+ // Verify URL change
34
+ await expect ( page ) . toHaveURL ( / \/ [ a - z A - Z 0 - 9 - ] + / )
35
+
36
+ // Verify ship detail view
37
+ const shipTitle = page . getByRole ( 'heading' , { level : 2 } )
38
+ await expect ( shipTitle ) . toHaveText ( shipName )
39
+ } )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import { test , expect } from '@playwright/test'
2
+
3
+ test ( 'should display the home page and perform search' , async ( { page } ) => {
4
+ await page . goto ( '/' )
5
+ await expect ( page ) . toHaveTitle ( 'Starship Deets' )
6
+
7
+ // Check for the filter input
8
+ const filterInput = page . getByPlaceholder ( 'filter ships' )
9
+ await expect ( filterInput ) . toBeVisible ( )
10
+
11
+ // Perform a search
12
+ await filterInput . fill ( 'hopper' )
13
+ await filterInput . press ( 'Enter' )
14
+
15
+ // Verify URL change with search params
16
+ await expect ( page ) . toHaveURL ( '/?search=hopper' )
17
+
18
+ // Verify filtered results
19
+ const shipLinks = page
20
+ . getByRole ( 'list' )
21
+ . first ( )
22
+ . getByRole ( 'listitem' )
23
+ . getByRole ( 'link' )
24
+ for ( const link of await shipLinks . all ( ) ) {
25
+ await expect ( link ) . toContainText ( 'hopper' , { ignoreCase : true } )
26
+ }
27
+
28
+ // Find and click on a ship in the filtered list
29
+ const shipLink = shipLinks . first ( )
30
+ const shipName = await shipLink . textContent ( )
31
+ await shipLink . click ( )
32
+
33
+ // Verify URL change
34
+ await expect ( page ) . toHaveURL ( / \/ [ a - z A - Z 0 - 9 - ] + / )
35
+
36
+ // Verify ship detail view
37
+ const shipTitle = page . getByRole ( 'heading' , { level : 2 } )
38
+ await expect ( shipTitle ) . toHaveText ( shipName )
39
+ } )
Original file line number Diff line number Diff line change
1
+ import { test , expect } from '@playwright/test'
2
+
3
+ test ( 'should display the home page and perform search' , async ( { page } ) => {
4
+ await page . goto ( '/' )
5
+ await expect ( page ) . toHaveTitle ( 'Starship Deets' )
6
+
7
+ // Check for the filter input
8
+ const filterInput = page . getByPlaceholder ( 'filter ships' )
9
+ await expect ( filterInput ) . toBeVisible ( )
10
+
11
+ // Perform a search
12
+ await filterInput . fill ( 'hopper' )
13
+ await filterInput . press ( 'Enter' )
14
+
15
+ // Verify URL change with search params
16
+ await expect ( page ) . toHaveURL ( '/?search=hopper' )
17
+
18
+ // Verify filtered results
19
+ const shipLinks = page
20
+ . getByRole ( 'list' )
21
+ . first ( )
22
+ . getByRole ( 'listitem' )
23
+ . getByRole ( 'link' )
24
+ for ( const link of await shipLinks . all ( ) ) {
25
+ await expect ( link ) . toContainText ( 'hopper' , { ignoreCase : true } )
26
+ }
27
+
28
+ // Find and click on a ship in the filtered list
29
+ const shipLink = shipLinks . first ( )
30
+ const shipName = await shipLink . textContent ( )
31
+ await shipLink . click ( )
32
+
33
+ // Verify URL change
34
+ await expect ( page ) . toHaveURL ( / \/ [ a - z A - Z 0 - 9 - ] + / )
35
+
36
+ // Verify ship detail view
37
+ const shipTitle = page . getByRole ( 'heading' , { level : 2 } )
38
+ await expect ( shipTitle ) . toHaveText ( shipName )
39
+ } )
Original file line number Diff line number Diff line change
1
+ import { test , expect } from '@playwright/test'
2
+
3
+ test ( 'should display the home page and perform search' , async ( { page } ) => {
4
+ await page . goto ( '/' )
5
+ await expect ( page ) . toHaveTitle ( 'Starship Deets' )
6
+
7
+ // Check for the filter input
8
+ const filterInput = page . getByPlaceholder ( 'filter ships' )
9
+ await expect ( filterInput ) . toBeVisible ( )
10
+
11
+ // Perform a search
12
+ await filterInput . fill ( 'hopper' )
13
+ await filterInput . press ( 'Enter' )
14
+
15
+ // Verify URL change with search params
16
+ await expect ( page ) . toHaveURL ( '/?search=hopper' )
17
+
18
+ // Verify filtered results
19
+ const shipLinks = page
20
+ . getByRole ( 'list' )
21
+ . first ( )
22
+ . getByRole ( 'listitem' )
23
+ . getByRole ( 'link' )
24
+ for ( const link of await shipLinks . all ( ) ) {
25
+ await expect ( link ) . toContainText ( 'hopper' , { ignoreCase : true } )
26
+ }
27
+
28
+ // Find and click on a ship in the filtered list
29
+ const shipLink = shipLinks . first ( )
30
+ const shipName = await shipLink . textContent ( )
31
+ await shipLink . click ( )
32
+
33
+ // Verify URL change
34
+ await expect ( page ) . toHaveURL ( / \/ [ a - z A - Z 0 - 9 - ] + / )
35
+
36
+ // Verify ship detail view
37
+ const shipTitle = page . getByRole ( 'heading' , { level : 2 } )
38
+ await expect ( shipTitle ) . toHaveText ( shipName )
39
+ } )
Original file line number Diff line number Diff line change
1
+ import { test , expect } from '@playwright/test'
2
+
3
+ test ( 'should display the home page and perform search' , async ( { page } ) => {
4
+ await page . goto ( '/' )
5
+ await expect ( page ) . toHaveTitle ( 'Starship Deets' )
6
+
7
+ // Check for the filter input
8
+ const filterInput = page . getByPlaceholder ( 'filter ships' )
9
+ await expect ( filterInput ) . toBeVisible ( )
10
+
11
+ // Perform a search
12
+ await filterInput . fill ( 'hopper' )
13
+ await filterInput . press ( 'Enter' )
14
+
15
+ // Verify URL change with search params
16
+ await expect ( page ) . toHaveURL ( '/?search=hopper' )
17
+
18
+ // Verify filtered results
19
+ const shipLinks = page
20
+ . getByRole ( 'list' )
21
+ . first ( )
22
+ . getByRole ( 'listitem' )
23
+ . getByRole ( 'link' )
24
+ for ( const link of await shipLinks . all ( ) ) {
25
+ await expect ( link ) . toContainText ( 'hopper' , { ignoreCase : true } )
26
+ }
27
+
28
+ // Find and click on a ship in the filtered list
29
+ const shipLink = shipLinks . first ( )
30
+ const shipName = await shipLink . textContent ( )
31
+ await shipLink . click ( )
32
+
33
+ // Verify URL change
34
+ await expect ( page ) . toHaveURL ( / \/ [ a - z A - Z 0 - 9 - ] + / )
35
+
36
+ // Verify ship detail view
37
+ const shipTitle = page . getByRole ( 'heading' , { level : 2 } )
38
+ await expect ( shipTitle ) . toHaveText ( shipName )
39
+ } )
You can’t perform that action at this time.
0 commit comments