test: cover empty webhook list for creators with no registered webhooks (#551)#561
Open
CodingAngel1 wants to merge 1 commit into
Open
test: cover empty webhook list for creators with no registered webhooks (#551)#561CodingAngel1 wants to merge 1 commit into
CodingAngel1 wants to merge 1 commit into
Conversation
|
@CodingAngel1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary\n\nCloses #551\n\nAdds an integration test verifying that
GET /api/v1/creators/:id/webhooksreturns200 OKwith an empty array (instead of404 Not Found) when a creator exists in the system but has not registered any webhooks.\n\nThelistWebhooksHandlerinsrc/modules/webhooks/webhook.controllers.tsdelegates towebhookService.listWebhooks, which already returns[]when no rows match — so the controller behavior is correct. This PR ensures that documented behavior is locked in by an automated test.\n\n## Scope\n\n- Register a creator (User → StellarWallet → CreatorProfile) but intentionally do not register any webhooks.\n- CallGET /api/v1/creators/:id/webhookswith valid wallet-signed auth headers from the creator's own Stellar keypair.\n- Assert:\n - HTTP status200\n - Response envelope:success: true\n -datais an array equal to[]\n\n## Files Changed\n\n| File | Change |\n| --- | --- |\n|src/modules/webhooks/webhook.integration.test.ts| Newdescribeblock — empty list for creator with no webhooks. |\n\n## Test Design Notes\n\n- Creator ID format: positive-integer-format string (\"551001\") so it satisfiesparseCreatorIdinsrc/modules/webhooks/webhook-signature.middleware.ts(regex^\\d+$).CreatorProfile.idis a PrismaStringcolumn, so this is accepted at the DB layer.\n- Dedicated Stellar keypair:Keypair.random()generated for this scenario so the signature middleware's ECDSA verification succeeds.\n- Auth path: reuses existingauthHeadersFor(keypair, method, path, creatorId)helper to match the signing-payload format used by every other test in this file.\n- Sanity guard: assertsprisma.webhook.count({ where: { creatorId: emptyCreatorId } }) === 0before the request.\n- Cleanup:afterAllremoves webhooks → CreatorProfile → StellarWallet → User in dependency-safe order.\n\n## Acceptance Criteria Coverage\n\n| Acceptance criterion | Coverage |\n| --- | --- |\n| Register a creator but do not register any webhooks |beforeAllcreates User/Wallet/CreatorProfile;webhook.createis never called. |\n| CallGET /creators/:id/webhookswith valid creator auth | UsesauthHeadersFor(emptyKeypair, \"GET\", emptyListPath, emptyCreatorId)— passes Stellar signature verification. |\n| Returns 200 with empty array for creator with no webhook |res.status === 200,Array.isArray(res.body.data) === true,res.body.datadeep-equals[]. |\n\n## Verification\n\n\ndocker compose up -d postgres\nDATABASE_URL=postgresql://postgres:postgres@localhost:5432/accesslayer pnpm exec prisma db push --force-reset --skip-generate\npnpm exec prisma generate\nDATABASE_URL=postgresql://postgres:postgres@localhost:5432/accesslayer pnpm jest src/modules/webhooks/webhook.integration.test.ts -t \"#551\" --runInBand\npnpm exec tsc --noEmit\n\n\nVerified locally on this branch: the new#551test passes andtsc --noEmitexits 0.\n\n## Risk\n\nLow. Test-only change; no production code modified.\n\n## Out of Scope\n\nPre-existing tests in the same file that still use non-integer creator IDs (e.g.\"webhook-test-creator-id\") and may not pass the currentparseCreatorIdmiddleware — tracked separately, not introduced by this PR.