feat(chat): limit in-game chat to one message per turn
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 12s
CI / ui (pull_request) Successful in 45s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m8s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 12s
CI / ui (pull_request) Successful in 45s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m8s
Enforce one chat message per turn on both ends. The backend rejects a second message in the same turn (ErrChatAlreadySentThisTurn -> 409 chat_already_sent), keyed on the move-driven turn start (turn_started_at). The UI derives "already wrote this turn" from the message list against GameView.lastActivityUnix (no counter, survives reopening, resets on turn change), hides the field behind a short caption once the limit is reached, and now reloads the game state on turn/game-state events so the toggle and the limit follow the live game. Enter is gated on !busy to avoid a double-send in the in-flight window. Backend: new game.TurnStartedAt; social GameReader gains it; PostMessage enforces the limit reusing lastMessageAt. UI: new lib/chatlimit.ts pure logic + unit tests; Chat/ChatScreen wiring; chat.sentThisTurn and error.chat_already_sent i18n (en/ru); extended chat e2e. Docs: FUNCTIONAL (+ru), ARCHITECTURE, UI_DESIGN.
This commit is contained in:
@@ -230,7 +230,7 @@ test('link account: the Telegram web sign-in control is offered in a browser', a
|
||||
await expect(page.getByRole('button', { name: 'Link Telegram' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('chat: the message field shows on your turn, the nudge replaces it otherwise', async ({ page }) => {
|
||||
test('chat: one message per turn — the field shows, then a caption replaces it after sending', async ({ page }) => {
|
||||
await loginLobby(page);
|
||||
await page.getByRole('button', { name: /Ann/ }).click(); // g1: your turn
|
||||
await page.locator('.scoreboard').click(); // open the history
|
||||
@@ -241,4 +241,11 @@ test('chat: the message field shows on your turn, the nudge replaces it otherwis
|
||||
// through the aria-label.
|
||||
await expect(page.getByRole('button', { name: 'Send' })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'Nudge' })).toHaveCount(0);
|
||||
// The limit is one message per turn: after sending, the field is hidden behind a caption.
|
||||
// It is still your turn, so the nudge does not appear either.
|
||||
await page.getByPlaceholder(/Quick message/).fill('hi there');
|
||||
await page.getByRole('button', { name: 'Send' }).click();
|
||||
await expect(page.getByText('You can write again next turn.')).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'Send' })).toHaveCount(0);
|
||||
await expect(page.getByRole('button', { name: 'Nudge' })).toHaveCount(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user