Files
scrabble-game/ui/src/lib/links.test.ts
T
Ilia Denisov db17287113 fix(ui): route external links out of the Android VK WebView
The Android VK client's WebView ignores target=_blank and navigates the
Mini App's own window to the target, stranding the player outside the
game with no way back (the dictionary lookup, About/Feedback links, the
ad banner and the bot-link modal fallbacks). vk-bridge 3.x has no method
to open an external URL, so external links are routed through VK's own
leave-VK redirect (vk.com/away.php), which the client intercepts
natively and hands to the system browser.

onExternalLinkClick moves from lib/telegram to a new lib/links that
composes the Telegram and VK routers; iOS and desktop VK open _blank
correctly and are left alone.
2026-07-02 00:09:52 +02:00

30 lines
977 B
TypeScript

import { afterEach, describe, expect, it, vi } from 'vitest';
import { openExternalUrl } from './links';
describe('openExternalUrl', () => {
afterEach(() => vi.unstubAllGlobals());
it('routes through the VK away redirect inside the Android VK client', () => {
const open = vi.fn();
vi.stubGlobal('location', {
pathname: '/vk/',
search: '?vk_user_id=1&vk_platform=mobile_android&sign=x',
href: 'https://app.example/vk/',
origin: 'https://app.example',
});
vi.stubGlobal('window', { open });
openExternalUrl('https://t.me/some_bot');
expect(open).toHaveBeenCalledWith(
`https://vk.com/away.php?to=${encodeURIComponent('https://t.me/some_bot')}`,
'_blank',
);
});
it('opens a plain new tab elsewhere', () => {
const open = vi.fn();
vi.stubGlobal('window', { open });
openExternalUrl('https://t.me/some_bot');
expect(open).toHaveBeenCalledWith('https://t.me/some_bot', '_blank');
});
});