Skip to content

test: wait for the state two flaky assertions depend on - #1321

Merged
sh00tg0a1 merged 1 commit into
mainfrom
fix/flaky-unit-tests
Nov 11, 2026
Merged

sh00tg0a1 merged 1 commit into
mainfrom
fix/flaky-unit-tests

Conversation

@sh00tg0a1

Copy link
Copy Markdown
Member

Pull Request

What Changed

  • ObjectAuthorizeDrawer.test.tsx: wait for the bundle button to be enabled before clicking it
  • ConnectorOptionsEditor.test.tsx: wait for the options card to reopen instead of asserting it immediately

Why


How

  • Key implementation points:
    • ObjectAuthorizeDrawer: the "new grant" heading renders before the grant list resolves, while the bundle button is disabled until it does. The test clicked as soon as the heading appeared, so under load the click landed on a disabled button and aria-pressed never became true. Delaying the mocked grant list by 80ms reproduces the exact CI failure; with the added wait the test passes under the same delay.
    • ConnectorOptionsEditor: the editor sets details.open in a useEffect keyed on the form item's errors. React runs that effect after the commit that already shows .ant-form-item-has-error, so the assertion right after waiting for that class could run first. Not reproduced locally; the order was confirmed by recording DOM mutations (the open attribute lands after the error class).
  • Breaking changes (API, config, database, etc.): none. Tests only.

Testing

  • Unit tests passed locally
  • Integration tests passed locally — not applicable, test-only change
  • Verified in test environment — not applicable

Test notes:

  • Both files pass locally (51 tests). Before the change each test also passed 14 local repetitions, so a local pass does not prove the flake is gone; the signal is whether it recurs on CI.
  • Pre-commit checks run: format, license headers, type-aware ESLint (whole repo), tsc -b, vite build, pnpm audit --prod.

Risk & Rollback

  • Potential risks: none for product code. Other tests in ObjectAuthorizeDrawer.test.tsx also start from the same heading, but they await another element before touching a load-gated control and have not failed on CI; they are unchanged.
  • Rollback plan: revert this commit.

Additional Notes

  • Only the last six failed runs on main were examined.

🤖 Generated with Claude Code

ObjectAuthorizeDrawer: the bundle button stays disabled until the grant
list resolves, but the form heading the test waited for renders earlier,
so the click was sometimes dropped on a disabled button.

ConnectorOptionsEditor: the editor reopens its card in an effect that runs
after the commit showing the error class, so asserting right after that
class appeared could run before the effect.

Co-Authored-By: Claude <noreply@anthropic.com>
@sh00tg0a1 sh00tg0a1 added the by-agent Issue or pull request produced by an agent label Nov 11, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

两处改动都只是在测试里补上对异步状态的等待,与组件实际行为对得上(ConnectorOptionsEditor 在 useEffect 里设置 details.open;bundle 按钮在 catalogLoading/loading/!resourceLoaded 期间是 disabled)。断言没有被放宽,也不是永真,可以放行。

有异议或想再评一轮,请回复 /review——普通回帖不会触发复评,且回帖人需为本仓 OWNER/MEMBER/COLLABORATOR。

@sh00tg0a1
sh00tg0a1 merged commit 85c7da0 into main Nov 11, 2026
27 checks passed
@sh00tg0a1
sh00tg0a1 deleted the fix/flaky-unit-tests branch November 11, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

by-agent Issue or pull request produced by an agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant