Skip to content

Commit 1d2d971

Browse files
authored
Merge pull request #23 from James-Cross/feature/find-help-e2e-tests
Add passing E2E tests for Find Help page with mocked category API a…
2 parents 3551986 + 5fb6621 commit 1d2d971

File tree

2 files changed

+81
-2
lines changed

2 files changed

+81
-2
lines changed

e2e/find-help.spec.ts

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,75 @@
11
import { test, expect } from '@playwright/test';
22

33
test.describe('Find Help Page', () => {
4-
test('loads and shows postcode input', async ({ page }) => {
4+
5+
test('should load the Find Help page and show fallback form when geolocation is blocked', async ({ context, page }) => {
6+
await context.grantPermissions([], { origin: 'http://localhost:3000' });
57
await page.goto('/find-help');
68

9+
await expect(page.getByRole('heading', { name: /find help near you/i })).toBeVisible();
710
await expect(page.getByLabel('Enter your postcode')).toBeVisible();
811
await expect(page.getByRole('button', { name: /continue/i })).toBeVisible();
912
});
10-
});
13+
14+
test('should allow postcode entry and show service results', async ({ context, page }) => {
15+
await context.grantPermissions([], { origin: 'http://localhost:3000' });
16+
await page.goto('/find-help');
17+
18+
await page.getByLabel('Enter your postcode').fill('M1 1AE');
19+
await page.getByRole('button', { name: /continue/i }).click();
20+
21+
await expect(page.getByText(/services near you/i)).toBeVisible();
22+
});
23+
24+
test('should allow selecting category and subcategory', async ({ context, page }) => {
25+
await context.grantPermissions([], { origin: 'http://localhost:3000' });
26+
27+
await page.route('/api/get-categories', async (route) => {
28+
route.fulfill({
29+
status: 200,
30+
contentType: 'application/json',
31+
body: JSON.stringify([
32+
{
33+
key: 'health',
34+
name: 'Health',
35+
subCategories: [
36+
{ key: 'gp', name: 'GP' },
37+
{ key: 'dentist', name: 'Dentist' }
38+
],
39+
},
40+
]),
41+
});
42+
});
43+
44+
await page.goto('/find-help');
45+
46+
await page.getByLabel('Enter your postcode').fill('M1 1AE');
47+
await page.getByRole('button', { name: /continue/i }).click();
48+
49+
await expect(page.getByLabel('Category')).toBeVisible();
50+
await page.locator('#category').selectOption('health');
51+
52+
await expect(page.getByLabel('Subcategory')).toBeVisible();
53+
await page.selectOption('#subCategory', 'gp');
54+
});
55+
56+
test('should toggle map visibility', async ({ context, page }) => {
57+
await context.grantPermissions([], { origin: 'http://localhost:3000' });
58+
await page.goto('/find-help');
59+
60+
await page.getByLabel('Enter your postcode').fill('M1 1AE');
61+
await page.getByRole('button', { name: /continue/i }).click();
62+
63+
await page.getByRole('button', { name: /show map/i }).click();
64+
await expect(page.getByText('🗺️ Map is toggled ON')).toBeVisible();
65+
});
66+
67+
test('should show service cards when services are matched', async ({ context, page }) => {
68+
await context.setGeolocation({ latitude: 53.4808, longitude: -2.2426 });
69+
await context.grantPermissions(['geolocation']);
70+
await page.goto('/find-help');
71+
72+
await expect(page.locator('[data-testid="service-card"]').first()).toBeVisible();
73+
});
74+
75+
});

test-checklist.ms

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,17 @@ This document tracks key test coverage across the Street Support Network rebuild
2727
- Test-driven development (TDD) applied where possible
2828
- Components are tested in isolation
2929
- API routes will be tested using integration suites where applicable
30+
31+
### ✅ Find Help – End-to-End (Playwright)
32+
33+
**Coverage:**
34+
- Page loads and fallback UI appears if geolocation is blocked
35+
- Manual postcode entry sets location
36+
- Category and subcategory filters function correctly
37+
- Map toggle button reveals map interface
38+
- Services display correctly based on geolocation and filters
39+
40+
**File:** `e2e/find-help.spec.ts`
41+
**Status:** ✅ All tests passing
42+
**Date:** 2025-06-03
43+
**Notes:** Mocks used for category API; geolocation stubbed for result validation

0 commit comments

Comments
 (0)