Skip to content

test: add more e2e test#75

Open
wuhan005 wants to merge 6 commits intomasterfrom
wh/more-e2e-test-case
Open

test: add more e2e test#75
wuhan005 wants to merge 6 commits intomasterfrom
wh/more-e2e-test-case

Conversation

@wuhan005
Copy link
Copy Markdown
Owner

@wuhan005 wuhan005 commented Apr 9, 2026

Signed-off-by: E99p1ant i@github.red

Summary by CodeRabbit

Release Notes

  • Tests

    • Added comprehensive end-to-end test coverage for authentication, question management, public profiles, and settings workflows.
    • Implemented tests validating sign-up duplicate domain detection, question visibility controls, deletion operations, profile display, and account management features.
  • Style

    • Minor HTML attribute improvement to the settings form.

Signed-off-by: E99p1ant <i@github.red>
Signed-off-by: E99p1ant <i@github.red>
Signed-off-by: E99p1ant <i@github.red>
Signed-off-by: E99p1ant <i@github.red>
Copilot AI review requested due to automatic review settings April 9, 2026 17:25
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

Caution

Review failed

The head commit changed during the review from 64e285b to be7efb2.

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
E2E Test Suite - Authentication & Helpers
e2e/tests/auth.spec.ts, e2e/tests/helpers.ts
Added test case for duplicate domain sign-up error validation. Introduced authHeaderFromPage() helper to extract auth tokens from localStorage and return formatted Authorization headers.
E2E Test Suite - Question Management
e2e/tests/mine.spec.ts
New comprehensive test suite covering question CRUD operations: posting, deleting, and toggling visibility (private↔public). Tests include UI assertions, API boundary checks (401/403 for unauthenticated access, 404 for cross-user operations), and mine list badge validation.
E2E Test Suite - Public Profile
e2e/tests/profile.spec.ts
New test suite verifying public profile page behavior: user profile card display, navigation to non-existent profiles, visibility of answered questions, and exclusion of unanswered and private questions. Includes API assertions for profile endpoints.
E2E Test Suite - Settings & Account
e2e/tests/settings.spec.ts
New comprehensive test suite covering profile/password updates, box intro configuration, harassment/block word settings, register-only mode, and account deactivation flow. Tests coordinate UI interactions with API assertions and response validation.
Vue Component
web/src/pages/mine/Settings.vue
Added explicit id="email" attribute to the email display input field.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 Through tests we hop, from auth to mines so deep,
Questions answered, profiles shown, secrets safe to keep,
Settings tweaked and visibility toggled with care,
E2E assertions everywhere, ensuring all is fair! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title "test: add more e2e test" is vague and generic, using non-descriptive language that doesn't convey meaningful information about which specific e2e tests were added or what functionality they cover. Enhance the title to be more specific, such as "test: add e2e tests for auth, mine questions, profile, and settings" or similar, to clearly indicate the scope and purpose of the new tests.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 wh/more-e2e-test-case

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 and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 9, 2026

Deploying nekobox-web with  Cloudflare Pages  Cloudflare Pages

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

View logs

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 id so 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.

Comment thread e2e/tests/profile.spec.ts Outdated
Comment thread e2e/tests/settings.spec.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
e2e/tests/mine.spec.ts (2)

184-200: Reuse authHeaderFromPage() here.

This duplicates the helper added in e2e/tests/helpers.ts and 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 first p.uk-text-small makes 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

📥 Commits

Reviewing files that changed from the base of the PR and between 97cb7c7 and 4315258.

📒 Files selected for processing (6)
  • e2e/tests/auth.spec.ts
  • e2e/tests/helpers.ts
  • e2e/tests/mine.spec.ts
  • e2e/tests/profile.spec.ts
  • e2e/tests/settings.spec.ts
  • web/src/pages/mine/Settings.vue

Comment thread e2e/tests/mine.spec.ts
Comment thread e2e/tests/profile.spec.ts
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (97cb7c7) to head (be7efb2).

❗ There is a different number of reports uploaded between BASE (97cb7c7) and HEAD (be7efb2). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (97cb7c7) HEAD (be7efb2)
2 0
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     
Flag Coverage Δ
e2e 0.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

3 participants