6a5ce12fab
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 55s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m22s
Contour review of the VK Bridge group: - #6 invite link: VK's documented '#' direct-link payload is eaten by the vk.com SPA before it reaches the app, so the friend-code link now carries the payload as a query param (vk.com/app<id>?hash=f<code>); the recipient already reads the `hash` query param (vkStartParam). (Whether VK forwards the '?' through to the iframe is being confirmed on the contour.) - #8 Android: the VK mobile webview does not surface the home-bar inset via CSS env() (config insets are iOS-only), so subscribe to the bridge insets (VKWebAppUpdateConfig + VKWebAppUpdateInsets) and set --tg-safe-* to max(env(), the VK value). - #8 landscape colour: the home-indicator strip was the (grey) page background because the two-pane landscape game has no bottom bar. The left-panel controls bar now paints its own chrome into the inset (Screen gains a selfInset flag that drops the shell's detached padding strip), and the game-land runs flush to the edge. Verified: svelte-check, 347 unit, build, bundle-gate; the landscape safe-area painting reproduced in the mock (controls bar + board reach the edge, strip takes the bar colour). The VK-Bridge / VK launch behaviours (Android insets, the ?hash forward) need the live contour.
67 lines
2.5 KiB
TypeScript
67 lines
2.5 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
import { botUsername, friendCodeParam, gameParam, invitationParam, parseStartParam, shareLink, vkShareLink } from './deeplink';
|
|
|
|
describe('parseStartParam', () => {
|
|
it('classifies game / invitation / friend code', () => {
|
|
expect(parseStartParam('g7c9e6679')).toEqual({ kind: 'game', id: '7c9e6679' });
|
|
expect(parseStartParam('iabc-123')).toEqual({ kind: 'invitation', id: 'abc-123' });
|
|
expect(parseStartParam('f123456')).toEqual({ kind: 'friendCode', code: '123456' });
|
|
});
|
|
|
|
it('falls back to the lobby for empty / unknown / value-less params', () => {
|
|
expect(parseStartParam('')).toEqual({ kind: 'lobby' });
|
|
expect(parseStartParam(undefined)).toEqual({ kind: 'lobby' });
|
|
expect(parseStartParam(null)).toEqual({ kind: 'lobby' });
|
|
expect(parseStartParam('x-nope')).toEqual({ kind: 'lobby' });
|
|
expect(parseStartParam('g')).toEqual({ kind: 'lobby' });
|
|
});
|
|
|
|
it('round-trips the build helpers', () => {
|
|
expect(parseStartParam(gameParam('id1'))).toEqual({ kind: 'game', id: 'id1' });
|
|
expect(parseStartParam(invitationParam('id2'))).toEqual({ kind: 'invitation', id: 'id2' });
|
|
expect(parseStartParam(friendCodeParam('654321'))).toEqual({ kind: 'friendCode', code: '654321' });
|
|
});
|
|
});
|
|
|
|
describe('shareLink', () => {
|
|
afterEach(() => vi.unstubAllEnvs());
|
|
|
|
it('returns null without a configured base', () => {
|
|
vi.stubEnv('VITE_TELEGRAM_LINK', '');
|
|
expect(shareLink('gx')).toBeNull();
|
|
});
|
|
|
|
it('wraps a payload in a startapp link', () => {
|
|
vi.stubEnv('VITE_TELEGRAM_LINK', 'https://t.me/bot/app');
|
|
expect(shareLink('f123456')).toBe('https://t.me/bot/app?startapp=f123456');
|
|
});
|
|
});
|
|
|
|
describe('vkShareLink', () => {
|
|
afterEach(() => vi.unstubAllGlobals());
|
|
|
|
it('returns null outside a VK launch (no vk_app_id)', () => {
|
|
vi.stubGlobal('location', { search: '' });
|
|
expect(vkShareLink('f123456')).toBeNull();
|
|
});
|
|
|
|
it('wraps the payload in a vk.com/app link as the hash query param', () => {
|
|
vi.stubGlobal('location', { search: '?vk_app_id=6736218&vk_user_id=1&sign=x' });
|
|
expect(vkShareLink('f123456')).toBe('https://vk.com/app6736218?hash=f123456');
|
|
});
|
|
});
|
|
|
|
describe('botUsername', () => {
|
|
afterEach(() => vi.unstubAllEnvs());
|
|
|
|
it('returns null without a configured base', () => {
|
|
vi.stubEnv('VITE_TELEGRAM_LINK', '');
|
|
expect(botUsername()).toBeNull();
|
|
});
|
|
|
|
it('extracts the bot handle from the Mini App link', () => {
|
|
vi.stubEnv('VITE_TELEGRAM_LINK', 'https://t.me/bot/app');
|
|
expect(botUsername()).toBe('bot');
|
|
});
|
|
});
|