test(e2e): add notifications flow suite, opt-in e2e CI and runbook - #158
Open
damispicyGithub wants to merge 5 commits into
Open
damispicyGithub wants to merge 5 commits into
damispicyGithub wants to merge 5 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The repository already ships e2e specs for auth, loans, repayment, liquidity, transactions, reputation, webhooks and the loan-default job math, but the notifications leg of the BNPL flow had no end-to-end coverage and the e2e suite was never wired into CI. This PR closes that gap: a self-contained notifications flow spec that runs the reminder job, reads the notification back over HTTP and marks it read; an opt-in GitHub Actions workflow that runs the e2e suite with the services and env vars it needs; and a runbook under
docs/setup/.Related Issue
Closes #150
Changes
Notifications flow E2E
test/e2e/modules/notifications/notifications.e2e-spec.tsNotificationsModulewithTest.createTestingModule+FastifyAdapterand drives it throughapp.inject(), so routing, guards, the validation pipe, controller and service are all exercised together.SupabaseServicewith an in-memory fake that implements only the query shapesNotificationsRepositoryandLoanPaymentReminderProcessoractually use:eq,gte,in,not('…','is',null),order,range,select({ count, head }),maybeSingle,single,insert, andupdate().select(). It also resolves thedata->>loan_db_idJSONB path the processor de-duplicates on.JwtAuthGuardwith a guard that mapsAuthorization: Bearer …to a fixed wallet and rejects requests with no token.LoanPaymentReminderProcessor.process()against an active loan due in three UTC days and asserts apayment_reminder_3drow is written with the merchant context, then reads it back throughGET /notifications.PATCH /notifications/:id/readreturnsupdatedCount: 1and clears the unread badge; re-reading an already-read notification returnsupdatedCount: 0.PATCH /notifications/read-allmarks every unread row and returns the affected count.unread=truepluslimit/offsetbehave as documented, andunreadCountstill reflects the whole mailbox rather than the filtered page.403(NOTIFICATION_FORBIDDEN), unknown id →404(NOTIFICATION_NOT_FOUND), missing token →401, invalid query params →400.E2E CI
.github/workflows/e2e.ymlworkflow_dispatchor when therun-e2elabel is added to a PR. The defaultci.ymlis untouched and stays build + unit only, as its own comment documents.E2E_SUPABASE_URL,E2E_SUPABASE_ANON_KEYandE2E_SUPABASE_SERVICE_ROLE_KEYrepository secrets.E2E_SUPABASE_URLis not configured, so adding the label can never fail a PR by accident.concurrencycancels superseded runs andtimeout-minutes: 20bounds the job.Documentation
docs/setup/e2e-testing.md— prerequisites, isolation rules, single-flow commands, the CI opt-in, and a flow → spec coverage map.README.md— notes the e2e prerequisites and links the runbook from the testing and documentation sections.docs/README.md— links the runbook from the setup index and the docs tree.Verification Results
test/e2e/modules/notifications/notifications.e2e-spec.tsbeforeEach, in-memory Supabase,app.close()inafterAll@nestjs/testingcreateTestingModulewith the Fastify adapterFastifyAdapter+app.inject().github/workflows/e2e.yml(Redis service + Supabase secrets, skips when unset)docs/setup/docs/setup/e2e-testing.md, linked fromREADME.mdanddocs/README.mdmain(test/e2e/modules/auth,loans,liquidity); not duplicated hereCloses #150