Skip to content

Commit 957fc37

Browse files
committed
add more tests
1 parent 7d55bc1 commit 957fc37

File tree

2 files changed

+77
-18
lines changed

2 files changed

+77
-18
lines changed

exercises/99.final/01.solution.final/src/data.json

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,110 @@
11
{
22
"recipients": [
33
{
4-
"id": "1",
4+
"id": "clh2x8k9m4n5p6q7r8s9t0u1",
55
"name": "Bethany",
66
"countryCode": "+1",
77
"phone": "5551234567",
88
"timeZone": "America/Denver",
99
"schedule": { "cron": "10 10 * * 1,3,5" },
1010
"messages": [
1111
{
12-
"id": "1",
12+
"id": "clm1n2o3p4q5r6s7t8u9v0w1",
1313
"content": "Thank you for being my partner in every adventure and my comfort in every storm.\n\nI love you more than you know.",
1414
"sentAt": "2044-06-06T10:00:00Z"
1515
},
1616
{
17-
"id": "2",
17+
"id": "clx2y3z4a5b6c7d8e9f0g1h2",
1818
"content": "You are my best friend, my confidant, and my greatest support. Thank you for being you.",
1919
"sentAt": "2044-06-13T10:00:00Z"
2020
},
2121
{
22-
"id": "3",
22+
"id": "cli3j4k5l6m7n8o9p0q1r2s3",
2323
"content": "Thank you for all the sacrifices you make for our family. Your hard work and dedication mean the world to me.",
2424
"sentAt": null
2525
},
2626
{
27-
"id": "4",
27+
"id": "clt4u5v6w7x8y9z0a1b2c3d4",
2828
"content": "Thank you for being my rock and always supporting me. I am grateful for your unwavering love.",
2929
"sentAt": null
3030
}
3131
]
3232
},
3333
{
34-
"id": "2",
34+
"id": "clb5c6d7e8f9g0h1i2j3k4l5",
3535
"name": "Mom",
3636
"countryCode": "+1",
3737
"phone": "5552345678",
3838
"timeZone": "America/Denver",
3939
"schedule": { "cron": "0 10 * * 3" },
4040
"messages": [
4141
{
42-
"id": "1",
42+
"id": "clm6n7o8p9q0r1s2t3u4v5w6",
4343
"content": "Happy Mother's Day! Thank you for all the love, guidance, and support you've given me throughout my life.",
4444
"sentAt": "2044-05-12T10:00:00Z"
4545
},
4646
{
47-
"id": "2",
47+
"id": "clx7y8z9a0b1c2d3e4f5g6h7",
4848
"content": "Just wanted to let you know I'm thinking of you and I love you. Your strength and wisdom inspire me every day.",
4949
"sentAt": null
5050
}
5151
]
5252
},
5353
{
54-
"id": "3",
54+
"id": "cli8j9k0l1m2n3o4p5q6r7s8",
5555
"name": "Dad",
5656
"countryCode": "+1",
5757
"phone": "5553456789",
5858
"timeZone": "America/Denver",
5959
"schedule": null,
6060
"messages": [
6161
{
62-
"id": "1",
62+
"id": "clt9u0v1w2x3y4z5a6b7c8d9",
6363
"content": "Happy Father's Day! Thank you for being the best role model and for always believing in me.",
6464
"sentAt": "2044-06-16T10:00:00Z"
6565
},
6666
{
67-
"id": "2",
67+
"id": "cle0f1g2h3i4j5k6l7m8n9o0",
6868
"content": "I really appreciate all the life lessons you've taught me. You've shaped who I am today.",
6969
"sentAt": "2044-06-17T10:00:00Z"
7070
}
7171
]
7272
},
7373
{
74-
"id": "4",
74+
"id": "clp1q2r3s4t5u6v7w8x9y0z1",
7575
"name": "Emily",
7676
"countryCode": "+1",
7777
"phone": "5554567890",
7878
"timeZone": "America/Denver",
7979
"schedule": { "cron": "0 9 * * 1" },
8080
"messages": [
8181
{
82-
"id": "1",
82+
"id": "cla2b3c4d5e6f7g8h9i0j1k2",
8383
"content": "Happy birthday to my amazing sister! Wishing you all the joy and success in the world.",
8484
"sentAt": "2044-05-20T09:00:00Z"
8585
},
8686
{
87-
"id": "2",
87+
"id": "cll3m4n5o6p7q8r9s0t1u2v3",
8888
"content": "Can't wait for our weekend getaway! It's going to be so much fun catching up.",
8989
"sentAt": null
9090
}
9191
]
9292
},
9393
{
94-
"id": "5",
94+
"id": "clw4x5y6z7a8b9c0d1e2f3g4",
9595
"name": "Grandpa",
9696
"countryCode": "+1",
9797
"phone": "5555678901",
9898
"timeZone": "America/Denver",
9999
"schedule": { "cron": "0 11 * * 0" },
100100
"messages": [
101101
{
102-
"id": "1",
102+
"id": "clh5i6j7k8l9m0n1o2p3q4r5",
103103
"content": "Thank you for all your wonderful stories and the delicious recipes you've shared with me. They keep our family traditions alive.",
104104
"sentAt": "2044-06-02T11:00:00Z"
105105
},
106106
{
107-
"id": "2",
107+
"id": "cls6t7u8v9w0x1y2z3a4b5c6",
108108
"content": "Looking forward to Sunday lunch together. Your cooking always makes everything better.",
109109
"sentAt": null
110110
}

exercises/99.final/01.solution.final/tests/router.test.ts

+60-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { test, expect } from '@playwright/test'
33
test('gratitext should be rendered', async ({ page }) => {
44
await page.goto('/')
55

6-
const gratitext = page.getByRole('banner').getByText(/gratitext/)
6+
const gratitext = page.getByRole('banner').getByText(/gratitext/i)
77
await expect(gratitext).toBeVisible({ timeout: 500 })
88
})
99

@@ -13,3 +13,62 @@ test('About should be rendered', async ({ page }) => {
1313
const about = page.getByRole('heading', { name: /about/i })
1414
await expect(about).toBeVisible({ timeout: 500 })
1515
})
16+
17+
test('should navigate from Home to About page', async ({ page }) => {
18+
await page.goto('/')
19+
20+
const aboutLink = page.getByRole('link', { name: /about/i })
21+
await aboutLink.click()
22+
23+
const aboutHeading = page.getByRole('heading', { name: /about/i })
24+
await expect(aboutHeading).toBeVisible({ timeout: 500 })
25+
})
26+
27+
test('should navigate from About to Home page', async ({ page }) => {
28+
await page.goto('/about')
29+
30+
const homeLink = page
31+
.getByRole('contentinfo')
32+
.getByRole('link', { name: /gratitext/i })
33+
await homeLink.click()
34+
35+
const gratitext = page.getByRole('heading', {
36+
level: 1,
37+
name: /Thoughtful Connections Made Simple/i,
38+
})
39+
await expect(gratitext).toBeVisible({ timeout: 500 })
40+
})
41+
42+
test('should show recipient index page when no recipient is selected', async ({
43+
page,
44+
}) => {
45+
await page.goto('/recipients')
46+
47+
const heading = page.getByRole('heading', { name: /select.*recipient/i })
48+
await expect(heading).toBeVisible({ timeout: 500 })
49+
})
50+
51+
test('should load specific recipient details', async ({ page }) => {
52+
await page.goto('/recipients')
53+
54+
const summary = page.getByText(/select recipient/i)
55+
await summary.click()
56+
57+
const bethanyLink = page.getByRole('link', { name: /bethany/i })
58+
await bethanyLink.click()
59+
60+
const recipientName = page.getByRole('heading', { name: /bethany/i })
61+
await expect(recipientName).toBeVisible({ timeout: 500 })
62+
63+
const phoneNumber = page.getByText(/\+\d+\s+\d{10}/)
64+
await expect(phoneNumber).toBeVisible({ timeout: 500 })
65+
})
66+
67+
test('404 error boundary should be shown for non-existent recipient', async ({
68+
page,
69+
}) => {
70+
await page.goto('/recipients/does-not-exist')
71+
72+
const errorMessage = page.getByText(/recipient.*not found/i)
73+
await expect(errorMessage).toBeVisible({ timeout: 500 })
74+
})

0 commit comments

Comments
 (0)