mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-07-29 18:51:16 -07:00
Census block groups should highlight when selected (#317)
* Fixes #280 - adds territory focus buttons for Alaska, Hawaii, Lower 48, and Puerto Rico to enable easy zoom to these locations * Adding tests - Specifically: * Adding VSCode debug command for Cypress and debug port specification * Disabling CORS on local tests * Adding waitForMapIdle Cypress test helper * Adding constants for easy change and access
This commit is contained in:
parent
5bade764c6
commit
d0c281ec72
9 changed files with 126 additions and 16 deletions
|
@ -1,4 +1,6 @@
|
|||
// / <reference types="Cypress" />
|
||||
import * as constants from '../../src/data/constants';
|
||||
import {LngLat} from 'maplibre-gl';
|
||||
|
||||
describe('Tests for the Explore the Map page', () => {
|
||||
beforeEach(() => {
|
||||
|
@ -17,9 +19,42 @@ describe('Tests for the Explore the Map page', () => {
|
|||
|
||||
for (const [territory, zxy] of Object.entries(tests)) {
|
||||
it(`Can zoom to ${territory} `, () => {
|
||||
cy.get(`[aria-label="Zoom to ${territory}"]`).click();
|
||||
cy.url().should('include', zxy);
|
||||
cy.getMap().then((map) => {
|
||||
cy.get(`[aria-label="Zoom to ${territory}"]`).click();
|
||||
cy.waitForMapIdle(map);
|
||||
cy.url().should('include', zxy);
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
it('Highlights selected regions', () => {
|
||||
// The area around Punxsutawney PA
|
||||
cy.visit('http://localhost:8000/en/cejst#10.29/40.8187/-78.9375');
|
||||
|
||||
cy.intercept('GET', `${constants.FEATURE_TILE_BASE_URL}/10/287/384.pbf`).as('getTile');
|
||||
cy.wait('@getTile');
|
||||
|
||||
const getFeatureState = (map, id) => {
|
||||
return map.getFeatureState(
|
||||
{
|
||||
'id': id,
|
||||
'source': constants.SCORE_SOURCE_NAME,
|
||||
'sourceLayer': constants.SCORE_SOURCE_LAYER,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
const punx1001Info = {
|
||||
'id': '420639601001',
|
||||
'coords': new LngLat(40.911134, -79.027089),
|
||||
};
|
||||
|
||||
cy.getMap().then((map) => {
|
||||
cy.waitForMapIdle(map);
|
||||
map.fire('click', {lngLat: punx1001Info.coords});
|
||||
const punx1001FeatureState = getFeatureState(map, punx1001Info.id);
|
||||
expect(punx1001FeatureState).to.deep.equal({'selected': true});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -21,3 +21,8 @@ Cypress.Commands.add('getMapCanvas', () => {
|
|||
return cy.get('.maplibregl-canvas');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('waitForMapIdle', (map) => {
|
||||
return new Cypress.Promise((resolve) => {
|
||||
map.once('idle', resolve);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue