Skip to content

Tests: End the About CSS slice at the next section, not a named one - #646

Merged
mmtr merged 2 commits into
trunkfrom
claude/fix-about-theme-test-boundary
Aug 21, 2026
Merged

Tests: End the About CSS slice at the next section, not a named one#646
mmtr merged 2 commits into
trunkfrom
claude/fix-about-theme-test-boundary

Conversation

@mmtr

@mmtr mmtr commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Proposed changes

Ends the About CSS slice in os-settings-about-theme.test.ts at the next top-level section comment instead of a named one.

Why are these changes being made?

Trunk is red on this test. It slices assets/css/os-settings.css between the About tab comment and /* Apps & Icons section:

const aboutStart = css.indexOf( '/*\n * About tab' );
const aboutEnd = css.indexOf( '/* Apps & Icons section', aboutStart );

That section no longer exists. #640 renamed it to "Navigation section" while #631 was in flight, so aboutEnd comes back -1 and css.slice( aboutStart, -1 ) yields an empty string. expect( aboutEnd ).toBeGreaterThan( aboutStart ) fails.

The empty slice also meant the second test in the file, the one checking the About block does not bypass theme tokens with raw brand meshes or hardcoded ink, was asserting against nothing and passing for free. It inspects the real block again now.

Naming the following section couples the test to whatever happens to sit after About, which is exactly how it broke. The next top-level comment is stable under a rename.

Testing instructions

  1. Check out trunk and run npx vitest run tests/vitest/os-settings-about-theme.test.ts. Make sure it fails with expected -1 to be greater than <n>.
  2. Check out this branch and run the same command. Make sure both tests pass.
  3. In assets/css/os-settings.css, rename /* Navigation section — per-item placement chooser. */ to anything else and run the test again. Make sure it still passes, which is the regression this guards against.
  4. To confirm the second test is no longer vacuous: add color: #fff; inside the About block in assets/css/os-settings.css and run the test. Make sure "does not bypass theme substitutions with a raw brand mesh or ink" now fails. Revert.
Open WordPress Playground Preview

The About theme contract test sliced os-settings.css between the About
tab comment and "Apps & Icons section". #640 renamed that section while
#631 was in flight, so the end index came back -1 and the slice was
empty. One assertion failed on the empty slice; the rest of the file's
assertions had nothing to inspect.

Take the next top-level section comment instead, so a rename downstream
of About cannot silently empty the slice again.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@mmtr mmtr self-assigned this Aug 21, 2026
@mmtr
mmtr enabled auto-merge (squash) August 21, 2026 12:27
@AllTerrainDeveloper

Copy link
Copy Markdown
Collaborator

Thank you Miguel!

@mmtr
mmtr merged commit 073edba into trunk Aug 21, 2026
5 checks passed
@mmtr
mmtr deleted the claude/fix-about-theme-test-boundary branch August 21, 2026 12:32
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