summaryrefslogtreecommitdiff
path: root/e2e/tests/figure-edit.spec.ts
blob: 9b7bc9b6aec9dcda8fab3c9e41508664a577d671 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
 * E2E: character level + rename from the status menu (the Phase 7
 * cross-check closed the `setCharacterLevel` / `changeName` gaps vs the
 * reference `SetCharacterLevelMenu`). Drives the real UI and asserts the
 * server round-trip re-renders on the tab.
 */
import { test, expect } from '../helpers/table.js';

test('a player can set a character level and rename it', async ({ table }) => {
	const p1 = (await table.newTab()).tab;
	await p1.open(table.server.url);
	await p1.addCharacter('Hatchet');

	// Open the status (stat) menu by tapping the row's name.
	const dlg = await p1.openStatusMenu('Hatchet');

	// Level pills 1..N are present; level 1 (the add default) is the current
	// one, so its pill is highlighted and disabled.
	await expect(dlg.locator('button.pill', { hasText: /^1$/ })).toBeDisabled();
	await expect(dlg.locator('button.pill', { hasText: /^1$/ })).toHaveClass(/pill--on/);

	// Set level 2: the server round-trip re-renders and the level-2 pill
	// becomes the highlighted current one.
	await dlg.locator('button.pill', { hasText: /^2$/ }).click();
	await expect(dlg.locator('button.pill', { hasText: /^2$/ })).toHaveClass(/pill--on/);
	await expect(dlg.locator('button.pill', { hasText: /^2$/ })).toBeDisabled();
	await expect(dlg.locator('button.pill', { hasText: /^1$/ })).toBeEnabled();

	// Rename via the name field: submit on Enter, the row re-renders with the
	// new display name. (Use a name with no overlap with "Hatchet" so the
	// substring-matched row helpers read the old and new names distinctly.)
	const name = dlg.locator('input.search');
	await name.fill('Molly');
	await name.press('Enter');
	await expect(p1.row('Molly')).toBeVisible();
	await expect(p1.row('Hatchet')).toHaveCount(0);
});