Skip to content

Commit

Permalink
feat: hide reboot button when embed auto-launches
Browse files Browse the repository at this point in the history
  • Loading branch information
nlepage committed Jul 2, 2024
1 parent f347a48 commit 4c7d28f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
24 changes: 13 additions & 11 deletions mon-pix/app/components/challenge-embed-simulator.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@
></iframe>
</div>

<div class="embed__reboot">
<button
type="button"
class="link link--grey embed-reboot__content"
aria-label={{t "pages.challenge.embed-simulator.actions.reset-label"}}
{{on "click" this.rebootSimulator}}
>
<FaIcon @icon="rotate-right" class="embed-reboot-content__icon" />
{{t "pages.challenge.embed-simulator.actions.reset"}}
</button>
</div>
{{#if this.isSimulatorRebootable}}
<div class="embed__reboot">
<button
type="button"
class="link link--grey embed-reboot__content"
aria-label={{t "pages.challenge.embed-simulator.actions.reset-label"}}
{{on "click" this.rebootSimulator}}
>
<FaIcon @icon="rotate-right" class="embed-reboot-content__icon" />
{{t "pages.challenge.embed-simulator.actions.reset"}}
</button>
</div>
{{/if}}
</div>
</div>
4 changes: 4 additions & 0 deletions mon-pix/app/components/challenge-embed-simulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export default class ChallengeEmbedSimulator extends Component {
@tracked
isSimulatorLaunched = false;

@tracked
isSimulatorRebootable = true;

@tracked
embedHeight;

Expand Down Expand Up @@ -55,6 +58,7 @@ export default class ChallengeEmbedSimulator extends Component {
}
if (isAutoLaunchMessage(data)) {
thisComponent.launchSimulator();
thisComponent.isSimulatorRebootable = false;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module('Integration | Component | Challenge Embed Simulator', function (hooks) {
});

module('when embed auto launches', function () {
test('should not display launch button', async function (assert) {
test('should not display launch button and reboot button', async function (assert) {
const event = new MessageEvent('message', {
data: { from: 'pix', type: 'auto-launch' },
origin: 'https://epreuves.pix.fr',
Expand All @@ -124,6 +124,7 @@ module('Integration | Component | Challenge Embed Simulator', function (hooks) {
await new Promise((resolve) => setTimeout(resolve, 0));

assert.dom(screen.queryByText(this.intl.t('pages.challenge.embed-simulator.actions.launch'))).doesNotExist();
assert.dom(screen.queryByText(this.intl.t('pages.challenge.embed-simulator.actions.reset'))).doesNotExist();
});
});
});
Expand Down

0 comments on commit 4c7d28f

Please sign in to comment.