@@ -51,87 +51,144 @@ module('Integration | Components | Campaigns | Assessment | Results | Evaluation
51
51
52
52
module ( 'display quests results' , function ( ) {
53
53
module ( 'isQuestEnabled feature flag' , function ( ) {
54
- test ( 'it should not display the quest result if the flag is false' , async function ( assert ) {
55
- // given
56
- class FeatureTogglesStub extends Service {
57
- featureToggles = { isQuestEnabled : false } ;
58
- }
59
- this . owner . register ( 'service:featureToggles' , FeatureTogglesStub ) ;
54
+ module ( 'user is Anonymous' , function ( ) {
55
+ test ( 'it should not display the quest result if the flag is false' , async function ( assert ) {
56
+ // given
57
+ class CurrentUserStub extends Service {
58
+ user = { isAnonymous : true } ;
59
+ }
60
+ this . owner . register ( 'service:currentUser' , CurrentUserStub ) ;
61
+ class FeatureTogglesStub extends Service {
62
+ featureToggles = { isQuestEnabled : false } ;
63
+ }
64
+ this . owner . register ( 'service:featureToggles' , FeatureTogglesStub ) ;
60
65
61
- this . set ( 'campaign' , {
62
- customResultPageText : 'My custom result page text' ,
63
- organizationId : 1 ,
64
- } ) ;
66
+ this . set ( 'campaign' , {
67
+ customResultPageText : 'My custom result page text' ,
68
+ organizationId : 1 ,
69
+ } ) ;
65
70
66
- this . set ( 'campaignParticipationResult' , {
67
- campaignParticipationBadges : [ ] ,
68
- isShared : false ,
69
- canImprove : false ,
70
- masteryRate : 0.75 ,
71
- reachedStage : { acquired : 4 , total : 5 } ,
72
- } ) ;
71
+ this . set ( 'campaignParticipationResult' , {
72
+ campaignParticipationBadges : [ ] ,
73
+ isShared : false ,
74
+ canImprove : false ,
75
+ masteryRate : 0.75 ,
76
+ reachedStage : { acquired : 4 , total : 5 } ,
77
+ } ) ;
73
78
74
- this . set ( 'questResults' , [
75
- {
76
- obtained : true ,
77
- profileRewardId : 12 ,
78
- reward : { key : 'SIXTH_GRADE' } ,
79
- } ,
80
- ] ) ;
79
+ this . set ( 'questResults' , [
80
+ {
81
+ obtained : true ,
82
+ profileRewardId : 12 ,
83
+ reward : { key : 'SIXTH_GRADE' } ,
84
+ } ,
85
+ ] ) ;
81
86
82
- // when
83
- const screen = await render (
84
- hbs `<Campaigns::Assessment::Results::EvaluationResultsHero
87
+ // when
88
+ const screen = await render (
89
+ hbs `<Campaigns::Assessment::Results::EvaluationResultsHero
85
90
@campaign={{this.campaign}}
86
91
@questResults={{this.questResults}}
87
92
@campaignParticipationResult={{this.campaignParticipationResult}}
88
93
@isSharableCampaign={{true}}
89
94
/>` ,
90
- ) ;
95
+ ) ;
91
96
92
- // then
93
- assert . notOk ( screen . queryByText ( t ( 'components.campaigns.attestation-result.obtained' ) ) ) ;
97
+ // then
98
+ assert . notOk ( screen . queryByText ( t ( 'components.campaigns.attestation-result.obtained' ) ) ) ;
99
+ } ) ;
94
100
} ) ;
95
101
96
- test ( 'it should display the quest result if the flag is true ', async function ( assert ) {
97
- // given
98
- class FeatureTogglesStub extends Service {
99
- featureToggles = { isQuestEnabled : true } ;
100
- }
101
- this . owner . register ( 'service:featureToggles ' , FeatureTogglesStub ) ;
102
+ module ( 'user is not anonymous ', function ( hooks ) {
103
+ hooks . beforeEach ( function ( ) {
104
+ class CurrentUserStub extends Service {
105
+ user = { isAnonymous : false } ;
106
+ }
107
+ this . owner . register ( 'service:currentUser ' , CurrentUserStub ) ;
102
108
103
- this . set ( 'campaign' , {
104
- customResultPageText : 'My custom result page text' ,
105
- organizationId : 1 ,
106
- } ) ;
109
+ test ( 'it should not display the quest result if the flag is true' , async function ( assert ) {
110
+ // given
111
+ class FeatureTogglesStub extends Service {
112
+ featureToggles = { isQuestEnabled : true } ;
113
+ }
114
+ this . owner . register ( 'service:featureToggles' , FeatureTogglesStub ) ;
107
115
108
- this . set ( 'campaignParticipationResult' , {
109
- campaignParticipationBadges : [ ] ,
110
- isShared : false ,
111
- canImprove : false ,
112
- masteryRate : 0.75 ,
113
- reachedStage : { acquired : 4 , total : 5 } ,
114
- } ) ;
115
- this . set ( 'questResults' , [
116
- {
117
- obtained : true ,
118
- profileRewardId : 12 ,
119
- reward : { key : 'SIXTH_GRADE' } ,
120
- } ,
121
- ] ) ;
116
+ this . set ( 'campaign' , {
117
+ customResultPageText : 'My custom result page text' ,
118
+ organizationId : 1 ,
119
+ } ) ;
122
120
123
- // when
124
- const screen = await render (
125
- hbs `<Campaigns::Assessment::Results::EvaluationResultsHero
121
+ this . set ( 'campaignParticipationResult' , {
122
+ campaignParticipationBadges : [ ] ,
123
+ isShared : false ,
124
+ canImprove : false ,
125
+ masteryRate : 0.75 ,
126
+ reachedStage : { acquired : 4 , total : 5 } ,
127
+ } ) ;
128
+
129
+ this . set ( 'questResults' , [
130
+ {
131
+ obtained : true ,
132
+ profileRewardId : 12 ,
133
+ reward : { key : 'SIXTH_GRADE' } ,
134
+ } ,
135
+ ] ) ;
136
+
137
+ // when
138
+ const screen = await render (
139
+ hbs `<Campaigns::Assessment::Results::EvaluationResultsHero
126
140
@campaign={{this.campaign}}
127
141
@questResults={{this.questResults}}
128
142
@campaignParticipationResult={{this.campaignParticipationResult}}
129
143
@isSharableCampaign={{true}}
130
144
/>` ,
131
- ) ;
145
+ ) ;
132
146
133
- // then
134
- assert . ok ( screen . getByText ( t ( 'components.campaigns.attestation-result.obtained' ) ) ) ;
147
+ // then
148
+ assert . notOk ( screen . queryByText ( t ( 'components.campaigns.attestation-result.obtained' ) ) ) ;
149
+ } ) ;
150
+
151
+ test ( 'it should display the quest result if the flag is true' , async function ( assert ) {
152
+ // given
153
+ class FeatureTogglesStub extends Service {
154
+ featureToggles = { isQuestEnabled : true } ;
155
+ }
156
+ this . owner . register ( 'service:featureToggles' , FeatureTogglesStub ) ;
157
+
158
+ this . set ( 'campaign' , {
159
+ customResultPageText : 'My custom result page text' ,
160
+ organizationId : 1 ,
161
+ } ) ;
162
+
163
+ this . set ( 'campaignParticipationResult' , {
164
+ campaignParticipationBadges : [ ] ,
165
+ isShared : false ,
166
+ canImprove : false ,
167
+ masteryRate : 0.75 ,
168
+ reachedStage : { acquired : 4 , total : 5 } ,
169
+ } ) ;
170
+ this . set ( 'questResults' , [
171
+ {
172
+ obtained : true ,
173
+ profileRewardId : 12 ,
174
+ reward : { key : 'SIXTH_GRADE' } ,
175
+ } ,
176
+ ] ) ;
177
+
178
+ // when
179
+ const screen = await render (
180
+ hbs `<Campaigns::Assessment::Results::EvaluationResultsHero
181
+ @campaign={{this.campaign}}
182
+ @questResults={{this.questResults}}
183
+ @campaignParticipationResult={{this.campaignParticipationResult}}
184
+ @isSharableCampaign={{true}}
185
+ />` ,
186
+ ) ;
187
+
188
+ // then
189
+ assert . ok ( screen . getByText ( t ( 'components.campaigns.attestation-result.obtained' ) ) ) ;
190
+ } ) ;
191
+ } ) ;
135
192
} ) ;
136
193
} ) ;
137
194
} ) ;
0 commit comments