Compare commits

...
Sign in to create a new pull request.

2 commits

Author SHA1 Message Date
Daniel Han
b75df445fb tests: anchor the account-block match and keep the wildcard in-attribute
Review caught two soft spots in the loosened regex: the broadened pattern
also matched the update-card wrapper, so a broken account block could hide
behind the lookalike, and the \S wildcard could in principle walk across the
closing quote into other markup. The match is now anchored to the
displayTitle span that only the account block contains (bounded, stopping at
any closing div), and every wildcard is restricted to non-quote characters
so it can never leave the className attribute. Verified exactly one match at
the account block on current sources; all three tests pass.
2026-07-18 11:06:12 +00:00
Daniel Han
a3861424a9 tests: unstick the sidebar descender guard after the truncation restyle
The account-block regex required flex and flex-col to be adjacent, but the
sidebar long-name truncation work (#7171) inserted min-w-0 flex-1 between
them, so the guard stopped matching anything and Backend CI's Repo tests
(CPU) job has failed on main and every branch since. The markup still uses
leading-tight, so the invariant the test protects was never violated; only
the pattern was stale. Allow utility classes between flex and flex-col,
keeping the leading-* capture unchanged. All three tests in the file pass
against the current sources.
2026-07-18 10:45:50 +00:00

View file

@ -34,10 +34,15 @@ def test_model_selector_trigger_label_uses_leading_tight():
def test_sidebar_account_block_uses_leading_tight():
src = _read(APP_SIDEBAR)
# Match the account-block parent div regardless of its gap utility; this
# guard is about the leading-* class, not the spacing.
# Match the account-block parent div regardless of its gap utility or any
# sizing classes between flex and flex-col (min-w-0 flex-1 arrived with the
# long-name truncation work); this guard is about the leading-* class only.
# [^"\s] keeps the wildcard inside the className attribute, and the trailing
# displayTitle anchor pins the match to the account block itself so a
# lookalike wrapper (the update card) can never satisfy the guard.
pattern = re.compile(
r'<div\s+className="flex\s+flex-col\s+gap-\S+\s+(\S+)\s+group-data-\[collapsible=icon\]:hidden">',
r'<div\s+className="flex\s+(?:[^"\s]+\s+)*?flex-col\s+gap-[^"\s]+\s+([^"\s]+)\s+'
r'group-data-\[collapsible=icon\]:hidden">(?:(?!</div>)[\s\S]){0,400}?\{displayTitle\}',
)
matches = pattern.findall(src)
assert matches, "could not find sidebar account-block parent div"