@@ -31,7 +31,9 @@ describe('Integration | Scripts | generate-knowledge-element-snapshots-for-campa
31
31
sharedAt : new Date ( '2020-01-01' ) ,
32
32
userId,
33
33
} ) ;
34
- databaseBuilder . factory . buildKnowledgeElementSnapshot ( { snappedAt : campaignParticipation . sharedAt , userId } ) ;
34
+ databaseBuilder . factory . buildKnowledgeElementSnapshot ( {
35
+ campaignParticipationId : campaignParticipation . id ,
36
+ } ) ;
35
37
await databaseBuilder . commit ( ) ;
36
38
37
39
// when
@@ -71,10 +73,23 @@ describe('Integration | Scripts | generate-knowledge-element-snapshots-for-campa
71
73
sharedAt : new Date ( '2020-01-01' ) ,
72
74
userId,
73
75
} ) ;
74
- databaseBuilder . factory . buildCampaignParticipation ( { sharedAt : new Date ( '2020-02-01' ) , userId } ) ;
75
- databaseBuilder . factory . buildCampaignParticipation ( { sharedAt : new Date ( '2020-03-01' ) , userId } ) ;
76
- databaseBuilder . factory . buildKnowledgeElementSnapshot ( { snappedAt : new Date ( '2020-02-01' ) , userId } ) ;
77
- databaseBuilder . factory . buildKnowledgeElementSnapshot ( { snappedAt : new Date ( '2020-03-01' ) , userId } ) ;
76
+
77
+ const firstCampaignParticiationId = databaseBuilder . factory . buildCampaignParticipation ( {
78
+ sharedAt : new Date ( '2020-02-01' ) ,
79
+ userId,
80
+ } ) . id ;
81
+ const secondCampaignParticiationId = databaseBuilder . factory . buildCampaignParticipation ( {
82
+ sharedAt : new Date ( '2020-03-01' ) ,
83
+ userId,
84
+ } ) . id ;
85
+ databaseBuilder . factory . buildKnowledgeElementSnapshot ( {
86
+ snappedAt : new Date ( '2020-02-01' ) ,
87
+ campaignParticipationId : firstCampaignParticiationId ,
88
+ } ) ;
89
+ databaseBuilder . factory . buildKnowledgeElementSnapshot ( {
90
+ snappedAt : new Date ( '2020-03-01' ) ,
91
+ campaignParticipationId : secondCampaignParticiationId ,
92
+ } ) ;
78
93
await databaseBuilder . commit ( ) ;
79
94
80
95
// when
@@ -152,8 +167,6 @@ describe('Integration | Scripts | generate-knowledge-element-snapshots-for-campa
152
167
153
168
// then
154
169
expect ( knowledgeElementSnapshotRepositoryStub . save ) . to . have . been . calledWithExactly ( {
155
- userId : campaignParticipationData [ 0 ] . userId ,
156
- snappedAt : campaignParticipationData [ 0 ] . sharedAt ,
157
170
snapshot : new KnowledgeElementCollection ( expectedKnowledgeElements ) . toSnapshot ( ) ,
158
171
campaignParticipationId : campaignParticipationData [ 0 ] . id ,
159
172
} ) ;
0 commit comments