mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-03-01 12:44:17 +00:00
add custom cypress commands for search testing
This commit is contained in:
parent
37113c8ab4
commit
81349e299b
45
cypress/support/commands.ts
Normal file
45
cypress/support/commands.ts
Normal file
@ -0,0 +1,45 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace Cypress {
|
||||
interface Chainable {
|
||||
/**
|
||||
* Clear the search input
|
||||
* @example cy.clearSearch()
|
||||
*/
|
||||
clearSearch(): Chainable<Element>
|
||||
|
||||
/**
|
||||
* 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<Element>
|
||||
|
||||
/**
|
||||
* Wait for the map and search components to be ready
|
||||
* @example cy.waitForMapReady()
|
||||
*/
|
||||
waitForMapReady(): Chainable<Element>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
|
||||
export {}
|
||||
@ -1,19 +1,10 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
|
||||
|
||||
// Import commands.ts using ES2015 syntax:
|
||||
// import './commands'
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
||||
import './commands'
|
||||
|
||||
// This file is processed and loaded automatically before your test files.
|
||||
// This is a great place to put global configuration and behavior that modifies Cypress.
|
||||
|
||||
// You can change the location of this file or turn off
|
||||
// automatically serving support files with the 'supportFile' configuration option.
|
||||
|
||||
// Global exception handler
|
||||
Cypress.on('uncaught:exception', (err) => {
|
||||
console.log('Uncaught exception:', err.message)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user