feat(ui): Actions menu + royalty-transfer target selection in GameView

This commit is contained in:
Joey Yakimowich-Payne 2026-04-21 12:04:55 -06:00
commit d6bc1ca2cc
No known key found for this signature in database
4 changed files with 355 additions and 5 deletions

View file

@ -324,3 +324,78 @@ test.describe('Rule variants — lobby vertical slice', () => {
if (errors.length > 0) throw new Error(errors.join('; '));
});
});
test.describe('F4c post-epic: transferable-royalty UI', () => {
test('transfer royalty action popover and selection flow', async ({ page }) => {
await page.goto('/');
// Open rules drawer
await page.locator('[data-action="play-solo"]').click();
await page.waitForURL('**/game');
// Open the drawer
await page.locator('[data-action="open-rules-drawer"]').click();
await expect(page.locator('[data-testid="rules-drawer"]')).toBeVisible();
// Toggle Transferable Royalty ON
const trToggle = page.locator('[data-preset="transferable-royalty"] [data-role="toggle"]');
await expect(trToggle).toBeVisible();
await trToggle.click();
await page.waitForTimeout(120);
// Close drawer
await page.locator('[data-action="close-rules-drawer"]').click();
await expect(page.locator('[data-testid="rules-drawer"]')).not.toBeVisible();
// Ensure game has started and is on white's turn
const turnIndicator = page.getByTestId('turn-indicator');
await expect(turnIndicator).toHaveText("White's turn");
// 3. Assert "Actions" button is visible
const actionsMenuBtn = page.getByTestId('actions-menu-button');
await expect(actionsMenuBtn).toBeVisible();
// 4. Click "Actions" -> popover opens
await actionsMenuBtn.click();
// 5. Click "Transfer royalty..." item
const transferBtn = page.getByTestId('action-transfer-royalty');
await expect(transferBtn).toBeVisible();
await transferBtn.click();
// 6. Hint card appears: "Select the piece whose royalty you want to transfer."
await expect(page.getByText('Select the piece whose royalty you want to transfer.')).toBeVisible();
// 7. Click the white king (e1).
await page.locator('[data-square="e1"]').click();
// 8. Hint updates: "Select the new royal piece."
await expect(page.getByText('Select the new royal piece.')).toBeVisible();
// 9. Click a friendly piece (e.g., the queen at d1)
await page.locator('[data-square="d1"]').click();
// 10. Board state updates: Turn flipped (meaning the action was accepted and consumed the turn)
await expect(turnIndicator).toHaveText("Black's turn");
// 11. "Transfer royalty..." is now greyed out (already used this game by White)
// Black's turn: click actions -> should be enabled for Black since Black hasn't used it.
await actionsMenuBtn.click();
const transferBtn2 = page.getByTestId('action-transfer-royalty');
await expect(transferBtn2).toBeVisible();
await expect(transferBtn2).toBeEnabled();
// Play a move for Black to get back to White
await drag(page, 'e7', 'e5');
await expect(turnIndicator).toHaveText("White's turn");
// Now White's action should be disabled
await actionsMenuBtn.click();
const transferBtn3 = page.getByTestId('action-transfer-royalty');
await expect(transferBtn3).toBeVisible();
await expect(transferBtn3).toBeDisabled();
await expect(page.getByText('Used this game')).toBeVisible();
});
});