UI: tab-bar navigation — drop the hamburger
CI / changes (pull_request) Successful in 1s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 39s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 59s
CI / changes (pull_request) Successful in 1s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 39s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 59s
Replace Menu.svelte (hamburger) everywhere with tab-bar navigation: - Settings hub (SettingsHub) from the lobby ⚙️ tab: Settings/Profile/ Friends/About as in-place tabs, back → lobby; the lobby ⚙️ badge counts incoming friend requests (invitations keep their own lobby section). - Comms hub (CommsHub) from the move-history 💬: Chat/Dictionary tabs, back → game; Dictionary only while the game is active. - Game menu items relocate into the open history: 🏁 leave / 📤 export in the header, 🤝 add-friend per opponent card, 💬 comms; unread chat is badged on the score bar + the 💬. - TapConfirm (tap → fading ✅ → tap) replaces the Skip/Hint press-and-hold popovers and drives the add-friend confirm. - Fix the move-history "jump": the slid board is inert and the stage can't scroll, so a swipe up genuinely closes the history. Remove Menu.svelte + HoldConfirm.svelte. Docs: UI_DESIGN, FUNCTIONAL(+ru), PRERELEASE. UI check/unit/build/bundle/e2e (Chromium+WebKit) all green.
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { createTapConfirm } from './tapconfirm';
|
||||
|
||||
describe('createTapConfirm', () => {
|
||||
beforeEach(() => vi.useFakeTimers());
|
||||
afterEach(() => vi.useRealTimers());
|
||||
|
||||
it('arms a window and reverts after the duration', () => {
|
||||
const changes: boolean[] = [];
|
||||
const c = createTapConfirm({ durationMs: 2000, onConfirm: () => {}, onChange: (x) => changes.push(x) });
|
||||
c.arm();
|
||||
expect(c.confirming).toBe(true);
|
||||
expect(changes).toEqual([true]);
|
||||
vi.advanceTimersByTime(1999);
|
||||
expect(c.confirming).toBe(true);
|
||||
vi.advanceTimersByTime(1);
|
||||
expect(c.confirming).toBe(false);
|
||||
expect(changes).toEqual([true, false]);
|
||||
});
|
||||
|
||||
it('confirms within the window exactly once and stops the revert timer', () => {
|
||||
const onConfirm = vi.fn();
|
||||
const c = createTapConfirm({ durationMs: 2000, onConfirm });
|
||||
c.arm();
|
||||
c.confirm();
|
||||
expect(onConfirm).toHaveBeenCalledTimes(1);
|
||||
expect(c.confirming).toBe(false);
|
||||
vi.advanceTimersByTime(5000); // the revert timer must not fire after a confirm
|
||||
expect(onConfirm).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('ignores confirm when the window is not open', () => {
|
||||
const onConfirm = vi.fn();
|
||||
const c = createTapConfirm({ durationMs: 2000, onConfirm });
|
||||
c.confirm();
|
||||
expect(onConfirm).not.toHaveBeenCalled();
|
||||
expect(c.confirming).toBe(false);
|
||||
});
|
||||
|
||||
it('treats arm as idempotent while already confirming', () => {
|
||||
const changes: boolean[] = [];
|
||||
const c = createTapConfirm({ durationMs: 2000, onConfirm: () => {}, onChange: (x) => changes.push(x) });
|
||||
c.arm();
|
||||
c.arm();
|
||||
expect(changes).toEqual([true]);
|
||||
});
|
||||
|
||||
it('cancel closes the window without confirming', () => {
|
||||
const onConfirm = vi.fn();
|
||||
const c = createTapConfirm({ durationMs: 2000, onConfirm });
|
||||
c.arm();
|
||||
c.cancel();
|
||||
expect(c.confirming).toBe(false);
|
||||
vi.advanceTimersByTime(5000);
|
||||
expect(onConfirm).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('dispose clears a pending timer without a revert callback', () => {
|
||||
const changes: boolean[] = [];
|
||||
const c = createTapConfirm({ durationMs: 2000, onConfirm: () => {}, onChange: (x) => changes.push(x) });
|
||||
c.arm();
|
||||
c.dispose();
|
||||
vi.advanceTimersByTime(5000);
|
||||
expect(changes).toEqual([true]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user