fix(test): make tailwind integration test rerun-safe#6473
Conversation
Two compounding bugs caused the (redis, 3.14, split 2) integration job to occasionally fail at test_tailwind_app[tailwind_v4]: 1. The test wrote its sentinel stylesheet to Path(__file__).resolve().parent.parent / "assets". On a rerun triggered by pytest-rerunfailures, importlib.reload reuses the original module spec, so __file__ keeps pointing at the previous tmp_path while the compiler reads stylesheets from Path.cwd() / "assets" in the new tmp_path. The mismatch raised FileNotFoundError at setup for every rerun. Write to Path.cwd() directly so the location matches the compiler regardless of reload-induced __file__ staleness. 2. The v4 color assertion read value_of_css_property without polling. In dev mode the @tailwindcss/postcss step can finish painting after the element appears, so under runner load the first attempt intermittently saw the default color and failed; that failure is what kicked off the buggy reruns above. Poll until the expected color is applied so first-attempt timing variance no longer fails the test.
Greptile SummaryThis PR fixes two bugs that caused the tailwind integration test to fail on reruns triggered by
Confidence Score: 5/5The change is safe to merge; it corrects two independent test-reliability issues without touching production code. Both fixes are narrowly scoped to the integration test file. The path change from No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[pytest runs test_tailwind_app] --> B[AppHarness.create with tmp_path]
B --> C["TailwindApp() called via importlib"]
C --> D["Write stylesheet to Path.cwd() / assets/\n(compiler's working directory)"]
D --> E[App compiles with Tailwind]
E --> F[Browser renders page]
F --> G[poll_for_or_raise_timeout: find #p-content]
G --> H{tailwind_version?}
H -- 0 disabled --> I[assert color NOT in v3 colors]
H -- 3 or 4 --> J["poll_for_or_raise_timeout:\nwait until color in expected_colors"]
J --> K[Color matches - test passes]
I --> K
K --> L[Assert external stylesheet color]
Reviews (1): Last reviewed commit: "fix(test): make tailwind integration tes..." | Re-trigger Greptile |
Merging this PR will not alter performance
Comparing Footnotes
|
Two compounding bugs caused the (redis, 3.14, split 2) integration job to occasionally fail at test_tailwind_app[tailwind_v4]:
The test wrote its sentinel stylesheet to Path(file).resolve().parent.parent / "assets". On a rerun triggered by pytest-rerunfailures, importlib.reload reuses the original module spec, so file keeps pointing at the previous tmp_path while the compiler reads stylesheets from Path.cwd() / "assets" in the new tmp_path. The mismatch raised FileNotFoundError at setup for every rerun. Write to Path.cwd() directly so the location matches the compiler regardless of reload-induced file staleness.
The v4 color assertion read value_of_css_property without polling. In dev mode the @tailwindcss/postcss step can finish painting after the element appears, so under runner load the first attempt intermittently saw the default color and failed; that failure is what kicked off the buggy reruns above. Poll until the expected color is applied so first-attempt timing variance no longer fails the test.