Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export default defineConfig({
viewport: { width: 1280, height: 720 },
},

/* Deterministic location for visual baselines generated by toHaveScreenshot(). */
snapshotPathTemplate: '{testDir}/__screenshots__/{testFilePath}/{arg}{ext}',

projects: [
{
name: 'chromium',
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions tests/e2e/m2-combat-mvp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,88 @@ test('GIVEN sortie running WHEN HUD rendered THEN sortie-status shows In Progres
})
})

// ---------------------------------------------------------------------------
// Playwright screenshot baselines (AC2, AC3) — Issue #681
// ---------------------------------------------------------------------------

test('GIVEN short sortie fixture WHEN defeat overlay baseline then Canvas screenshot matches', async ({
page,
}) => {
// GIVEN the sortie reaches timeout defeat via __E2E_SHORT_SORTIE__ fixture (targetTicks≈30)
// WHEN the canvas overlay settles after defeat
// THEN the canvas screenshot should match the defeat overlay baseline
test.setTimeout(15_000)
await page.addInitScript(() => {
;(window as Window & { __E2E_SHORT_SORTIE__?: boolean }).__E2E_SHORT_SORTIE__ = true
})
await page.goto('/')

await expect
.poll(
async () => {
const s = await getGameState(page)
return s.sortie.status
},
{ timeout: 10_000, intervals: [100] },
)
.toBe('defeat')

await page.waitForTimeout(200)

await expect(page.locator('canvas.battle-stage__canvas')).toHaveScreenshot(
'm2-defeat-overlay-baseline.png',
{
animations: 'disabled',
maxDiffPixels: 1,
},
)
})

test('GIVEN sortie running WHEN running HUD baseline then HUD screenshot matches', async ({
page,
}) => {
// GIVEN the sortie is in running state
// WHEN the HUD is rendered
// THEN the status locator screenshot should match the running HUD baseline
await expect
.poll(
async () => {
const s = await getGameState(page)
return s.sortie.status
},
{ timeout: 3000, intervals: [50] },
)
.toBe('running')

await expect(page.locator('[data-field="sortie-status"]')).toHaveText('In Progress', {
timeout: 3000,
})

await page.addStyleTag({
content: `[data-field="sortie-status"] {
display: block;
width: 118px;
height: 66px;
line-height: 66px;
text-align: center;
white-space: nowrap;
box-sizing: border-box;
overflow: hidden;
font-family: monospace;
font-size: 18px;
font-weight: 600;
}`,
})

await expect(page.locator('[data-field="sortie-status"]')).toHaveScreenshot(
'm2-running-hud-baseline.png',
{
animations: 'disabled',
maxDiffPixels: 1,
},
)
})

// ---------------------------------------------------------------------------
// Canvas bitmap visual verification (AC7, AC8) — Issue #541
// ---------------------------------------------------------------------------
Expand Down
Loading