Repository navigation
test: fix flaky Angular and Chart tests, stop the Angular Inspector test leak - #8205
Merged
Merged
Conversation
The Angular MCP Apps widget spec polled 40 zero-delay timers for the
sandbox, which a cold import of @copilotkit/mcp-apps-renderer outlasts
on a loaded CI runner ("sandbox proxy was not installed", 7 CI runs in
30 days). It now polls against a 5 s time budget, and the two tests that
slept a fixed 10 ms and 50 ms now poll for their alert.
The react-core Chart tests waited the default 1 s for recharts, which
Chart loads with React.lazy. Both files now load recharts in beforeAll.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
AlemTuzlak
requested review from
jpr5,
mme,
rainerhahnekamp,
tylerslaton and
wolfmanfx
as code owners
November 4, 2026 13:31
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review: 1
Please check the settings in the CodeRabbit UI or the
|
Contributor
|
Size Change: 0 B Total Size: 2.39 MB ℹ️ View Unchanged
|
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/channels
@copilotkit/channels-core
@copilotkit/channels-discord
@copilotkit/channels-intelligence
@copilotkit/channels-slack
@copilotkit/channels-teams
@copilotkit/channels-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@copilotkit/intelligence-langgraph
@copilotkit/intelligence-mastra
@copilotkit/learning
@copilotkit/markdown
@copilotkit/mcp-apps-renderer
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/runtime
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
The test failed in 4 CI runs and could not be reproduced locally. Co-Authored-By: Claude Opus 5.5 <[email protected]>
All spec files share one jsdom document, and TestBed never tears down a test's injector, so an Inspector mount left pending by one test could add its element during a later test. Give jsdom a non-loopback host so the Inspector stays off by default; inspector.spec.ts switches back to localhost. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two unit tests fail at random in CI because they give a lazy import a fixed, short time to load. On a slow runner the import is not done yet, so the test fails, and a rerun of the same commit passes. This PR makes the tests wait for the result itself, with a time limit, so they no longer depend on runner speed. It also stops a leak that made the Angular Inspector tests fail at random.
What does this PR do?
mcp-apps-widget.spec.ts. ThewaitForhelper polled 40 zero-delay timers, about 80 ms on CI. The first widget in a run waits for the uncachedimport("@copilotkit/mcp-apps-renderer"), which can take longer. CI then failed withsandbox proxy was not installed. The helper now polls every 5 ms, for a maximum of 5 s.role="alert"element.data.test.tsxanddata-media-parity.test.tsx.Chartloads recharts withReact.lazy. The tests waited for the chart with the 1 s default ofwaitFor. Both files now load recharts inbeforeAll, which has a 10 s limit, before a test waits for a chart.document(singleThread).test-setup.tssetsdestroyAfterEach: false, so TestBed never disposes the Inspector mount of a test. The lazy Inspector load then finishes in a later test, and adds a<cpk-web-inspector>element there.inspector.spec.tsthen finds an element it did not create.vitest.config.mtsnow gives jsdom the hostangular-tests.invalid. The Inspector does not load on a non-loopback host, so it stays off in all other specs.inspector.spec.tsstubslocationtolocalhost:4200for its own tests.How often these failed in the last 30 days of CI:
mainpushRelated PRs and Issues
learning-status.browser.ts. That test was not flaky. It read the live CDN "What's new" feed.Checklist
!(for examplefeat(react-core)!: ...) and the description has aBREAKING CHANGE:line with migration steps. See VERSIONING.mdThis PR changes tests only. It has no functionality change and no breaking change.
Testing
Commands run.
pnpm exec vitest run src/mcp-appsinpackages/angular: 50 passed, 3 times.pnpm exec vitest runon the 2 chart test files inpackages/react-core: 35 passed.nx run @copilotkit/angular:test -- src/lib/inspector.spec.ts: 8 passed.<cpk-web-inspector>append with the running test. Before the fix, 5 other spec files added the element, and 1copilotkit.spec.tstest added 24. After the fix, onlyinspector.spec.tsadds it, inside its own tests. The CI failure does not reproduce locally, because it depends on CI timing.tsc -p tsconfig.spec.jsonfor Angular shows 4 errors inmcp-apps-widget.spec.ts. The same 4 errors are on2.0.0without this PR.Manual test. These steps reproduce the old failure with a slow import:
packages/angular/src/mcp-apps/lib/mcp-apps-widget.ts, changeimportRendererto() => new Promise((r) => setTimeout(r, 300)).then(() => import("@copilotkit/mcp-apps-renderer")).2.0.0, runpnpm exec vitest run src/mcp-apps/lib/__tests__/mcp-apps-widget.spec.tsinpackages/angular. Result: 26 of 33 tests fail, most withsandbox proxy was not installed.How this PR makes testing easy. The changed tests are the artifact. The manual test above shows the old failure and the fix with one temporary line.
Risk / rollback
Low. Only test files and the Angular test config change. A test that really breaks now fails after 5 s instead of after about 80 ms. With the removed Inspector test, no test checks that the auto-mounted Inspector gets the exact
corebefore it is added to the page. To undo, revert this PR.🤖 Generated with Claude Code