mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 11:30:13 +08:00
Add check finished, typing delay
This commit is contained in:
1 parent
7a3b6b1cfb
commit
10ac3c720e
1 file changed
+26
-2
@@ -38,7 +38,9 @@ Cypress.Commands.add('InitTerminal', () => {
|
|||||||
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, { delay: 10 })
|
cy.get('.xterm-screen', { timeout: 150000 }).type(command, {
|
||||||
|
delay: 100,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
Cypress.Commands.add('getQuestInfo', (id) => {
|
Cypress.Commands.add('getQuestInfo', (id) => {
|
||||||
return cy
|
return cy
|
||||||
@@ -60,7 +62,7 @@ Cypress.Commands.add('waitUntilActive', () => {
|
|||||||
cy.get('input[id="currentStatus"]', { timeout: 1000000 })
|
cy.get('input[id="currentStatus"]', { timeout: 1000000 })
|
||||||
.invoke('val')
|
.invoke('val')
|
||||||
.then((value) => {
|
.then((value) => {
|
||||||
if (value === 'active' || value === 'finished') {
|
if (value === 'active') {
|
||||||
cy.log('story ends')
|
cy.log('story ends')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -68,6 +70,22 @@ Cypress.Commands.add('waitUntilActive', () => {
|
|||||||
cy.waitUntilActive()
|
cy.waitUntilActive()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Cypress.Commands.add('checkFinished', () => {
|
||||||
|
cy.get('input[id="currentStatus"]', { timeout: 1000000 })
|
||||||
|
.invoke('val')
|
||||||
|
.then((value) => {
|
||||||
|
if (value === 'finished') {
|
||||||
|
cy.log(value)
|
||||||
|
cy.log('Quest Finished')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (value === 'pending') {
|
||||||
|
cy.log(value)
|
||||||
|
cy.typeInCommand('{enter}')
|
||||||
|
cy.checkFinished()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
Cypress.Commands.add('checkPending', () => {
|
Cypress.Commands.add('checkPending', () => {
|
||||||
cy.get('input[id="currentStatus"]', { timeout: 1000000 }).should(
|
cy.get('input[id="currentStatus"]', { timeout: 1000000 }).should(
|
||||||
'have.value',
|
'have.value',
|
||||||
@@ -91,6 +109,12 @@ Cypress.Commands.add('CompleteStageWithCommands', (stagename) => {
|
|||||||
cy.checkPending()
|
cy.checkPending()
|
||||||
cy.waitUntilActive()
|
cy.waitUntilActive()
|
||||||
}
|
}
|
||||||
|
if (answerarr.indexOf(element) + 1 === answerarr.length) {
|
||||||
|
cy.checkFinished()
|
||||||
|
cy.CheckTextElement('#QuestCompleted', '關卡完成!', 'Quest Completed!')
|
||||||
|
cy.get('div[class="modal"]').find('p').should('be.visible')
|
||||||
|
cy.get('#BacktoMap').should('be.visible').and('contain', '回到地圖')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in new issue
Block a user