mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
disable wait pending in e2e tests
This commit is contained in:
1 parent
039da53bbe
commit
a389d2752d
3 files changed
+20
-20
No files matched your search
@@ -75,7 +75,7 @@ describe('example helloworld app', () => {
|
||||
describe('Game Start Page UI', () => {
|
||||
const title = '終端機的基本知識'
|
||||
beforeEach(() => {
|
||||
cy.PrepareForGame()
|
||||
cy.PrepareForGame('get-started')
|
||||
})
|
||||
it('Check Header', () => {
|
||||
cy.get('#GameTitle').should('contain', 'Linux Odyssey').and('be.visible')
|
||||
@@ -124,7 +124,7 @@ describe('example helloworld app', () => {
|
||||
})
|
||||
describe('Game Play', () => {
|
||||
beforeEach(() => {
|
||||
cy.PrepareForGame()
|
||||
cy.PrepareForGame('get-started')
|
||||
})
|
||||
it('Typing in Terminal', () => {
|
||||
cy.typeInCommand('12345{enter}')
|
||||
@@ -136,7 +136,7 @@ describe('example helloworld app', () => {
|
||||
cy.checkTaskInit()
|
||||
cy.InitTerminal()
|
||||
cy.typeInCommand('echo start{enter}')
|
||||
cy.checkPending()
|
||||
// cy.checkPending()
|
||||
cy.waitUntilActive()
|
||||
cy.get('#Lbutton').should('be.visible').and('be.disabled')
|
||||
cy.get('#Rbutton').should('be.visible').and('be.disabled')
|
||||
@@ -144,7 +144,7 @@ describe('example helloworld app', () => {
|
||||
cy.getQuestInfo('✓ 輸入 echo start 來開始教程').should('be.visible')
|
||||
cy.getQuestInfo('➤ 在終端機輸入 echo hello').should('be.visible')
|
||||
cy.typeInCommand('echo hello{enter}')
|
||||
cy.checkPending()
|
||||
// cy.checkPending()
|
||||
cy.waitUntilActive()
|
||||
cy.get('#Lbutton').should('be.visible').and('be.enabled')
|
||||
cy.get('#Rbutton').should('be.visible').and('be.disabled')
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
describe('Complete quests with only commands', () => {
|
||||
beforeEach(() => {
|
||||
cy.PrepareForGame()
|
||||
})
|
||||
it('Complete quest : get-started', () => {
|
||||
cy.CompleteStageWithCommands('get-started')
|
||||
})
|
||||
|
||||
@@ -38,7 +38,7 @@ Cypress.Commands.add('LoginWithPassword', (username, password) => {
|
||||
cy.get('#password').type(password)
|
||||
cy.get('#LogInOrSignUp').click()
|
||||
})
|
||||
Cypress.Commands.add('PrepareForGame', () => {
|
||||
Cypress.Commands.add('PrepareForGame', (questId) => {
|
||||
cy.visit('/')
|
||||
// make sure the login page is loaded
|
||||
cy.url().should('satisfy', (elements: string) => {
|
||||
@@ -51,8 +51,9 @@ Cypress.Commands.add('PrepareForGame', () => {
|
||||
)
|
||||
// make sure the map page is loaded
|
||||
cy.url().should('include', '/map')
|
||||
cy.visit('/game/get-started')
|
||||
cy.url().should('include', '/game/get-started')
|
||||
const url = `/game/${questId}`
|
||||
cy.visit(url)
|
||||
cy.url().should('include', url)
|
||||
// check task first so the terminal has better possibility loaded
|
||||
cy.checkTaskInit()
|
||||
cy.get('.xterm-screen', { timeout: 10000 })
|
||||
@@ -114,8 +115,7 @@ Cypress.Commands.add('checkPending', () => {
|
||||
)
|
||||
})
|
||||
Cypress.Commands.add('CompleteStageWithCommands', (stagename) => {
|
||||
cy.visit(`/game/${stagename}`)
|
||||
cy.url().should('include', `/game/${stagename}`, { timeout: 50000 })
|
||||
cy.PrepareForGame(stagename)
|
||||
cy.log(`Completing stage :${stagename}`)
|
||||
cy.checkTaskInit()
|
||||
cy.CheckTextElement('#reset', '重來', 'Reset').click()
|
||||
@@ -123,19 +123,22 @@ Cypress.Commands.add('CompleteStageWithCommands', (stagename) => {
|
||||
cy.InitTerminal()
|
||||
cy.readFile(`../quests/${stagename}/answer.sh`, 'utf-8').then((answers) => {
|
||||
const answerarr = answers.split('\n')
|
||||
for (const element of answerarr) {
|
||||
answerarr.forEach((element, index) => {
|
||||
cy.typeInCommand(`${element}{enter}`)
|
||||
if (answerarr.indexOf(element) + 1 !== answerarr.length) {
|
||||
cy.checkPending()
|
||||
if (index < answerarr.length - 1) {
|
||||
cy.waitUntilActive()
|
||||
}
|
||||
if (answerarr.indexOf(element) + 1 === answerarr.length) {
|
||||
cy.waitUntilActive(true)
|
||||
cy.CheckTextElement('#QuestCompleted', '關卡完成!', 'Quest Completed!')
|
||||
} else {
|
||||
cy.waitUntilActive(true).then(() => {
|
||||
cy.CheckTextElement(
|
||||
'#QuestCompleted',
|
||||
'關卡完成!',
|
||||
'Quest Completed!'
|
||||
)
|
||||
cy.get('div[class="modal"]').find('p').should('be.visible')
|
||||
cy.get('#BacktoMap').should('be.visible').and('contain', '回到地圖')
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
Cypress.Commands.add('CheckTextElement', (id, chText, enText) => {
|
||||
|
||||
Reference in new issue
Block a user