multica/e2e/comments.spec.ts
Jiayuan Zhang 6dfc61fa86 test: add comprehensive test suite (Go unit/integration, Vitest, Playwright E2E)
- Add JWT middleware unit tests (8 tests covering all auth edge cases)
- Add WebSocket hub tests (5 tests for client lifecycle and broadcast)
- Add full HTTP integration tests (12 tests through real Chi router with DB)
- Add frontend component tests for login, issues, and issue detail pages
- Add auth context unit tests (9 tests for login/logout/name resolution)
- Add Playwright E2E tests for auth, issues, comments, and navigation
- Configure Vitest with jsdom, React plugin, and path aliases

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 11:50:25 +08:00

47 lines
1.6 KiB
TypeScript

import { test, expect } from "@playwright/test";
import { loginAsDefault } from "./helpers";
test.describe("Comments", () => {
test("can add a comment on an issue", async ({ page }) => {
await loginAsDefault(page);
// Wait for issues to load and click first one
const issueLink = page.locator('a[href^="/issues/"]').first();
await expect(issueLink).toBeVisible({ timeout: 5000 });
await issueLink.click();
await page.waitForURL(/\/issues\/[\w-]+/);
// Wait for issue detail to load
await expect(page.locator("text=Properties")).toBeVisible();
// Type a comment
const commentText = "E2E comment " + Date.now();
const commentInput = page.locator(
'input[placeholder="Leave a comment..."]',
);
await commentInput.fill(commentText);
// Submit the comment
await page.locator('form button[type="submit"]').last().click();
// Comment should appear in the activity section
await expect(page.locator(`text=${commentText}`)).toBeVisible({
timeout: 5000,
});
});
test("comment submit button is disabled when empty", async ({ page }) => {
await loginAsDefault(page);
const issueLink = page.locator('a[href^="/issues/"]').first();
await expect(issueLink).toBeVisible({ timeout: 5000 });
await issueLink.click();
await page.waitForURL(/\/issues\/[\w-]+/);
await expect(page.locator("text=Properties")).toBeVisible();
// Submit button should be disabled when input is empty
const submitBtn = page.locator('form button[type="submit"]').last();
await expect(submitBtn).toBeDisabled();
});
});