-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f637e2
commit f286d5d
Showing
34 changed files
with
216 additions
and
52 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
exercises/03.client-components/01.problem.loader/tests/smoke.test.js
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,39 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('should display the home page and perform search', async ({ page }) => { | ||
await page.goto('/') | ||
await expect(page).toHaveTitle('Starship Deets') | ||
|
||
// Check for the filter input | ||
const filterInput = page.getByPlaceholder('filter ships') | ||
await expect(filterInput).toBeVisible() | ||
|
||
// Perform a search | ||
await filterInput.fill('hopper') | ||
await filterInput.press('Enter') | ||
|
||
// Verify URL change with search params | ||
await expect(page).toHaveURL('/?search=hopper') | ||
|
||
// Verify filtered results | ||
const shipLinks = page | ||
.getByRole('list') | ||
.first() | ||
.getByRole('listitem') | ||
.getByRole('link') | ||
for (const link of await shipLinks.all()) { | ||
await expect(link).toContainText('hopper', { ignoreCase: true }) | ||
} | ||
|
||
// Find and click on a ship in the filtered list | ||
const shipLink = shipLinks.first() | ||
const shipName = await shipLink.textContent() | ||
await shipLink.click() | ||
|
||
// Verify URL change | ||
await expect(page).toHaveURL(/\/[a-zA-Z0-9-]+/) | ||
|
||
// Verify ship detail view | ||
const shipTitle = page.getByRole('heading', { level: 2 }) | ||
await expect(shipTitle).toHaveText(shipName) | ||
}) |
7 changes: 0 additions & 7 deletions
7
exercises/03.client-components/01.problem.loader/tests/solution.test.js
This file was deleted.
Oops, something went wrong.
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
39 changes: 39 additions & 0 deletions
39
exercises/03.client-components/01.solution.loader/tests/smoke.test.js
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,39 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('should display the home page and perform search', async ({ page }) => { | ||
await page.goto('/') | ||
await expect(page).toHaveTitle('Starship Deets') | ||
|
||
// Check for the filter input | ||
const filterInput = page.getByPlaceholder('filter ships') | ||
await expect(filterInput).toBeVisible() | ||
|
||
// Perform a search | ||
await filterInput.fill('hopper') | ||
await filterInput.press('Enter') | ||
|
||
// Verify URL change with search params | ||
await expect(page).toHaveURL('/?search=hopper') | ||
|
||
// Verify filtered results | ||
const shipLinks = page | ||
.getByRole('list') | ||
.first() | ||
.getByRole('listitem') | ||
.getByRole('link') | ||
for (const link of await shipLinks.all()) { | ||
await expect(link).toContainText('hopper', { ignoreCase: true }) | ||
} | ||
|
||
// Find and click on a ship in the filtered list | ||
const shipLink = shipLinks.first() | ||
const shipName = await shipLink.textContent() | ||
await shipLink.click() | ||
|
||
// Verify URL change | ||
await expect(page).toHaveURL(/\/[a-zA-Z0-9-]+/) | ||
|
||
// Verify ship detail view | ||
const shipTitle = page.getByRole('heading', { level: 2 }) | ||
await expect(shipTitle).toHaveText(shipName) | ||
}) |
7 changes: 0 additions & 7 deletions
7
exercises/03.client-components/01.solution.loader/tests/solution.test.js
This file was deleted.
Oops, something went wrong.
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
30 changes: 30 additions & 0 deletions
30
exercises/03.client-components/02.problem.module-resolution/tests/edit-text.test.js
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,30 @@ | ||
import { test, expect } from '@playwright/test' | ||
import { searchShips } from '../db/ship-api.js' | ||
|
||
test('should display the home page and perform search', async ({ page }) => { | ||
const { | ||
ships: [ship], | ||
} = await searchShips({ search: 'hopper' }) | ||
const newName = `${ship.name} 🚀` | ||
await page.goto(`/${ship.id}`) | ||
|
||
// Wait for the loading state to disappear | ||
await page.waitForSelector('h2:has-text("Loading...")', { state: 'detached' }) | ||
|
||
// Ensure the ship name is visible | ||
await expect(page.getByRole('heading', { name: ship.name })).toBeVisible() | ||
// Find and click the edit button | ||
await page.getByRole('button', { name: ship.name }).click() | ||
|
||
// Check if the input is focused | ||
await expect(page.getByRole('textbox', { name: 'Ship Name' })).toBeFocused() | ||
|
||
// Change the value of the input | ||
await page.getByRole('textbox', { name: 'Ship Name' }).fill(newName) | ||
|
||
// Press Enter | ||
await page.keyboard.press('Enter') | ||
|
||
// Check if the button is back | ||
await expect(page.getByRole('button', { name: newName })).toBeVisible() | ||
}) |
39 changes: 39 additions & 0 deletions
39
exercises/03.client-components/02.problem.module-resolution/tests/smoke.test.js
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,39 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('should display the home page and perform search', async ({ page }) => { | ||
await page.goto('/') | ||
await expect(page).toHaveTitle('Starship Deets') | ||
|
||
// Check for the filter input | ||
const filterInput = page.getByPlaceholder('filter ships') | ||
await expect(filterInput).toBeVisible() | ||
|
||
// Perform a search | ||
await filterInput.fill('hopper') | ||
await filterInput.press('Enter') | ||
|
||
// Verify URL change with search params | ||
await expect(page).toHaveURL('/?search=hopper') | ||
|
||
// Verify filtered results | ||
const shipLinks = page | ||
.getByRole('list') | ||
.first() | ||
.getByRole('listitem') | ||
.getByRole('link') | ||
for (const link of await shipLinks.all()) { | ||
await expect(link).toContainText('hopper', { ignoreCase: true }) | ||
} | ||
|
||
// Find and click on a ship in the filtered list | ||
const shipLink = shipLinks.first() | ||
const shipName = await shipLink.textContent() | ||
await shipLink.click() | ||
|
||
// Verify URL change | ||
await expect(page).toHaveURL(/\/[a-zA-Z0-9-]+/) | ||
|
||
// Verify ship detail view | ||
const shipTitle = page.getByRole('heading', { level: 2 }) | ||
await expect(shipTitle).toHaveText(shipName) | ||
}) |
7 changes: 0 additions & 7 deletions
7
exercises/03.client-components/02.problem.module-resolution/tests/solution.test.js
This file was deleted.
Oops, something went wrong.
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
30 changes: 30 additions & 0 deletions
30
exercises/03.client-components/02.solution.module-resolution/tests/edit-text.test.js
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,30 @@ | ||
import { test, expect } from '@playwright/test' | ||
import { searchShips } from '../db/ship-api.js' | ||
|
||
test('should display the home page and perform search', async ({ page }) => { | ||
const { | ||
ships: [ship], | ||
} = await searchShips({ search: 'hopper' }) | ||
const newName = `${ship.name} 🚀` | ||
await page.goto(`/${ship.id}`) | ||
|
||
// Wait for the loading state to disappear | ||
await page.waitForSelector('h2:has-text("Loading...")', { state: 'detached' }) | ||
|
||
// Ensure the ship name is visible | ||
await expect(page.getByRole('heading', { name: ship.name })).toBeVisible() | ||
// Find and click the edit button | ||
await page.getByRole('button', { name: ship.name }).click() | ||
|
||
// Check if the input is focused | ||
await expect(page.getByRole('textbox', { name: 'Ship Name' })).toBeFocused() | ||
|
||
// Change the value of the input | ||
await page.getByRole('textbox', { name: 'Ship Name' }).fill(newName) | ||
|
||
// Press Enter | ||
await page.keyboard.press('Enter') | ||
|
||
// Check if the button is back | ||
await expect(page.getByRole('button', { name: newName })).toBeVisible() | ||
}) |
39 changes: 39 additions & 0 deletions
39
exercises/03.client-components/02.solution.module-resolution/tests/smoke.test.js
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,39 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('should display the home page and perform search', async ({ page }) => { | ||
await page.goto('/') | ||
await expect(page).toHaveTitle('Starship Deets') | ||
|
||
// Check for the filter input | ||
const filterInput = page.getByPlaceholder('filter ships') | ||
await expect(filterInput).toBeVisible() | ||
|
||
// Perform a search | ||
await filterInput.fill('hopper') | ||
await filterInput.press('Enter') | ||
|
||
// Verify URL change with search params | ||
await expect(page).toHaveURL('/?search=hopper') | ||
|
||
// Verify filtered results | ||
const shipLinks = page | ||
.getByRole('list') | ||
.first() | ||
.getByRole('listitem') | ||
.getByRole('link') | ||
for (const link of await shipLinks.all()) { | ||
await expect(link).toContainText('hopper', { ignoreCase: true }) | ||
} | ||
|
||
// Find and click on a ship in the filtered list | ||
const shipLink = shipLinks.first() | ||
const shipName = await shipLink.textContent() | ||
await shipLink.click() | ||
|
||
// Verify URL change | ||
await expect(page).toHaveURL(/\/[a-zA-Z0-9-]+/) | ||
|
||
// Verify ship detail view | ||
const shipTitle = page.getByRole('heading', { level: 2 }) | ||
await expect(shipTitle).toHaveText(shipName) | ||
}) |
7 changes: 0 additions & 7 deletions
7
exercises/03.client-components/02.solution.module-resolution/tests/solution.test.js
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
Oops, something went wrong.