Conversation
📝 WalkthroughWalkthroughThis pull request adds comprehensive end-to-end test coverage for authentication, profile pages, question management, and settings features. It also adds a helper function to extract authentication headers from browser storage and makes a minor HTML attribute addition to the Settings component. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 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 |
Deploying nekobox-web with
|
| Latest commit: |
be7efb2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a687a81a.nekobox-web.pages.dev |
| Branch Preview URL: | https://wh-more-e2e-test-case.nekobox-web.pages.dev |
There was a problem hiding this comment.
Pull request overview
Adds Playwright end-to-end coverage for additional user flows (settings, public profile, and “mine” question management), with a small UI tweak to improve selector/accessibility support.
Changes:
- Added new e2e specs covering settings flows, public profile behavior, and mine question management/API boundary cases.
- Extended auth e2e coverage with a duplicate-domain sign-up test.
- Updated Settings email input to include an
idso it can be reliably targeted by label-based selectors.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| web/src/pages/mine/Settings.vue | Adds id="email" to associate the email label with its input (enables getByLabel and improves accessibility). |
| e2e/tests/settings.spec.ts | New settings e2e suite (profile updates, password change, box/harassment settings, deactivation). |
| e2e/tests/profile.spec.ts | New public profile e2e suite (page rendering + API checks). |
| e2e/tests/mine.spec.ts | New “mine” e2e suite (delete/toggle visibility/badges + auth boundary checks). |
| e2e/tests/helpers.ts | Adds helper to derive an Authorization header from localStorage session state. |
| e2e/tests/auth.spec.ts | Adds a duplicate-domain registration negative test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
e2e/tests/mine.spec.ts (2)
184-200: ReuseauthHeaderFromPage()here.This duplicates the helper added in
e2e/tests/helpers.tsand will drift if the auth storage key or header format changes.♻️ Suggested refactor
-import { registerAndLogin, clickSubmitWhenReady } from './helpers'; +import { registerAndLogin, clickSubmitWhenReady, authHeaderFromPage } from './helpers';- const sessionID = await otherPage.evaluate(() => { - const raw = window.localStorage.getItem('auth'); - if (!raw) return ''; - try { - return (JSON.parse(raw) as { sessionID?: string }).sessionID ?? ''; - } catch { - return ''; - } - }); - expect(sessionID).not.toBe(''); + const authHeader = await authHeaderFromPage(otherPage); const answerResponse = await otherPage.request.put( `/api/mine/questions/${questionID}/answer`, { - headers: { Authorization: `Token ${sessionID}` }, + headers: authHeader, multipart: { answer: 'Hacked!' }, } );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@e2e/tests/mine.spec.ts` around lines 184 - 200, The code duplicates localStorage auth extraction and manual header creation; replace that block by calling the existing helper authHeaderFromPage(otherPage) to obtain the Authorization header and use it in the request. Specifically, remove the manual sessionID extraction (the evaluate call and expect) and instead call authHeaderFromPage(otherPage) to get the header value, assert it's non-empty if needed, and pass it into otherPage.request.put's headers (the request to /api/mine/questions/${questionID}/answer) so the page-level auth format and storage key are reused consistently.
13-16: Target the created question by content instead of.first().This helper already has
content, so relying on the firstp.uk-text-smallmakes the flow unnecessarily order-dependent.♻️ Suggested refactor
- await expect(page.locator('p.uk-text-small').first()).toContainText(content, { timeout: 10_000 }); - await page.locator('p.uk-text-small').first().click(); + const questionRow = page.locator('p.uk-text-small').filter({ hasText: content }).first(); + await expect(questionRow).toBeVisible({ timeout: 10_000 }); + await questionRow.click();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@e2e/tests/mine.spec.ts` around lines 13 - 16, Replace order-dependent uses of page.locator('p.uk-text-small').first() with a locator that targets the created question by its content: use page.locator('p.uk-text-small', { hasText: content }) (or equivalent hasText/has option) for both the toContainText assertion and the click, so the test asserts and clicks the element that contains the helper-provided content instead of relying on the first match; keep the final URL assertion unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@e2e/tests/mine.spec.ts`:
- Around line 67-68: Replace the visibility-based assertion with an assertion
that the element is absent from the DOM: instead of using the page locator check
that calls not.toBeVisible(), assert that the locator for the deleted question
has zero matches (use the locator created with the text content variable and an
assertion like toHaveCount(0) or the equivalent "not attached" check). Update
the assertion after page.goto('/mine/questions') so it verifies absence (zero
count) of the locator rather than invisibility.
In `@e2e/tests/profile.spec.ts`:
- Around line 84-86: The test currently uses
page.locator(...).not.toBeVisible(), which can pass if the text exists but is
hidden; replace those assertions with DOM-absence checks such as await
expect(page.locator('text=This unanswered question should stay
hidden')).toHaveCount(0) (or an equivalent not-attached assertion) to ensure the
element is not present in the DOM. Apply the same change for the other
occurrence mentioned (the assertion at the second location).
---
Nitpick comments:
In `@e2e/tests/mine.spec.ts`:
- Around line 184-200: The code duplicates localStorage auth extraction and
manual header creation; replace that block by calling the existing helper
authHeaderFromPage(otherPage) to obtain the Authorization header and use it in
the request. Specifically, remove the manual sessionID extraction (the evaluate
call and expect) and instead call authHeaderFromPage(otherPage) to get the
header value, assert it's non-empty if needed, and pass it into
otherPage.request.put's headers (the request to
/api/mine/questions/${questionID}/answer) so the page-level auth format and
storage key are reused consistently.
- Around line 13-16: Replace order-dependent uses of
page.locator('p.uk-text-small').first() with a locator that targets the created
question by its content: use page.locator('p.uk-text-small', { hasText: content
}) (or equivalent hasText/has option) for both the toContainText assertion and
the click, so the test asserts and clicks the element that contains the
helper-provided content instead of relying on the first match; keep the final
URL assertion unchanged.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 48e8c122-c5fb-4d3c-bcfb-fcc76acbfd8e
📒 Files selected for processing (6)
e2e/tests/auth.spec.tse2e/tests/helpers.tse2e/tests/mine.spec.tse2e/tests/profile.spec.tse2e/tests/settings.spec.tsweb/src/pages/mine/Settings.vue
Agent-Logs-Url: https://github.com/wuhan005/NekoBox/sessions/6edcd154-2011-4271-97c4-2da46bb5ea9a Co-authored-by: wuhan005 <12731778+wuhan005@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #75 +/- ##
==========================================
- Coverage 12.42% 0.00% -12.43%
==========================================
Files 32 30 -2
Lines 1924 1869 -55
==========================================
- Hits 239 0 -239
- Misses 1659 1869 +210
+ Partials 26 0 -26
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: E99p1ant i@github.red
Summary by CodeRabbit
Release Notes
Tests
Style