Skip to content

test(devtools): make e2e behaviour-driven and leaner - #1045

Merged
antfu merged 2 commits into
mainfrom
early-knives-dig
Jul 27, 2026
Merged

test(devtools): make e2e behaviour-driven and leaner#1045
antfu merged 2 commits into
mainfrom
early-knives-dig

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

What & why

The Playwright e2e suite asserted Vite DevTools' internal dock-registry entry shapes (type/category/groupId/frameId/subTabs/visibility) and drove the panel by mutating that internal state directly. Those assertions are what kept breaking the e2e workflow whenever the dock plumbing was refactored (most recently the visibility: 'false' assertion). The suite also ran every playground-independent test once per playground, and produced a full production build of four playgrounds just to check a page renders.

This reworks the suite to test high-level behaviour, makes it more robust, and makes it leaner.

Behaviour-driven

  • Fixtures now open and navigate DevTools through the public host API (__NUXT_DEVTOOLS_HOST__.devtools.open() / .navigate()), the same surface the keyboard shortcut uses — no reaching into Vite DevTools' panel/dock internals.
  • Specs assert what the user sees (the client opens chromelessly, each tab renders its content, the Data Inspector exposes the live Nuxt app, Code Server reports a missing editor) instead of registry entry shapes.
  • iframe / nuxt-group / playground-empty specs are folded into a behavioural devtools spec plus a dedicated spa (ssr:false) dock-regression spec.

Fixing the public API

Driving the public API surfaced a real bug: devtools.open/close/navigate wrote to ctx.panel.store.value.open, treating the dock panel store as a Vue ref, but Vite DevTools exposes it as a plain object — so the panel never opened through the public API. Fixed in a separate commit.

Leaner

  • Playground-independent dev specs run once (on empty) instead of four times over.
  • Built (preview) mode is limited to the two distinct render targets (empty + spa); the prebuild no longer produces four production builds.

Local runs: dev suite 20 passing, built suite 2 passing, plus lint / typecheck / unit all green.

This PR was created with the help of an agent.

antfubot added 2 commits July 27, 2026 07:55
The host API's open/close/navigate wrote to ctx.panel.store.value.open,
treating the dock panel store as a Vue ref. Vite DevTools exposes it as a
plain object with an open boolean, so the panel never actually opened or
closed through the public __NUXT_DEVTOOLS_HOST__.devtools API.
Drive the DevTools panel through the public host API (devtools.open /
devtools.navigate) instead of poking Vite DevTools' internal panel and dock
state, and assert what the user sees rather than the dock registry's entry
shapes. The old shape assertions (category/frameId/subTabs/visibility) were
what kept breaking CI whenever the dock plumbing was refactored.

- Fold iframe/nuxt-group/playground-empty specs into a behavioural
  devtools spec plus a dedicated spa (ssr:false) regression spec.
- Trim data-inspector/code-server to their observable contracts.
- Scope playground-independent dev specs to the empty playground so they
  stop running four times over, and limit built (preview) mode to the two
  distinct render targets (empty + spa).
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying nuxt-devtools with  Cloudflare Pages  Cloudflare Pages

Latest commit: 78c26fb
Status: ✅  Deploy successful!
Preview URL: https://d55dfa27.nuxt-devtools.pages.dev
Branch Preview URL: https://early-knives-dig.nuxt-devtools.pages.dev

View logs

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change updates DevTools panel state access and migrates E2E fixtures to public host APIs. Playwright now separates built and development playground modes, adjusts retries, and builds only selected playgrounds. E2E coverage is revised for Code Server, Data Inspector, DevTools, SPA rendering, tab navigation, and built-in components, while several overlapping specs are removed or narrowed.

