Skip to content

Commit ff6c08f

Browse files
committed
some more improvements to testing setup
1 parent 7cac487 commit ff6c08f

File tree

37 files changed

+444
-37
lines changed

37 files changed

+444
-37
lines changed

exercises/01.init/01.problem.static/tests/playwright.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
import os from 'os'
2+
import path from 'path'
13
import { defineConfig, devices } from '@playwright/test'
24

35
const PORT = process.env.PORT || '3000'
46

7+
const tmpDir = path.join(os.tmpdir(), 'epicreact-server-components')
8+
59
export default defineConfig({
6-
reporter: [['html', { open: 'never' }]],
10+
outputDir: path.join(tmpDir, 'playwright-test-output'),
11+
reporter: [
12+
[
13+
'html',
14+
{ open: 'never', outputFolder: path.join(tmpDir, 'playwright-report') },
15+
],
16+
],
717
use: {
818
baseURL: `http://localhost:${PORT}/`,
919
trace: 'retain-on-failure',
Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,39 @@
11
import { test, expect } from '@playwright/test'
22

3-
test('should display the home page', async ({ page }) => {
3+
test('should display the home page and perform search', async ({ page }) => {
44
await page.goto('/')
55
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-zA-Z0-9-]+/)
35+
36+
// Verify ship detail view
37+
const shipTitle = page.getByRole('heading', { level: 2 })
38+
await expect(shipTitle).toHaveText(shipName)
639
})

exercises/01.init/01.solution.static/tests/playwright.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
import os from 'os'
2+
import path from 'path'
13
import { defineConfig, devices } from '@playwright/test'
24

35
const PORT = process.env.PORT || '3000'
46

7+
const tmpDir = path.join(os.tmpdir(), 'epicreact-server-components')
8+
59
export default defineConfig({
6-
reporter: [['html', { open: 'never' }]],
10+
outputDir: path.join(tmpDir, 'playwright-test-output'),
11+
reporter: [
12+
[
13+
'html',
14+
{ open: 'never', outputFolder: path.join(tmpDir, 'playwright-report') },
15+
],
16+
],
717
use: {
818
baseURL: `http://localhost:${PORT}/`,
919
trace: 'retain-on-failure',
Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,39 @@
11
import { test, expect } from '@playwright/test'
22

3-
test('should display the home page', async ({ page }) => {
3+
test('should display the home page and perform search', async ({ page }) => {
44
await page.goto('/')
55
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-zA-Z0-9-]+/)
35+
36+
// Verify ship detail view
37+
const shipTitle = page.getByRole('heading', { level: 2 })
38+
await expect(shipTitle).toHaveText(shipName)
639
})

exercises/02.server-components/01.problem.rsc/tests/playwright.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
import os from 'os'
2+
import path from 'path'
13
import { defineConfig, devices } from '@playwright/test'
24

35
const PORT = process.env.PORT || '3000'
46

7+
const tmpDir = path.join(os.tmpdir(), 'epicreact-server-components')
8+
59
export default defineConfig({
6-
reporter: [['html', { open: 'never' }]],
10+
outputDir: path.join(tmpDir, 'playwright-test-output'),
11+
reporter: [
12+
[
13+
'html',
14+
{ open: 'never', outputFolder: path.join(tmpDir, 'playwright-report') },
15+
],
16+
],
717
use: {
818
baseURL: `http://localhost:${PORT}/`,
919
trace: 'retain-on-failure',

exercises/02.server-components/01.solution.rsc/tests/playwright.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
import os from 'os'
2+
import path from 'path'
13
import { defineConfig, devices } from '@playwright/test'
24

35
const PORT = process.env.PORT || '3000'
46

7+
const tmpDir = path.join(os.tmpdir(), 'epicreact-server-components')
8+
59
export default defineConfig({
6-
reporter: [['html', { open: 'never' }]],
10+
outputDir: path.join(tmpDir, 'playwright-test-output'),
11+
reporter: [
12+
[
13+
'html',
14+
{ open: 'never', outputFolder: path.join(tmpDir, 'playwright-report') },
15+
],
16+
],
717
use: {
818
baseURL: `http://localhost:${PORT}/`,
919
trace: 'retain-on-failure',

exercises/02.server-components/02.problem.async-components/tests/playwright.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
import os from 'os'
2+
import path from 'path'
13
import { defineConfig, devices } from '@playwright/test'
24

35
const PORT = process.env.PORT || '3000'
46

7+
const tmpDir = path.join(os.tmpdir(), 'epicreact-server-components')
8+
59
export default defineConfig({
6-
reporter: [['html', { open: 'never' }]],
10+
outputDir: path.join(tmpDir, 'playwright-test-output'),
11+
reporter: [
12+
[
13+
'html',
14+
{ open: 'never', outputFolder: path.join(tmpDir, 'playwright-report') },
15+
],
16+
],
717
use: {
818
baseURL: `http://localhost:${PORT}/`,
919
trace: 'retain-on-failure',

exercises/02.server-components/02.solution.async-components/tests/playwright.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
import os from 'os'
2+
import path from 'path'
13
import { defineConfig, devices } from '@playwright/test'
24

35
const PORT = process.env.PORT || '3000'
46

7+
const tmpDir = path.join(os.tmpdir(), 'epicreact-server-components')
8+
59
export default defineConfig({
6-
reporter: [['html', { open: 'never' }]],
10+
outputDir: path.join(tmpDir, 'playwright-test-output'),
11+
reporter: [
12+
[
13+
'html',
14+
{ open: 'never', outputFolder: path.join(tmpDir, 'playwright-report') },
15+
],
16+
],
717
use: {
818
baseURL: `http://localhost:${PORT}/`,
919
trace: 'retain-on-failure',

exercises/02.server-components/03.problem.streaming/tests/playwright.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
import os from 'os'
2+
import path from 'path'
13
import { defineConfig, devices } from '@playwright/test'
24

35
const PORT = process.env.PORT || '3000'
46

7+
const tmpDir = path.join(os.tmpdir(), 'epicreact-server-components')
8+
59
export default defineConfig({
6-
reporter: [['html', { open: 'never' }]],
10+
outputDir: path.join(tmpDir, 'playwright-test-output'),
11+
reporter: [
12+
[
13+
'html',
14+
{ open: 'never', outputFolder: path.join(tmpDir, 'playwright-report') },
15+
],
16+
],
717
use: {
818
baseURL: `http://localhost:${PORT}/`,
919
trace: 'retain-on-failure',

exercises/02.server-components/03.solution.streaming/tests/playwright.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
import os from 'os'
2+
import path from 'path'
13
import { defineConfig, devices } from '@playwright/test'
24

35
const PORT = process.env.PORT || '3000'
46

7+
const tmpDir = path.join(os.tmpdir(), 'epicreact-server-components')
8+
59
export default defineConfig({
6-
reporter: [['html', { open: 'never' }]],
10+
outputDir: path.join(tmpDir, 'playwright-test-output'),
11+
reporter: [
12+
[
13+
'html',
14+
{ open: 'never', outputFolder: path.join(tmpDir, 'playwright-report') },
15+
],
16+
],
717
use: {
818
baseURL: `http://localhost:${PORT}/`,
919
trace: 'retain-on-failure',

0 commit comments

Comments
 (0)