Skip to content

Feat/reward system backend#963

Draft
sachinkmrsin wants to merge 7 commits intostagefrom
Feat/Reward-System-Backend
Draft

Feat/reward system backend#963
sachinkmrsin wants to merge 7 commits intostagefrom
Feat/Reward-System-Backend

Conversation

@sachinkmrsin
Copy link
Copy Markdown
Member

@sachinkmrsin sachinkmrsin commented Feb 23, 2026

Description

closes:#943

This is a test only pr created to distribute the size of the pr. Contains test for reward creation and transactions.
Tech Document : https://www.notion.so/OpenLogo-Reward-System-Architecture-2e11cb09a77180ed8e60d4f57e6d0d49?source=copy_link

What type of PR is this? (Check all applicable)

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📄 Documentation Update
  • 👨‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🛠️ CI/CD

Screenshots (if applicable)

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@github-actions
Copy link
Copy Markdown

No linked issues found. Please add the corresponding issues in the pull request description.
Use GitHub automation to close the issue when a PR is merged

Copy link
Copy Markdown
Member

@AryaDharkar AryaDharkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one fundamental error in the services tests. Please check

Comment thread packages/app/__tests__/controllers/rewards.js Outdated
Comment thread packages/app/__tests__/controllers/rewards.js Outdated
Comment thread packages/app/__tests__/controllers/rewards.js Outdated
Comment thread packages/app/__tests__/controllers/rewards.js Outdated
Comment thread packages/app/__tests__/services/rewards.test.js
Comment thread packages/app/__tests__/services/rewards.test.js Outdated
Comment thread packages/app/__tests__/services/rewardTransactions.test.js Outdated
@sachinkmrsin sachinkmrsin marked this pull request as draft March 23, 2026 14:15
@sachinkmrsin sachinkmrsin marked this pull request as ready for review March 27, 2026 19:20
Copilot AI review requested due to automatic review settings March 27, 2026 19:20
Copy link
Copy Markdown
Member

@AryaDharkar AryaDharkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to comments, make sonarqube changes too as they are following latest conventions

Comment thread packages/app/__tests__/controllers/milestones/delete.test.js Outdated
Comment thread packages/app/__tests__/services/rewardTransactions.test.js Outdated
Comment thread packages/app/__tests__/services/rewardTransactions.test.js Outdated
Comment thread packages/app/__tests__/services/rewards.test.js
Comment thread packages/app/__tests__/controllers/users/getuserdata.js
Comment thread packages/app/__tests__/controllers/logo/get-logo.js
Comment thread packages/app/__tests__/services/rewards.test.js
Comment thread packages/app/__tests__/services/rewards.test.js
@sachinkmrsin sachinkmrsin marked this pull request as draft April 10, 2026 13:03
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@sachinkmrsin sachinkmrsin marked this pull request as ready for review April 12, 2026 05:43
Copilot AI review requested due to automatic review settings April 12, 2026 05:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a large set of Jest tests and supporting mock fixtures intended to cover the upcoming rewards system (reward tracking, reward processing, milestone config admin APIs, and rewards transaction endpoints), plus a few updates to existing controller tests.

Changes:

  • Expanded packages/app/utils/mocks.js with reward-system and image-service mock data/factories.
  • Added new service-level test suites for reward tracking, rewards processing, and milestone config service.
  • Added new controller test suites for rewards endpoints and milestone admin endpoints; updated existing get-logo and getuserdata controller tests.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 35 comments.

Show a summary per file
File Description
packages/app/utils/mocks.js Adds extensive mock fixtures/factories for images + rewards + milestones
packages/app/tests/services/rewardTransactions.test.js New tests for reward tracking request validation/logging
packages/app/tests/services/rewards.test.js New tests for rewards processing/leaderboard/transaction reversal
packages/app/tests/services/milestoneConfig.test.js New tests for milestone config service behavior
packages/app/tests/controllers/users/getuserdata.js Updates expected user payload and key fields
packages/app/tests/controllers/rewards/transactions.test.js New controller tests for rewards transaction retrieval
packages/app/tests/controllers/rewards/transactionReversal.test.js New controller tests for admin transaction reversal
packages/app/tests/controllers/rewards/summaries.test.js New controller tests for image/user reward summaries
packages/app/tests/controllers/rewards/stats.test.js New controller tests for user transaction stats endpoint
packages/app/tests/controllers/rewards/search.test.js New controller tests for admin transaction search
packages/app/tests/controllers/rewards/leaderboard.test.js New controller tests for rewards leaderboard
packages/app/tests/controllers/rewards/bonusPoints.test.js New controller tests for admin bonus points endpoint
packages/app/tests/controllers/rewards/auditTrail.test.js New controller tests for rewards audit trail endpoint
packages/app/tests/controllers/milestones/update.test.js New controller tests for milestone config update
packages/app/tests/controllers/milestones/list.test.js New controller tests for milestone config list/get
packages/app/tests/controllers/milestones/delete.test.js New controller tests for milestone config delete
packages/app/tests/controllers/milestones/create.test.js New controller tests for milestone config create
packages/app/tests/controllers/milestones/activate.test.js New controller tests for milestone config activate
packages/app/tests/controllers/logo/get-logo.js Updates logo controller tests to include reward tracking hook (mocked)
packages/app/tests/controllers/catalog/updatepermission.js Switches STATUS_CODES import to node:http
Comments suppressed due to low confidence (1)

packages/app/tests/controllers/users/getuserdata.js:142

  • The test now expects key objects to omit key_description and subscription_id, but the test setup mocks KeyService.getAllUserKeys() to return those properties (and the controller returns keysData as-is). This will cause the toEqual to fail; either update the mocked key shape to match the expected response or keep the expected fields consistent with the mocked return value.
      keys: [
        {
          _id: mockKeyModel._id.toString(),
          created_at: mockKeyModel._id.getTimestamp().toISOString(),
          updated_at: mockKeyModel.updated_at.toISOString(),
          expires_at: mockKeyModel.expires_at.toISOString(),
        },
      ],

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/app/__tests__/services/rewardTransactions.test.js
Comment thread packages/app/__tests__/services/rewardTransactions.test.js
Comment thread packages/app/__tests__/services/rewards.test.js
Comment thread packages/app/__tests__/services/milestoneConfig.test.js
Comment thread packages/app/__tests__/controllers/logo/get-logo.js
Comment thread packages/app/__tests__/controllers/milestones/list.test.js
Comment thread packages/app/__tests__/controllers/milestones/create.test.js
Comment thread packages/app/__tests__/controllers/milestones/update.test.js
Comment thread packages/app/__tests__/controllers/milestones/delete.test.js
Comment thread packages/app/__tests__/controllers/milestones/activate.test.js
@sachinkmrsin sachinkmrsin marked this pull request as draft April 20, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants