|
1 | 1 | import { test, expect } from '@playwright/test' |
2 | 2 |
|
3 | 3 | const resetWiremock = async () => { |
4 | | - await fetch('http://localhost:8001/__admin/mappings/reset', { |
| 4 | + const response = await fetch('http://localhost:8001/__admin/mappings/reset', { |
5 | 5 | method: 'POST' |
6 | 6 | }) |
| 7 | + if (!response.ok) { |
| 8 | + throw new Error(`Failed to reset WireMock mappings: ${response.status} ${await response.text()}`) |
| 9 | + } |
7 | 10 | } |
8 | 11 |
|
9 | 12 | const addWiremockStub = async (stub) => { |
10 | | - await fetch('http://localhost:8001/__admin/mappings', { |
| 13 | + const response = await fetch('http://localhost:8001/__admin/mappings', { |
11 | 14 | method: 'POST', |
12 | 15 | headers: { 'Content-Type': 'application/json' }, |
13 | 16 | body: JSON.stringify(stub) |
14 | 17 | }) |
| 18 | + if (!response.ok) { |
| 19 | + throw new Error(`Failed to add WireMock stub: ${response.status} ${await response.text()}`) |
| 20 | + } |
15 | 21 | } |
16 | 22 |
|
17 | | -test.beforeEach(async () => { |
18 | | - await resetWiremock() |
19 | | -}) |
| 23 | +test.describe('Planning group', () => { |
| 24 | + test.describe.configure({ mode: 'serial' }) |
20 | 25 |
|
21 | | -test('An LPA that is a member of a planning group shows the group membership banner on the overview page', async ({ page }) => { |
22 | | - // Stub the local-planning-group entity endpoint to return a group containing local-authority:SLF |
23 | | - await addWiremockStub({ |
24 | | - priority: 1, |
25 | | - request: { |
26 | | - method: 'GET', |
27 | | - urlPattern: '/entity.json.*prefix=local-planning-group.*' |
28 | | - }, |
29 | | - response: { |
30 | | - status: 200, |
31 | | - jsonBody: { |
32 | | - entities: [ |
33 | | - { |
34 | | - entity: 9000001, |
35 | | - name: 'South London Joint Planning Group', |
36 | | - prefix: 'local-planning-group', |
37 | | - reference: 'south-london-joint', |
38 | | - 'organisation-entity': 9000001, |
39 | | - organisations: 'local-authority:SLF;local-authority:LBH', |
40 | | - 'end-date': '' |
41 | | - } |
42 | | - ], |
43 | | - count: 1 |
44 | | - } |
45 | | - } |
| 26 | + test.beforeEach(async () => { |
| 27 | + await resetWiremock() |
46 | 28 | }) |
47 | 29 |
|
48 | | - // Navigate to the LPA overview for SLF |
49 | | - await page.goto('/organisations/local-authority:SLF') |
| 30 | + test('An LPA that is a member of a planning group shows the group membership banner on the overview page', async ({ page }) => { |
| 31 | + // Stub the local-planning-group entity endpoint to return a group containing local-authority:SLF |
| 32 | + await addWiremockStub({ |
| 33 | + priority: 1, |
| 34 | + request: { |
| 35 | + method: 'GET', |
| 36 | + urlPattern: '/entity.json.*prefix=local-planning-group.*' |
| 37 | + }, |
| 38 | + response: { |
| 39 | + status: 200, |
| 40 | + jsonBody: { |
| 41 | + entities: [ |
| 42 | + { |
| 43 | + entity: 9000001, |
| 44 | + name: 'South London Joint Planning Group', |
| 45 | + prefix: 'local-planning-group', |
| 46 | + reference: 'south-london-joint', |
| 47 | + 'organisation-entity': 9000001, |
| 48 | + organisations: 'local-authority:SLF;local-authority:LBH', |
| 49 | + 'end-date': '' |
| 50 | + } |
| 51 | + ], |
| 52 | + count: 1 |
| 53 | + } |
| 54 | + } |
| 55 | + }) |
50 | 56 |
|
51 | | - // The Group Membership banner should be visible |
52 | | - await expect(page.getByText('Group Membership')).toBeVisible() |
| 57 | + // Navigate to the LPA overview for SLF |
| 58 | + await page.goto('/organisations/local-authority:SLF') |
53 | 59 |
|
54 | | - // The planning group name should appear as a link |
55 | | - await expect(page.getByRole('link', { name: 'South London Joint Planning Group' })).toBeVisible() |
| 60 | + // The Group Membership banner should be visible |
| 61 | + await expect(page.getByText('Group Membership')).toBeVisible() |
| 62 | + |
| 63 | + // The planning group name should appear as a link |
| 64 | + await expect(page.getByRole('link', { name: 'South London Joint Planning Group' })).toBeVisible() |
| 65 | + }) |
56 | 66 | }) |
0 commit comments