feat(ui): explicit offline state inside an online game (+ offline word check)
CI / changes (pull_request) Successful in 3s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Failing after 12s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Failing after 1s
CI / deploy (pull_request) Has been skipped
CI / changes (pull_request) Successful in 3s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Failing after 12s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Failing after 1s
CI / deploy (pull_request) Has been skipped
When an online game loses the connection the game screen now says so and freezes instead of silently greying out: a "connection lost" banner appears and the rack, the move controls, the add-friend/block controls and the chat/dictionary entry all disable (a started move stays a draft, committed by the player on reconnect). It is driven off the net-state machine (netState.offline), so it also covers the Telegram/VK mini-apps, where a lost connection was previously mute in-game. If the player is already in the dictionary when the drop happens, the word check falls back to the game's pinned on-device dictionary (exact when that dawg is cached; "unavailable offline" otherwise) and the network-only complaint + external look-up hide. Chat, when already open, keeps its existing read-only degrade (send/nudge disable). New pure helper localWordCheck is unit-tested; the in-game gating gets an e2e.
This commit is contained in:
@@ -39,3 +39,38 @@ test('in-game UX: turn strip, bag badge + table footer, staged-play highlight an
|
||||
await expect(page.locator('.scorebadge')).toBeVisible();
|
||||
await expect(page.locator('.make')).toBeVisible();
|
||||
});
|
||||
|
||||
test('online game offline: banner shows, the tray and comms entry freeze, and it thaws on recovery', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.getByRole('button', { name: /guest/i }).click();
|
||||
await page.getByRole('button', { name: /🎲/ }).click();
|
||||
await page.getByRole('button', { name: 'Random player' }).click();
|
||||
await page.locator('.variant').first().click();
|
||||
await page.getByRole('button', { name: /Start game/i }).click();
|
||||
await page.evaluate(() => (window as unknown as { __mock: { joinOpponent(): void } }).__mock.joinOpponent());
|
||||
await expect(page.getByText('Robo')).toBeVisible();
|
||||
|
||||
// Baseline online: no banner, the tray is interactive, the comms (chat/dictionary) entry is enabled.
|
||||
await expect(page.locator('.offline-banner')).toHaveCount(0);
|
||||
await expect(page.locator('.rack .tile').first()).toBeEnabled();
|
||||
|
||||
// The connection drops (the net hook rides past the hysteresis straight to offline).
|
||||
await page.evaluate(() => (window as unknown as { __net: { offline(): void } }).__net.offline());
|
||||
|
||||
// The explicit "connection lost" banner appears and every rack tile freezes (cannot compose a move).
|
||||
await expect(page.locator('.offline-banner')).toBeVisible({ timeout: 15000 });
|
||||
const tiles = page.locator('.rack .tile');
|
||||
const n = await tiles.count();
|
||||
expect(n).toBeGreaterThan(0);
|
||||
for (let i = 0; i < n; i++) await expect(tiles.nth(i)).toBeDisabled();
|
||||
|
||||
// The comms entry (💬 — chat + dictionary) is disabled; it lives in the history drawer, so open it.
|
||||
await page.locator('.scoreboard').click();
|
||||
await expect(page.locator('button:has(.chat-ico)')).toBeDisabled();
|
||||
|
||||
// Recovery: the network returns, the banner clears and the tray is interactive again.
|
||||
await page.evaluate(() => (window as unknown as { __net: { online(): void } }).__net.online());
|
||||
await expect(page.locator('.offline-banner')).toHaveCount(0, { timeout: 15000 });
|
||||
await expect(page.locator('.rack .tile').first()).toBeEnabled();
|
||||
await expect(page.locator('button:has(.chat-ico)')).toBeEnabled();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user