test: pin feature flags off in vitest env - #496
Conversation
Vitest reads the local .env, so a flag left on there (e.g. VITE_RTE_PERICOPE=true) changes the editing surface under test and fails suites that assume the flag-off textarea path. Pin both feature flags in test.env so suites opt in via config.features.* instead. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Warning Review limit reachedNext included review available in 1 minute. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
henrique221
left a comment
There was a problem hiding this comment.
I reproduced the 3 failures without the fix. With this change, all 615 tests pass with VITE_RTE_PERICOPE and VITE_USFM_IMPORT set to true in .env, and again with both set to false. I also ran 68 targeted tests with both flags exported as true in the shell; all passed.
The fix works.
Why 3 tests fail on
mainWhen
fluent-web/.envsetsVITE_RTE_PERICOPE=true, and that leaks into the test run:compose.yaml:163bind-mounts your local.envinto the web container at/app/.env..envintoimport.meta.env.vite.config.ts:60-67pins dummy values for otherVITE_*vars intest.envbut does not pinVITE_RTE_PERICOPE, so thetruevalue passes through.config.features.rtePericopeinitializes totrueat module load (src/lib/config.ts:109), so the suite starts with the rich-text flag on — but most tests assume the flag-off textarea surface.Why exactly those 3 tests fail:
CrossChapterPericope.test.tsx— the first test (it.each, chapter 8) runs before the file'safterEachresets the flag tofalse(line 94). With the flag on,PericopeTargetGrouptakes the RTE branch (DraftingGridPericope.tsx:354), the lazyPericopeRteGroupchunk hasn't resolved, and you get thepericope-editor-loadingskeleton instead of textboxes. The un-interpolatedChapter {{chapter}}in the dump is just the test-env i18n — cosmetic, not the bug.DraftingUI.test.tsx— the two "keeps neighboring reference verses visible" tests run in pericope mode with the flag on.PericopeRteGroupis mocked there as a bare<div data-testid='pericope-rte-group'/>that ignoresbeforeContent/afterContent, soPericopeContextTextnever mounts — no "Saved neighboring translation", no textboxes.Everything else passes because it either runs in verse mode (flag irrelevant), sets the flag explicitly, or runs after an
afterEachreset.Summary
vite.config.tstest.envnow pinsVITE_RTE_PERICOPEandVITE_USFM_IMPORTto'false'.envintoimport.meta.env, andtest.envonly overrode the keys it listed — soVITE_RTE_PERICOPE=truein a local.envflippedconfig.features.rtePericopeon at module load and changed the editing surface under testmaincheckout —CrossChapterPericope.test.tsx(lazyPericopeRteGroupsuspended, showing thepericope-editor-loadingskeleton instead of textboxes) and twoDraftingUI.test.tsxpericope-mode tests (mockedPericopeRteGroupdropsbeforeContent/afterContent, so context text never mounts)config.features.*explicitly, so pinning the env off is safeTest plan
.env(VITE_RTE_PERICOPE=true) mounted.envin placeGenerated with Devin