From 9bac360498d282d1d33d4342928875a7fd699c4f Mon Sep 17 00:00:00 2001 From: Annie Huang Date: Mon, 19 Feb 2024 18:46:50 +0800 Subject: [PATCH] fixed type error --- tests/cypress/e2e/UItests.cy.ts | 22 ++++++++++------------ tests/cypress/support/commands.ts | 14 ++++++-------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/tests/cypress/e2e/UItests.cy.ts b/tests/cypress/e2e/UItests.cy.ts index 9d0050f..b5ab9a0 100644 --- a/tests/cypress/e2e/UItests.cy.ts +++ b/tests/cypress/e2e/UItests.cy.ts @@ -95,20 +95,18 @@ describe('example helloworld app', () => { cy.CheckTextElement('#tasks', '任務', 'Tasks:') }) it('Check Terminal', () => { - cy.get('#terminal', { timeout: 20000 }).within(($terminal) => { - cy.get($terminal).should('be.visible') - cy.get('svg[data-icon="terminal"]').should('be.visible') - cy.CheckTextElement('#Terminal', '終端機', 'Terminal') - cy.get('@Terminaltextbox') - .should('be.visible') - .and('contain', 'commander:~ $') - }) + // cy.get('#terminal', { timeout: 20000 }).within(($terminal) => { + // cy.get($terminal).should('be.visible') + cy.get('#terminal', { timeout: 20000 }).should('be.visible') + cy.get('svg[data-icon="terminal"]').should('be.visible') + cy.CheckTextElement('#Terminal', '終端機', 'Terminal') + cy.get('@Terminaltextbox') + .should('be.visible') + .and('contain', 'commander:~ $') }) it('Check Hint Part', () => { - cy.get('#hint', { timeout: 20000 }).within(($hint) => { - cy.get($hint).should('be.visible') - cy.get('svg[data-icon="lightbulb"]').should('be.visible') - }) + cy.get('#hint', { timeout: 20000 }).should('be.visible') + cy.get('svg[data-icon="lightbulb"]').should('be.visible') cy.CheckTextElement('#hint', '提示', 'Hint') }) it('Check File TreeChart', () => { diff --git a/tests/cypress/support/commands.ts b/tests/cypress/support/commands.ts index 342d831..afda4fc 100644 --- a/tests/cypress/support/commands.ts +++ b/tests/cypress/support/commands.ts @@ -8,7 +8,7 @@ declare global { PrepareForGame(): Chainable InitTerminal(): Chainable typeInCommand(command: string): Chainable - getQuestInfo(id: string): Chainable + getQuestInfo(id: string): Chainable> checkHint(index: number, total: number): Chainable // 修改類型 checkTaskInit(): Chainable waitUntilActive(last?: boolean): Chainable // 注意小寫boolean,並且變量名應該是小寫 @@ -136,13 +136,11 @@ Cypress.Commands.add('CompleteStageWithCommands', (stagename) => { }) }) Cypress.Commands.add('CheckTextElement', (id, chText, enText) => { - cy.get(id, { timeout: 50000 }).within(($element) => { - if (Cypress.env('isCHVersion')) { - cy.get($element).should('contain', chText).and('be.visible') - } else { - cy.get($element).should('contain', enText).and('be.visible') - } - }) + if (Cypress.env('isCHVersion')) { + cy.get(id, { timeout: 50000 }).should('contain', chText).and('be.visible') + } else { + cy.get(id, { timeout: 50000 }).should('contain', enText).and('be.visible') + } }) Cypress.Commands.add('CheckPlaceholder', (id, chText, enText) => { cy.get(id)