mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
fix; cypress use 'get-started' as test quest
This commit is contained in:
1 parent
2cc8a98734
commit
f03a544108
2 files changed
+40
-55
No files matched your search
@@ -74,19 +74,18 @@ describe('example helloworld app', () => {
|
||||
})
|
||||
})
|
||||
describe('Game Start Page UI', () => {
|
||||
const title = '終端機的基本知識'
|
||||
beforeEach(() => {
|
||||
cy.PrepareForGame()
|
||||
})
|
||||
it('Check Header', () => {
|
||||
cy.get('#HeaderText')
|
||||
.should('contain', 'Hello, Linux World!')
|
||||
.and('be.visible')
|
||||
cy.get('#HeaderText').should('contain', title).and('be.visible')
|
||||
cy.findByRole('link', { name: 'Bug Report' }).should('be.visible')
|
||||
cy.findByRole('button', { name: 'Sign Out' }).should('be.visible')
|
||||
})
|
||||
it('Check QuestInfo', () => {
|
||||
cy.get('#topic').should('contain', 'Hello, Linux World!')
|
||||
cy.get('#quest').find('p.text-text').should('have.length', 3)
|
||||
cy.get('#topic').should('contain', title)
|
||||
cy.get('#quest').find('p.text-text').should('have.length', 4)
|
||||
cy.CheckTextElement('#tasks', '任務', 'Tasks:')
|
||||
cy.getQuestInfo('輸入 `echo help` 來朗誦咒語').should('be.visible')
|
||||
})
|
||||
@@ -120,7 +119,6 @@ describe('example helloworld app', () => {
|
||||
describe('Game Play', () => {
|
||||
beforeEach(() => {
|
||||
cy.PrepareForGame()
|
||||
cy.readFile('../quests/helloworld/answer.sh', 'utf-8').as('answers')
|
||||
})
|
||||
it('Typing in Terminal', () => {
|
||||
cy.typeInCommand('12345{enter}')
|
||||
@@ -129,54 +127,41 @@ describe('example helloworld app', () => {
|
||||
.and('contain', '12345')
|
||||
})
|
||||
it('Complete the Game(relating UI)', () => {
|
||||
// get answersheet
|
||||
cy.get('@answers').then((answers) => {
|
||||
const answerarr = answers.split('\n')
|
||||
// Stage1
|
||||
cy.log('Stage1')
|
||||
cy.typeInCommand(answerarr[0])
|
||||
cy.checkPending()
|
||||
cy.waitUntilActive()
|
||||
cy.get('#Lbutton').should('be.visible').and('be.disabled')
|
||||
cy.get('#Rbutton').should('be.visible').and('be.disabled')
|
||||
cy.checkHint(1, 1)
|
||||
cy.getQuestInfo('✓ 輸入 `echo help` 來朗誦咒語').should('be.visible')
|
||||
cy.getQuestInfo('搜索卷軸').should('be.visible')
|
||||
// Stage2
|
||||
cy.log('Stage2')
|
||||
cy.typeInCommand(answerarr[1])
|
||||
cy.checkPending()
|
||||
cy.waitUntilActive()
|
||||
cy.get('#tree')
|
||||
.get('a')
|
||||
.should('contain', 'forgotten_scroll.txt')
|
||||
.and('be.visible')
|
||||
cy.get('#Lbutton').should('be.visible').and('be.enabled')
|
||||
cy.get('#Rbutton').should('be.visible').and('be.disabled')
|
||||
cy.checkHint(2, 2)
|
||||
cy.get('#Lbutton').click()
|
||||
cy.get('#Rbutton').should('be.enabled')
|
||||
cy.getQuestInfo('✓ 搜索卷軸').should('be.visible')
|
||||
cy.getQuestInfo('查看卷軸').should('be.visible')
|
||||
// Stage3
|
||||
cy.log('Stage3')
|
||||
cy.typeInCommand(answerarr[2])
|
||||
cy.checkPending()
|
||||
cy.waitUntilActive()
|
||||
cy.getQuestInfo('✓ 查看卷軸').should('be.visible')
|
||||
cy.getQuestInfo('解除封印').should('be.visible')
|
||||
cy.checkHint(3, 3)
|
||||
// Stage4
|
||||
cy.log('Stage4')
|
||||
cy.typeInCommand(answerarr[3])
|
||||
cy.checkPending()
|
||||
cy.waitUntilActive()
|
||||
cy.getQuestInfo('✓ 解除封印').should('be.visible')
|
||||
// Check survey dialog pop up
|
||||
cy.CheckTextElement('#QuestCompleted', '關卡完成!', 'Quest Completed!')
|
||||
cy.get('div[class="modal"]').find('p').should('be.visible')
|
||||
cy.findByRole('link', { name: '填寫問卷' }).should('be.visible')
|
||||
})
|
||||
// Stage1
|
||||
cy.log('Stage1')
|
||||
cy.typeInCommand('echo start{enter}')
|
||||
cy.checkPending()
|
||||
cy.waitUntilActive()
|
||||
cy.get('#Lbutton').should('be.visible').and('be.disabled')
|
||||
cy.get('#Rbutton').should('be.visible').and('be.disabled')
|
||||
cy.checkHint(1, 1)
|
||||
cy.getQuestInfo('✓ 輸入 `echo start` 來開始教程').should('be.visible')
|
||||
cy.getQuestInfo('➤ 在終端機輸入 `echo hello`').should('be.visible')
|
||||
// Stage2
|
||||
cy.log('Stage2')
|
||||
cy.typeInCommand('echo hello{enter}')
|
||||
cy.checkPending()
|
||||
cy.waitUntilActive()
|
||||
// cy.get('#tree')
|
||||
// .get('a')
|
||||
// .should('contain', 'forgotten_scroll.txt')
|
||||
// .and('be.visible')
|
||||
cy.get('#Lbutton').should('be.visible').and('be.enabled')
|
||||
cy.get('#Rbutton').should('be.visible').and('be.disabled')
|
||||
cy.checkHint(2, 2)
|
||||
cy.get('#Lbutton').click()
|
||||
cy.get('#Rbutton').should('be.enabled')
|
||||
cy.getQuestInfo('✓ 在終端機輸入 `echo hello`').should('be.visible')
|
||||
cy.getQuestInfo('➤ 結束關卡').should('be.visible')
|
||||
// Stage3
|
||||
cy.log('Stage3')
|
||||
cy.typeInCommand('echo finish{enter}')
|
||||
cy.checkPending()
|
||||
cy.waitUntilActive()
|
||||
cy.getQuestInfo('✓ 結束關卡').should('be.visible')
|
||||
cy.CheckTextElement('#QuestCompleted', '關卡完成!', 'Quest Completed!')
|
||||
cy.get('div[class="modal"]').find('p').should('be.visible')
|
||||
cy.findByRole('link', { name: '填寫問卷' }).should('be.visible')
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -14,7 +14,7 @@ Cypress.Commands.add('PrepareForGame', () => {
|
||||
Cypress.env('defaultPassword')
|
||||
)
|
||||
cy.url().should('include', '/map')
|
||||
cy.visit('/game/helloworld')
|
||||
cy.visit('/game/get-started')
|
||||
cy.get('.xterm-screen', { timeout: 10000 })
|
||||
.as('Terminaltextbox')
|
||||
.should('be.visible')
|
||||
|
||||
Reference in new issue
Block a user