Skip to content

test(e2e): cover all plugin behaviors - #32

Open
SoonIter wants to merge 3 commits into
mainfrom
test/plugin-e2e-coverage
Open

test(e2e): cover all plugin behaviors#32
SoonIter wants to merge 3 commits into
mainfrom
test/plugin-e2e-coverage

Conversation

@SoonIter

Copy link
Copy Markdown
Member

This PR adds two behavior-focused Playwright cases for each of the 13 plugins and makes the shared Rspress dev-server fixture wait for HTTP readiness.

It also compiles the back-to-top component Less into published CSS, so consumers do not need to install or configure @rsbuild/plugin-less.

Copilot AI review requested due to automatic review settings July 31, 2026 09:48

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3af6f8b473

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +11 to +12
dts: {
bundle: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add API Extractor for bundled declarations

On a fresh non-hoisted pnpm install, pnpm run build reaches this configuration with dts.bundle enabled, but the back-to-top importer does not declare @microsoft/api-extractor; the lockfile consequently resolves its Rslib/DTS-plugin variant without that optional peer. Rslib cannot perform the requested declaration bundling, so the repository build fails instead of producing this package's dist; add API Extractor as a dev dependency or disable declaration bundling.

AGENTS.md reference: AGENTS.md:L23-L24

Useful? React with 👍 / 👎.

import * as path from 'path';
import { defineConfig } from '@rspress/core';
import back2Top from './src';
import back2Top from './dist/index.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep docs development connected to source changes

When a contributor runs the package's existing docs:dev command and edits src, this configuration now serves the last prebuilt dist and no longer watches the source as it did previously. The package's dev script still invokes tsc -w, which cannot regenerate the newly required Less-derived CSS (and preserves the component as .jsx rather than the referenced .js), so component and style changes remain stale or missing until a manual Rslib build; wire the development workflow to rslib build -w or keep the development config source-based.

Useful? React with 👍 / 👎.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@SoonIter, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e3d6beb2-6e32-4f9b-ab41-c3bc9bc752dc

📥 Commits

Reviewing files that changed from the base of the PR and between 3af6f8b and 6f99dbc.

📒 Files selected for processing (1)
  • package.json
📝 Walkthrough

Walkthrough

The pull request adds server-readiness polling and a shared Playwright development-server fixture. It expands browser coverage across multiple plugins and updates related example configurations. The BackToTop package now builds with Rslib and registers built assets. Repository ignore rules cover Rslib directories. Playwright artifact retention now occurs only after failures.

🚥 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 The title clearly summarizes the main change: adding end-to-end coverage for plugin behaviors.
Description check ✅ Passed The description accurately covers the Playwright tests, server-readiness fixture, and compiled back-to-top styles.
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 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/plugin-e2e-coverage

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

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
e2e/utils.ts (1)

11-28: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Add a per-attempt timeout to the readiness poll.

waitForServer checks Date.now() < deadline only before starting each fetch call. If a single fetch call hangs (for example, the server accepts the connection but never responds), the loop can block past the 30-second deadline before the next check runs. Use AbortSignal.timeout() to bound each attempt.

♻️ Proposed fix
   while (Date.now() < deadline) {
     try {
-      const response = await fetch(url);
+      const response = await fetch(url, { signal: AbortSignal.timeout(2_000) });
       if (response.ok) {
         return;
       }
     } catch {
       // The Rspress dev server can briefly restart during its first compilation.
     }
🤖 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 `@e2e/utils.ts` around lines 11 - 28, Update waitForServer so each fetch
attempt uses an AbortSignal.timeout() duration, ensuring a hanging request is
aborted and the overall 30-second deadline remains enforceable. Pass the signal
to fetch and preserve the existing retry and readiness behavior.
🤖 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 `@packages/rspress-plugin-back-to-top/rspress.config.ts`:
- Around line 3-8: Update the package’s E2E command configuration so the Rslib
build runs before Playwright starts, ensuring the dist/index.js artifact
imported by the rspress config exists on clean checkouts. Preserve the existing
Playwright test command and use the package’s existing build script or Rslib
command.

---

Nitpick comments:
In `@e2e/utils.ts`:
- Around line 11-28: Update waitForServer so each fetch attempt uses an
AbortSignal.timeout() duration, ensuring a hanging request is aborted and the
overall 30-second deadline remains enforceable. Pass the signal to fetch and
preserve the existing retry and readiness behavior.
🪄 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: 1676f8d3-1efd-46e3-8a44-d839b92d657e

📥 Commits

Reviewing files that changed from the base of the PR and between a59a167 and 3af6f8b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (29)
  • .gitignore
  • .prettierignore
  • e2e/utils.ts
  • packages/rspress-plugin-align-image/index.spec.ts
  • packages/rspress-plugin-align-image/rspress.config.ts
  • packages/rspress-plugin-back-to-top/index.spec.ts
  • packages/rspress-plugin-back-to-top/package.json
  • packages/rspress-plugin-back-to-top/rslib.config.ts
  • packages/rspress-plugin-back-to-top/rspress.config.ts
  • packages/rspress-plugin-back-to-top/src/index.ts
  • packages/rspress-plugin-devkit/components/DevkitCode.tsx
  • packages/rspress-plugin-devkit/docs/index.md
  • packages/rspress-plugin-devkit/index.spec.ts
  • packages/rspress-plugin-devkit/rspress.config.ts
  • packages/rspress-plugin-directives/index.spec.ts
  • packages/rspress-plugin-file-tree/index.spec.ts
  • packages/rspress-plugin-file-tree/rspress.config.ts
  • packages/rspress-plugin-gh-pages/index.spec.ts
  • packages/rspress-plugin-google-analytics/index.spec.ts
  • packages/rspress-plugin-google-analytics/rspress.config.ts
  • packages/rspress-plugin-katex/index.spec.ts
  • packages/rspress-plugin-live2d/index.spec.ts
  • packages/rspress-plugin-live2d/rspress.config.ts
  • packages/rspress-plugin-mermaid/index.spec.ts
  • packages/rspress-plugin-reading-time/index.spec.ts
  • packages/rspress-plugin-supersub/index.spec.ts
  • packages/rspress-plugin-vercel-analytics/index.spec.ts
  • packages/rspress-plugin-vercel-analytics/rspress.config.ts
  • playwright.config.ts

Comment on lines +3 to +8
import back2Top from './dist/index.js';

export default defineConfig({
root: path.join(__dirname, 'docs'),
title: 'Rspress x Back2Top Example',
themeConfig: {
enableScrollToTop: true,
},
plugins: [back2Top({ threshold: 100 })],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

# Map the shared server fixture before inspecting its implementation.
ast-grep outline e2e/utils.ts --items all
sed -n '1,280p' e2e/utils.ts

# Show workspace scripts that can establish the required build-before-E2E order.
fd -a --type f '^package\.json$' . -x sh -c '
  jq -r "
    .name as \$name
    | (.scripts // {})
    | to_entries[]
    | select(.key | test(\"^(pre)?(test|e2e|build)$\"))
    | \"\(\$name // input_filename): \(.key) = \(.value)\"
  " "$1"
' sh {}

Repository: rstackjs/rspress-plugins

Length of output: 6939


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '--- top-level package scripts ---\n'
jq -r '
  .name as $name
  | (.scripts // {})
  | to_entries[]
  | select(.key | test("^(pre)?(test|e2e|build|prepare|postinstall|preinstall|install|dev)$"))
  | "\($name // "root"): \(.key) = \(.value)"
' package.json

printf '\n--- back-to-top config and package scripts ---\n'
cat -n packages/rspress-plugin-back-to-top/rspress.config.ts
jq -r '
  .name as $name
  | (.scripts // {})
  | to_entries[]
  | select(.key | test("^(test|e2e|build|dev|rslib|rspress)$"))
  | "\($name // "pkg"): \(.key) = \(.value)"
' packages/rspress-plugin-back-to-top/package.json

printf '\n--- e2e package scripts and fixtures ---\n'
jq -r '
  .name as $name
  | (.scripts // {})
  | to_entries[]
  | select(.key | test("^(test|e2e|build|dev)$"))
  | "\($name // "pkg"): \(.key) = \(.value)"
' e2e/package.json
sed -n '1,220p' e2e/playwright.config.ts
rg -n "useRspressDevServer|scripts|e2e|rspress-plugin-back-to-top|back-to-top|dist/index" e2e packages/rspress-plugin-back-to-top -g '!node_modules'

Repository: rstackjs/rspress-plugins

Length of output: 253


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- top-level package scripts ---'
jq -r '
  .name as $name
  | (.scripts // {})
  | to_entries[]
  | select(.key | test("^(pre)?(test|e2e|build|prepare|postinstall|preinstall|install|dev)$"))
  | "\($name // "root"): \(.key) = \(.value)"
' package.json

printf '%s\n' ''
printf '%s\n' '--- back-to-top config and package scripts ---'
cat -n packages/rspress-plugin-back-to-top/rspress.config.ts
jq -r '
  .name as $name
  | (.scripts // {})
  | to_entries[]
  | select(.key | test("^(test|e2e|build|dev|rslib|rspress)$"))
  | "\($name // "pkg"): \(.key) = \(.value)"
' packages/rspress-plugin-back-to-top/package.json

printf '%s\n' ''
printf '%s\n' '--- e2e package scripts and fixtures ---'
jq -r '
  .name as $name
  | (.scripts // {})
  | to_entries[]
  | select(.key | test("^(test|e2e|build|dev|pre|post)$"))
  | "\($name // "pkg"): \(.key) = \(.value)"
' e2e/package.json
sed -n '1,220p' e2e/playwright.config.ts
rg -n "useRspressDevServer|scripts|e2e|rspress-plugin-back-to-top|back-to-top|dist/index|pnpm rslib|rslib" e2e packages/rspress-plugin-back-to-top root -g '!node_modules' 2>/dev/null || true

Repository: rstackjs/rspress-plugins

Length of output: 967


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- root package files and scripts ---'
jq -r '
  (.scripts // {}) | to_entries[] | select(.key | test("^(pre)?(test|e2e|build|prepare|postinstall|preinstall|install|dev)$"))
  | "\(.key) = \(.value)"
' package.json

printf '%s\n' ''
printf '%s\n' '--- back-to-top package scripts ---'
jq -r '
  .name,
  "build = \(.scripts.build // ""),",
  "dev = \(.scripts.dev // ""),",
  "rslib = \(.scripts.rslib // "")"
' packages/rspress-plugin-back-to-top/package.json

printf '%s\n' ''
printf '%s\n' '--- locate and inspect root e2e entry ---'
fd -a -e js -e ts package.json -e ts|rg 'e2e|playwright|rspress' .
fd -a -e js -e ts . -x sh -c 'echo "--- $1"; sed -n "1,220p" "$1"' sh {} | rg -n -A200 'useRspressDevServer|pnpm.*(rspress|e2e)|test:' || true

printf '%s\n' ''
printf '%s\n' '--- references to back-to-top e2e setup ---'
rg -n "back-to-top|rspress-plugin-back-to-top|dist/index|useRspressDevServer|pnpm .*rspress|playwright test" packages e2e -g '!node_modules' -g '!dist' 2>/dev/null || true

printf '%s\n' ''
printf '%s\n' '--- deterministic script dependency check ---'
node - <<'JS'
const fs = require('fs');
const root = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const pkg = JSON.parse(fs.readFileSync('packages/rspress-plugin-back-to-top/package.json', 'utf8'));
const e2eScript = root.scripts && root.scripts.e2e;
const buildScript = root.scripts && root.scripts.build;

console.log(JSON.stringify({
  e2eScript,
  buildScript,
  backToTopBuildScript: pkg.scripts && pkg.scripts.build,
  e2eBuildsBeforeLoading: Boolean(e2eScript && /(?:^|\||&&|;|\b)rslib\s+build\b/.test(e2eScript)),
  workspaceBuildExists: Boolean(buildScript && /packages:build/.test(buildScript))
}, null, 2));
JS

Repository: rstackjs/rspress-plugins

Length of output: 50381


Add the Rslib build step before E2E starts the dev server.

packages/rspress-plugin-back-to-top/rspress.config.ts imports ./dist/index.js, and package.json has e2e = playwright test without pre-running rslib build. Clean checkout runs can fail when useRspressDevServer loads this config while the generated artifact is missing.

🤖 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 `@packages/rspress-plugin-back-to-top/rspress.config.ts` around lines 3 - 8,
Update the package’s E2E command configuration so the Rslib build runs before
Playwright starts, ensuring the dist/index.js artifact imported by the rspress
config exists on clean checkouts. Preserve the existing Playwright test command
and use the package’s existing build script or Rslib command.

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