Skip to content

Commit 876e1d2

Browse files
feat: search map (#919)
* chore: stash * chore: replace vector feature map with npm version * feat: add search map * chore: use bcgov/prp-map library * test: add ol/style fill and stroke mocks * test: remove map canvas in happo screenshot util * chore: fix search results style regression * refactor: organize search map components * chore: test filter map features by id * chore: set empty array if id list exists * refactor: clean up map layer functions
1 parent b7cedc0 commit 876e1d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+657
-1117
lines changed

public/frontend/e2e/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ import { MAX_VISIBLE_OPTIONS } from '@/components/search/filters/FilterGroup';
33
export const BASE_URL = process.env.E2E_BASE_URL || 'http://localhost:3000';
44

55
export const MAX_VISIBLE_FILTERS = MAX_VISIBLE_OPTIONS;
6+
7+
export const MAP_CANVAS_SELECTOR = '#map-container';

public/frontend/e2e/pages/recResource.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ test.describe('Recreation Resource page', () => {
1616
await layout.verifyFooterContent();
1717
await recResourcePage.verifySectionsExistInPageMenu();
1818

19-
await recResourcePage.removeRecreationResourceFeatureMap();
20-
2119
await recResourcePage.verifyPdfDocLinks();
2220

2321
await utils.accessibility();

public/frontend/e2e/poms/pages/recResource.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { waitForImagesToLoad } from 'e2e/utils';
66
import { RecResource } from 'e2e/poms/pages/types';
77
import { SectionTitles } from '@/components/rec-resource/enum';
88

9-
const MAP_CANVAS_SELECTOR = '#map-container';
10-
119
export class RecreationResourcePOM {
1210
readonly page: Page;
1311

@@ -49,29 +47,6 @@ export class RecreationResourcePOM {
4947
}
5048
}
5149

52-
/**
53-
* Remove the map canvas element
54-
*
55-
* @remarks
56-
* Happo e2e automatically converts canvas elements to inline img elements
57-
* with a URL that looks like "_inlined/...png" without actually creating
58-
* the file in the directory. When the tests are done, it then tries to
59-
* package every URL in the asset bundle for the test review page and tries to
60-
* resolve this non-existent url which ends up throwing the error.
61-
*/
62-
async removeRecreationResourceFeatureMap() {
63-
try {
64-
await this.page
65-
.locator(MAP_CANVAS_SELECTOR)
66-
.waitFor({ state: 'visible', timeout: 5000 });
67-
await this.page.evaluate((selector) => {
68-
document.querySelector(selector)?.remove();
69-
}, MAP_CANVAS_SELECTOR);
70-
} catch (error) {
71-
console.warn(`Map element not found: ${error}`);
72-
}
73-
}
74-
7550
async verifyPdfDocLinks() {
7651
const pdfLink = this.page.getByRole('link', { name: /\[PDF\]/ });
7752
await expect(pdfLink).toHaveAttribute('href', /.*\.pdf$/);

public/frontend/e2e/poms/utils.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
waitForNetworkRequest,
88
waitForNetworkResponse,
99
} from 'e2e/utils';
10-
import { BASE_URL } from 'e2e/constants';
10+
import { BASE_URL, MAP_CANVAS_SELECTOR } from 'e2e/constants';
1111

1212
export class UtilsPOM {
1313
readonly page: Page;
@@ -44,6 +44,8 @@ export class UtilsPOM {
4444
}
4545

4646
async screenshot(component: string, variant: string) {
47+
// Remove the map canvas element if it exists as it breaks Happo
48+
await this.removeVectorFeatureMap();
4749
await happoPlaywright.screenshot(this.page, this.pageContent, {
4850
component,
4951
variant,
@@ -62,4 +64,23 @@ export class UtilsPOM {
6264
await this.waitForNetworkRequest(url);
6365
await this.waitForNetworkResponse(statusCode);
6466
}
67+
68+
/**
69+
* Remove the map canvas element
70+
*
71+
* @remarks
72+
* Happo e2e automatically converts canvas elements to inline img elements
73+
* with a URL that looks like "_inlined/...png" without actually creating
74+
* the file in the directory. When the tests are done, it then tries to
75+
* package every URL in the asset bundle for the test review page and tries to
76+
* resolve this non-existent url which ends up throwing the error.
77+
*/
78+
async removeVectorFeatureMap() {
79+
const canvas = this.page.locator(MAP_CANVAS_SELECTOR);
80+
if ((await canvas.count()) > 0) {
81+
await this.page.evaluate((selector) => {
82+
document.querySelector(selector)?.remove();
83+
}, MAP_CANVAS_SELECTOR);
84+
}
85+
}
6586
}

public/frontend/e2e/workflows/user/landing-search.spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ test.describe('User flows from the landing page to searching for a rec resource'
5454

5555
await utils.accessibility();
5656

57-
await recResourcePage.removeRecreationResourceFeatureMap();
58-
5957
await utils.screenshot('Recreation Resource page', '10k cabin');
6058
});
6159

@@ -96,8 +94,6 @@ test.describe('User flows from the landing page to searching for a rec resource'
9694

9795
await utils.accessibility();
9896

99-
await recResourcePage.removeRecreationResourceFeatureMap();
100-
10197
await utils.screenshot(
10298
'Recreation Resource page',
10399
'24 mile snowmobile area',

public/frontend/package-lock.json

Lines changed: 22 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
},
2121
"dependencies": {
2222
"@bcgov/bc-sans": "^2.1.0",
23+
"@bcgov/prp-map": "^0.0.4",
2324
"@digitalspace/bcparks-bootstrap-theme": "^1.4.6",
2425
"@fortawesome/fontawesome-free": "^6.7.2",
2526
"@fortawesome/fontawesome-svg-core": "^6.7.2",
3.53 KB
Loading
4.19 KB
Loading

public/frontend/src/components/StyledVectorFeatureMap/StyledVectorFeatureMap.test.tsx

Lines changed: 0 additions & 93 deletions
This file was deleted.

public/frontend/src/components/StyledVectorFeatureMap/StyledVectorFeatureMap.tsx

Lines changed: 0 additions & 74 deletions
This file was deleted.

public/frontend/src/components/StyledVectorFeatureMap/components/MapControls.scss

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)