@@ -46,7 +46,7 @@ Clipper.getCachedValue = (key: string) => {
46
46
QUnit . module ( "ratingsPanel" , {
47
47
beforeEach : ( ) => {
48
48
Clipper . logger = new StubSessionLogger ( ) ;
49
- Settings . setSettingsJsonForTesting ( ) ;
49
+ Settings . setSettingsJsonForTesting ( { } ) ;
50
50
51
51
mockStorage = { } ;
52
52
mockStorageCache = { } ;
@@ -95,8 +95,6 @@ test("'Positive' click at RatingsPromptStage.Init goes to RatingsPromptStage.Rat
95
95
test ( "'Positive' click at RatingsPromptStage.Init goes to RatingsPromptStage.End when rate url does not exist" , ( assert : QUnitAssert ) => {
96
96
let done = assert . async ( ) ;
97
97
98
- Settings . setSettingsJsonForTesting ( { } ) ;
99
-
100
98
let clipperState = HelperFunctions . getMockClipperState ( ) ;
101
99
clipperState . showRatingsPrompt = new SmartValue < boolean > ( true ) ;
102
100
@@ -151,8 +149,6 @@ test("'Negative' click at RatingsPromptStage.Init without a prior bad rating goe
151
149
test ( "'Negative' click at RatingsPromptStage.Init without a prior bad rating goes to RatingsPromptStage.End when feedback url does not exist (and doNotPromptRatings === undefined)" , ( assert : QUnitAssert ) => {
152
150
let done = assert . async ( ) ;
153
151
154
- Settings . setSettingsJsonForTesting ( { } ) ;
155
-
156
152
Clipper . storeValue ( ClipperStorageKeys . lastSeenVersion , "3.1.0" ) ;
157
153
158
154
let clipperState = HelperFunctions . getMockClipperState ( ) ;
@@ -210,8 +206,6 @@ test("'Negative' click at RatingsPromptStage.Init with a prior bad rating sets d
210
206
test ( "'Negative' click at RatingsPromptStage.Init with a prior bad rating sets doNotPromptRatings to 'true' (feedback url does not exist)" , ( assert : QUnitAssert ) => {
211
207
let done = assert . async ( ) ;
212
208
213
- Settings . setSettingsJsonForTesting ( { } ) ;
214
-
215
209
Clipper . storeValue ( ClipperStorageKeys . lastBadRatingDate , ( Date . now ( ) - Constants . Settings . minTimeBetweenBadRatings ) . toString ( ) ) ;
216
210
Clipper . storeValue ( ClipperStorageKeys . lastSeenVersion , "3.1.0" ) ;
217
211
@@ -249,11 +243,9 @@ test("'Rate' click at RatingsPromptStage.Rate goes to RatingsPromptStage.End whe
249
243
250
244
let controllerInstance = HelperFunctions . mountToFixture ( ratingsPanel ) ;
251
245
252
- // go to RATE panel, then click 'Rate'
253
- let initPositive = document . getElementById ( Constants . Ids . ratingsButtonInitYes ) ;
254
- HelperFunctions . simulateAction ( ( ) => {
255
- initPositive . click ( ) ;
256
- } ) ;
246
+ // skip to RATE panel
247
+ controllerInstance . setState ( { userSelectedRatingsPromptStage : RatingsPromptStage . Rate } ) ;
248
+ m . redraw ( true ) ;
257
249
258
250
let ratePositive = document . getElementById ( Constants . Ids . ratingsButtonRateYes ) ;
259
251
HelperFunctions . simulateAction ( ( ) => {
@@ -263,26 +255,21 @@ test("'Rate' click at RatingsPromptStage.Rate goes to RatingsPromptStage.End whe
263
255
strictEqual ( RatingsPromptStage [ controllerInstance . state . userSelectedRatingsPromptStage ] , RatingsPromptStage [ RatingsPromptStage . End ] ) ;
264
256
} ) ;
265
257
266
- test ( "'Rate' click at RatingsPromptStage.Rate not available when rate url does not exist" , ( ) => {
258
+ test ( "'Rate' click at RatingsPromptStage.Rate not available when rate url does not exist (unexpected scenario) " , ( ) => {
267
259
let clipperState = HelperFunctions . getMockClipperState ( ) ;
268
260
clipperState . showRatingsPrompt = new SmartValue < boolean > ( true ) ;
269
261
270
262
let ratingsPanel = < RatingsPanel clipperState = { clipperState } /> ;
271
263
272
264
let controllerInstance = HelperFunctions . mountToFixture ( ratingsPanel ) ;
273
265
274
- // go to RATE panel
275
- let initPositive = document . getElementById ( Constants . Ids . ratingsButtonInitYes ) ;
276
- HelperFunctions . simulateAction ( ( ) => {
277
- initPositive . click ( ) ;
278
- // clearing rate url before rendering RATE panel
279
- // to test the unexpected case that we got to it without a rate url
280
- Settings . setSettingsJsonForTesting ( { } ) ;
281
- } ) ;
266
+ // skip to RATE panel
267
+ controllerInstance . setState ( { userSelectedRatingsPromptStage : RatingsPromptStage . Rate } ) ;
268
+ m . redraw ( true ) ;
282
269
283
270
let ratePositive = document . getElementById ( Constants . Ids . ratingsButtonRateYes ) ;
284
-
285
271
ok ( Utils . isNullOrUndefined ( ratePositive ) , "'Rate' button should not exist" ) ;
272
+
286
273
strictEqual ( RatingsPromptStage [ controllerInstance . state . userSelectedRatingsPromptStage ] , RatingsPromptStage [ RatingsPromptStage . None ] ) ;
287
274
} ) ;
288
275
@@ -300,11 +287,9 @@ test("'No Thanks' click at RatingsPromptStage.Rate goes to RatingsPromptStage.No
300
287
301
288
let controllerInstance = HelperFunctions . mountToFixture ( ratingsPanel ) ;
302
289
303
- // go to RATE panel, then click 'No Thanks'
304
- let initPositive = document . getElementById ( Constants . Ids . ratingsButtonInitYes ) ;
305
- HelperFunctions . simulateAction ( ( ) => {
306
- initPositive . click ( ) ;
307
- } ) ;
290
+ // skip to RATE panel
291
+ controllerInstance . setState ( { userSelectedRatingsPromptStage : RatingsPromptStage . Rate } ) ;
292
+ m . redraw ( true ) ;
308
293
309
294
let rateNegative = document . getElementById ( Constants . Ids . ratingsButtonRateNo ) ;
310
295
HelperFunctions . simulateAction ( ( ) => {
@@ -314,26 +299,21 @@ test("'No Thanks' click at RatingsPromptStage.Rate goes to RatingsPromptStage.No
314
299
strictEqual ( RatingsPromptStage [ controllerInstance . state . userSelectedRatingsPromptStage ] , RatingsPromptStage [ RatingsPromptStage . None ] ) ;
315
300
} ) ;
316
301
317
- test ( "'No Thanks' click at RatingsPromptStage.Rate not available when rate url does not exist" , ( ) => {
302
+ test ( "'No Thanks' click at RatingsPromptStage.Rate not available when rate url does not exist (unexpected scenario) " , ( ) => {
318
303
let clipperState = HelperFunctions . getMockClipperState ( ) ;
319
304
clipperState . showRatingsPrompt = new SmartValue < boolean > ( true ) ;
320
305
321
306
let ratingsPanel = < RatingsPanel clipperState = { clipperState } /> ;
322
307
323
308
let controllerInstance = HelperFunctions . mountToFixture ( ratingsPanel ) ;
324
309
325
- // go to RATE panel
326
- let initPositive = document . getElementById ( Constants . Ids . ratingsButtonInitYes ) ;
327
- HelperFunctions . simulateAction ( ( ) => {
328
- initPositive . click ( ) ;
329
- // clearing rate url before rendering RATE panel
330
- // to test the unexpected case that we got to it without a rate url
331
- Settings . setSettingsJsonForTesting ( { } ) ;
332
- } ) ;
310
+ // skip to RATE panel
311
+ controllerInstance . setState ( { userSelectedRatingsPromptStage : RatingsPromptStage . Rate } ) ;
312
+ m . redraw ( true ) ;
333
313
334
314
let rateNegative = document . getElementById ( Constants . Ids . ratingsButtonRateNo ) ;
335
-
336
315
ok ( Utils . isNullOrUndefined ( rateNegative ) , "'No Thanks' button should not exist" ) ;
316
+
337
317
strictEqual ( RatingsPromptStage [ controllerInstance . state . userSelectedRatingsPromptStage ] , RatingsPromptStage [ RatingsPromptStage . None ] ) ;
338
318
} ) ;
339
319
@@ -353,11 +333,9 @@ test("'Feedback' click at RatingsPromptStage.Feedback goes to RatingsPromptStage
353
333
354
334
let controllerInstance = HelperFunctions . mountToFixture ( ratingsPanel ) ;
355
335
356
- // go to FEEDBACK panel, then click 'Feedback'
357
- let initNegative = document . getElementById ( Constants . Ids . ratingsButtonInitNo ) ;
358
- HelperFunctions . simulateAction ( ( ) => {
359
- initNegative . click ( ) ;
360
- } ) ;
336
+ // skip to FEEDBACK panel
337
+ controllerInstance . setState ( { userSelectedRatingsPromptStage : RatingsPromptStage . Feedback } ) ;
338
+ m . redraw ( true ) ;
361
339
362
340
let feedbackPositive = document . getElementById ( Constants . Ids . ratingsButtonFeedbackYes ) ;
363
341
HelperFunctions . simulateAction ( ( ) => {
@@ -367,7 +345,7 @@ test("'Feedback' click at RatingsPromptStage.Feedback goes to RatingsPromptStage
367
345
strictEqual ( RatingsPromptStage [ controllerInstance . state . userSelectedRatingsPromptStage ] , RatingsPromptStage [ RatingsPromptStage . End ] ) ;
368
346
} ) ;
369
347
370
- test ( "'Feedback' click at RatingsPromptStage.Feedback not available when feedback url does not exist" , ( ) => {
348
+ test ( "'Feedback' click at RatingsPromptStage.Feedback not available when feedback url does not exist (unexpected scenario) " , ( ) => {
371
349
Clipper . storeValue ( ClipperStorageKeys . lastSeenVersion , "3.1.0" ) ;
372
350
373
351
let clipperState = HelperFunctions . getMockClipperState ( ) ;
@@ -377,18 +355,13 @@ test("'Feedback' click at RatingsPromptStage.Feedback not available when feedbac
377
355
378
356
let controllerInstance = HelperFunctions . mountToFixture ( ratingsPanel ) ;
379
357
380
- // go to FEEDBACK panel
381
- let initNegative = document . getElementById ( Constants . Ids . ratingsButtonInitNo ) ;
382
- HelperFunctions . simulateAction ( ( ) => {
383
- initNegative . click ( ) ;
384
- // clearing feedback url before rendering FEEDBACK panel
385
- // to test the unexpected case that we got to it without a feedback url
386
- Settings . setSettingsJsonForTesting ( { } ) ;
387
- } ) ;
358
+ // skip to FEEDBACK panel
359
+ controllerInstance . setState ( { userSelectedRatingsPromptStage : RatingsPromptStage . Feedback } ) ;
360
+ m . redraw ( true ) ;
388
361
389
362
let feedbackPositive = document . getElementById ( Constants . Ids . ratingsButtonFeedbackYes ) ;
390
-
391
363
ok ( Utils . isNullOrUndefined ( feedbackPositive ) , "'Feedback' button should not exist" ) ;
364
+
392
365
strictEqual ( RatingsPromptStage [ controllerInstance . state . userSelectedRatingsPromptStage ] , RatingsPromptStage [ RatingsPromptStage . None ] ) ;
393
366
} ) ;
394
367
@@ -408,11 +381,9 @@ test("'No Thanks' click at RatingsPromptStage.Feedback goes to RatingsPromptStag
408
381
409
382
let controllerInstance = HelperFunctions . mountToFixture ( ratingsPanel ) ;
410
383
411
- // go to FEEDBACK panel, then click 'No Thanks'
412
- let initNegative = document . getElementById ( Constants . Ids . ratingsButtonInitNo ) ;
413
- HelperFunctions . simulateAction ( ( ) => {
414
- initNegative . click ( ) ;
415
- } ) ;
384
+ // skip to FEEDBACK panel
385
+ controllerInstance . setState ( { userSelectedRatingsPromptStage : RatingsPromptStage . Feedback } ) ;
386
+ m . redraw ( true ) ;
416
387
417
388
let feedbackNegative = document . getElementById ( Constants . Ids . ratingsButtonFeedbackNo ) ;
418
389
HelperFunctions . simulateAction ( ( ) => {
@@ -422,7 +393,7 @@ test("'No Thanks' click at RatingsPromptStage.Feedback goes to RatingsPromptStag
422
393
strictEqual ( RatingsPromptStage [ controllerInstance . state . userSelectedRatingsPromptStage ] , RatingsPromptStage [ RatingsPromptStage . None ] ) ;
423
394
} ) ;
424
395
425
- test ( "'No Thanks' click at RatingsPromptStage.Feedback not available when feedback url does not exist" , ( ) => {
396
+ test ( "'No Thanks' click at RatingsPromptStage.Feedback not available when feedback url does not exist (unexpected scenario) " , ( ) => {
426
397
Clipper . storeValue ( ClipperStorageKeys . lastSeenVersion , "3.1.0" ) ;
427
398
428
399
let clipperState = HelperFunctions . getMockClipperState ( ) ;
@@ -432,17 +403,12 @@ test("'No Thanks' click at RatingsPromptStage.Feedback not available when feedba
432
403
433
404
let controllerInstance = HelperFunctions . mountToFixture ( ratingsPanel ) ;
434
405
435
- // go to FEEDBACK panel
436
- let initNegative = document . getElementById ( Constants . Ids . ratingsButtonInitNo ) ;
437
- HelperFunctions . simulateAction ( ( ) => {
438
- initNegative . click ( ) ;
439
- // clearing feedback url before rendering FEEDBACK panel
440
- // to test the unexpected case that we got to it without a feedback url
441
- Settings . setSettingsJsonForTesting ( { } ) ;
442
- } ) ;
406
+ // skip to FEEDBACK panel
407
+ controllerInstance . setState ( { userSelectedRatingsPromptStage : RatingsPromptStage . Feedback } ) ;
408
+ m . redraw ( true ) ;
443
409
444
410
let feedbackNegative = document . getElementById ( Constants . Ids . ratingsButtonFeedbackNo ) ;
445
-
446
411
ok ( Utils . isNullOrUndefined ( feedbackNegative ) , "'No Thanks' button should not exist" ) ;
412
+
447
413
strictEqual ( RatingsPromptStage [ controllerInstance . state . userSelectedRatingsPromptStage ] , RatingsPromptStage [ RatingsPromptStage . None ] ) ;
448
414
} ) ;
0 commit comments