@@ -49,7 +49,7 @@ module('Integration | Component | Module | Passage', function (hooks) {
49
49
assert .dom (screen .queryByRole (' button' , { name: ' Continuer' })).doesNotExist ();
50
50
});
51
51
52
- module (' When a grain contains non existing elements' , function () {
52
+ module (' when a grain contains non existing elements' , function () {
53
53
test (' should not display the grain if it contains only non existing elements' , async function (assert ) {
54
54
// given
55
55
const store = this .owner .lookup (' service:store' );
@@ -160,7 +160,7 @@ module('Integration | Component | Module | Passage', function (hooks) {
160
160
assert .dom (screen .queryByRole (' button' , { name: ' Continuer' })).exists ({ count: 1 });
161
161
});
162
162
163
- module (' when user click on skip button' , function () {
163
+ module (' when user clicks on skip button' , function () {
164
164
test (' should display next grain' , async function (assert ) {
165
165
// given
166
166
const store = this .owner .lookup (' service:store' );
@@ -223,7 +223,7 @@ module('Integration | Component | Module | Passage', function (hooks) {
223
223
});
224
224
});
225
225
226
- module (' when user click on continue button' , function (hooks ) {
226
+ module (' when user clicks on continue button' , function (hooks ) {
227
227
let continueButtonName;
228
228
hooks .beforeEach (function () {
229
229
continueButtonName = t (' pages.modulix.buttons.grain.continue' );
@@ -321,7 +321,7 @@ module('Integration | Component | Module | Passage', function (hooks) {
321
321
});
322
322
});
323
323
324
- module (' when user click on an answerable element verify button' , function () {
324
+ module (' when user clicks on an answerable element verify button' , function () {
325
325
test (' should save the element answer' , async function (assert ) {
326
326
// given
327
327
const metrics = this .owner .lookup (' service:metrics' );
@@ -401,7 +401,7 @@ module('Integration | Component | Module | Passage', function (hooks) {
401
401
});
402
402
});
403
403
404
- module (' when user click on an answerable element retry button' , function () {
404
+ module (' when user clicks on an answerable element retry button' , function () {
405
405
test (' should push metrics event' , async function (assert ) {
406
406
// given
407
407
const metrics = this .owner .lookup (' service:metrics' );
@@ -432,6 +432,78 @@ module('Integration | Component | Module | Passage', function (hooks) {
432
432
});
433
433
});
434
434
435
+ module (' when user clicks on a flashcards element self-assessment button' , function () {
436
+ test (' should push metrics event' , async function (assert ) {
437
+ // given
438
+ const metrics = this .owner .lookup (' service:metrics' );
439
+ metrics .add = sinon .stub ();
440
+
441
+ const store = this .owner .lookup (' service:store' );
442
+ const firstCard = {
443
+ id: ' e1de6394-ff88-4de3-8834-a40057a50ff4' ,
444
+ recto: {
445
+ image: {
446
+ url: ' https://images.pix.fr/modulix/bien-ecrire-son-adresse-mail-explication-les-parties-dune-adresse-mail.svg' ,
447
+ },
448
+ text: " A quoi sert l'arobase dans mon adresse email ?" ,
449
+ },
450
+ verso: {
451
+ image: { url: ' https://images.pix.fr/modulix/didacticiel/ordi-spatial.svg' },
452
+ text: " Parce que c'est joli" ,
453
+ },
454
+ };
455
+ const secondCard = {
456
+ id: ' e1de6394-ff88-4de3-8834-a40057a50ff4' ,
457
+ recto: {
458
+ image: {
459
+ url: ' https://images.pix.fr/modulix/didacticiel/icon.svg' ,
460
+ },
461
+ text: ' Qui a écrit le Dormeur du Val ?' ,
462
+ },
463
+ verso: {
464
+ image: {
465
+ url: ' https://images.pix.fr/modulix/didacticiel/chaton.jpg' ,
466
+ },
467
+ text: ' <p>Arthur Rimbaud</p>' ,
468
+ },
469
+ };
470
+
471
+ const flashcardsElement = {
472
+ id: ' 71de6394-ff88-4de3-8834-a40057a50ff4' ,
473
+ type: ' flashcards' ,
474
+ title: " Introduction à l'adresse e-mail" ,
475
+ instruction: ' <p>...</p>' ,
476
+ introImage: { url: ' https://images.pix.fr/modulix/placeholder-details.svg' },
477
+ cards: [firstCard, secondCard],
478
+ };
479
+
480
+ const grain1 = store .createRecord (' grain' , { components: [{ type: ' element' , element: flashcardsElement }] });
481
+
482
+ const module = store .createRecord (' module' , { id: ' module-id' , title: ' Module title' , grains: [grain1] });
483
+ const passage = store .createRecord (' passage' );
484
+
485
+ const createRecordMock = sinon .mock ();
486
+ createRecordMock .returns ({ save : function () {} });
487
+ store .createRecord = createRecordMock;
488
+
489
+ await render (<template ><ModulePassage @ module ={{module }} @ passage ={{passage }} /></template >);
490
+
491
+ // when
492
+ await clickByName (t (' pages.modulix.buttons.flashcards.start' ));
493
+ await clickByName (t (' pages.modulix.buttons.flashcards.seeAnswer' ));
494
+ await clickByName (t (' pages.modulix.buttons.flashcards.answers.notAtAll' ));
495
+
496
+ // then
497
+ sinon .assert .calledOnceWithExactly (metrics .add , {
498
+ event : ' custom-event' ,
499
+ ' pix-event-category' : ' Modulix' ,
500
+ ' pix-event-action' : ` Passage du module : ${ module .id } ` ,
501
+ ' pix-event-name' : ` Click sur le bouton 'no' de la flashcard : ${ firstCard .id } ` ,
502
+ });
503
+ assert .ok (true );
504
+ });
505
+ });
506
+
435
507
module (' when user opens an image alternative text modal' , function () {
436
508
test (' should push metrics event' , async function (assert ) {
437
509
// given
@@ -504,7 +576,7 @@ module('Integration | Component | Module | Passage', function (hooks) {
504
576
});
505
577
});
506
578
507
- module (' when user opens an video transcription modal' , function () {
579
+ module (' when user opens a video transcription modal' , function () {
508
580
test (' should push metrics event' , async function (assert ) {
509
581
// given
510
582
const metrics = this .owner .lookup (' service:metrics' );
@@ -578,7 +650,7 @@ module('Integration | Component | Module | Passage', function (hooks) {
578
650
});
579
651
});
580
652
581
- module (' when user click on next step button' , function () {
653
+ module (' when user clicks on next step button' , function () {
582
654
test (' should push event' , async function (assert ) {
583
655
// given
584
656
const store = this .owner .lookup (' service:store' );
@@ -903,7 +975,7 @@ module('Integration | Component | Module | Passage', function (hooks) {
903
975
});
904
976
});
905
977
906
- module (' When click on terminate button' , function () {
978
+ module (' when user clicks on terminate button' , function () {
907
979
test (' should push an event' , async function (assert ) {
908
980
// given
909
981
class PassageAdapterStub extends ApplicationAdapter {
0 commit comments