From ca5df78114c06686cf2e20f6efde088fe3641323 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Thu, 17 Jul 2025 17:03:41 +0100 Subject: [PATCH] Increase Cypress timeouts and add waitForSelectOptions command Raised default and request timeouts to 60 seconds in Cypress config to improve test reliability. Added a custom 'waitForSelectOptions' command to ensure select elements are populated before interacting, and updated station location test to use this command. --- cypress.config.js | 2 ++ cypress/e2e/4-station-locations.cy.js | 4 ++++ cypress/support/commands.js | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/cypress.config.js b/cypress.config.js index f2103337..dfdd1546 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -4,6 +4,8 @@ module.exports = defineConfig({ projectId: 'gm8wco', e2e: { baseUrl: "http://localhost/", + defaultCommandTimeout: 60000, // Increase default timeout to 60 seconds + requestTimeout: 60000, // Increase request timeout to 60 seconds setupNodeEvents(on, config) { // implement node event listeners here }, diff --git a/cypress/e2e/4-station-locations.cy.js b/cypress/e2e/4-station-locations.cy.js index 1e3104fa..4ec4dcdf 100644 --- a/cypress/e2e/4-station-locations.cy.js +++ b/cypress/e2e/4-station-locations.cy.js @@ -41,7 +41,11 @@ describe("Create station location", () => { cy.get('input[name="station_profile_name"]').type(stationLocationName); cy.get('input[name="station_callsign"]').type(stationCallsign); cy.get('input[name="station_power"]').type(stationPower); + + // Wait for the DXCC select to be populated with options before trying to select + cy.waitForSelectOptions('select[name="dxcc"]'); cy.get('select[name="dxcc"]').select(stationDXCC); + cy.get('input[name="city"]').type(stationCity); cy.get('select[name="station_state"]').select(stationState); cy.get("#stationCntyInput-selectized") diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 80e96b91..489fe9a3 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -6,3 +6,9 @@ Cypress.Commands.add("login", () => { cy.get('input[name="user_password"]').type(password); cy.get('button[type="submit"]').click(); }); + +// Custom command to wait for select elements to be populated +Cypress.Commands.add("waitForSelectOptions", (selector, minOptions = 1) => { + cy.get(selector).should('be.visible'); + cy.get(`${selector} option`).should('have.length.greaterThan', minOptions); +});