mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +08:00
Update tests:
- Add public command to press enter until story end - Add public command to check status pending
This commit is contained in:
1 parent
5d7c922fa6
commit
c86163fd10
2 files changed
+36
-18
No files matched your search
@@ -1,5 +1,4 @@
|
|||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
export default function checkLoginUI() {
|
export default function checkLoginUI() {
|
||||||
cy.get('h1.text-text-primary')
|
cy.get('h1.text-text-primary')
|
||||||
.should('contain', 'Linux Odyssey')
|
.should('contain', 'Linux Odyssey')
|
||||||
@@ -49,6 +48,12 @@ describe('example helloworld app', () => {
|
|||||||
'be.visible'
|
'be.visible'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
it('Check login fail', () => {
|
||||||
|
cy.LoginWithPassword('dddd', '123456')
|
||||||
|
cy.get('p').contains('Wrong username or password.').should('be.visible')
|
||||||
|
cy.LoginWithPassword(`ddd\``, '123456')
|
||||||
|
cy.get('p').contains('Invalid username or password.').should('be.visible')
|
||||||
|
})
|
||||||
it('Login-Password Already Register', () => {
|
it('Login-Password Already Register', () => {
|
||||||
cy.LoginWithPassword(
|
cy.LoginWithPassword(
|
||||||
Cypress.env('defaultAccount'),
|
Cypress.env('defaultAccount'),
|
||||||
@@ -64,6 +69,8 @@ describe('example helloworld app', () => {
|
|||||||
cy.findByRole('button', { name: 'Hello, Linux World!' }).should(
|
cy.findByRole('button', { name: 'Hello, Linux World!' }).should(
|
||||||
'be.visible'
|
'be.visible'
|
||||||
)
|
)
|
||||||
|
cy.findByRole('link', { name: 'Bug Report' }).should('be.visible')
|
||||||
|
cy.findByRole('button', { name: 'Sign Out' }).should('be.visible')
|
||||||
})
|
})
|
||||||
it('Check QuestInfo', () => {
|
it('Check QuestInfo', () => {
|
||||||
cy.get('#topic').should('contain', 'Hello, Linux World!')
|
cy.get('#topic').should('contain', 'Hello, Linux World!')
|
||||||
@@ -128,10 +135,8 @@ describe('example helloworld app', () => {
|
|||||||
// Stage1
|
// Stage1
|
||||||
cy.log('Stage1')
|
cy.log('Stage1')
|
||||||
cy.typeInCommand(answerarr[0])
|
cy.typeInCommand(answerarr[0])
|
||||||
cy.get('input[id="currentStatus"]', { timeout: 1000000 }).should(
|
cy.checkPending()
|
||||||
'have.value',
|
cy.waitUntilActive()
|
||||||
'active'
|
|
||||||
)
|
|
||||||
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')
|
||||||
cy.checkHint(1, 1)
|
cy.checkHint(1, 1)
|
||||||
@@ -140,10 +145,8 @@ describe('example helloworld app', () => {
|
|||||||
// Stage2
|
// Stage2
|
||||||
cy.log('Stage2')
|
cy.log('Stage2')
|
||||||
cy.typeInCommand(answerarr[1])
|
cy.typeInCommand(answerarr[1])
|
||||||
cy.get('input[id="currentStatus"]', { timeout: 1000000 }).should(
|
cy.checkPending()
|
||||||
'have.value',
|
cy.waitUntilActive()
|
||||||
'active'
|
|
||||||
)
|
|
||||||
cy.get('#tree')
|
cy.get('#tree')
|
||||||
.get('a')
|
.get('a')
|
||||||
.should('contain', 'forgotten_scroll.txt')
|
.should('contain', 'forgotten_scroll.txt')
|
||||||
@@ -158,20 +161,16 @@ describe('example helloworld app', () => {
|
|||||||
// Stage3
|
// Stage3
|
||||||
cy.log('Stage3')
|
cy.log('Stage3')
|
||||||
cy.typeInCommand(answerarr[2])
|
cy.typeInCommand(answerarr[2])
|
||||||
cy.get('input[id="currentStatus"]', { timeout: 1000000 }).should(
|
cy.checkPending()
|
||||||
'have.value',
|
cy.waitUntilActive()
|
||||||
'active'
|
|
||||||
)
|
|
||||||
cy.getQuestInfo('✓ 查看卷軸').should('be.visible')
|
cy.getQuestInfo('✓ 查看卷軸').should('be.visible')
|
||||||
cy.getQuestInfo('解除封印').should('be.visible')
|
cy.getQuestInfo('解除封印').should('be.visible')
|
||||||
cy.checkHint(3, 3)
|
cy.checkHint(3, 3)
|
||||||
// Stage4
|
// Stage4
|
||||||
cy.log('Stage4')
|
cy.log('Stage4')
|
||||||
cy.typeInCommand(answerarr[3])
|
cy.typeInCommand(answerarr[3])
|
||||||
cy.get('input[id="currentStatus"]', { timeout: 1000000 }).should(
|
cy.checkPending()
|
||||||
'have.value',
|
cy.waitUntilActive()
|
||||||
'active'
|
|
||||||
)
|
|
||||||
cy.getQuestInfo('✓ 解除封印').should('be.visible')
|
cy.getQuestInfo('✓ 解除封印').should('be.visible')
|
||||||
cy.findByRole(
|
cy.findByRole(
|
||||||
'heading',
|
'heading',
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ Cypress.Commands.add('typeInCommand', (command) => {
|
|||||||
Cypress.Commands.add('getQuestInfo', (id) => {
|
Cypress.Commands.add('getQuestInfo', (id) => {
|
||||||
return cy
|
return cy
|
||||||
.get('#quest')
|
.get('#quest')
|
||||||
.find('p.text-text')
|
.find('li')
|
||||||
|
.find('p')
|
||||||
.contains(`${id}`, { timeout: 100000 })
|
.contains(`${id}`, { timeout: 100000 })
|
||||||
})
|
})
|
||||||
Cypress.Commands.add('checkHint', (index, total) => {
|
Cypress.Commands.add('checkHint', (index, total) => {
|
||||||
@@ -36,3 +37,21 @@ Cypress.Commands.add('checkHint', (index, total) => {
|
|||||||
.contains(`${index}/${total}`)
|
.contains(`${index}/${total}`)
|
||||||
.should('be.visible')
|
.should('be.visible')
|
||||||
})
|
})
|
||||||
|
Cypress.Commands.add('waitUntilActive', () => {
|
||||||
|
cy.get('input[id="currentStatus"]', { timeout: 1000000 })
|
||||||
|
.invoke('val')
|
||||||
|
.then((value) => {
|
||||||
|
if (value === 'active' || value === 'finished') {
|
||||||
|
cy.log('story ends')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cy.typeInCommand('{enter}')
|
||||||
|
cy.waitUntilActive()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
Cypress.Commands.add('checkPending', () => {
|
||||||
|
cy.get('input[id="currentStatus"]', { timeout: 1000000 }).should(
|
||||||
|
'have.value',
|
||||||
|
'pending'
|
||||||
|
)
|
||||||
|
})
|
||||||
Reference in new issue
Block a user