fix: refactor enchanter and fabricator e2e tests
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m21s

Enchanter test:
- Use data-testid selectors for debug buttons
- Add waitForBridge pattern
- Switch baseURL to localhost:3000

Fabricator test:
- Use data-testid selectors for all debug buttons (attunements, elements, disciplines, materials)
- Activate discipline via toggle button before adding XP
- Unlock recipes via discipline XP + store unlockRecipes
- Replace waitForTimeout with runTicks for crafting (instant tick-based waiting)
- Add ticksForHours helper for deterministic craft completion
- Verify each craft completed via store check instead of currentAction polling
- Remove direct store manipulation for attunement/element unlock (use debug UI buttons)
This commit is contained in:
2026-06-02 16:39:33 +02:00
parent e95a378731
commit 3383aedd2f
7 changed files with 109 additions and 84 deletions
+18 -10
View File
@@ -1,7 +1,7 @@
import { test, expect, type Page } from '@playwright/test';
test.use({
baseURL: 'https://manaloop.tailf367e3.ts.net/',
baseURL: 'http://localhost:3000/',
});
// ─── Helpers ─────────────────────────────────────────────────────────────────
@@ -15,6 +15,7 @@ async function startFreshGame(page: Page) {
await page.evaluate(() => localStorage.clear());
await page.reload();
await page.waitForLoadState('networkidle');
await waitForMs(page, 3000);
}
async function clickTab(page: Page, label: string) {
@@ -23,12 +24,21 @@ async function clickTab(page: Page, label: string) {
await waitForMs(page, 400);
}
async function waitForBridge(page: Page) {
for (let attempt = 0; attempt < 30; attempt++) {
const ready = await page.evaluate(() => !!(window as any).__TEST__);
if (ready) return;
await waitForMs(page, 1000);
}
throw new Error('Debug bridge (window.__TEST__) not available after 30s');
}
// ─── Test ────────────────────────────────────────────────────────────────────
test.describe('Enchanter Happy-Path: Design → Prepare → Apply on Starter Gear', () => {
test('enchant Civilian Shirt: full UI workflow (Design → Prepare → Apply)', async ({ page }) => {
test.setTimeout(240000);
test.setTimeout(240_000);
const errors: string[] = [];
page.on('console', (msg) => {
@@ -37,18 +47,16 @@ test.describe('Enchanter Happy-Path: Design → Prepare → Apply on Starter Gea
// ── 1. Start fresh game ───────────────────────────────────────────────────
await startFreshGame(page);
await waitForMs(page, 1000);
await waitForBridge(page);
// ── 2. Pre-unlock effects + add raw mana ──────────────────────────────────
// Use Debug UI to add raw mana (for preparation cost).
// ── 2. Add raw mana via Debug UI ──────────────────────────────────────────
await clickTab(page, 'debug');
await waitForMs(page, 500);
const add10KBtn = page.getByRole('button', { name: /\+10k/i }).first();
if (await add10KBtn.isVisible({ timeout: 3000 })) {
await add10KBtn.click();
await waitForMs(page, 200);
}
const add10KBtn = page.getByTestId('debug-mana-add-10k');
await expect(add10KBtn).toBeVisible({ timeout: 5000 });
await add10KBtn.click();
await waitForMs(page, 200);
// ── 3. Navigate to Crafting → Enchanter ────────────────────────────────────
await clickTab(page, 'craft');