Repository navigation
test(web-inspector): stub the live notification feed in browser tests - #8187
Merged
Merged
Conversation
The Inspector fetches https://cdn.copilotkit.ai/notifications/v1.json and https://cdn.copilotkit.ai/inspector-hud/v1.json on load. The browser tests did not mock them, so an unread CDN item renamed the launcher button and broke learning-status.browser.ts. A shared Playwright fixture now serves both feeds from empty fixtures at context level; page.route mocks still win. learning-status.browser.ts also assumed reopening lands on Home. On 2.0.0 the harness boots on the Learning view and reopening keeps it, so the test now opens Home explicitly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
|
@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: |
Contributor
|
Size Change: 0 B Total Size: 2.21 MB ℹ️ View Unchanged
|
AlemTuzlak
added a commit
that referenced
this pull request
Nov 4, 2026
Brings in the lint gate (#8172), the inspector feed fixture (#8187) and the CI checkout fix (#8198). The Angular copy buttons keep the stack's core copy feedback, which already voids its promise. Core lists jsdom as a devDependency, so knip no longer flags its jsdom tests as unlisted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4 tasks
AlemTuzlak
added a commit
that referenced
this pull request
Nov 4, 2026
…est leak (#8205) 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? 1. **Angular `mcp-apps-widget.spec.ts`.** The `waitFor` helper polled 40 zero-delay timers, about 80 ms on CI. The first widget in a run waits for the uncached `import("@copilotkit/mcp-apps-renderer")`, which can take longer. CI then failed with `sandbox proxy was not installed`. The helper now polls every 5 ms, for a maximum of 5 s. 2. **The same spec, 2 more tests.** "shows an accessible error when the sandbox handshake times out" slept 10 ms. "names the missing packages when the MCP Apps bridge cannot be loaded" slept 50 ms. Both now poll for their `role="alert"` element. 3. **react-core `data.test.tsx` and `data-media-parity.test.tsx`.** `Chart` loads recharts with `React.lazy`. The tests waited for the chart with the 1 s default of `waitFor`. Both files now load recharts in `beforeAll`, which has a 10 s limit, before a test waits for a chart. 4. **Angular Inspector leak.** All Angular spec files share one jsdom `document` (`singleThread`). `test-setup.ts` sets `destroyAfterEach: 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.ts` then finds an element it did not create. `vitest.config.mts` now gives jsdom the host `angular-tests.invalid`. The Inspector does not load on a non-loopback host, so it stays off in all other specs. `inspector.spec.ts` stubs `location` to `localhost:4200` for its own tests. 5. **Removed test.** This PR also removes the Inspector test "mounts by default in development and attaches the exact core before connection". It failed in 4 CI runs because of the leak above. How often these failed in the last 30 days of CI: | Test | Failed runs | Passed on rerun | | --- | --- | --- | | "loads the resource through the selected agent and boots the sandbox" | 7, on 5 branches and 1 `main` push | 5 times | | "Chart > draws the chart with recharts and gives the series data as a table" | 1 | yes | | Inspector "mounts by default in development…" (removed) | 4 | yes | ## Related PRs and Issues - #8187 already fixed `learning-status.browser.ts`. That test was not flaky. It read the live CDN "What's new" feed. ## Checklist - [ ] I have read the [Contribution Guide](https://github.com/copilotkit/copilotkit/blob/master/CONTRIBUTING.md) - [ ] If the PR changes or adds functionality, I have updated the relevant documentation - [ ] If the PR contains a breaking change, the title has `!` (for example `feat(react-core)!: ...`) and the description has a `BREAKING CHANGE:` line with migration steps. See [VERSIONING.md](https://github.com/CopilotKit/CopilotKit/blob/main/VERSIONING.md) - [ ] "Allow edits by maintainers" is checked (lets us help iterate on your PR directly — faster turnaround for everyone) This PR changes tests only. It has no functionality change and no breaking change. ## Testing **Commands run.** - `pnpm exec vitest run src/mcp-apps` in `packages/angular`: 50 passed, 3 times. - `pnpm exec vitest run` on the 2 chart test files in `packages/react-core`: 35 passed. - `nx run @copilotkit/angular:test -- src/lib/inspector.spec.ts`: 8 passed. - Full Angular suite with file order shuffled, 4 times: 734 passed each time. - To find the leak, I logged each `<cpk-web-inspector>` append with the running test. Before the fix, 5 other spec files added the element, and 1 `copilotkit.spec.ts` test added 24. After the fix, only `inspector.spec.ts` adds it, inside its own tests. The CI failure does not reproduce locally, because it depends on CI timing. - The pre-commit hook ran oxlint and the react-core tests: passed. - `tsc -p tsconfig.spec.json` for Angular shows 4 errors in `mcp-apps-widget.spec.ts`. The same 4 errors are on `2.0.0` without this PR. **Manual test.** These steps reproduce the old failure with a slow import: 1. In `packages/angular/src/mcp-apps/lib/mcp-apps-widget.ts`, change `importRenderer` to `() => new Promise((r) => setTimeout(r, 300)).then(() => import("@copilotkit/mcp-apps-renderer"))`. 2. On `2.0.0`, run `pnpm exec vitest run src/mcp-apps/lib/__tests__/mcp-apps-widget.spec.ts` in `packages/angular`. Result: 26 of 33 tests fail, most with `sandbox proxy was not installed`. 3. On this branch, run the same command. Result: 33 of 33 pass. 4. Revert the change from step 1. **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 `core` before it is added to the page. To undo, revert this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.
The Web Inspector browser tests read the live What's New feed at
https://cdn.copilotkit.ai/notifications/v1.json. That feed now has an unread item, so the launcher button is named "Web Inspector, What's new unread" and all 3 cases inlearning-status.browser.tstime out. This PR serves the feeds from empty fixtures in one shared Playwright fixture, so the result no longer depends on the CDN.This unblocks the "Run Web Inspector browser tests" step (test / unit, Node 22.x React 19) for every PR into
2.0.0, for example #8181.What does this PR do?
packages/web-inspector/dev/browser-test.ts. It extends the Playwrighttestwith acontextfixture. That fixture serves both CDN feeds that the Inspector fetches on load:https://cdn.copilotkit.ai/notifications/**→{ schemaVersion: 1, notifications: [] }https://cdn.copilotkit.ai/inspector-hud/**→{ schemaVersion: 1, rules: [] }*.browser.tsfiles importtestandexpectfrom this fixture.hud-content.browser.tsandthread-message-refresh.browser.ts.learning-status.browser.tsthat the empty feed exposed. See below.The stubs are context routes. Playwright gives
page.routepriority over context routes, so a test that mocks a feed on purpose still wins.hud-content.browser.tskeeps its own HUD feed mocks, and they still pass.The second fault in
learning-status.browser.tsWith an empty feed, the test failed at the next step. It expected the Home view after it reopened the Inspector.
main, the Inspector has no Learning menu item when Learning is unavailable. So the harness stays on Home.2.0.0, Learning is always in the menu. So the harness boots on the Learning view, and reopening keeps that view.Before, the unread feed item hid this: the "What's new" signal sends the reopen to Home. The test now opens Home with the sidebar button. It uses the keyboard (
press("Enter")), because the workbench.stage-toolbarcovers the top of the sidebar and blocks a pointer click. The button-name assertion is unchanged.Related PRs and Issues
2.0.0.2.0.0frommainthrough the merge in feat(web-inspector): add Try from here and isolate domains #6761. It has not passed against the2.0.0Inspector before.Checklist
!(for examplefeat(react-core)!: ...) and the description has aBREAKING CHANGE:line with migration steps. See VERSIONING.md (no breaking change)Testing
Commands run (all pass):
pnpm nx run @copilotkit/web-inspector:test:browser --skip-nx-cache: 23 passed.pnpm nx run @copilotkit/web-inspector:test --skip-nx-cache: 1204 passed.pnpm nx run @copilotkit/web-inspector:check-types: passes.tsc -p packages/web-inspector/dev/tsconfig.json --noEmit: 0 errors.oxlintandoxfmt --checkonpackages/web-inspector/dev: clean.Manual test:
origin/2.0.0, runpnpm nx run @copilotkit/web-inspector:test:browser --skip-nx-cache -- dev/learning-status.browser.ts. All 3 cases time out at line 39 while they wait for the "Web Inspector" button.In a fresh worktree, run
pnpm nx run @copilotkit/web-inspector:buildfirst. If you do not, Vite cannot resolve@copilotkit/coreand every case fails at line 33.How this PR makes testing easy: the fix is the test harness itself. The commands above are the full check.
Risk / rollback
Low risk. The change is in test files only. No published code changes. To undo, revert this PR.
🤖 Generated with Claude Code