Skip to content

Commit

Permalink
feat(api): stop save userId / assessmentId in snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
lionelB committed Feb 5, 2025
1 parent 4822cc2 commit a2c8317
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import lodash from 'lodash';
import pick from 'lodash/pick.js';

import { knex } from '../../../../../db/knex-database-connection.js';
import { constants } from '../../../../shared/domain/constants.js';
Expand All @@ -14,8 +14,6 @@ import { AvailableCampaignParticipation } from '../../domain/read-models/Availab

const { TO_SHARE } = CampaignParticipationStatuses;

const { pick } = lodash;

const CAMPAIGN_PARTICIPATION_ATTRIBUTES = [
'participantExternalId',
'sharedAt',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('Integration | Repository | Campaign Participation', function () {
describe('#updateWithSnapshot', function () {
let clock;
let campaignParticipation;
let ke;
const frozenTime = new Date('1987-09-01T00:00:00Z');

beforeEach(async function () {
Expand All @@ -28,7 +29,7 @@ describe('Integration | Repository | Campaign Participation', function () {
sharedAt: null,
});

databaseBuilder.factory.buildKnowledgeElement({
ke = databaseBuilder.factory.buildKnowledgeElement({
userId: campaignParticipation.userId,
createdAt: new Date('1985-09-01T00:00:00Z'),
});
Expand Down Expand Up @@ -75,8 +76,22 @@ describe('Integration | Repository | Campaign Participation', function () {
});

// then
const snapshotInDB = await knex.select('id').from('knowledge-element-snapshots');
const snapshotInDB = await knex.pluck('snapshot').from('knowledge-element-snapshots');
expect(snapshotInDB).to.have.lengthOf(1);
expect(snapshotInDB).to.deep.equal([
[
{
id: ke.id,
answerId: ke.answerId,
competenceId: ke.competenceId,
createdAt: ke.createdAt.toISOString(),
earnedPix: 2,
skillId: ke.skillId,
source: ke.source,
status: ke.status,
},
],
]);
});

context('when there is a transaction', function () {
Expand Down

0 comments on commit a2c8317

Please sign in to comment.