2021-10-13 14:06:05 -07:00
|
|
|
import {hyphenizeString} from '../integration/common/helpers';
|
2021-07-06 14:52:35 -04:00
|
|
|
|
|
|
|
// For some interactions, we need access to the underlying map
|
|
|
|
// Below adapted from https://github.com/codeforcologne/edelgard-map
|
|
|
|
Cypress.Commands.add('getMap', () => {
|
2021-07-23 08:52:34 -04:00
|
|
|
return cy.window().its('underlyingMap', {timeout: 10000});
|
2021-07-06 14:52:35 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
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', () => {
|
2021-07-07 15:04:00 -04:00
|
|
|
return cy.get('.maplibregl-canvas');
|
2021-07-06 14:52:35 -04:00
|
|
|
});
|
|
|
|
|
2021-07-09 10:56:38 -04:00
|
|
|
Cypress.Commands.add('waitForMapIdle', (map) => {
|
|
|
|
return new Cypress.Promise((resolve) => {
|
|
|
|
map.once('idle', resolve);
|
|
|
|
});
|
|
|
|
});
|
2021-10-13 14:06:05 -07:00
|
|
|
|
|
|
|
Cypress.Commands.add('testExternalLinks', (string) => {
|
|
|
|
return cy.get(`[data-cy="${hyphenizeString(string)}-block"] a`).each((link) => {
|
|
|
|
cy.request(link.prop('href'))
|
|
|
|
.its('status')
|
|
|
|
.should('eq', 200);
|
|
|
|
});
|
|
|
|
});
|