/// declare global { // eslint-disable-next-line @typescript-eslint/no-namespace namespace Cypress { interface Chainable { /** * Clear the search input * @example cy.clearSearch() */ clearSearch(): Chainable /** * Search for a term and wait for search suggestions to appear * @param query - The search term to type * @example cy.searchFor('berlin') */ searchFor(query: string): Chainable /** * Wait for the map and search components to be ready * @example cy.waitForMapReady() */ waitForMapReady(): Chainable /** * Click on a map marker * @example cy.clickMarker() // clicks first marker */ clickMarker(): Chainable /** * Wait for a popup to appear on the map * @example cy.waitForPopup() */ waitForPopup(): Chainable /** * Close the currently open popup * @example cy.closePopup() */ closePopup(): Chainable /** * Toggle a layer's visibility in the layer control * @param layerName - Name of the layer to toggle * @example cy.toggleLayer('places') */ toggleLayer(layerName: string): Chainable /** * Open the layer control panel * @example cy.openLayerControl() */ openLayerControl(): Chainable /** * Close the layer control panel * @example cy.closeLayerControl() */ closeLayerControl(): Chainable } } } Cypress.Commands.add('clearSearch', () => { cy.get('[data-cy="search-input"]').clear() }) Cypress.Commands.add('searchFor', (query: string) => { cy.get('[data-cy="search-input"]').clear() cy.get('[data-cy="search-input"]').type(query) cy.get('[data-cy="search-suggestions"]', { timeout: 10000 }).should('be.visible') }) Cypress.Commands.add('waitForMapReady', () => { cy.get('[data-cy="search-input"]', { timeout: 10000 }).should('be.visible') cy.get('.leaflet-container', { timeout: 10000 }).should('be.visible') cy.get('.leaflet-marker-icon', { timeout: 15000 }).should('have.length.at.least', 1) }) Cypress.Commands.add('clickMarker', () => { // For now, always use force click since markers might be clustered or outside viewport cy.get('.leaflet-marker-icon').first().click({ force: true }) }) Cypress.Commands.add('waitForPopup', () => { cy.get('[data-cy="item-popup"]', { timeout: 10000 }).should('be.visible') }) Cypress.Commands.add('closePopup', () => { cy.get('.leaflet-popup-close-button').click() }) Cypress.Commands.add('toggleLayer', (layerName: string) => { cy.get(`[data-cy="layer-checkbox-${layerName}"]`).click() }) Cypress.Commands.add('openLayerControl', () => { cy.get('[data-cy="layer-control-button"]').click() cy.get('[data-cy="layer-control-panel"]', { timeout: 5000 }).should('be.visible') }) Cypress.Commands.add('closeLayerControl', () => { cy.get('[data-cy="layer-control-close"]').click() }) export {}