mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
typescript initial edit
This commit is contained in:
1 parent
c06d6d6deb
commit
5c17f5ea3c
6 files changed
+60
-10
No files matched your search
@@ -1,4 +1,3 @@
|
||||
/// <reference types="cypress" />
|
||||
export default function checkLoginUI() {
|
||||
cy.get('#title').should('contain', 'Linux Odyssey').and('be.visible')
|
||||
cy.CheckPlaceholder('#password', '密碼', 'Password')
|
||||
@@ -1,4 +1,3 @@
|
||||
/// <reference types="cypress" />
|
||||
describe('Complete quests with only commands', () => {
|
||||
beforeEach(() => {
|
||||
cy.PrepareForGame()
|
||||
@@ -1,12 +1,52 @@
|
||||
import '@testing-library/cypress/add-commands'
|
||||
// import '@testing-library/cypress/add-commands'
|
||||
declare global {
|
||||
declare namespace Cypress {
|
||||
interface Chainable {
|
||||
// 確保你有正確的泛型參數
|
||||
fillWith(
|
||||
account: string,
|
||||
password: string
|
||||
): Chainable<JQuery<HTMLElement>>
|
||||
LoginWithPassword(
|
||||
username: string,
|
||||
password: string
|
||||
): Chainable<JQuery<HTMLElement>>
|
||||
PrepareForGame(): Chainable<JQuery<HTMLElement>>
|
||||
InitTerminal(): Chainable<JQuery<HTMLElement>>
|
||||
typeInCommand(command: string): Chainable<JQuery<HTMLElement>>
|
||||
getQuestInfo(id: string): Chainable<JQuery<HTMLElement>>
|
||||
checkHint(index: number, total: number): Chainable<JQuery<HTMLElement>> // 修改類型
|
||||
checkTaskInit(): Chainable<JQuery<HTMLElement>>
|
||||
waitUntilActive(last: boolean): Chainable<JQuery<HTMLElement>> // 注意小寫boolean,並且變量名應該是小寫
|
||||
checkPending(): Chainable<JQuery<HTMLElement>>
|
||||
CompleteStageWithCommands(
|
||||
stagename: string
|
||||
): Chainable<JQuery<HTMLElement>>
|
||||
CheckTextElement(
|
||||
id: string,
|
||||
chText: string,
|
||||
enText: string
|
||||
): Chainable<JQuery<HTMLElement>>
|
||||
CheckPlaceholder(
|
||||
id: string,
|
||||
chText: string,
|
||||
enText: string
|
||||
): Chainable<JQuery<HTMLElement>>
|
||||
CheckTreeElement(element: string): Chainable<JQuery<HTMLElement>>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Cypress.Commands.add('LoginWithPassword', (username, password) => {
|
||||
cy.clearAllCookies({ domain: null })
|
||||
cy.visit('/login')
|
||||
cy.get('#username').type(username)
|
||||
cy.get('#password').type(password)
|
||||
cy.get('#LogInOrSignUp').click()
|
||||
})
|
||||
Cypress.Commands.add(
|
||||
'LoginWithPassword',
|
||||
(username: string, password: string) => {
|
||||
cy.clearAllCookies({ domain: null })
|
||||
cy.visit('/login')
|
||||
cy.get('#username').type(username)
|
||||
cy.get('#password').type(password)
|
||||
cy.get('#LogInOrSignUp').click()
|
||||
}
|
||||
)
|
||||
Cypress.Commands.add('PrepareForGame', () => {
|
||||
cy.visit('/')
|
||||
// make sure the login page is loaded
|
||||
@@ -13,5 +13,8 @@
|
||||
"@testing-library/cypress": "^10.0.1",
|
||||
"cypress": "^13.5.1",
|
||||
"dotenv": "^16.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.3.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": ["es5", "dom"],
|
||||
"types": ["cypress", "node"]
|
||||
},
|
||||
"include": ["**/*.ts"]
|
||||
}
|
||||
Reference in new issue
Block a user