Skip to content

Studio tests: match the model-name span in its cn() form - #8801

Closed
danielhanchen wants to merge 2 commits into
mainfrom
fix-descender-guard-cn-form
Closed

danielhanchen wants to merge 2 commits into
mainfrom
fix-descender-guard-cn-form

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Aug 14, 2026 •

Copy link
Copy Markdown
Member

Repo tests (CPU) is red on main for every PR:

FAILED tests/studio/test_studio_text_descender_clipping.py::test_model_selector_trigger_label_uses_leading_tight
E       AssertionError: could not find ModelSelectorTrigger model-name span
E       assert []

The product is fine. The guard looked for a literal attribute:

r'<span\s+className="[^"]*\bmin-w-0\b[^"]*\bflex-1\b[^"]*\btruncate\b...'

and model-selector.tsx:275 now writes the label as

<span
  className={cn(
    "min-w-0 flex flex-1 items-baseline truncate font-heading text-ui-16 font-medium leading-tight text-black dark:text-white",
    triggerLabelClassName,
  )}
>

so the regex matched nothing. leading-tight is present and correct; only the test broke.

The change

Match the identifying class set against every string literal in the file instead of against an attribute. Order-insensitive, and it survives the next wrapper. Exactly one literal matches today, the right one.

Why this is not a weaker test

The assertion it guards is unchanged: leading-tight present, leading-none never beside truncate. Mutating leading-tight to leading-none in model-selector.tsx fails both this test and test_no_truncate_plus_leading_none_in_changed_files. The assert matches line is what makes this safe: once the markup moved, the old form matched nothing and that assert turned it into the hard failure on main rather than a silent pass.

tests/studio/test_studio_text_descender_clipping.py  3 passed
with the mutation applied                            2 failed, 1 passed

The descender guard looked for a literal className="..." attribute. The
ModelSelectorTrigger label moved to className={cn("...", triggerLabelClassName)},
so the regex found nothing and the test failed on main with "could not find
ModelSelectorTrigger model-name span".

Match the class set against every string literal in the file instead. That is
order-insensitive and survives the next wrapper, and it keeps the real assertion:
leading-tight present, leading-none never beside truncate. Reverting leading-tight
to leading-none in model-selector.tsx fails this test and the third one.
@danielhanchen

Copy link
Copy Markdown
Member Author

Superseded by #8765, which landed the same fix ahead of this one: the guard now selects class literals by their token set wherever they are written, so the cn() form is matched and the test passes on main again. Closing to keep one guard rather than three, and this branch now conflicts with that file anyway. The set-based selection in here was the right shape and is what #8765 uses.

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.

1 participant