Skip to content

Commit 9820860

Browse files
committed
improve tests
1 parent 25893e3 commit 9820860

File tree

20 files changed

+160
-20
lines changed

20 files changed

+160
-20
lines changed

exercises/04.router/01.problem.router/tests/smoke.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {
1010

1111
// Perform a search
1212
await filterInput.fill('hopper')
13-
await filterInput.press('Enter')
1413

1514
// Verify URL change with search params
1615
await expect(page).toHaveURL('/?search=hopper')
1716

17+
const shipList = page.getByRole('list').first()
18+
19+
// Wait for the list to be filtered down to two items
20+
await expect(async () => {
21+
const items = await shipList.getByRole('listitem').all()
22+
expect(items.length).toBe(2)
23+
}).toPass()
24+
1825
// Verify filtered results
1926
const shipLinks = page
2027
.getByRole('list')

exercises/04.router/01.solution.router/tests/smoke.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {
1010

1111
// Perform a search
1212
await filterInput.fill('hopper')
13-
await filterInput.press('Enter')
1413

1514
// Verify URL change with search params
1615
await expect(page).toHaveURL('/?search=hopper')
1716

17+
const shipList = page.getByRole('list').first()
18+
19+
// Wait for the list to be filtered down to two items
20+
await expect(async () => {
21+
const items = await shipList.getByRole('listitem').all()
22+
expect(items.length).toBe(2)
23+
}).toPass()
24+
1825
// Verify filtered results
1926
const shipLinks = page
2027
.getByRole('list')

exercises/04.router/02.problem.pending-ui/tests/smoke.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {
1010

1111
// Perform a search
1212
await filterInput.fill('hopper')
13-
await filterInput.press('Enter')
1413

1514
// Verify URL change with search params
1615
await expect(page).toHaveURL('/?search=hopper')
1716

17+
const shipList = page.getByRole('list').first()
18+
19+
// Wait for the list to be filtered down to two items
20+
await expect(async () => {
21+
const items = await shipList.getByRole('listitem').all()
22+
expect(items.length).toBe(2)
23+
}).toPass()
24+
1825
// Verify filtered results
1926
const shipLinks = page
2027
.getByRole('list')

exercises/04.router/02.solution.pending-ui/tests/smoke.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {
1010

1111
// Perform a search
1212
await filterInput.fill('hopper')
13-
await filterInput.press('Enter')
1413

1514
// Verify URL change with search params
1615
await expect(page).toHaveURL('/?search=hopper')
1716

17+
const shipList = page.getByRole('list').first()
18+
19+
// Wait for the list to be filtered down to two items
20+
await expect(async () => {
21+
const items = await shipList.getByRole('listitem').all()
22+
expect(items.length).toBe(2)
23+
}).toPass()
24+
1825
// Verify filtered results
1926
const shipLinks = page
2027
.getByRole('list')

exercises/04.router/03.problem.race-conditions/tests/smoke.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {
1010

1111
// Perform a search
1212
await filterInput.fill('hopper')
13-
await filterInput.press('Enter')
1413

1514
// Verify URL change with search params
1615
await expect(page).toHaveURL('/?search=hopper')
1716

17+
const shipList = page.getByRole('list').first()
18+
19+
// Wait for the list to be filtered down to two items
20+
await expect(async () => {
21+
const items = await shipList.getByRole('listitem').all()
22+
expect(items.length).toBe(2)
23+
}).toPass()
24+
1825
// Verify filtered results
1926
const shipLinks = page
2027
.getByRole('list')

exercises/04.router/03.solution.race-conditions/tests/smoke.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {
1010

1111
// Perform a search
1212
await filterInput.fill('hopper')
13-
await filterInput.press('Enter')
1413

1514
// Verify URL change with search params
1615
await expect(page).toHaveURL('/?search=hopper')
1716

17+
const shipList = page.getByRole('list').first()
18+
19+
// Wait for the list to be filtered down to two items
20+
await expect(async () => {
21+
const items = await shipList.getByRole('listitem').all()
22+
expect(items.length).toBe(2)
23+
}).toPass()
24+
1825
// Verify filtered results
1926
const shipLinks = page
2027
.getByRole('list')

exercises/04.router/04.problem.history/tests/smoke.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {
1010

1111
// Perform a search
1212
await filterInput.fill('hopper')
13-
await filterInput.press('Enter')
1413

1514
// Verify URL change with search params
1615
await expect(page).toHaveURL('/?search=hopper')
1716

17+
const shipList = page.getByRole('list').first()
18+
19+
// Wait for the list to be filtered down to two items
20+
await expect(async () => {
21+
const items = await shipList.getByRole('listitem').all()
22+
expect(items.length).toBe(2)
23+
}).toPass()
24+
1825
// Verify filtered results
1926
const shipLinks = page
2027
.getByRole('list')

exercises/04.router/04.solution.history/tests/smoke.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {
1010

1111
// Perform a search
1212
await filterInput.fill('hopper')
13-
await filterInput.press('Enter')
1413

1514
// Verify URL change with search params
1615
await expect(page).toHaveURL('/?search=hopper')
1716

17+
const shipList = page.getByRole('list').first()
18+
19+
// Wait for the list to be filtered down to two items
20+
await expect(async () => {
21+
const items = await shipList.getByRole('listitem').all()
22+
expect(items.length).toBe(2)
23+
}).toPass()
24+
1825
// Verify filtered results
1926
const shipLinks = page
2027
.getByRole('list')

exercises/04.router/05.problem.cache/tests/smoke.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {
1010

1111
// Perform a search
1212
await filterInput.fill('hopper')
13-
await filterInput.press('Enter')
1413

1514
// Verify URL change with search params
1615
await expect(page).toHaveURL('/?search=hopper')
1716

17+
const shipList = page.getByRole('list').first()
18+
19+
// Wait for the list to be filtered down to two items
20+
await expect(async () => {
21+
const items = await shipList.getByRole('listitem').all()
22+
expect(items.length).toBe(2)
23+
}).toPass()
24+
1825
// Verify filtered results
1926
const shipLinks = page
2027
.getByRole('list')

exercises/04.router/05.solution.cache/tests/smoke.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {
1010

1111
// Perform a search
1212
await filterInput.fill('hopper')
13-
await filterInput.press('Enter')
1413

1514
// Verify URL change with search params
1615
await expect(page).toHaveURL('/?search=hopper')
1716

17+
const shipList = page.getByRole('list').first()
18+
19+
// Wait for the list to be filtered down to two items
20+
await expect(async () => {
21+
const items = await shipList.getByRole('listitem').all()
22+
expect(items.length).toBe(2)
23+
}).toPass()
24+
1825
// Verify filtered results
1926
const shipLinks = page
2027
.getByRole('list')

0 commit comments

Comments
 (0)