Skip to content

test: pin feature flags off in vitest env - #496

Merged
kaseywright merged 1 commit into
mainfrom
fix/failing-tests-pericope-view
Sep 17, 2026
Merged

kaseywright merged 1 commit into
mainfrom
fix/failing-tests-pericope-view

Conversation

@kaseywright

@kaseywright kaseywright commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Why 3 tests fail on main

When fluent-web/.env sets VITE_RTE_PERICOPE=true, and that leaks into the test run:

  1. compose.yaml:163 bind-mounts your local .env into the web container at /app/.env.
  2. Vitest auto-loads .env into import.meta.env. vite.config.ts:60-67 pins dummy values for other VITE_* vars in test.env but does not pin VITE_RTE_PERICOPE, so the true value passes through.
  3. config.features.rtePericope initializes to true at 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's afterEach resets the flag to false (line 94). With the flag on, PericopeTargetGroup takes the RTE branch (DraftingGridPericope.tsx:354), the lazy PericopeRteGroup chunk hasn't resolved, and you get the pericope-editor-loading skeleton instead of textboxes. The un-interpolated Chapter {{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. PericopeRteGroup is mocked there as a bare <div data-testid='pericope-rte-group'/> that ignores beforeContent/afterContent, so PericopeContextText never 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 afterEach reset.

Summary

  • vite.config.ts test.env now pins VITE_RTE_PERICOPE and VITE_USFM_IMPORT to 'false'
  • Vitest auto-loads a developer's local .env into import.meta.env, and test.env only overrode the keys it listed — so VITE_RTE_PERICOPE=true in a local .env flipped config.features.rtePericope on at module load and changed the editing surface under test
  • Symptom: 3 failures on a clean main checkout — CrossChapterPericope.test.tsx (lazy PericopeRteGroup suspended, showing the pericope-editor-loading skeleton instead of textboxes) and two DraftingUI.test.tsx pericope-mode tests (mocked PericopeRteGroup drops beforeContent/afterContent, so context text never mounts)
  • Suites that want a flag on already set config.features.* explicitly, so pinning the env off is safe

Test plan

  • Reproduced the 3 failures inside the web container with .env (VITE_RTE_PERICOPE=true) mounted
  • Full suite passes 615/615 in the container with the fix applied and the same .env in place

Generated with Devin

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>
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 1602ed8b-050b-4a79-a92b-c1340aafa92b

📥 Commits

Reviewing files that changed from the base of the PR and between 4b204a9 and ad4b7f7.

📒 Files selected for processing (1)
  • vite.config.ts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kaseywright
kaseywright enabled auto-merge (squash) September 17, 2026 16:14

@henrique221 henrique221 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kaseywright
kaseywright merged commit cfa8e31 into main Sep 17, 2026
6 checks passed
@github-actions
github-actions Bot deleted the fix/failing-tests-pericope-view branch September 17, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants