Skip to content

Commit

Permalink
[FEATURE] Ajouter le profileRewardId dans le endpoint qui remonte les…
Browse files Browse the repository at this point in the history
… résultats d'une quête (PIX-15322)

 #10565
  • Loading branch information
pix-service-auto-merge authored Nov 18, 2024
2 parents 90b65ac + 279edff commit c8c91a0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion api/src/quest/domain/models/QuestResult.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export class QuestResult {
constructor({ id, obtained, reward }) {
constructor({ id, obtained, reward, profileRewardId }) {
this.id = id;
this.obtained = obtained;
this.profileRewardId = profileRewardId;
this.reward = reward;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const getByQuestAndUserId = async ({
return new QuestResult({
id: quest.id,
obtained: true,
profileRewardId: profileRewardForQuest.id,
reward,
});
}
Expand All @@ -41,6 +42,7 @@ export const getByQuestAndUserId = async ({
return new QuestResult({
id: quest.id,
obtained,
profileRewardId: null,
reward,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { Serializer } = jsonapiSerializer;

const serialize = function (questResult) {
return new Serializer('quest-result', {
attributes: ['obtained', 'reward'],
attributes: ['obtained', 'reward', 'profileRewardId'],
}).serialize(questResult);
};

Expand Down
2 changes: 2 additions & 0 deletions api/src/shared/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ const configuration = (function () {
config.featureToggles.isPix1dEnabled = true;
config.featureToggles.isPixCompanionEnabled = false;
config.featureToggles.isSelfAccountDeletionEnabled = false;
config.featureToggles.isQuestEnabled = false;
config.featureToggles.isAsyncQuestRewardingCalculationEnabled = false;
config.featureToggles.isTextToSpeechButtonEnabled = false;
config.featureToggles.showNewResultPage = false;
config.featureToggles.showExperimentalMissions = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Quest | Unit | Infrastructure | Repositories | Reward', function () {

it('should return QuestResult with obtained true when reward is obtained', async function () {
// given
const profileReward = [{ rewardId: quest.rewardId, rewardType: quest.rewardType }];
const profileReward = [{ rewardId: quest.rewardId, rewardType: quest.rewardType, profileRewardId: 1 }];
profileRewardApiStub.getByUserId.withArgs(userId).resolves(profileReward);

// when
Expand All @@ -51,6 +51,7 @@ describe('Quest | Unit | Infrastructure | Repositories | Reward', function () {
// then
expect(result).to.be.an.instanceof(QuestResult);
expect(result.id).to.equal(quest.id);
expect(result.profileRewardId).to.equal(profileReward.profileRewardId);
expect(result.reward).to.equal(reward);
expect(result.obtained).to.be.true;
});
Expand All @@ -75,6 +76,7 @@ describe('Quest | Unit | Infrastructure | Repositories | Reward', function () {
expect(result).to.be.an.instanceof(QuestResult);
expect(result.id).to.equal(quest.id);
expect(result.reward).to.equal(reward);
expect(result.profileRewardId).to.be.null;
expect(result.obtained).to.be.false;
});

Expand All @@ -98,6 +100,7 @@ describe('Quest | Unit | Infrastructure | Repositories | Reward', function () {
expect(result).to.be.an.instanceof(QuestResult);
expect(result.id).to.equal(quest.id);
expect(result.reward).to.equal(reward);
expect(result.profileRewardId).to.be.null;
expect(result.obtained).to.be.null;
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('Quest | Unit | Infrastructure | Serializers | quest-result', function
id: 1,
obtained: true,
reward: new Attestation({ id: 10, key: 'MY_KEY', templateName: 'my-key', createdAt: new Date('2020-10-10') }),
profileRewardId: 1,
});

// when
Expand All @@ -23,6 +24,7 @@ describe('Quest | Unit | Infrastructure | Serializers | quest-result', function
attributes: {
obtained: true,
reward: { id: 10, templateName: 'my-key', key: 'MY_KEY', createdAt: new Date('2020-10-10') },
'profile-reward-id': 1,
},
},
});
Expand Down

0 comments on commit c8c91a0

Please sign in to comment.