- Add auto-complete quest command

- Change spec name
- Add spec complete all quests
- Add Icon (totem version)
- Add some id for tests
- Add answer.sh for all quests
This commit is contained in:
Annie Huang committed 2023-12-03 01:40:51 +08:00
1 parent dc1d3f6ce5
commit 7a3b6b1cfb
17 files changed
+241 -37

No files matched your search

+32 -4
View File
@@ -25,15 +25,20 @@ Cypress.Commands.add('PrepareForGame', () => {
cy.get('.xterm-screen', { timeout: 10000 })
.as('Terminaltextbox')
.should('be.visible')
cy.checkTaskInit()
cy.CheckTextElement('#reset', '重來', 'Reset').click()
cy.typeInCommand('clear{enter}')
cy.checkTaskInit()
cy.InitTerminal()
})
Cypress.Commands.add('InitTerminal', () => {
cy.get('@Terminaltextbox', { timeout: 150000 }).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: 150000 }).type(command, { delay: 10 })
})
Cypress.Commands.add('getQuestInfo', (id) => {
return cy
@@ -48,6 +53,9 @@ Cypress.Commands.add('checkHint', (index, total) => {
.contains(`${index}/${total}`)
.should('be.visible')
})
Cypress.Commands.add('checkTaskInit', () => {
cy.get('#tasks').next().children().should('be.visible')
})
Cypress.Commands.add('waitUntilActive', () => {
cy.get('input[id="currentStatus"]', { timeout: 1000000 })
.invoke('val')
@@ -66,8 +74,25 @@ Cypress.Commands.add('checkPending', () => {
'pending'
)
})
Cypress.Commands.add('Complete the Stage (only command)', () => {
cy.log('')
Cypress.Commands.add('CompleteStageWithCommands', (stagename) => {
cy.visit(`/game/${stagename}`)
cy.url().should('include', `/game/${stagename}`)
cy.log(`Completing stage :${stagename}`)
cy.checkTaskInit()
cy.CheckTextElement('#reset', '重來', 'Reset').click()
cy.checkTaskInit()
cy.InitTerminal()
cy.readFile(`../quests/${stagename}/answer.sh`, 'utf-8').as('answers')
cy.get('@answers').then((answers) => {
const answerarr = answers.split('\n')
for (const element of answerarr) {
cy.typeInCommand(`${element}{enter}`)
if (answerarr.indexOf(element) + 1 !== answerarr.length) {
cy.checkPending()
cy.waitUntilActive()
}
}
})
})
Cypress.Commands.add('CheckTextElement', (id, chText, enText) => {
cy.get(id).within(($element) => {
@@ -89,3 +114,6 @@ Cypress.Commands.add('CheckPlaceholder', (id, chText, enText) => {
}
})
})
Cypress.Commands.add('CheckTreeElement', (element) => {
cy.get('#tree').get('a').should('contain', `${element}`).and('be.visible')
})