From 581e75ee577715181ad7d0d613ebc98d20be0258 Mon Sep 17 00:00:00 2001 From: Annie Huang Date: Sat, 9 Dec 2023 21:18:03 +0800 Subject: [PATCH 1/2] Add configs retrying and longer timeout to load --- tests/cypress.config.js | 3 +++ tests/cypress/support/commands.js | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/cypress.config.js b/tests/cypress.config.js index 1b6910c..b2bb72e 100644 --- a/tests/cypress.config.js +++ b/tests/cypress.config.js @@ -20,6 +20,9 @@ module.exports = defineConfig({ viewportWidth: 1920, viewportHeight: 1080, pageLoadTimeout: 120000, + redirectionLimit: 20, + defaultCommandTimeout: 10000, + retries: { runMode: 5, openMode: 5 }, }, env: { defaultAccount: getOrFail('TESTING_USERNAME'), diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 625d0df..f3b8a02 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -22,10 +22,11 @@ Cypress.Commands.add('PrepareForGame', () => { cy.url().should('include', '/map') cy.visit('/game/get-started') cy.url().should('include', '/game/get-started') - cy.get('.xterm-screen', { timeout: 10000 }) + // check task first so the terminal has better possibility loaded + cy.checkTaskInit() + cy.get('.xterm-screen', { timeout: 100000 }) .as('Terminaltextbox') .should('be.visible') - cy.checkTaskInit() cy.CheckTextElement('#reset', '重來', 'Reset').click() cy.checkTaskInit() cy.InitTerminal() @@ -83,7 +84,7 @@ Cypress.Commands.add('checkPending', () => { }) Cypress.Commands.add('CompleteStageWithCommands', (stagename) => { cy.visit(`/game/${stagename}`) - cy.url().should('include', `/game/${stagename}`) + cy.url().should('include', `/game/${stagename}`, { timeout: 50000 }) cy.log(`Completing stage :${stagename}`) cy.checkTaskInit() cy.CheckTextElement('#reset', '重來', 'Reset').click() From 175db7b8bc9810cb4ff6ef71a2af09fca6caaded Mon Sep 17 00:00:00 2001 From: Annie Huang Date: Sun, 10 Dec 2023 00:08:45 +0800 Subject: [PATCH 2/2] reduce timeout --- tests/cypress/support/commands.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index f3b8a02..9428779 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -24,7 +24,7 @@ Cypress.Commands.add('PrepareForGame', () => { cy.url().should('include', '/game/get-started') // check task first so the terminal has better possibility loaded cy.checkTaskInit() - cy.get('.xterm-screen', { timeout: 100000 }) + cy.get('.xterm-screen', { timeout: 10000 }) .as('Terminaltextbox') .should('be.visible') cy.CheckTextElement('#reset', '重來', 'Reset').click() @@ -32,21 +32,21 @@ Cypress.Commands.add('PrepareForGame', () => { cy.InitTerminal() }) Cypress.Commands.add('InitTerminal', () => { - cy.get('@Terminaltextbox', { timeout: 150000 }).should( + cy.get('@Terminaltextbox', { timeout: 15000 }).should( 'contain', 'commander:~ $' ) cy.log('Check terminal init done') }) Cypress.Commands.add('typeInCommand', (command) => { - cy.get('.xterm-screen', { timeout: 150000 }).type(command) + cy.get('.xterm-screen', { timeout: 15000 }).type(command) }) Cypress.Commands.add('getQuestInfo', (id) => { return cy .get('#quest') .find('li') .find('p') - .contains(`${id}`, { timeout: 100000 }) + .contains(`${id}`, { timeout: 10000 }) }) Cypress.Commands.add('checkHint', (index, total) => { cy.get('#hint') @@ -58,7 +58,7 @@ Cypress.Commands.add('checkTaskInit', () => { cy.get('#tasks').next().children().should('be.visible') }) Cypress.Commands.add('waitUntilActive', (last = false) => { - cy.get('input[id="currentStatus"]', { timeout: 1000000 }) + cy.get('input[id="currentStatus"]', { timeout: 10000 }) .invoke('val') .then((value) => { if (value === 'active') { @@ -77,7 +77,7 @@ Cypress.Commands.add('waitUntilActive', (last = false) => { }) }) Cypress.Commands.add('checkPending', () => { - cy.get('input[id="currentStatus"]', { timeout: 1000000 }).should( + cy.get('input[id="currentStatus"]', { timeout: 10000 }).should( 'have.value', 'pending' )