yeatmanlab / roar-dashboard

A dashboard to administer ROAR assessments
https://roar.education
Other
4 stars 4 forks source link

Fix App Check `debugToken` conditional for Cypress environment #792

Closed maximilianoertel closed 1 month ago

maximilianoertel commented 1 month ago

Proposed changes

This PR fixes the App Check debugToken conditional for Cypress environment by leveraging window.Cypress for the environment determination as NODE_ENV === 'test' also evaluates to true when running unit tests, causing tests to fail:

 FAIL  src/composables/queries/useSurveyResponsesQuery.test.js [ src/composables/queries/useSurveyResponsesQuery.test.js ]
 FAIL  src/composables/queries/useUserAssignmentsQuery.test.js [ src/composables/queries/useUserAssignmentsQuery.test.js ]
 FAIL  src/composables/queries/useUserDataQuery.test.js [ src/composables/queries/useUserDataQuery.test.js ]
ReferenceError: Cypress is not defined
 ❯ setDebugToken src/config/firebaseRoar.js:17:17
     15|   const debugToken =
     16|     import.meta.env.NODE_ENV === 'test'
     17|       ? Cypress.env('appCheckDebugToken')
       |                 ^
     18|       : import.meta.env.VITE_APPCHECK_DEBUG_TOKEN || (self.FIREBASE_AP…
     19| 
 ❯ src/config/firebaseRoar.js:86:1
 ❯ src/firebaseInit.js:2:31

Source

Types of changes

Checklist

Justification of missing checklist items

n/a

Further comments

n/a

github-actions[bot] commented 1 month ago

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 0.97% 73 / 7504
🔵 Statements 0.89% 74 / 8243
🔵 Functions 0.76% 14 / 1830
🔵 Branches 0.44% 20 / 4473
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
src/config/firebaseRoar.js 0% 0% 0% 0% 7-9, 16-18, 20, 20, 23-82, 24-82, 43-60, 62-70, 72-81, 84-85
Generated in workflow #280
github-actions[bot] commented 1 month ago

Visit the preview URL for this PR (updated for commit a9b881b):

https://roar-staging--pr792-fix-firebase-roar-co-0awxayw0.web.app

(expires Tue, 17 Sep 2024 22:24:10 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 2631e9c58fd0104ecbfddd72a62245ddac467460

ROAR
cypress[bot] commented 1 month ago

roar-dashboard-e2e    Run #6212

Run Properties:  status check passed Passed #6212  •  git commit a9b881b82a: Component Tests for PR 792 "Fix App Check `debugToken` conditional for Cypress e...
Project roar-dashboard-e2e
Branch Review fix/firebase-roar-config
Run status status check passed Passed #6212
Run duration 01m 20s
Commit git commit a9b881b82a: Component Tests for PR 792 "Fix App Check `debugToken` conditional for Cypress e...
Committer Maximilian Oertel
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 2
View all changes introduced in this branch ↗︎