feat-automation-test (stabilise) (#90)

feat-automation-test (stabilise)
This commit is contained in:
Lin, Hung-Shin authored and GitHub committed 2023-12-10 08:57:18 +08:00
commit 660a7ce4e8
2 files changed
+11 -7

No files matched your search

+3
View File
@@ -20,6 +20,9 @@ module.exports = defineConfig({
viewportWidth: 1920, viewportWidth: 1920,
viewportHeight: 1080, viewportHeight: 1080,
pageLoadTimeout: 120000, pageLoadTimeout: 120000,
redirectionLimit: 20,
defaultCommandTimeout: 10000,
retries: { runMode: 5, openMode: 5 },
}, },
env: { env: {
defaultAccount: getOrFail('TESTING_USERNAME'), defaultAccount: getOrFail('TESTING_USERNAME'),
+8 -7
View File
@@ -22,30 +22,31 @@ Cypress.Commands.add('PrepareForGame', () => {
cy.url().should('include', '/map') cy.url().should('include', '/map')
cy.visit('/game/get-started') cy.visit('/game/get-started')
cy.url().should('include', '/game/get-started') cy.url().should('include', '/game/get-started')
// check task first so the terminal has better possibility loaded
cy.checkTaskInit()
cy.get('.xterm-screen', { timeout: 10000 }) cy.get('.xterm-screen', { timeout: 10000 })
.as('Terminaltextbox') .as('Terminaltextbox')
.should('be.visible') .should('be.visible')
cy.checkTaskInit()
cy.CheckTextElement('#reset', '重來', 'Reset').click() cy.CheckTextElement('#reset', '重來', 'Reset').click()
cy.checkTaskInit() cy.checkTaskInit()
cy.InitTerminal() cy.InitTerminal()
}) })
Cypress.Commands.add('InitTerminal', () => { Cypress.Commands.add('InitTerminal', () => {
cy.get('@Terminaltextbox', { timeout: 150000 }).should( cy.get('@Terminaltextbox', { timeout: 15000 }).should(
'contain', 'contain',
'commander:~ $' 'commander:~ $'
) )
cy.log('Check terminal init done') cy.log('Check terminal init done')
}) })
Cypress.Commands.add('typeInCommand', (command) => { 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) => { Cypress.Commands.add('getQuestInfo', (id) => {
return cy return cy
.get('#quest') .get('#quest')
.find('li') .find('li')
.find('p') .find('p')
.contains(`${id}`, { timeout: 100000 }) .contains(`${id}`, { timeout: 10000 })
}) })
Cypress.Commands.add('checkHint', (index, total) => { Cypress.Commands.add('checkHint', (index, total) => {
cy.get('#hint') cy.get('#hint')
@@ -57,7 +58,7 @@ Cypress.Commands.add('checkTaskInit', () => {
cy.get('#tasks').next().children().should('be.visible') cy.get('#tasks').next().children().should('be.visible')
}) })
Cypress.Commands.add('waitUntilActive', (last = false) => { Cypress.Commands.add('waitUntilActive', (last = false) => {
cy.get('input[id="currentStatus"]', { timeout: 1000000 }) cy.get('input[id="currentStatus"]', { timeout: 10000 })
.invoke('val') .invoke('val')
.then((value) => { .then((value) => {
if (value === 'active') { if (value === 'active') {
@@ -76,14 +77,14 @@ Cypress.Commands.add('waitUntilActive', (last = false) => {
}) })
}) })
Cypress.Commands.add('checkPending', () => { Cypress.Commands.add('checkPending', () => {
cy.get('input[id="currentStatus"]', { timeout: 1000000 }).should( cy.get('input[id="currentStatus"]', { timeout: 10000 }).should(
'have.value', 'have.value',
'pending' 'pending'
) )
}) })
Cypress.Commands.add('CompleteStageWithCommands', (stagename) => { Cypress.Commands.add('CompleteStageWithCommands', (stagename) => {
cy.visit(`/game/${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.log(`Completing stage :${stagename}`)
cy.checkTaskInit() cy.checkTaskInit()
cy.CheckTextElement('#reset', '重來', 'Reset').click() cy.CheckTextElement('#reset', '重來', 'Reset').click()