mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +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 process from 'process'
|
||||
import dotenv from 'dotenv'
|
||||
import fs from 'fs' // Import fs module
|
||||
|
||||
dotenv.config({ path: '../.env.dev' })
|
||||
dotenv.config({ path: '../.env' })
|
||||
@@ -17,6 +18,9 @@ const getOrFail = (key) => {
|
||||
return value
|
||||
}
|
||||
|
||||
// Check if the .env file exists
|
||||
const EnableoAuth = fs.existsSync('../.env')
|
||||
|
||||
export default defineConfig({
|
||||
e2e: {
|
||||
baseUrl: getConfig('BASE_URL', 'http://localhost:5173'),
|
||||
@@ -31,13 +35,13 @@ export default defineConfig({
|
||||
defaultAccount: getOrFail('TESTING_USERNAME'),
|
||||
defaultPassword: getOrFail('TESTING_PASSWORD'),
|
||||
isCHVersion: true,
|
||||
EnableoAuth, // Add the EnableoAuth variable here
|
||||
// google_username: process.env.GOOGLE_USERNAME,
|
||||
// google_password: process.env.GOOGLE_PASSWORD,
|
||||
// google_client_id: process.env.GOOGLE_CLIENT_ID,
|
||||
// google_client_secret: process.env.GOOGLE_CLIENT_SECRET,
|
||||
|
||||
// github_username: process.env.GITHUB_USERNAME,
|
||||
// github_password: process.env.GITHUB_PASSWORD,
|
||||
// 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')
|
||||
})
|
||||
it('Check social account UI', () => {
|
||||
cy.CheckTextElement(
|
||||
'#GoogleLogin',
|
||||
'以 Google 繼續',
|
||||
'Continue with Google'
|
||||
)
|
||||
cy.CheckTextElement('#or', '或', 'or')
|
||||
cy.CheckTextElement(
|
||||
'#GitHubLogin',
|
||||
'以 GitHub 繼續',
|
||||
'Continue with GitHub'
|
||||
)
|
||||
if (Cypress.env('EnableoAuth')) {
|
||||
cy.CheckTextElement(
|
||||
'#GoogleLogin',
|
||||
'以 Google 繼續',
|
||||
'Continue with Google'
|
||||
)
|
||||
cy.CheckTextElement('#or', '或', 'or')
|
||||
cy.CheckTextElement(
|
||||
'#GitHubLogin',
|
||||
'以 GitHub 繼續',
|
||||
'Continue with GitHub'
|
||||
)
|
||||
}
|
||||
})
|
||||
it('Check login fail', () => {
|
||||
cy.LoginWithPassword('dddd', '123456')
|
||||
|
||||
Reference in new issue
Block a user