From 4c6e4c6f457de023f2f4163ef7f06c98e5b79185 Mon Sep 17 00:00:00 2001 From: Eric Lim Date: Mon, 23 Dec 2024 12:03:40 +0100 Subject: [PATCH] feat(mon-pix): add on-expand-click in stepper Co-authored-by: Diane Cordier --- mon-pix/app/components/module/grain.gjs | 1 + mon-pix/app/components/module/step.gjs | 1 + mon-pix/app/components/module/stepper.gjs | 1 + .../components/module/passage_test.gjs | 45 +++++++++++++++++++ 4 files changed, 48 insertions(+) diff --git a/mon-pix/app/components/module/grain.gjs b/mon-pix/app/components/module/grain.gjs index 2aa2331915a..6d932e28c84 100644 --- a/mon-pix/app/components/module/grain.gjs +++ b/mon-pix/app/components/module/grain.gjs @@ -218,6 +218,7 @@ export default class ModuleGrain extends Component { @onVideoTranscriptionOpen={{@onVideoTranscriptionOpen}} @onVideoPlay={{@onVideoPlay}} @onFileDownload={{@onFileDownload}} + @onExpandToggle={{@onExpandToggle}} /> {{/if}} diff --git a/mon-pix/app/components/module/step.gjs b/mon-pix/app/components/module/step.gjs index 29792c3af3b..b9efec9779d 100644 --- a/mon-pix/app/components/module/step.gjs +++ b/mon-pix/app/components/module/step.gjs @@ -47,6 +47,7 @@ export default class ModulixStep extends Component { @onVideoTranscriptionOpen={{@onVideoTranscriptionOpen}} @onVideoPlay={{@onVideoPlay}} @onFileDownload={{@onFileDownload}} + @onExpandToggle={{@onExpandToggle}} /> {{/each}} diff --git a/mon-pix/app/components/module/stepper.gjs b/mon-pix/app/components/module/stepper.gjs index 2b351794121..b2907666f59 100644 --- a/mon-pix/app/components/module/stepper.gjs +++ b/mon-pix/app/components/module/stepper.gjs @@ -93,6 +93,7 @@ export default class ModulixStepper extends Component { @onVideoTranscriptionOpen={{@onVideoTranscriptionOpen}} @onVideoPlay={{@onVideoPlay}} @onFileDownload={{@onFileDownload}} + @onExpandToggle={{@onExpandToggle}} /> {{/each}} {{#if this.shouldDisplayNextButton}} diff --git a/mon-pix/tests/integration/components/module/passage_test.gjs b/mon-pix/tests/integration/components/module/passage_test.gjs index df7265afb55..312dc89b03b 100644 --- a/mon-pix/tests/integration/components/module/passage_test.gjs +++ b/mon-pix/tests/integration/components/module/passage_test.gjs @@ -1212,5 +1212,50 @@ module('Integration | Component | Module | Passage', function (hooks) { }); assert.ok(true); }); + + module('when expand is in a stepper', function () { + test('should push metrics event', async function (assert) { + // given + const store = this.owner.lookup('service:store'); + const expandElement = { + id: 'f5e7ce21-b71d-4054-8886-a4e9a17016ff', + type: 'expand', + isAnswerable: false, + title: 'Mon Expand', + content: "

Ceci est le contenu d'un expand dans mon module

", + }; + + const step = { elements: [expandElement] }; + const grain = store.createRecord('grain', { + title: 'Grain title', + type: 'discovery', + id: '123-abc', + components: [{ type: 'stepper', steps: [step] }], + }); + + const module = store.createRecord('module', { + title: 'Didacticiel', + grains: [grain], + transitionTexts: [], + }); + const passage = store.createRecord('passage'); + const metrics = this.owner.lookup('service:metrics'); + metrics.add = sinon.stub(); + + // when + const screen = await render(); + const details = screen.getByRole('group'); + await triggerEvent(details, 'toggle'); + + // then + sinon.assert.calledWithExactly(metrics.add, { + event: 'custom-event', + 'pix-event-category': 'Modulix', + 'pix-event-action': `Passage du module : ${module.id}`, + 'pix-event-name': `Click sur l'Expand : ${expandElement.id}`, + }); + assert.ok(true); + }); + }); }); });