import { expect, test } from "@playwright/test"; test.beforeEach(async ({ page }) => { await page.goto("/"); await page.getByRole("button", { name: "IDX", exact: true }).click(); }); test("new PHY key is registered at the end, reorder its output number, and undo", async ({ page }) => { await page.getByRole("button", { name: "PHY", exact: true }).click(); await page.getByRole("button", { name: "キーを足す" }).click(); const keyId = await page.locator('[data-node-type="key"]').last().getAttribute("data-node-id"); await page.getByRole("button", { name: "IDX", exact: true }).click(); const row = page.getByTestId(`idx-row-${keyId}`); await expect(row).toBeVisible(); const previewKey = page.locator(`[data-testid="keyboard-view"] [data-key-id="${keyId}"] text`); await expect(previewKey).toHaveText("16"); await row.getByRole("button", { name: `${keyId}を上へ` }).click(); await expect(previewKey).toHaveText("15"); await page.getByRole("button", { name: "Undo" }).click(); await expect(previewKey).toHaveText("16"); }); test("output numbers recalculate after switching to a variant that excludes ordered keys", async ({ page, }) => { await page.getByRole("button", { name: "PHY", exact: true }).click(); const keys = page.locator('[data-node-type="key"]'); const firstId = await keys.nth(0).getAttribute("data-node-id"); const secondId = await keys.nth(1).getAttribute("data-node-id"); await keys.nth(0).click(); await keys.nth(1).click({ modifiers: ["Shift"] }); await page.getByRole("button", { name: "選択からバリアントグループ" }).click(); await page.getByRole("button", { name: "IDX", exact: true }).click(); await expect(page.getByTestId(`idx-row-${firstId}`)).toContainText("出力 0"); await page.getByLabel("Variant Group 出力バリアント").selectOption({ label: "Option B" }); await expect(page.getByTestId(`idx-row-${firstId}`)).toContainText("出力対象外"); await expect(page.getByTestId(`idx-row-${secondId}`)).toContainText("出力対象外"); const remaining = page.locator(".idx-all-keys .idx-preview").filter({ hasText: "出力 0" }); await expect(remaining).toHaveCount(1); });