Update function in command.js

This commit is contained in:
Annie Huang committed 2023-10-30 15:00:30 +08:00
1 parent a351eef898
commit 030b7b749e
2 files changed
+23 -24

No files matched your search

+15 -1
View File
@@ -32,8 +32,16 @@ Cypress.Commands.add('LoginWithPassword', (username, password) => {
cy.get('#password').type(password)
cy.findByRole('button', { name: 'Log in' }).click()
})
Cypress.Commands.add('PrepareForGame', () => {
cy.visit('/')
cy.LoginWithPassword('alex', '123456')
cy.get('.xterm-screen').as('Terminaltextbox').should('be.visible')
cy.findByRole('button', { name: 'Reset' }).click()
cy.typeInCommand('clear{enter}')
cy.get('@Terminaltextbox').should('contain', 'commander:~ $')
})
Cypress.Commands.add('typeInCommand', (command) => {
cy.get('.xterm-screen').type(command)
cy.get('.xterm-screen', { timeout: 150000 }).type(command)
})
Cypress.Commands.add('getQuestInfo', (id) => {
return cy.get('#quest').find('p.text-text').contains(`${id}`)
@@ -41,3 +49,9 @@ Cypress.Commands.add('getQuestInfo', (id) => {
Cypress.Commands.add('getTaskCheckbox', (id) => {
return cy.getQuestInfo(id).findByRole('checkbox')
})
Cypress.Commands.add('checkHint', (index, total) => {
cy.get('#hint')
.get('.flex-wrap')
.contains(`${index}/${total}`)
.should('be.visible')
})