j40-cejst-2/client/cypress/support/commands.js
Nat Hillard d0c281ec72
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
2021-07-09 10:56:38 -04:00

28 lines
686 B
JavaScript

/* MAP */
// For some interactions, we need access to the underlying map
// Below adapted from https://github.com/codeforcologne/edelgard-map
Cypress.Commands.add('getMap', () => {
return cy.window().its('underlyingMap');
});
Cypress.Commands.add('waitForMove', (map) => {
return new Cypress.Promise((resolve) => {
map.on('moveend', resolve);
});
});
Cypress.Commands.add('panTo', (map, lngLat) => {
map.panTo(lngLat);
cy.waitForMove(map);
});
Cypress.Commands.add('getMapCanvas', () => {
return cy.get('.maplibregl-canvas');
});
Cypress.Commands.add('waitForMapIdle', (map) => {
return new Cypress.Promise((resolve) => {
map.once('idle', resolve);
});
});