diff --git a/docs/FUNCTIONAL.md b/docs/FUNCTIONAL.md index c6206c6..30a4875 100644 --- a/docs/FUNCTIONAL.md +++ b/docs/FUNCTIONAL.md @@ -31,7 +31,10 @@ ephemeral guest. The gateway validates the credential once and mints a thin session token; the backend resolves it to an internal `user_id`. A **Telegram Mini App** launch authenticates from the platform's signed `initData`, themes the UI to the Telegram colours, and — on first contact — seeds the new account's interface -language from the Telegram client. Telegram runs a **single bot**: every player uses +language from the Telegram client. If a launch cannot reach the backend (for example during a +deployment), the Mini App retries quietly and then shows a small "couldn't load" screen with a +**Retry** button, rather than dropping to the web sign-in, which has no place inside Telegram. +Telegram runs a **single bot**: every player uses the same bot, and all of its chat and out-of-app notifications are written in the player's own **interface language** (en/ru). A separate optional **promo bot** can run alongside the main one — its only job is to answer `/start` with a short message and a button that opens the @@ -56,6 +59,10 @@ reconnect), and pending reads resume on their own — the interface stays usable flashing a red banner each time. ### Accounts, linking & merge +_Sign-in is currently provider-only, so the in-profile linking UI is temporarily hidden; it +returns once the anonymous `/app/` guest (whose upgrade path this is) ships. The flow below +describes it for when it does._ + First platform contact auto-provisions a durable account. From the profile a player links an email (via a confirm code) or their Telegram (via the web sign-in); a guest who links their first identity becomes a durable account. The "already taken" status diff --git a/docs/FUNCTIONAL_ru.md b/docs/FUNCTIONAL_ru.md index b5058fc..43c47a3 100644 --- a/docs/FUNCTIONAL_ru.md +++ b/docs/FUNCTIONAL_ru.md @@ -32,7 +32,10 @@ top-1 подсказку, безлимитную проверку слова с session-токен; backend сопоставляет его с внутренним `user_id`. Запуск **Telegram Mini App** авторизует по подписанным `initData` платформы, перекрашивает интерфейс в цвета Telegram и — при первом контакте — задаёт язык интерфейса нового аккаунта по -языку Telegram-клиента. Telegram держит **единого бота**: все игроки пользуются одним +языку Telegram-клиента. Если запуск не может достучаться до бэкенда (например, во время +деплоя), Mini App тихо повторяет попытки, а затем показывает небольшой экран «не удалось +загрузить» с кнопкой **Повторить**, вместо того чтобы сбрасывать на веб-вход, которому внутри +Telegram не место. Telegram держит **единого бота**: все игроки пользуются одним и тем же ботом, а весь его чат и внеприложенческие уведомления пишутся на **языке интерфейса** самого игрока (en/ru). Рядом с основным может работать отдельный опциональный **промо-бот** — его единственная задача отвечать на `/start` коротким сообщением и кнопкой, @@ -57,6 +60,10 @@ Mini App** авторизует по подписанным `initData` плат рабочим вместо красного баннера каждый раз. ### Аккаунты, привязка и слияние +_Вход сейчас только через провайдера, поэтому UI привязки в профиле временно скрыт; он +вернётся, когда появится анонимный `/app/`-гость (для апгрейда которого он и нужен). Описание +ниже — на этот случай._ + Первый контакт с платформы заводит постоянный аккаунт. Из профиля игрок привязывает email (по confirm-коду) или свой Telegram (через веб-вход); гость, привязавший первую личность, становится постоянным аккаунтом. Факт «личность уже diff --git a/ui/e2e/social.spec.ts b/ui/e2e/social.spec.ts index d07d1ec..ae01d0f 100644 --- a/ui/e2e/social.spec.ts +++ b/ui/e2e/social.spec.ts @@ -238,7 +238,10 @@ test('profile edit disables Save and flags an invalid display name', async ({ pa await expect(save).toBeEnabled(); }); -test('link account: a taken email opens the irreversible merge confirmation', async ({ page }) => { +// Account linking is hidden in Profile.svelte while we target provider sign-in (the anonymous +// /app/ guest who upgrades by linking comes later). The flow is kept wired; re-enable these two +// specs together with the `.emailbox` section. +test.skip('link account: a taken email opens the irreversible merge confirmation', async ({ page }) => { await loginLobby(page); await openProfile(page); @@ -258,7 +261,7 @@ test('link account: a taken email opens the irreversible merge confirmation', as await expect(page.getByText('Merge accounts?')).toBeHidden(); }); -test('link account: the Telegram web sign-in control is offered in a browser', async ({ page }) => { +test.skip('link account: the Telegram web sign-in control is offered in a browser', async ({ page }) => { await loginLobby(page); await openProfile(page); await expect(page.getByRole('button', { name: 'Link Telegram' })).toBeVisible(); diff --git a/ui/e2e/telegram.spec.ts b/ui/e2e/telegram.spec.ts index dbc3e00..d402033 100644 --- a/ui/e2e/telegram.spec.ts +++ b/ui/e2e/telegram.spec.ts @@ -83,6 +83,30 @@ test('tg-fullscreen header keeps a constant native-nav gap as the font scales', expect(large.overflows).toBe(false); }); +test('inside Telegram, a failed launch shows the retry screen, not the web login', async ({ page }) => { + // initData carrying the mock's "bootfail" sentinel makes authTelegram reject, simulating a + // backend outage during launch (e.g. a deploy rolling). The Mini App must surface its own + // boot-error/retry screen and never fall back to the web (guest/email) login. + await page.addInitScript(() => { + Object.assign(window, { + Telegram: { + WebApp: { + initData: 'query_id=bootfail&user=%7B%22id%22%3A1%7D&auth_date=1&hash=deadbeef', + initDataUnsafe: {}, + ready() {}, + expand() {}, + }, + }, + }); + }); + await page.goto('/'); + + // After the silent retries, the boot-error screen with its Retry button shows… + await expect(page.getByRole('button', { name: 'Retry' })).toBeVisible(); + // …and the web login (guest) is never shown inside Telegram. + await expect(page.getByRole('button', { name: /guest/i })).toHaveCount(0); +}); + test('outside Telegram, the /telegram/ entry redirects to the site root', async ({ page }) => { await page.goto('/telegram/'); diff --git a/ui/src/App.svelte b/ui/src/App.svelte index b0920dc..2368666 100644 --- a/ui/src/App.svelte +++ b/ui/src/App.svelte @@ -18,6 +18,7 @@ import CommsHub from './game/CommsHub.svelte'; import Feedback from './screens/Feedback.svelte'; import Blocked from './screens/Blocked.svelte'; + import BootError from './screens/BootError.svelte'; onMount(() => { void bootstrap(); @@ -83,6 +84,10 @@ {#if !routeIsLobby}
{t('boot.errorBody')}
+ +