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