Align combat and replay smoke tests with current behavior
This commit is contained in:
parent
1217836c20
commit
786352b34a
2 changed files with 51 additions and 16 deletions
|
|
@ -55,10 +55,11 @@ try {
|
|||
);
|
||||
const marker = page.locator('.map-combat-label');
|
||||
await marker.waitFor();
|
||||
assert.equal(await marker.innerText(), 'Battle · C1');
|
||||
assert.match(await marker.getAttribute('aria-label'), /Rome attacks Greece · C2 to C1/);
|
||||
assert.equal(await marker.innerText(), 'Battle · Round 1');
|
||||
assert.equal(await marker.getAttribute('aria-label'), 'Rome attacks Greece · C2 to C1 · Round 1');
|
||||
await page.getByRole('button', { name: 'Open journal', exact: true }).click();
|
||||
const table = page.getByRole('table', { name: 'Combat round 1', exact: true });
|
||||
const journal = page.getByRole('tabpanel', { name: 'Journal', exact: true });
|
||||
const table = journal.getByRole('table', { name: 'Combat round 1', exact: true });
|
||||
await table.waitFor();
|
||||
assert.equal(
|
||||
await table
|
||||
|
|
@ -85,9 +86,10 @@ try {
|
|||
await page.screenshot({ path: `/tmp/clash-combat-active-${width}.png` });
|
||||
await page.evaluate((state) => host.emit('state', state), completed);
|
||||
await marker.waitFor({ state: 'hidden' });
|
||||
await page.getByText('Rome wins', { exact: true }).waitFor();
|
||||
await journal.getByText('Rome wins', { exact: true }).waitFor();
|
||||
assert.match(await table.innerText(), /Peltasts/);
|
||||
assert.match(await table.innerText(), /Encircled/);
|
||||
// The fixture's engine name "Encircled" is printed as "Routing" in the UI.
|
||||
assert.match(await table.innerText(), /Routing/);
|
||||
assert.doesNotMatch(await table.innerText(), /Gain Fortress|Lose Fortress/);
|
||||
assert.ok(await page.locator('.journal').evaluate((el) => el.scrollWidth <= el.clientWidth + 1));
|
||||
await page.screenshot({ path: `/tmp/clash-combat-result-${width}.png` });
|
||||
|
|
@ -108,10 +110,14 @@ try {
|
|||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
|
||||
await page.screenshot({ path: `/tmp/clash-combat-elephant-${width}.png` });
|
||||
await page.evaluate((state) => host.emit('state', state), naval);
|
||||
await page.waitForFunction(() => document.querySelectorAll('.combat-die').length === 3);
|
||||
// The carried-unit casualty decision closes the journal. Wait for the naval
|
||||
// state to render, then reopen it before waiting for its (unmounted) dice.
|
||||
await page.locator('.map-combat-label[aria-label="Greece attacks Rome · C3 to D2 · Round 1"]').waitFor();
|
||||
const journalButton = page.getByRole('button', { name: 'Open journal', exact: true });
|
||||
if ((await journalButton.getAttribute('aria-expanded')) === 'false') await journalButton.click();
|
||||
await journalButton.and(page.locator('[aria-expanded="false"]')).waitFor();
|
||||
await journalButton.click();
|
||||
await table.waitFor();
|
||||
assert.equal(await table.locator('.combat-die').count(), 3);
|
||||
await page.screenshot({ path: `/tmp/clash-combat-naval-${width}.png` });
|
||||
assert.equal(
|
||||
await table.getByRole('img', { name: '6 · Infantry face · No ability activated', exact: true }).count(),
|
||||
|
|
|
|||
|
|
@ -92,7 +92,12 @@ try {
|
|||
const back = bar.getByRole('button', { name: 'Previous action', exact: true });
|
||||
await bar.waitFor();
|
||||
assert.match(await bar.innerText(), /Since your last turn/);
|
||||
assert.equal(await page.locator('.board-toolbar').isVisible(), false);
|
||||
// Replay keeps reference tools available, but cannot submit live actions.
|
||||
const toolbar = page.locator('.board-toolbar');
|
||||
assert(await toolbar.isVisible());
|
||||
assert.match(await toolbar.innerText(), /Replay · Browse game details/);
|
||||
assert(await toolbar.getByRole('button', { name: 'Undo last action', exact: true }).isDisabled());
|
||||
assert(await toolbar.getByRole('button', { name: 'End turn', exact: true }).isDisabled());
|
||||
await bar.getByRole('button', { name: 'Pause replay', exact: true }).click();
|
||||
assert(await next.isVisible());
|
||||
assert(await back.isVisible());
|
||||
|
|
@ -111,22 +116,35 @@ try {
|
|||
);
|
||||
assert.match(caption, /Action 2 of 3/);
|
||||
const bounds = await bar.boundingBox();
|
||||
assert(bounds.x >= 0 && bounds.x + bounds.width <= width + 1 && bounds.height < 185);
|
||||
assert(bounds.x >= 0 && bounds.x + bounds.width <= width + 1);
|
||||
assert(bounds.y >= 0 && bounds.y + bounds.height <= height + 1);
|
||||
// The current recap is a narrow desktop dock, or a bottom panel on phones.
|
||||
if (width >= 1100 || (width >= 760 && height <= 550)) {
|
||||
assert(bounds.x <= 30 && bounds.width <= 380);
|
||||
assert(bounds.x + bounds.width < width / 2, 'recap leaves the map center clear');
|
||||
} else {
|
||||
assert(bounds.y + bounds.height >= height - 150, 'phone recap stays near the bottom');
|
||||
}
|
||||
for (const control of await bar.locator('.playback-controls button, .playback-controls input').all()) {
|
||||
const box = await control.boundingBox();
|
||||
assert(box && box.x >= bounds.x && box.x + box.width <= bounds.x + bounds.width + 1);
|
||||
assert(box.y >= bounds.y && box.y + box.height <= bounds.y + bounds.height + 1);
|
||||
}
|
||||
assert.equal(await bar.evaluate((el) => el.scrollWidth <= el.clientWidth), true);
|
||||
await page.screenshot({ path: `/tmp/clash-replay-${width}.png` });
|
||||
await next.click();
|
||||
await bar.getByRole('button', { name: 'Back to game', exact: true }).waitFor();
|
||||
assert(await next.isDisabled());
|
||||
await bar.getByRole('button', { name: 'Replay this turn', exact: true }).click();
|
||||
await bar.getByRole('button', { name: 'Replay these actions', exact: true }).click();
|
||||
assert(await back.isDisabled());
|
||||
assert.match(await bar.innerText(), /Start/);
|
||||
await bar.getByRole('button', { name: 'Skip', exact: true }).click();
|
||||
const shortcut = page.getByRole('button', { name: 'Replay last turn', exact: true });
|
||||
const shortcut = page.getByRole('button', { name: 'Replay since your last turn', exact: true });
|
||||
await shortcut.waitFor();
|
||||
if (width <= 760) assert(await shortcut.getByText('Last turn', { exact: true }).isVisible());
|
||||
if (width <= 760) assert(await shortcut.getByText('Since my turn', { exact: true }).isVisible());
|
||||
await shortcut.click();
|
||||
await bar.getByRole('button', { name: 'Play replay', exact: true }).waitFor();
|
||||
assert.match(await bar.innerText(), /Last turn/);
|
||||
assert.match(await bar.innerText(), /Since your last turn/);
|
||||
assert(await back.isDisabled());
|
||||
await page.evaluate((raw) => host.emit('state', raw), updated);
|
||||
await next.click();
|
||||
|
|
@ -142,19 +160,30 @@ try {
|
|||
await bar.getByRole('button', { name: 'Back to game', exact: true }).waitFor({ timeout: 15000 });
|
||||
assert(await bar.isVisible(), 'autoplay finishes without dismissing the recap');
|
||||
await bar.getByRole('button', { name: 'Back to game', exact: true }).click();
|
||||
// Full replay uses the host's transport, not the since-last-turn recap panel.
|
||||
await page.evaluate(() => host.emit('replay:start'));
|
||||
await bar.waitFor();
|
||||
await page.locator('.game-shell.full-replay').waitFor();
|
||||
assert.equal(await bar.count(), 0, 'host replay does not render recap controls');
|
||||
await page.waitForFunction(
|
||||
({ start, end }) => replayInfo.at(-1)?.start === start && replayInfo.at(-1)?.end === end,
|
||||
{ start: history.frames[0].cursor, end: history.frames.at(-1).cursor },
|
||||
);
|
||||
await page.evaluate((cursor) => host.emit('replay:to', cursor), history.frames.at(-1).cursor);
|
||||
await page.waitForFunction(
|
||||
(cursor) => replayInfo.at(-1)?.current === cursor,
|
||||
history.frames.at(-1).cursor,
|
||||
);
|
||||
await bar.getByRole('button', { name: 'Back to game', exact: true }).click();
|
||||
assert.equal(await page.locator('.public-effect').count(), 0, 'host replay has no recap notifications');
|
||||
await page.evaluate(() => host.emit('replay:end'));
|
||||
await page.locator('.game-shell.playing-back').waitFor({ state: 'hidden' });
|
||||
await shortcut.waitFor();
|
||||
await page.evaluate(() => host.emit('preferences', { analysis: true, sound: false }));
|
||||
await page.getByText('Analysis · Simulation', { exact: true }).waitFor();
|
||||
await page.evaluate(() => host.emit('replay:start'));
|
||||
assert.equal(await page.locator('.game-shell.playing-back').count(), 0);
|
||||
assert.equal(await bar.count(), 0);
|
||||
assert.equal(await shortcut.count(), 0);
|
||||
await page.getByText('Analysis · Simulation', { exact: true }).waitFor();
|
||||
assert.deepEqual(await page.evaluate(() => sent), [], 'recaps and host replay never submit moves');
|
||||
assert.deepEqual(errors, []);
|
||||
console.log(
|
||||
`${width}x${height}: manual/automatic recap, visible stepping, bounded last-turn replay, remembered preference, live updates, native replay and analysis isolation verified.`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue