test(e2e): cover all plugin behaviors - #32
Conversation
There was a problem hiding this comment.
💡 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".
| dts: { | ||
| bundle: true, |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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 👍 / 👎.
|
Warning Review limit reached
Next review available in: 51 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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. 📝 WalkthroughWalkthroughThe 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)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
e2e/utils.ts (1)
11-28: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winAdd a per-attempt timeout to the readiness poll.
waitForServerchecksDate.now() < deadlineonly before starting eachfetchcall. If a singlefetchcall 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. UseAbortSignal.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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (29)
.gitignore.prettierignoree2e/utils.tspackages/rspress-plugin-align-image/index.spec.tspackages/rspress-plugin-align-image/rspress.config.tspackages/rspress-plugin-back-to-top/index.spec.tspackages/rspress-plugin-back-to-top/package.jsonpackages/rspress-plugin-back-to-top/rslib.config.tspackages/rspress-plugin-back-to-top/rspress.config.tspackages/rspress-plugin-back-to-top/src/index.tspackages/rspress-plugin-devkit/components/DevkitCode.tsxpackages/rspress-plugin-devkit/docs/index.mdpackages/rspress-plugin-devkit/index.spec.tspackages/rspress-plugin-devkit/rspress.config.tspackages/rspress-plugin-directives/index.spec.tspackages/rspress-plugin-file-tree/index.spec.tspackages/rspress-plugin-file-tree/rspress.config.tspackages/rspress-plugin-gh-pages/index.spec.tspackages/rspress-plugin-google-analytics/index.spec.tspackages/rspress-plugin-google-analytics/rspress.config.tspackages/rspress-plugin-katex/index.spec.tspackages/rspress-plugin-live2d/index.spec.tspackages/rspress-plugin-live2d/rspress.config.tspackages/rspress-plugin-mermaid/index.spec.tspackages/rspress-plugin-reading-time/index.spec.tspackages/rspress-plugin-supersub/index.spec.tspackages/rspress-plugin-vercel-analytics/index.spec.tspackages/rspress-plugin-vercel-analytics/rspress.config.tsplaywright.config.ts
| 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 })], |
There was a problem hiding this comment.
🩺 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 || trueRepository: 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));
JSRepository: 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.
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.