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() {
|
export default function checkLoginUI() {
|
||||||
cy.get('#title').should('contain', 'Linux Odyssey').and('be.visible')
|
cy.get('#title').should('contain', 'Linux Odyssey').and('be.visible')
|
||||||
cy.CheckPlaceholder('#password', '密碼', 'Password')
|
cy.CheckPlaceholder('#password', '密碼', 'Password')
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
/// <reference types="cypress" />
|
|
||||||
describe('Complete quests with only commands', () => {
|
describe('Complete quests with only commands', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.PrepareForGame()
|
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) => {
|
Cypress.Commands.add(
|
||||||
cy.clearAllCookies({ domain: null })
|
'LoginWithPassword',
|
||||||
cy.visit('/login')
|
(username: string, password: string) => {
|
||||||
cy.get('#username').type(username)
|
cy.clearAllCookies({ domain: null })
|
||||||
cy.get('#password').type(password)
|
cy.visit('/login')
|
||||||
cy.get('#LogInOrSignUp').click()
|
cy.get('#username').type(username)
|
||||||
})
|
cy.get('#password').type(password)
|
||||||
|
cy.get('#LogInOrSignUp').click()
|
||||||
|
}
|
||||||
|
)
|
||||||
Cypress.Commands.add('PrepareForGame', () => {
|
Cypress.Commands.add('PrepareForGame', () => {
|
||||||
cy.visit('/')
|
cy.visit('/')
|
||||||
// make sure the login page is loaded
|
// make sure the login page is loaded
|
||||||
@@ -13,5 +13,8 @@
|
|||||||
"@testing-library/cypress": "^10.0.1",
|
"@testing-library/cypress": "^10.0.1",
|
||||||
"cypress": "^13.5.1",
|
"cypress": "^13.5.1",
|
||||||
"dotenv": "^16.3.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"]
|
||||||
|
}
|
||||||
@@ -9098,6 +9098,7 @@ __metadata:
|
|||||||
"@testing-library/cypress": "npm:^10.0.1"
|
"@testing-library/cypress": "npm:^10.0.1"
|
||||||
cypress: "npm:^13.5.1"
|
cypress: "npm:^13.5.1"
|
||||||
dotenv: "npm:^16.3.1"
|
dotenv: "npm:^16.3.1"
|
||||||
|
typescript: "npm:^5.3.3"
|
||||||
languageName: unknown
|
languageName: unknown
|
||||||
linkType: soft
|
linkType: soft
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user