[Investigation] Flaky unit tests fail intermittently in full verify run #138

Closed
opened 2026-11-03 22:51:48 +03:00 by codex-bot · 1 comment
Owner

Problem

During verification of WealthLedger/main#18 on frontend develop (ad93725), the full npm run verify failed once on three unit tests. The same tests passed in two subsequent full runs and in isolation. The failure is intermittent; the cause is not established.

Failing tests in the failing run:

  • src/features/tbank-connection/model/screen-sync.test.tsx — "retries the resource with GET without requesting source observation" (expected undefined to deeply equal [])
  • src/pages/card/ui/OperationForm/OperationForm.test.tsx — "blocks closing and editing while save is pending, then closes after success"
  • src/pages/stock/ui/StockPage/StockPage.test.tsx — "preserves unknown and unambiguous currencies with compact, ratio and percent formatting" (Unable to find an element with the text: 1,23 млн валюта неизвестна)

Evidence

  • Failing run: npm run verify exit 1 at the vitest run --coverage step: Test Files 3 failed | 74 passed (77), Tests 3 failed | 577 passed (580).
  • Same three files alone: npx vitest run <3 files> → 3 files, 24 tests, all passed.
  • Two later full npx vitest run --coverage: 580/580 passed each time.
  • Environment at the failing run: Node 24.22.1, TZ unset, LANG=en_NZ.UTF-8, system under load from parallel tooling (not controlled).

Not investigated: whether the failing run was affected by timing (async UI assertions), shared test state, or environment. No stack trace analysis beyond the messages above.

Hypotheses (unverified)

  • Timing-dependent assertions in async UI tests under worker load.
  • Locale/number formatting dependence (1,23 млн expects a specific Intl behaviour) under a non-ru runtime locale.

Scope

  • In: reproduce, identify the cause for each of the three tests, and fix the test or the underlying race if it is in product code.
  • Out: changing product behaviour or assertions to make tests pass; unrelated test refactors.

Acceptance Criteria

  • Reproduce the intermittent failure, or document that it cannot be reproduced after N repeated full verify runs (state N and the environment).
  • Root cause recorded for each of the three tests (timing, shared state, locale/TZ, or other), with evidence.
  • Fix does not weaken assertions; if a product race is found, it is fixed in product code.
  • 10 consecutive full npx vitest run --coverage runs pass on the same environment, or the remaining flake rate is recorded.
  • npm run verify is green on develop.

Verification

Not started. Relates to WealthLedger/main#18 (frontend part verified, with this caveat).

## Problem During verification of WealthLedger/main#18 on frontend `develop` (`ad93725`), the full `npm run verify` failed once on three unit tests. The same tests passed in two subsequent full runs and in isolation. The failure is intermittent; the cause is not established. Failing tests in the failing run: - `src/features/tbank-connection/model/screen-sync.test.tsx` — "retries the resource with GET without requesting source observation" (`expected undefined to deeply equal []`) - `src/pages/card/ui/OperationForm/OperationForm.test.tsx` — "blocks closing and editing while save is pending, then closes after success" - `src/pages/stock/ui/StockPage/StockPage.test.tsx` — "preserves unknown and unambiguous currencies with compact, ratio and percent formatting" (`Unable to find an element with the text: 1,23 млн валюта неизвестна`) ## Evidence - Failing run: `npm run verify` exit 1 at the `vitest run --coverage` step: `Test Files 3 failed | 74 passed (77)`, `Tests 3 failed | 577 passed (580)`. - Same three files alone: `npx vitest run <3 files>` → 3 files, 24 tests, all passed. - Two later full `npx vitest run --coverage`: 580/580 passed each time. - Environment at the failing run: Node 24.22.1, `TZ` unset, `LANG=en_NZ.UTF-8`, system under load from parallel tooling (not controlled). Not investigated: whether the failing run was affected by timing (async UI assertions), shared test state, or environment. No stack trace analysis beyond the messages above. ## Hypotheses (unverified) - Timing-dependent assertions in async UI tests under worker load. - Locale/number formatting dependence (`1,23 млн` expects a specific `Intl` behaviour) under a non-ru runtime locale. ## Scope - In: reproduce, identify the cause for each of the three tests, and fix the test or the underlying race if it is in product code. - Out: changing product behaviour or assertions to make tests pass; unrelated test refactors. ## Acceptance Criteria - [ ] Reproduce the intermittent failure, or document that it cannot be reproduced after N repeated full `verify` runs (state N and the environment). - [ ] Root cause recorded for each of the three tests (timing, shared state, locale/TZ, or other), with evidence. - [ ] Fix does not weaken assertions; if a product race is found, it is fixed in product code. - [ ] 10 consecutive full `npx vitest run --coverage` runs pass on the same environment, or the remaining flake rate is recorded. - [ ] `npm run verify` is green on develop. ## Verification Not started. Relates to WealthLedger/main#18 (frontend part verified, with this caveat).
codex-bot added the Kind/Investigation label 2026-11-03 22:51:48 +03:00
Author
Owner

Закрыто через #166 (squash d910d62 в develop).

По Acceptance Criteria:

  • Воспроизведение: да, под CPU-нагрузкой (10 ядер, 10–40 процессов yes), Node 24.22.1, macOS.
  • Причины:
    • screen-sync: тест вызывал ручной retry, пока транспорт ещё сам повторял запрос (1 s + 2 s back-off), поэтому успех зависел от времени. Исправлено fake timers, проверки строже.
    • Новый случай, AppRoutes «offers a retry…»: toBeVisible ловил fade-in RouteTransition (opacity 0.18). Исправлено MotionGlobalConfig.skipAnimations в unit setup.
    • OperationForm / StockPage: не воспроизвелись примерно за 10 полных прогонов под нагрузкой. Локаль/TZ (LANG=C, en_NZ, Pacific/Auckland) исключены. Причина не установлена.
  • Проверки не ослаблены, продуктовой гонки не найдено.
  • Прогоны: 6 полных прогонов vitest run --project unit подряд под нагрузкой, 576/576 каждый. Целевые 10 не набраны; оставшаяся частота сбоев не измерена.
  • npm run verify локально exit 0; CI PR зелёный.

Если OperationForm/StockPage упадут снова, нужно открыть новую Issue с полным логом.

Закрыто через #166 (squash `d910d62` в `develop`). По Acceptance Criteria: - Воспроизведение: да, под CPU-нагрузкой (10 ядер, 10–40 процессов `yes`), Node 24.22.1, macOS. - Причины: - screen-sync: тест вызывал ручной retry, пока транспорт ещё сам повторял запрос (1 s + 2 s back-off), поэтому успех зависел от времени. Исправлено fake timers, проверки строже. - Новый случай, AppRoutes «offers a retry…»: `toBeVisible` ловил fade-in `RouteTransition` (opacity 0.18). Исправлено `MotionGlobalConfig.skipAnimations` в unit setup. - OperationForm / StockPage: не воспроизвелись примерно за 10 полных прогонов под нагрузкой. Локаль/TZ (`LANG=C`, `en_NZ`, `Pacific/Auckland`) исключены. Причина не установлена. - Проверки не ослаблены, продуктовой гонки не найдено. - Прогоны: 6 полных прогонов `vitest run --project unit` подряд под нагрузкой, 576/576 каждый. Целевые 10 не набраны; оставшаяся частота сбоев не измерена. - `npm run verify` локально exit 0; CI PR зелёный. Если OperationForm/StockPage упадут снова, нужно открыть новую Issue с полным логом.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: WealthLedger/frontend#138