mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +08:00
Optional oAuth activation in Cypress
This commit is contained in:
1 parent
ed142ab27b
commit
b1a9a6102c
2 files changed
+19
-13
No files matched your search
@@ -1,6 +1,7 @@
|
|||||||
import { defineConfig } from 'cypress'
|
import { defineConfig } from 'cypress'
|
||||||
import process from 'process'
|
import process from 'process'
|
||||||
import dotenv from 'dotenv'
|
import dotenv from 'dotenv'
|
||||||
|
import fs from 'fs' // Import fs module
|
||||||
|
|
||||||
dotenv.config({ path: '../.env.dev' })
|
dotenv.config({ path: '../.env.dev' })
|
||||||
dotenv.config({ path: '../.env' })
|
dotenv.config({ path: '../.env' })
|
||||||
@@ -17,6 +18,9 @@ const getOrFail = (key) => {
|
|||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the .env file exists
|
||||||
|
const EnableoAuth = fs.existsSync('../.env')
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
e2e: {
|
e2e: {
|
||||||
baseUrl: getConfig('BASE_URL', 'http://localhost:5173'),
|
baseUrl: getConfig('BASE_URL', 'http://localhost:5173'),
|
||||||
@@ -31,13 +35,13 @@ export default defineConfig({
|
|||||||
defaultAccount: getOrFail('TESTING_USERNAME'),
|
defaultAccount: getOrFail('TESTING_USERNAME'),
|
||||||
defaultPassword: getOrFail('TESTING_PASSWORD'),
|
defaultPassword: getOrFail('TESTING_PASSWORD'),
|
||||||
isCHVersion: true,
|
isCHVersion: true,
|
||||||
|
EnableoAuth, // Add the EnableoAuth variable here
|
||||||
// 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,
|
||||||
// google_client_secret: process.env.GOOGLE_CLIENT_SECRET,
|
|
||||||
// github_username: process.env.GITHUB_USERNAME,
|
// github_username: process.env.GITHUB_USERNAME,
|
||||||
// github_password: process.env.GITHUB_PASSWORD,
|
// github_password: process.env.GITHUB_PASSWORD,
|
||||||
// github_client_id: process.env.GITHUB_CLIENT_ID,
|
// github_client_id: process.env.GITHUB_CLIENT_ID,
|
||||||
// github_client_secret: process.env.GITHUB_CLIENT_SECRET,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -36,17 +36,19 @@ describe('example helloworld app', () => {
|
|||||||
cy.CheckTextElement('#SwitchtoRegister', '註冊', 'Sign up')
|
cy.CheckTextElement('#SwitchtoRegister', '註冊', 'Sign up')
|
||||||
})
|
})
|
||||||
it('Check social account UI', () => {
|
it('Check social account UI', () => {
|
||||||
cy.CheckTextElement(
|
if (Cypress.env('EnableoAuth')) {
|
||||||
'#GoogleLogin',
|
cy.CheckTextElement(
|
||||||
'以 Google 繼續',
|
'#GoogleLogin',
|
||||||
'Continue with Google'
|
'以 Google 繼續',
|
||||||
)
|
'Continue with Google'
|
||||||
cy.CheckTextElement('#or', '或', 'or')
|
)
|
||||||
cy.CheckTextElement(
|
cy.CheckTextElement('#or', '或', 'or')
|
||||||
'#GitHubLogin',
|
cy.CheckTextElement(
|
||||||
'以 GitHub 繼續',
|
'#GitHubLogin',
|
||||||
'Continue with GitHub'
|
'以 GitHub 繼續',
|
||||||
)
|
'Continue with GitHub'
|
||||||
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
it('Check login fail', () => {
|
it('Check login fail', () => {
|
||||||
cy.LoginWithPassword('dddd', '123456')
|
cy.LoginWithPassword('dddd', '123456')
|
||||||
|
|||||||
Reference in new issue
Block a user