Cypress update (not yet for playing game)

This commit is contained in:
Annie Huang committed 2023-11-12 21:15:36 +08:00
1 parent 433ced4867
commit cd7d48b322
5 files changed
+141 -75

No files matched your search

+7 -4
View File
@@ -2,14 +2,17 @@ import '@testing-library/cypress/add-commands'
Cypress.Commands.add('LoginWithPassword', (username, password) => {
cy.clearAllCookies({ domain: null })
cy.get('a.text-text-primary').should('contain', 'Log in').click()
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()
cy.findByRole('button', { name: 'Log In' }).click()
})
Cypress.Commands.add('PrepareForGame', () => {
cy.visit('/')
cy.LoginWithPassword('alex', '123456')
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}')
@@ -26,7 +29,7 @@ Cypress.Commands.add('getTaskCheckbox', (id) => {
})
Cypress.Commands.add('checkHint', (index, total) => {
cy.get('#hint')
.get('.flex-wrap')
.find('.flex-wrap')
.contains(`${index}/${total}`)
.should('be.visible')
})