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
(cherry picked from commit c86163fd10)
This commit is contained in:
1 parent
103a8dbd0f
commit
837712b742
2 files changed
+239
-31
No files matched your search
@@ -1,25 +1,57 @@
|
||||
// ***********************************************
|
||||
// This example commands.js shows you how to
|
||||
// create various custom commands and overwrite
|
||||
// existing commands.
|
||||
//
|
||||
// For more comprehensive examples of custom
|
||||
// commands please read more here:
|
||||
// https://on.cypress.io/custom-commands
|
||||
// ***********************************************
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
// Cypress.Commands.add('login', (email, password) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a dual command --
|
||||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||
import '@testing-library/cypress/add-commands'
|
||||
|
||||
Cypress.Commands.add('LoginWithPassword', (username, password) => {
|
||||
cy.clearAllCookies({ domain: null })
|
||||
cy.get('a.text-text-primary', { timeout: 100000 }).contains('Log in').click()
|
||||
cy.get('#username').type(username)
|
||||
cy.get('#password').type(password)
|
||||
cy.findByRole('button', { name: 'Log In' }).click()
|
||||
})
|
||||
Cypress.Commands.add('PrepareForGame', () => {
|
||||
cy.visit('/')
|
||||
cy.LoginWithPassword(
|
||||
Cypress.env('defaultAccount'),
|
||||
Cypress.env('defaultPassword')
|
||||
)
|
||||
cy.get('.xterm-screen').as('Terminaltextbox').should('be.visible')
|
||||
cy.findByRole('button', { name: 'Reset' }).click()
|
||||
cy.typeInCommand('clear{enter}')
|
||||
cy.get('@Terminaltextbox', { timeout: 150000 }).should(
|
||||
'contain',
|
||||
'commander:~ $'
|
||||
)
|
||||
})
|
||||
Cypress.Commands.add('typeInCommand', (command) => {
|
||||
cy.get('.xterm-screen', { timeout: 150000 }).type(command)
|
||||
})
|
||||
Cypress.Commands.add('getQuestInfo', (id) => {
|
||||
return cy
|
||||
.get('#quest')
|
||||
.find('li')
|
||||
.find('p')
|
||||
.contains(`${id}`, { timeout: 100000 })
|
||||
})
|
||||
Cypress.Commands.add('checkHint', (index, total) => {
|
||||
cy.get('#hint')
|
||||
.find('.justify-end')
|
||||
.contains(`${index}/${total}`)
|
||||
.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