Estimated code review effort: 4 (Complex) | ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed It accurately summarizes the main shift to behavior-driven, leaner devtools e2e tests.
Description check ✅ Passed It clearly describes the e2e refactor and public API bug fix, matching the PR changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch early-knives-dig

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/e2e/specs/code-server.spec.ts`:
- Around line 20-24: Update the Code Server opening step in the e2e test to
select the visible dock entry through the page UI rather than calling
__VITE_DEVTOOLS_CLIENT_CONTEXT__.docks.switchEntry via page.evaluate. Use the
dock entry’s user-facing selector or label and preserve the existing
CODE_SERVER_DOCK_ID target.

In `@tests/e2e/specs/playground-loads.spec.ts`:
- Around line 3-5: Update the coverage comment above the playground boot/render
sanity check to reflect the configured project matrix: it runs for every project
in dev, while built mode runs only for empty and spa; do not imply built tab-seo
coverage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f40fdf0f-a59f-4f95-8815-ad09087be0bf

📥 Commits

Reviewing files that changed from the base of the PR and between 06de1bb and 78c26fb.

📒 Files selected for processing (13)
  • package.json
  • packages/devtools/src/runtime/plugins/view/client.ts
  • tests/e2e/fixtures/devtools.ts
  • tests/e2e/playwright.config.ts
  • tests/e2e/specs/code-server.spec.ts
  • tests/e2e/specs/data-inspector.spec.ts
  • tests/e2e/specs/devtools.spec.ts
  • tests/e2e/specs/iframe.spec.ts
  • tests/e2e/specs/nuxt-group.spec.ts
  • tests/e2e/specs/playground-empty.spec.ts
  • tests/e2e/specs/playground-loads.spec.ts
  • tests/e2e/specs/spa.spec.ts
  • tests/e2e/specs/tabs.spec.ts
💤 Files with no reviewable changes (3)
  • tests/e2e/specs/nuxt-group.spec.ts
  • tests/e2e/specs/playground-empty.spec.ts
  • tests/e2e/specs/iframe.spec.ts

Comment on lines +20 to 24
// Open the Code Server member the way a user would.
await page.evaluate(async (id) => {
const ctx = (globalThis as any).__VITE_DEVTOOLS_CLIENT_CONTEXT__
await ctx.docks.switchEntry(id)
}, CODE_SERVER_DOCK_ID)

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Open Code Server through the dock UI, not its internal registry.

This directly drives __VITE_DEVTOOLS_CLIENT_CONTEXT__.docks.switchEntry, so the test can pass while the user cannot select the Code Server dock. Select the visible dock entry instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/specs/code-server.spec.ts` around lines 20 - 24, Update the Code
Server opening step in the e2e test to select the visible dock entry through the
page UI rather than calling __VITE_DEVTOOLS_CLIENT_CONTEXT__.docks.switchEntry
via page.evaluate. Use the dock entry’s user-facing selector or label and
preserve the existing CODE_SERVER_DOCK_ID target.

Comment on lines +3 to +5
// Runs for every project (both dev and built) — a sanity check that the
// playground itself boots and renders. In built mode this is the only thing we
// verify, since Nuxt DevTools only attaches in dev.

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Align the coverage comment with the configured project matrix.

The test runs for all playgrounds in dev, but built mode is limited to empty and spa; removing the tab-seo skip does not add tab-seo:built coverage. Update the comment to describe the actual configured scope.

Proposed wording
-// Runs for every project (both dev and built) — a sanity check that the
-// playground itself boots and renders. In built mode this is the only thing we
-// verify, since Nuxt DevTools only attaches in dev.
+// Runs for every configured project: all playgrounds in dev, and `empty`/`spa`
+// in built mode. In built mode this is the only thing we verify, since Nuxt
+// DevTools only attaches in dev.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Runs for every project (both dev and built) — a sanity check that the
// playground itself boots and renders. In built mode this is the only thing we
// verify, since Nuxt DevTools only attaches in dev.
// Runs for every configured project: all playgrounds in dev, and `empty`/`spa`
// in built mode. In built mode this is the only thing we verify, since Nuxt
// DevTools only attaches in dev.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/specs/playground-loads.spec.ts` around lines 3 - 5, Update the
coverage comment above the playground boot/render sanity check to reflect the
configured project matrix: it runs for every project in dev, while built mode
runs only for empty and spa; do not imply built tab-seo coverage.

@antfu
antfu merged commit 8badc89 into main Jul 27, 2026
6 of 7 checks passed
@antfu
antfu deleted the early-knives-dig branch July 27, 2026 08:25
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