mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
Add check chtext element and ids,fix quest problem
This commit is contained in:
1 parent
9da23b5dc1
commit
869f01a62b
11 files changed
+90
-78
No files matched your search
@@ -99,7 +99,7 @@ const handleChange = () => {
|
|||||||
</div>
|
</div>
|
||||||
<form @submit.prevent="handleSubmit()" class="w-full">
|
<form @submit.prevent="handleSubmit()" class="w-full">
|
||||||
<div v-if="socialLogin && hasSocialLogins">
|
<div v-if="socialLogin && hasSocialLogins">
|
||||||
<a
|
<a id="GoogleLogin"
|
||||||
v-if="availableMethods.google"
|
v-if="availableMethods.google"
|
||||||
class="inline-flex justify-center items-center rounded-lg py-2 mt-3 bg-bg-primary text-text-secondary w-full border-text-secondary border-2"
|
class="inline-flex justify-center items-center rounded-lg py-2 mt-3 bg-bg-primary text-text-secondary w-full border-text-secondary border-2"
|
||||||
href="/api/v1/auth/google"
|
href="/api/v1/auth/google"
|
||||||
@@ -113,7 +113,7 @@ const handleChange = () => {
|
|||||||
以Google繼續
|
以Google繼續
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a id="GitHubLogin"
|
||||||
v-if="availableMethods.github"
|
v-if="availableMethods.github"
|
||||||
class="inline-flex justify-center items-center rounded-lg py-2 mt-3 bg-bg-primary text-text-secondary w-full border-text-secondary border-2"
|
class="inline-flex justify-center items-center rounded-lg py-2 mt-3 bg-bg-primary text-text-secondary w-full border-text-secondary border-2"
|
||||||
href="/api/v1/auth/github"
|
href="/api/v1/auth/github"
|
||||||
@@ -124,10 +124,11 @@ const handleChange = () => {
|
|||||||
/>
|
/>
|
||||||
<span class="font-medium">
|
<span class="font-medium">
|
||||||
<!-- Continue with GitHub -->
|
<!-- Continue with GitHub -->
|
||||||
以Github繼續
|
以GitHub繼續
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<p
|
<p
|
||||||
|
id="or"
|
||||||
class="text-text-secondary flex justify-center mt-3"
|
class="text-text-secondary flex justify-center mt-3"
|
||||||
v-if="type === 'login' || type === 'register'"
|
v-if="type === 'login' || type === 'register'"
|
||||||
>
|
>
|
||||||
@@ -210,10 +211,11 @@ const handleChange = () => {
|
|||||||
@input="handleChange()"
|
@input="handleChange()"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-error flex justify-center" v-if="errorMessage">
|
<p id="ErrorDisplay" class="text-error flex justify-center" v-if="errorMessage">
|
||||||
{{ errorMessage }}
|
{{ errorMessage }}
|
||||||
</p>
|
</p>
|
||||||
<button
|
<button
|
||||||
|
id="LogInOrSignUp"
|
||||||
class="inline-flex justify-center rounded-lg font-black py-2 bg-text-primary text-bg w-full"
|
class="inline-flex justify-center rounded-lg font-black py-2 bg-text-primary text-bg w-full"
|
||||||
type="submit"
|
type="submit"
|
||||||
>
|
>
|
||||||
@@ -227,21 +229,21 @@ const handleChange = () => {
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<p class="text-text flex justify-center mt-3">
|
<p id="SwitchLoginRegister" class="text-text flex justify-center mt-3">
|
||||||
<span v-if="type === 'register'">
|
<span id="CheckRegistered" v-if="type === 'register'">
|
||||||
<!-- Already have an account? -->
|
<!-- Already have an account? -->
|
||||||
已經有帳號了嗎?
|
已經有帳號了嗎?
|
||||||
<RouterLink class="text-text-primary font-bold" to="/login">
|
<RouterLink id="SwitchtoLogin" class="text-text-primary font-bold" to="/login">
|
||||||
<u>
|
<u>
|
||||||
<!-- Log in -->
|
<!-- Log in -->
|
||||||
登入
|
登入
|
||||||
</u>
|
</u>
|
||||||
</RouterLink></span
|
</RouterLink></span
|
||||||
>
|
>
|
||||||
<span v-else-if="type === 'login'">
|
<span id="CheckRegistered" v-else-if="type === 'login'">
|
||||||
<!-- Don't have an account? -->
|
<!-- Don't have an account? -->
|
||||||
還沒有帳號嗎?
|
還沒有帳號嗎?
|
||||||
<RouterLink class="text-text-primary font-bold" to="/register">
|
<RouterLink id="SwitchtoRegister" class="text-text-primary font-bold" to="/register">
|
||||||
<u>
|
<u>
|
||||||
<!-- Sign up -->
|
<!-- Sign up -->
|
||||||
註冊
|
註冊
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<font-awesome-icon :icon="['fas', 'list']" class="text-text-primary p-1" />
|
<font-awesome-icon :icon="['fas', 'list']" class="text-text-primary p-1" />
|
||||||
<h1 class="inline text-text-primary font-xl">
|
<h1 id="CommandBook" class="inline text-text-primary font-xl">
|
||||||
<!-- Command Cheatsheets -->
|
<!-- Command Cheatsheets -->
|
||||||
指令之書
|
指令之書
|
||||||
</h1>
|
</h1>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ setTimeout(() => {
|
|||||||
<div v-if="showModal" class="modal">
|
<div v-if="showModal" class="modal">
|
||||||
<div class="modal-content bg-bg-secondary rounded-lg">
|
<div class="modal-content bg-bg-secondary rounded-lg">
|
||||||
<span class="close text-text" @click="closeModal">×</span>
|
<span class="close text-text" @click="closeModal">×</span>
|
||||||
<h2 class="text-2xl text-text mb-5 w-full inline-flex justify-center">
|
<h2 id="QuestCompleted" class="text-2xl text-text mb-5 w-full inline-flex justify-center">
|
||||||
<!-- Quest Completed! -->
|
<!-- Quest Completed! -->
|
||||||
關卡完成!
|
關卡完成!
|
||||||
</h2>
|
</h2>
|
||||||
@@ -27,6 +27,7 @@ setTimeout(() => {
|
|||||||
如果您能撥冗填寫這份問卷,我們將不勝感激,這對我們非常重要!
|
如果您能撥冗填寫這份問卷,我們將不勝感激,這對我們非常重要!
|
||||||
</p>
|
</p>
|
||||||
<a
|
<a
|
||||||
|
id="SurveyButton"
|
||||||
:href="surveyUrl"
|
:href="surveyUrl"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
class="inline-flex justify-center rounded-lg text-base font-black py-2 mt-3 bg-text-primary w-full"
|
class="inline-flex justify-center rounded-lg text-base font-black py-2 mt-3 bg-text-primary w-full"
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const handleLogout = async () => {
|
|||||||
class="text-text-tertiary h-full w-full"
|
class="text-text-tertiary h-full w-full"
|
||||||
/>
|
/>
|
||||||
</button> -->
|
</button> -->
|
||||||
<p
|
<p id="HeaderText"
|
||||||
class="text-text-primary inline-block font-bold whitespace-nowrap"
|
class="text-text-primary inline-block font-bold whitespace-nowrap"
|
||||||
style="font-size: 2vh"
|
style="font-size: 2vh"
|
||||||
v-if="sessionStore.quest"
|
v-if="sessionStore.quest"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import sessionStore from '../store/session'
|
|||||||
<div v-if="sessionStore.quest" class="whitespace-pre-wrap">
|
<div v-if="sessionStore.quest" class="whitespace-pre-wrap">
|
||||||
<p class="text-text">{{ sessionStore.quest.instruction }}</p>
|
<p class="text-text">{{ sessionStore.quest.instruction }}</p>
|
||||||
<br />
|
<br />
|
||||||
<p class="text-text">
|
<p id="tasks" class="text-text">
|
||||||
<!-- Tasks: -->
|
<!-- Tasks: -->
|
||||||
任務:
|
任務:
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<font-awesome-icon :icon="['fas', 'terminal']" class="text-text p-1" />
|
<font-awesome-icon :icon="['fas', 'terminal']" class="text-text p-1" />
|
||||||
<button class="text-text h-[5%]">
|
<button id="Terminal" class="text-text h-[5%]">
|
||||||
<!-- Terminal -->
|
<!-- Terminal -->
|
||||||
終端機
|
終端機
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ const handleLogin = async ({ username, password, success, error }) => {
|
|||||||
class="w-screen h-screen absolute top-0 left-0 flex flex-wrap justify-center content-center"
|
class="w-screen h-screen absolute top-0 left-0 flex flex-wrap justify-center content-center"
|
||||||
>
|
>
|
||||||
<div class="w-fit">
|
<div class="w-fit">
|
||||||
<AuthForm @onSubmit="handleLogin" type="login" />
|
<AuthForm @onSubmit="handleLogin" type="login" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -79,6 +79,16 @@ export async function deleteContainer(id) {
|
|||||||
await container.remove()
|
await container.remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseJSONOutput(data) {
|
||||||
|
const { stream, error } = JSON.parse(data.toString())
|
||||||
|
if (stream) {
|
||||||
|
console.log(stream)
|
||||||
|
}
|
||||||
|
if (error) {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function buildQuestImage(questPath, questId) {
|
export function buildQuestImage(questPath, questId) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
engine.buildImage(
|
engine.buildImage(
|
||||||
@@ -97,13 +107,17 @@ export function buildQuestImage(questPath, questId) {
|
|||||||
}
|
}
|
||||||
response.on('data', (data) => {
|
response.on('data', (data) => {
|
||||||
// Process the data (this could be Docker build output)
|
// Process the data (this could be Docker build output)
|
||||||
const { stream, error } = JSON.parse(data.toString())
|
try {
|
||||||
if (stream) {
|
data
|
||||||
console.log(stream)
|
.toString()
|
||||||
}
|
.split('\n')
|
||||||
if (error) {
|
.map((line) => line.trim())
|
||||||
console.error(error)
|
.filter((line) => line !== '')
|
||||||
reject(error)
|
.forEach((line) => {
|
||||||
|
parseJSONOutput(line.trim())
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
reject(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ module.exports = defineConfig({
|
|||||||
env: {
|
env: {
|
||||||
defaultAccount: getOrFail('TESTING_USERNAME'),
|
defaultAccount: getOrFail('TESTING_USERNAME'),
|
||||||
defaultPassword: getOrFail('TESTING_PASSWORD'),
|
defaultPassword: getOrFail('TESTING_PASSWORD'),
|
||||||
|
isCHVersion:true,
|
||||||
// google_username: process.env.GOOGLE_USERNAME,
|
// google_username: process.env.GOOGLE_USERNAME,
|
||||||
// google_password: process.env.GOOGLE_PASSWORD,
|
// google_password: process.env.GOOGLE_PASSWORD,
|
||||||
// google_client_id: process.env.GOOGLE_CLIENT_ID,
|
// google_client_id: process.env.GOOGLE_CLIENT_ID,
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ export default function checkLoginUI() {
|
|||||||
cy.get('h1.text-text-primary')
|
cy.get('h1.text-text-primary')
|
||||||
.should('contain', 'Linux Odyssey')
|
.should('contain', 'Linux Odyssey')
|
||||||
.and('be.visible')
|
.and('be.visible')
|
||||||
cy.get('#password')
|
cy.CheckPlaceholder('#password','密碼','Password')
|
||||||
.invoke('attr', 'placeholder')
|
|
||||||
.should('contain', 'Password')
|
|
||||||
}
|
}
|
||||||
describe('example helloworld app', () => {
|
describe('example helloworld app', () => {
|
||||||
describe('Login tests', () => {
|
describe('Login tests', () => {
|
||||||
@@ -14,51 +12,37 @@ describe('example helloworld app', () => {
|
|||||||
})
|
})
|
||||||
it('Check Login Page Elements-Register', () => {
|
it('Check Login Page Elements-Register', () => {
|
||||||
checkLoginUI()
|
checkLoginUI()
|
||||||
cy.get('#username')
|
cy.CheckPlaceholder('#username','帳號名稱','Username')
|
||||||
.invoke('attr', 'placeholder')
|
|
||||||
.should('contain', 'Username')
|
|
||||||
cy.get('label.text-text-secondary').should('be.visible') // check the rules is displayed
|
cy.get('label.text-text-secondary').should('be.visible') // check the rules is displayed
|
||||||
cy.get('#email').invoke('attr', 'placeholder').should('contain', 'Email')
|
cy.CheckPlaceholder('#email','電子郵件','Email')
|
||||||
cy.get('span').contains('Already have an account?').should('be.visible')
|
cy.CheckTextElement('#CheckRegistered','已經有帳號了嗎?','Already have an account?')
|
||||||
cy.get('a.text-text-primary')
|
cy.CheckTextElement('#SwitchtoLogin','登入','Log in')
|
||||||
.should('contain', 'Log in')
|
|
||||||
.and('be.visible')
|
|
||||||
})
|
})
|
||||||
it('Check Login Page Elements-Login', () => {
|
it('Check Login Page Elements-Login', () => {
|
||||||
cy.get('a.text-text-primary')
|
cy.get('#SwitchtoLogin').click()
|
||||||
.should('contain', 'Log in')
|
|
||||||
.and('be.visible')
|
|
||||||
.click()
|
|
||||||
checkLoginUI()
|
checkLoginUI()
|
||||||
cy.get('#username')
|
cy.CheckPlaceholder('#username','電子郵件 / 帳號名稱', 'Email / Username')
|
||||||
.invoke('attr', 'placeholder')
|
cy.get('#LogInOrSignUp').should('be.visible')
|
||||||
.should('contain', 'Email / Username')
|
cy.CheckTextElement('#CheckRegistered','還沒有帳號嗎?',"Don't have an account?")
|
||||||
cy.findByRole('button', { name: 'Log In' }).should('be.visible')
|
cy.CheckTextElement('#SwitchtoRegister','註冊','Sign up')
|
||||||
cy.get('span').contains("Don't have an account?").should('be.visible')
|
|
||||||
cy.get('a.text-text-primary')
|
|
||||||
.should('contain', 'Sign up')
|
|
||||||
.and('be.visible')
|
|
||||||
})
|
})
|
||||||
it('Check social account UI', () => {
|
it('Check social account UI', () => {
|
||||||
cy.get('p').contains('or').should('be.visible')
|
cy.CheckTextElement('#or','或','or')
|
||||||
cy.findByRole('link', { name: 'Continue with Google' }).should(
|
cy.CheckTextElement('#GoogleLogin','以Google繼續','Continue with Google')
|
||||||
'be.visible'
|
cy.CheckTextElement('#GitHubLogin','以GitHub繼續','Continue with GitHub')
|
||||||
)
|
|
||||||
cy.findByRole('link', { name: 'Continue with GitHub' }).should(
|
|
||||||
'be.visible'
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
it('Check login fail', () => {
|
it('Check login fail', () => {
|
||||||
cy.LoginWithPassword('dddd', '123456')
|
cy.LoginWithPassword('dddd', '123456')
|
||||||
cy.get('p').contains('Wrong username or password.').should('be.visible')
|
cy.CheckTextElement('#ErrorDisplay','錯誤的帳號名稱或密碼。','Wrong username or password.')
|
||||||
cy.LoginWithPassword(`ddd\``, '123456')
|
cy.LoginWithPassword(`ddd\``, '123456')
|
||||||
cy.get('p').contains('Invalid username or password.').should('be.visible')
|
cy.CheckTextElement('#ErrorDisplay','無效的帳號名稱或密碼。','Invalid username or password.')
|
||||||
})
|
})
|
||||||
it('Login-Password Already Register', () => {
|
it('Login-Password Already Register', () => {
|
||||||
cy.LoginWithPassword(
|
cy.LoginWithPassword(
|
||||||
Cypress.env('defaultAccount'),
|
Cypress.env('defaultAccount'),
|
||||||
Cypress.env('defaultPassword')
|
Cypress.env('defaultPassword')
|
||||||
)
|
)
|
||||||
|
cy.url().should('include', '/game')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
describe('Game Start Page UI', () => {
|
describe('Game Start Page UI', () => {
|
||||||
@@ -66,33 +50,29 @@ describe('example helloworld app', () => {
|
|||||||
cy.PrepareForGame()
|
cy.PrepareForGame()
|
||||||
})
|
})
|
||||||
it('Check Header', () => {
|
it('Check Header', () => {
|
||||||
cy.findByRole('button', { name: 'Hello, Linux World!' }).should(
|
cy.get('#HeaderText').should('contain','Hello, Linux World!').and('be.visible')
|
||||||
'be.visible'
|
|
||||||
)
|
|
||||||
cy.findByRole('link', { name: 'Bug Report' }).should('be.visible')
|
cy.findByRole('link', { name: 'Bug Report' }).should('be.visible')
|
||||||
cy.findByRole('button', { name: 'Sign Out' }).should('be.visible')
|
cy.findByRole('button', { name: 'Sign Out' }).should('be.visible')
|
||||||
})
|
})
|
||||||
it('Check QuestInfo', () => {
|
it('Check QuestInfo', () => {
|
||||||
cy.get('#topic').should('contain', 'Hello, Linux World!')
|
cy.get('#topic').should('contain', 'Hello, Linux World!')
|
||||||
cy.get('#quest').find('p.text-text').should('have.length', 3)
|
cy.get('#quest').find('p.text-text').should('have.length', 3)
|
||||||
cy.getQuestInfo('Tasks:').should('be.visible')
|
cy.CheckTextElement('#tasks','任務','Tasks:')
|
||||||
cy.getQuestInfo('輸入 `echo help` 來朗誦咒語').should('be.visible')
|
cy.getQuestInfo('輸入 `echo help` 來朗誦咒語').should('be.visible')
|
||||||
})
|
})
|
||||||
it('Check Command Cheat Sheet', () => {
|
it('Check Command Cheat Sheet', () => {
|
||||||
cy.get('#cmdlist').within(($cmdlist) => {
|
cy.get('#cmdlist').within(($cmdlist) => {
|
||||||
cy.get($cmdlist).should('be.visible')
|
cy.get($cmdlist).should('be.visible')
|
||||||
cy.get('svg[data-icon="list"]').should('be.visible')
|
cy.get('svg[data-icon="list"]').should('be.visible')
|
||||||
cy.get('h1').should('contain', 'Command Cheatsheets').and('be.visible')
|
cy.CheckTextElement('#CommandBook','指令之書','Command Cheatsheets')
|
||||||
cy.get('#cheatsheets')
|
cy.CheckTextElement('#cheatsheets','-- --指令列表-- --','--Command List--')
|
||||||
.should('contain', '--Command List--')
|
|
||||||
.and('be.visible')
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
it('Check Terminal', () => {
|
it('Check Terminal', () => {
|
||||||
cy.get('#terminal', { timeout: 20000 }).within(($terminal) => {
|
cy.get('#terminal', { timeout: 20000 }).within(($terminal) => {
|
||||||
cy.get($terminal).should('be.visible')
|
cy.get($terminal).should('be.visible')
|
||||||
cy.get('svg[data-icon="terminal"]').should('be.visible')
|
cy.get('svg[data-icon="terminal"]').should('be.visible')
|
||||||
cy.findByRole('button').should('contain', 'Terminal').and('be.visible')
|
cy.CheckTextElement('#Terminal','終端機','Terminal')
|
||||||
cy.get('@Terminaltextbox')
|
cy.get('@Terminaltextbox')
|
||||||
.should('be.visible')
|
.should('be.visible')
|
||||||
.and('contain', 'commander:~ $')
|
.and('contain', 'commander:~ $')
|
||||||
@@ -102,19 +82,17 @@ describe('example helloworld app', () => {
|
|||||||
cy.get('#hint', { timeout: 20000 }).within(($hint) => {
|
cy.get('#hint', { timeout: 20000 }).within(($hint) => {
|
||||||
cy.get($hint).should('be.visible')
|
cy.get($hint).should('be.visible')
|
||||||
cy.get('svg[data-icon="lightbulb"]').should('be.visible')
|
cy.get('svg[data-icon="lightbulb"]').should('be.visible')
|
||||||
cy.get('h1').should('contain', 'Hint').and('be.visible')
|
|
||||||
})
|
})
|
||||||
|
cy.CheckTextElement('#hint','提示','Hint')
|
||||||
})
|
})
|
||||||
it('Check File TreeChart', () => {
|
it('Check File TreeChart', () => {
|
||||||
cy.get('#tree').should('be.visible')
|
cy.get('#tree').should('be.visible')
|
||||||
cy.get('#tree').get('a').should('contain', '???').and('be.visible')
|
cy.get('#tree').get('a').should('contain', '???').and('be.visible')
|
||||||
})
|
})
|
||||||
it('Check Fucnctional Buttons', () => {
|
it('Check Fucnctional Buttons', () => {
|
||||||
cy.findByRole('button', { name: 'Solution' }, { timeout: 30000 }).should(
|
cy.CheckTextElement('#solution','解答','Solution')
|
||||||
'be.visible'
|
cy.CheckTextElement('#reset','重來','Reset')
|
||||||
)
|
cy.CheckTextElement('#continue','繼續','Continue')
|
||||||
cy.findByRole('button', { name: 'Reset' }).should('be.visible')
|
|
||||||
cy.findByRole('button', { name: 'Continue' }).should('be.visible')
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
describe('Game Play', () => {
|
describe('Game Play', () => {
|
||||||
@@ -128,7 +106,7 @@ describe('example helloworld app', () => {
|
|||||||
.should('contain', 'zsh: command not found: 12345')
|
.should('contain', 'zsh: command not found: 12345')
|
||||||
.and('contain', '12345')
|
.and('contain', '12345')
|
||||||
})
|
})
|
||||||
it.only('Complete the Game(relating UI)', () => {
|
it('Complete the Game(relating UI)', () => {
|
||||||
// get answersheet
|
// get answersheet
|
||||||
cy.get('@answers').then((answers) => {
|
cy.get('@answers').then((answers) => {
|
||||||
const answerarr = answers.split('\n')
|
const answerarr = answers.split('\n')
|
||||||
@@ -172,12 +150,8 @@ describe('example helloworld app', () => {
|
|||||||
cy.checkPending()
|
cy.checkPending()
|
||||||
cy.waitUntilActive()
|
cy.waitUntilActive()
|
||||||
cy.getQuestInfo('✓ 解除封印').should('be.visible')
|
cy.getQuestInfo('✓ 解除封印').should('be.visible')
|
||||||
cy.findByRole(
|
|
||||||
'heading',
|
|
||||||
{ name: 'Quest Completed!' },
|
|
||||||
{ timeout: 20000 }
|
|
||||||
).should('be.visible')
|
|
||||||
// Check survey dialog pop up
|
// Check survey dialog pop up
|
||||||
|
cy.CheckTextElement('#QuestCompleted','關卡完成!','Quest Completed!')
|
||||||
cy.get('div[class="modal"]').find('p').should('be.visible')
|
cy.get('div[class="modal"]').find('p').should('be.visible')
|
||||||
cy.findByRole('link', { name: '填寫問卷' }).should('be.visible')
|
cy.findByRole('link', { name: '填寫問卷' }).should('be.visible')
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ Cypress.Commands.add('LoginWithPassword', (username, password) => {
|
|||||||
cy.visit('/login')
|
cy.visit('/login')
|
||||||
cy.get('#username').type(username)
|
cy.get('#username').type(username)
|
||||||
cy.get('#password').type(password)
|
cy.get('#password').type(password)
|
||||||
cy.findByRole('button', { name: 'Log In' }).click()
|
cy.get('#LogInOrSignUp').click()
|
||||||
cy.url().should('include', '/game')
|
|
||||||
})
|
})
|
||||||
Cypress.Commands.add('PrepareForGame', () => {
|
Cypress.Commands.add('PrepareForGame', () => {
|
||||||
cy.visit('/')
|
cy.visit('/')
|
||||||
@@ -14,11 +13,12 @@ Cypress.Commands.add('PrepareForGame', () => {
|
|||||||
Cypress.env('defaultAccount'),
|
Cypress.env('defaultAccount'),
|
||||||
Cypress.env('defaultPassword')
|
Cypress.env('defaultPassword')
|
||||||
)
|
)
|
||||||
|
cy.url().should('include', '/game')
|
||||||
cy.visit('/game/helloworld')
|
cy.visit('/game/helloworld')
|
||||||
cy.get('.xterm-screen', { timeout: 10000 })
|
cy.get('.xterm-screen', { timeout: 10000 })
|
||||||
.as('Terminaltextbox')
|
.as('Terminaltextbox')
|
||||||
.should('be.visible')
|
.should('be.visible')
|
||||||
cy.findByRole('button', { name: 'Reset' }).click()
|
cy.CheckTextElement('#reset','重來','Reset').click()
|
||||||
cy.typeInCommand('clear{enter}')
|
cy.typeInCommand('clear{enter}')
|
||||||
cy.get('@Terminaltextbox', { timeout: 150000 }).should(
|
cy.get('@Terminaltextbox', { timeout: 150000 }).should(
|
||||||
'contain',
|
'contain',
|
||||||
@@ -66,3 +66,23 @@ Cypress.Commands.add('checkPending', () => {
|
|||||||
Cypress.Commands.add('Complete the Stage (only command)', () => {
|
Cypress.Commands.add('Complete the Stage (only command)', () => {
|
||||||
cy.log('')
|
cy.log('')
|
||||||
})
|
})
|
||||||
|
Cypress.Commands.add('CheckTextElement',(id,chText,enText)=>{
|
||||||
|
cy.get(id).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')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
Cypress.Commands.add('CheckPlaceholder',(id,chText,enText)=>{
|
||||||
|
cy.get(id).invoke('attr', 'placeholder').then(($placeHolder)=>{
|
||||||
|
if(Cypress.env('isCHVersion')){
|
||||||
|
expect($placeHolder).eq(chText)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
expect($placeHolder).eq(enText)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in new issue
Block a user