first round of review
This commit is contained in:
parent
7ebfb7a2dd
commit
da5a0d03eb
14 changed files with 362 additions and 244 deletions
|
|
@ -8,7 +8,7 @@ function uniqueEmail(): string {
|
|||
// Helper to authenticate a user
|
||||
async function authenticate(page: Page): Promise<string> {
|
||||
const email = uniqueEmail();
|
||||
await page.evaluate(() => localStorage.clear());
|
||||
await page.context().clearCookies();
|
||||
await page.goto("/signup");
|
||||
await page.fill('input[type="email"]', email);
|
||||
await page.fill('input[type="password"]', "password123");
|
||||
|
|
@ -95,13 +95,13 @@ test.describe("Counter - Authenticated", () => {
|
|||
|
||||
test.describe("Counter - Unauthenticated", () => {
|
||||
test("redirects to login when accessing counter without auth", async ({ page }) => {
|
||||
await page.evaluate(() => localStorage.clear());
|
||||
await page.context().clearCookies();
|
||||
await page.goto("/");
|
||||
await expect(page).toHaveURL("/login");
|
||||
});
|
||||
|
||||
test("shows login form when redirected", async ({ page }) => {
|
||||
await page.evaluate(() => localStorage.clear());
|
||||
await page.context().clearCookies();
|
||||
await page.goto("/");
|
||||
await expect(page.locator("h1")).toHaveText("Welcome back");
|
||||
});
|
||||
|
|
@ -138,11 +138,11 @@ test.describe("Counter - Session Integration", () => {
|
|||
test("counter API requires authentication", async ({ page }) => {
|
||||
// Try to access counter API directly without auth
|
||||
const response = await page.request.get("http://localhost:8000/api/counter");
|
||||
expect(response.status()).toBe(403);
|
||||
expect(response.status()).toBe(401);
|
||||
});
|
||||
|
||||
test("counter increment API requires authentication", async ({ page }) => {
|
||||
const response = await page.request.post("http://localhost:8000/api/counter/increment");
|
||||
expect(response.status()).toBe(403);
|
||||
expect(response.status()).toBe(401);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue