Unit tests for the morning summary's title, local day and wanted rules

Aperta Adatta ai principianti
#735 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
90/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
testing

Direzione di ricerca

Leggi app/packages/core/src/notifications/summary.ts e usa app/tests/app/notification-summary-schedule.test.ts e app/tests/app/notification-levels-core.test.ts come modelli. Aggiungi app/tests/app/notification-summary-core.test.ts con i casi node:test specificati, quindi esegui il comando di test della issue. Il lavoro è concluso quando i casi passano senza modifiche al codice di produzione e i controlli del repository restano verdi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

good first issue

Context

The morning summary (#350) sends one push a day that counts what waits in a person's inbox. Three small pure functions decide whether it is sent, which day it counts as, and what the title says. They run only inside the larger summary tests; none has a test of its own, so a change to the wording or the day boundary would not be caught where it happens.

Found on main at 75df7fffd by searching app/tests for each exported name in app/packages/core/src: no test file names summaryTitle, summaryWanted or localDay.

Files

  • app/packages/core/src/notifications/summary.ts
    • localDay(now, timeZone) (line 18): the local calendar day as YYYY-MM-DD.
    • summaryWanted(preferences) (line 23): true only when summaryEnabled is on and the level is not "Nothing".
    • summaryTitle(count, more) (line 35): 1 thing waits in your inbox, N things wait in your inbox, N+ things wait in your inbox.
  • Pattern to copy: app/tests/app/notification-summary-schedule.test.ts (imports from ../../packages/core/src/notifications/...js) and app/tests/app/notification-levels-core.test.ts (imports from @flux/core; its fresh() helper at line 22 builds stored preferences from DEFAULT_PREFERENCES, and applyPreferenceChange(fresh(), { level: 'nothing' }) sets a level).

Checked before filing: a draft of the cases below passed against main at cb25512e6 in the test image, so the tests describe today's behaviour and need no production change.

Acceptance criteria

  • A new file app/tests/app/notification-summary-core.test.ts (the -core suffix means: no database, no network) covers, with node:test and node:assert/strict:
    • summaryTitle: singular for 1, plural for 0 and 2, the + form when more is true (also for 1).
    • summaryWanted: false when summaryEnabled is false; false at the "Nothing" level even when enabled; true when enabled at "Needs you" and at "Everything".
    • localDay: the same instant gives different days in UTC and Pacific/Kiritimati; a time-zone change of day at local midnight (an instant one second before and one second after).
  • No production code changes. If a test shows a real bug, open a separate issue with the failing case instead of fixing it here.
  • The new tests pass, and the repository checks stay green.

How to check

docker build --file docker/Dockerfile --target test --tag flux-unit app
docker run --rm --network none flux-unit node_modules/.bin/tsx --test tests/app/notification-summary-core.test.ts
docker image rm flux-unit
python3 scripts/check_agent_setup.py
git diff --check

See CONTRIBUTING for the fork and PR steps. Put Closes #<this issue> in the PR description.

Lingua principale
TypeScript
Stelle
3
Fork
0
Merge medio
19h 42m
PR unite (30g)
383

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ColdPhase/flux

Tutte le issue di ColdPhase/flux

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.