veza/tests/e2e/fixtures/auth.fixture.ts
senke 172581ff02 chore(cleanup): remove orphan code + archive disabled workflows + .playwright-mcp
Triple cleanup, landed together because they share the same cleanup
branch intent and touch non-overlapping trees.

1. 38× tracked .playwright-mcp/*.yml stage-deleted
   MCP session recordings that had been inadvertently committed.
   .gitignore already covers .playwright-mcp/ (post-audit J2 block
   added in d12b901de). Working tree copies removed separately.

2. 19× disabled CI workflows moved to docs/archive/workflows/
   Legacy .yml.disabled files in .github/workflows/ were 1676 LOC of
   dead config (backend-ci, cd, staging-validation, accessibility,
   chromatic, visual-regression, storybook-audit, contract-testing,
   zap-dast, container-scan, semgrep, sast, mutation-testing,
   rust-mutation, load-test-nightly, flaky-report, openapi-lint,
   commitlint, performance). Preserved in docs/archive/workflows/
   for historical reference; `.github/workflows/` now only lists the
   5 actually-running pipelines.

3. Orphan code removed (0 consumers confirmed via grep)
   - veza-backend-api/internal/repository/user_repository.go
     In-memory UserRepository mock, never imported anywhere.
   - proto/chat/chat.proto
     Chat server Rust deleted 2026-02-22 (commit 279a10d31); proto
     file was orphan spec. Chat lives 100% in Go backend now.
   - veza-common/src/types/chat.rs (Conversation, Message, MessageType,
     Attachment, Reaction)
   - veza-common/src/types/websocket.rs (WebSocketMessage,
     PresenceStatus, CallType — depended on chat::MessageType)
   - veza-common/src/types/mod.rs updated: removed `pub mod chat;`,
     `pub mod websocket;`, and their re-exports.
   Only `veza_common::logging` is consumed by veza-stream-server
   (verified with `grep -r "veza_common::"`). `cargo check` on
   veza-common passes post-removal.

Refs: AUDIT_REPORT.md §8.2 "Code mort / orphelin" + §9.1.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 20:33:40 +02:00

59 lines
1.8 KiB
TypeScript

import { test as base, expect, type Page } from '@playwright/test';
import { CONFIG } from '../helpers';
/**
* API-driven authentication fixture.
* Replaces UI login flows for faster, deterministic tests.
*
* Usage:
* import { test } from './fixtures/auth.fixture';
* test('something', async ({ listenerPage, creatorPage }) => { ... });
*/
async function loginAndSetup(page: Page, email: string, password: string): Promise<void> {
const base = CONFIG.baseURL;
await page.goto(`${base}/`, { waitUntil: 'commit', timeout: CONFIG.timeouts.navigation });
const response = await page.request.post(`${base}/api/v1/auth/login`, {
data: { email, password, remember_me: false },
});
expect(response.ok(), `Login API failed: ${response.status()} for ${email}`).toBeTruthy();
await page.evaluate(() => {
localStorage.setItem(
'auth-storage',
JSON.stringify({ state: { isAuthenticated: true, isLoading: false, error: null }, version: 1 }),
);
});
}
type AuthFixtures = {
listenerPage: Page;
creatorPage: Page;
adminPage: Page;
moderatorPage: Page;
};
export const test = base.extend<AuthFixtures>({
listenerPage: async ({ page }, use) => {
await loginAndSetup(page, CONFIG.users.listener.email, CONFIG.users.listener.password);
await use(page);
},
creatorPage: async ({ page }, use) => {
await loginAndSetup(page, CONFIG.users.creator.email, CONFIG.users.creator.password);
await use(page);
},
adminPage: async ({ page }, use) => {
await loginAndSetup(page, CONFIG.users.admin.email, CONFIG.users.admin.password);
await use(page);
},
moderatorPage: async ({ page }, use) => {
await loginAndSetup(page, CONFIG.users.moderator.email, CONFIG.users.moderator.password);
await use(page);
},
});
export { expect } from '@playwright/test';