Files
kima-hub/frontend/tests/e2e/global.setup.ts
T
Your Name fc8071b7aa fix: issue triage -- #155 #156 #154 #25, CI hardening, E2E improvements
Issue fixes:
- #155: /api/browse/playlists/parse now handles YouTube/YouTube Music URLs
- #156: stop passing album MBID to verifyArtistName (was calling MB /artist/{id}
  with an album MBID, always 404d); fix spotify trackCount stale value
- #154: remove hardcoded port-3030 detection from getApiBaseUrl -- now returns
  relative URLs by default so any host:port mapping works
- #25 (partial): fix spotify playlist trackCount to use tracks.length instead of
  stale playlist.tracks.total after pagination

Dead code / quality:
- Remove unused rootFolderPath param from processDownload + call sites
- Remove unused req params in route handlers (prefix _req)
- Remove dead push condition from integration.yml job gate
- Remove dead baseUrl constructor param and private field from ApiService
- Fix LibraryTabs hover effect: remove inline style={{ opacity: 0.1 }} that
  overrode Tailwind group-hover; change to group-hover:opacity-10
- Fix mobile tab centering in LibraryTabs (add justify-center)

CI security:
- Mask TEST_PASS before writing to GITHUB_ENV in all three workflow files
- Add missing concurrency block to nightly.yml
- Add username validation + remove credential echo in create-e2e-user.sh
- Fix global.setup.ts error message to mention .env.test

E2E:
- Fix vibe test race condition: replace Promise.race + transient text with
  stable trackCount.or(noData) assertion
- Fix security test flakiness: toBe(beforeCount) -> not.toBeGreaterThan for
  playlist count check (parallel tests can delete playlists concurrently)
- Fix global.setup.ts error message to reference .env.test file

Vibe map:
- Increase cluster label size (13->15 / 10->12 px) and opacity (50->70 / 35->50)
  for slightly better readability
2026-03-17 10:04:03 -05:00

57 lines
2.2 KiB
TypeScript

/**
* Playwright global setup -- runs once before all tests.
*
* Verifies the E2E test user exists and can authenticate.
* If login fails with the configured credentials, prints setup instructions and aborts.
*
* Required env vars (set in .env.test or export before running):
* KIMA_TEST_USERNAME -- username of the dedicated E2E test user
* KIMA_TEST_PASSWORD -- password of the dedicated E2E test user
* KIMA_UI_BASE_URL -- base URL of the running app (default: http://127.0.0.1:3030)
*/
import { chromium } from "@playwright/test";
async function globalSetup(): Promise<void> {
const username = process.env.KIMA_TEST_USERNAME;
const password = process.env.KIMA_TEST_PASSWORD;
const baseUrl = process.env.KIMA_UI_BASE_URL || "http://127.0.0.1:3030";
if (!username || !password) {
throw new Error(
"E2E test user credentials not set.\n" +
"Set KIMA_TEST_USERNAME and KIMA_TEST_PASSWORD in .env.test or export them before running E2E tests.\n" +
"To create a test user, run: bash scripts/create-e2e-user.sh"
);
}
// Verify the test user can log in via browser (also saves auth state)
const browser = await chromium.launch();
const page = await browser.newPage();
try {
await page.goto(`${baseUrl}/login`);
await page.locator("#username").fill(username);
await page.locator("#password").fill(password);
await page.getByRole("button", { name: "Sign In" }).click();
// Wait for redirect to the home page (matches /, /?..., /home)
// Same pattern used by loginAsTestUser in test-helpers.ts
try {
await page.waitForURL(/\/($|\?|home)/, { timeout: 20_000 });
} catch {
const url = page.url();
throw new Error(
`Login failed for E2E test user '${username}'. Still on: ${url}\n` +
"Create the user by running: bash scripts/create-e2e-user.sh"
);
}
await page.context().storageState({ path: "tests/e2e/.auth/user.json" });
console.log(`[setup] E2E test user '${username}' verified, auth state saved.`);
} finally {
await browser.close();
}
}
export default globalSetup;