Skip to content

TEST: Wait for rendered estimates in scenario launch tests - #4646

Open
Richard Lundeen (richlundeen) wants to merge 1 commit into
microsoft:mainfrom
richlundeen:test/scenario-estimate-render-race
Open

Richard Lundeen (richlundeen) wants to merge 1 commit into
microsoft:mainfrom
richlundeen:test/scenario-estimate-render-race

Conversation

@richlundeen

Copy link
Copy Markdown
Contributor

Description

Two scenario launch tests could fail on a busy CI runner because they checked the run estimate before it had rendered. The frontend unit test job for #4226 failed this way: the catalog-to-run test expected the total attack count 2 but got Calculating....

  • useScenarioRunEstimate sends the estimate request after a debounce and updates the UI only when the request resolves. Both tests waited until the mocked request had been sent, then checked the rendered value right away. If rendering was slow, the check saw the loading text.
  • ScenarioFlow.test.tsx: wait for the "Total atomic attacks" value to become 2.
  • ScenarioDetail.test.tsx ("uses effective Jailbreak defaults and sends only prompt_sending"): wait for num_jailbreaks to show the backend's effective value 2. Before the response arrives it shows Not set.
  • The expected values and request assertions are unchanged. Other tests that wait on estimateRun check request arguments, control resolution with act(), or already wait for rendered output.

A delayed estimate mock (50, 200, and 500 ms) reproduces the CI failure in the original tests every time: they receive Calculating... and num_jailbreaksNot set. The updated tests pass under the same delays.

The Microsoft package mirror does not yet have some locked releases (pyyaml==6.0.4, av==18.1.1, types-pyyaml==6.0.12.20261122), so pre-commit could not run locally. This PR's CI is the check for those hooks. The change touches only two frontend test files, which pass ESLint and tsc --noEmit.

The catalog-to-run flow test and the Jailbreak defaults test waited only
until the mocked estimate request was sent, then read values that render
after it resolves. On a loaded runner the render lags and the assertions
see "Calculating..." or "Not set". Wait for the rendered values instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 22:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the test changes that wait for rendered run estimates.

No open issues 🎉

What changed in this PR

Reduces timing-related CI failures in frontend scenario launch tests by waiting for run estimates to render, rather than only for requests to be sent. Production behavior is unchanged.

Changes:

  • Wraps the total attack count and effective num_jailbreaks assertions in waitFor.
  • Preserves existing expected values and request assertions.
File Description
frontend/​src/​components/​Scenarios/​ScenarioFlow.test.tsx Waits for “Total atomic attacks” to display 2.
frontend/​src/​components/​Scenarios/​ScenarioDetail.test.tsx Waits for the effective num_jailbreaks value to display 2.

Review effort: Balanced

This branch has not been deployed

No deployments
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