Skip to content

Commit ca6a352

Browse files
committed
EES-4902 Re-enable skipped map tests
1 parent 13f180c commit ca6a352

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

src/explore-education-statistics-common/src/modules/charts/components/__tests__/MapBlock.test.tsx

+31-29
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ const tableBuilderService = _tableBuilderService as jest.Mocked<
2121
typeof _tableBuilderService
2222
>;
2323

24-
// EES-4902 react leaflet now uses ESM so unable to test this currently.
25-
// It's stubbed out in the mocks folder.
26-
// Tests are skipped or partially commented out when they
27-
// are testing the maps directly.
2824
describe('MapBlock', () => {
2925
const testFullTable = mapFullTable(testMapTableData);
3026
const testBlockProps: MapBlockProps = {
@@ -43,29 +39,28 @@ describe('MapBlock', () => {
4339
tableBuilderService.getLocationGeoJson.mockResolvedValue(
4440
testMapTableData.subjectMeta.locations,
4541
);
46-
render(<MapBlock {...testBlockProps} />);
4742

48-
// await waitFor(() => {
49-
// const paths = container.querySelectorAll<HTMLElement>(
50-
// '.leaflet-container svg:not(.leaflet-attribution-flag) path',
51-
// );
43+
const { container } = render(<MapBlock {...testBlockProps} />);
5244

53-
// expect(paths).toHaveLength(4);
45+
await waitFor(() => {
46+
const paths = container.querySelectorAll<HTMLElement>(
47+
'.leaflet-container svg:not(.leaflet-attribution-flag) path',
48+
);
5449

55-
// // Location polygons
56-
// expect(paths[0]).toHaveAttribute('fill', 'rgba(145, 161, 201, 1)');
57-
// expect(paths[1]).toHaveAttribute('fill', 'rgba(218, 224, 237, 1)');
58-
// expect(paths[2]).toHaveAttribute('fill', 'rgba(71, 99, 165, 1)');
59-
// // UK polygon
60-
// expect(paths[3]).toHaveAttribute('fill', '#003078');
61-
// });
50+
expect(paths).toHaveLength(4);
6251

63-
await waitFor(() => {
64-
expect(
65-
screen.getByLabelText('1. Select data to view'),
66-
).toBeInTheDocument();
52+
// Location polygons
53+
expect(paths[0]).toHaveAttribute('fill', 'rgba(145, 161, 201, 1)');
54+
expect(paths[1]).toHaveAttribute('fill', 'rgba(218, 224, 237, 1)');
55+
expect(paths[2]).toHaveAttribute('fill', 'rgba(71, 99, 165, 1)');
56+
// UK polygon
57+
expect(paths[3]).toHaveAttribute('fill', '#003078');
6758
});
6859

60+
expect(
61+
await screen.findByLabelText('1. Select data to view'),
62+
).toBeInTheDocument();
63+
6964
const legendItems = screen.getAllByTestId('mapBlock-legend-item');
7065

7166
expect(legendItems).toHaveLength(5);
@@ -199,7 +194,7 @@ describe('MapBlock', () => {
199194
expect(legendColours[4].style.backgroundColor).toBe('rgb(245, 164, 80)');
200195
});
201196

202-
test.skip('changing selected location focuses the correct polygon', async () => {
197+
test('changing selected location focuses the correct polygon', async () => {
203198
tableBuilderService.getLocationGeoJson.mockResolvedValue(
204199
testMapTableData.subjectMeta.locations,
205200
);
@@ -221,17 +216,18 @@ describe('MapBlock', () => {
221216
expect(group1Options[0]).toHaveTextContent('Leeds');
222217

223218
await userEvent.selectOptions(select, group1Options[0]);
219+
224220
const paths = container.querySelectorAll<HTMLElement>(
225-
'.leaflet-container svg:not(.leaflet-attribution-flag) path',
221+
'.leaflet-container svg:not(.leaflet-attribution-flag) path.leaflet-interactive',
226222
);
227223

228-
expect(paths).toHaveLength(4);
224+
expect(paths).toHaveLength(3);
229225

230226
// Location polygons
231227
// selected polygon has a wider border.
232-
expect(paths[0]).toHaveAttribute('stroke-width', '3');
228+
expect(paths[0]).toHaveAttribute('stroke-width', '1');
233229
expect(paths[1]).toHaveAttribute('stroke-width', '1');
234-
expect(paths[2]).toHaveAttribute('stroke-width', '1');
230+
expect(paths[2]).toHaveAttribute('stroke-width', '3');
235231
});
236232

237233
test('changing selected location renders its indicator tile', async () => {
@@ -331,7 +327,7 @@ describe('MapBlock', () => {
331327
).toHaveTextContent('4.01%');
332328
});
333329

334-
test.skip('resetting the map when select None Selected', async () => {
330+
test('resetting the map when no location selected', async () => {
335331
tableBuilderService.getLocationGeoJson.mockResolvedValue(
336332
testMapTableData.subjectMeta.locations,
337333
);
@@ -353,17 +349,23 @@ describe('MapBlock', () => {
353349
await userEvent.selectOptions(select, group1Options[0]);
354350

355351
const paths = container.querySelectorAll<HTMLElement>(
356-
'.leaflet-container svg:not(.leaflet-attribution-flag) path',
352+
'.leaflet-container svg:not(.leaflet-attribution-flag) path.leaflet-interactive',
357353
);
358354

359-
expect(paths[0]).toHaveAttribute('stroke-width', '3');
355+
expect(paths).toHaveLength(3);
356+
expect(paths[0]).toHaveAttribute('stroke-width', '1');
357+
expect(paths[1]).toHaveAttribute('stroke-width', '1');
358+
expect(paths[2]).toHaveAttribute('stroke-width', '3');
360359

361360
await userEvent.selectOptions(
362361
select,
363362
within(select).getAllByRole('option')[0],
364363
);
365364

366365
expect(paths[0]).toHaveAttribute('stroke-width', '1');
366+
expect(paths[1]).toHaveAttribute('stroke-width', '1');
367+
// Stroke width is reset
368+
expect(paths[2]).toHaveAttribute('stroke-width', '1');
367369
});
368370

369371
test('ensure values with decimal places go are assigned the correct colour when the legend values are set to 0 decimal places', async () => {

src/explore-education-statistics-common/src/modules/find-statistics/components/__tests__/DataBlockTabs.test.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ describe('DataBlockTabs', () => {
342342
});
343343
});
344344

345-
// EES-4902 react-leaflet now uses ESM so unable to test this currently
346-
test.skip('renders map', async () => {
345+
test('renders map', async () => {
347346
tableBuilderService.getDataBlockTableData.mockResolvedValue(
348347
testMapTableData,
349348
);

0 commit comments

Comments
 (0)