Skip to content

Commit a148dd2

Browse files
rattnakkasya
andauthored
test: add smoke tests for public mentorship programs listing page (#4410)
* test: add smoke tests for public mentorship programs listing page * fix: inline mock program data to avoid generated type import in e2e environment * Add a test for clickable card redirect --------- Co-authored-by: Kate <kate@kgthreads.com>
1 parent e4d0a21 commit a148dd2

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { expectBreadCrumbsToBeVisible } from '@e2e/helpers/expects'
2+
import { test, expect } from '@playwright/test'
3+
4+
const mockPrograms = [
5+
{
6+
key: 'program_1',
7+
name: 'Program 1',
8+
description: 'This is a summary of Program 1.',
9+
startedAt: '2025-01-01T00:00:00Z',
10+
endedAt: '2025-12-31T00:00:00Z',
11+
status: 'PUBLISHED',
12+
modules: ['Module A', 'Module B'],
13+
},
14+
]
15+
16+
test.describe('Mentorship Programs Page', () => {
17+
test.beforeEach(async ({ page }) => {
18+
await page.route('**/idx/', async (route) => {
19+
await route.fulfill({
20+
status: 200,
21+
body: JSON.stringify({ hits: mockPrograms, nbPages: 1 }),
22+
})
23+
})
24+
await page.goto('/mentorship/programs', { timeout: 25000 })
25+
})
26+
27+
test('renders program card from mock data', async ({ page }) => {
28+
await expect(page.getByRole('link', { name: 'Program 1' })).toBeVisible()
29+
await expect(page.getByText('This is a summary of Program 1.')).toBeVisible()
30+
})
31+
32+
test('program card link navigates to program details', async ({ page }) => {
33+
const programLink = page.getByRole('link', { name: 'Program 1' })
34+
await programLink.waitFor({ state: 'visible' })
35+
await expect(programLink).toHaveAttribute('href', '/mentorship/programs/program_1')
36+
await programLink.click()
37+
await expect(page).toHaveURL('/mentorship/programs/program_1')
38+
})
39+
40+
test('search input is visible', async ({ page }) => {
41+
await expect(page.getByPlaceholder('Search for programs...')).toBeVisible()
42+
})
43+
44+
test('displays "No programs found" when there are no programs', async ({ page }) => {
45+
await page.route('**/idx/', async (route) => {
46+
await route.fulfill({
47+
status: 200,
48+
body: JSON.stringify({ hits: [], nbPages: 0 }),
49+
})
50+
})
51+
await page.goto('/mentorship/programs', { timeout: 25000 })
52+
await expect(page.getByText('No programs found')).toBeVisible()
53+
})
54+
55+
test('breadcrumb renders correct segments on /mentorship/programs', async ({ page }) => {
56+
await expectBreadCrumbsToBeVisible(page, ['Home', 'Mentorship'])
57+
})
58+
})

0 commit comments

Comments
 (0)