Skip to content

Commit 5bf04db

Browse files
🐛 mon-pix: fix focus and time information page when challenge is both focused and timed
Co-authored-by: Andreia Pena Ferreira <[email protected]>
1 parent 879320e commit 5bf04db

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

mon-pix/app/controllers/assessments/challenge.js

+17
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export default class ChallengeController extends Controller {
6060
get couldDisplayInfoAlert() {
6161
return (
6262
!this.hasFocusedOutOfWindow &&
63+
this.displayChallenge &&
6364
!this.model.answer &&
6465
this.model.challenge.focused &&
6566
!this.model.assessment.hasFocusedOutChallenge
@@ -163,6 +164,13 @@ export default class ChallengeController extends Controller {
163164
return true;
164165
}
165166

167+
if (this._isTimedChallenge && this._isFocusedCertificationChallenge) {
168+
return !!(
169+
(this.hasConfirmedFocusChallengeWarningScreen && this.hasUserConfirmedTimedChallengeWarning) ||
170+
this.model.assessment.hasTimeoutChallenge
171+
);
172+
}
173+
166174
if (this._isTimedChallenge) {
167175
if (this.hasUserConfirmedTimedChallengeWarning || this.model.assessment.hasTimeoutChallenge) return true;
168176
}
@@ -201,6 +209,15 @@ export default class ChallengeController extends Controller {
201209
}
202210

203211
get displayTimedChallengeInstructions() {
212+
if (this.isTimedChallengeWithoutAnswer && this.isFocusedCertificationChallengeWithoutAnswer) {
213+
return (
214+
this.hasConfirmedFocusChallengeWarningScreen &&
215+
this.isTimedChallengeWithoutAnswer &&
216+
!this.hasUserConfirmedTimedChallengeWarning &&
217+
!this.model.assessment.hasTimeoutChallenge
218+
);
219+
}
220+
204221
return (
205222
this.isTimedChallengeWithoutAnswer &&
206223
!this.hasUserConfirmedTimedChallengeWarning &&

mon-pix/tests/acceptance/challenge-item-test.js

+58
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,64 @@ module('Acceptance | Displaying a challenge of any type', function (hooks) {
572572
assert.dom(screen.getByText('Mode focus')).exists();
573573
});
574574
});
575+
576+
module('when a challenge is focused and timed', function () {
577+
test('should display focus first then timer information page', async function (assert) {
578+
// given
579+
const user = server.create('user', 'withEmail');
580+
await authenticate(user);
581+
582+
const focusedCertificationChallengeWarningManager = this.owner.lookup(
583+
'service:focused-certification-challenge-warning-manager',
584+
);
585+
focusedCertificationChallengeWarningManager.reset();
586+
587+
assessment = server.create('assessment', 'ofCertificationType');
588+
server.create('challenge', 'forCertification', 'QCM', 'withFocused', { timer: 60 });
589+
590+
const certificationCourse = server.create('certification-course', {
591+
accessCode: 'ABCD12',
592+
sessionId: 1,
593+
nbChallenges: 2,
594+
firstName: 'Alin',
595+
lastName: 'Cendy',
596+
});
597+
assessment = certificationCourse.assessment;
598+
599+
// when
600+
const screen = await visit(`/assessments/${assessment.id}/challenges/0`);
601+
602+
// then
603+
assert
604+
.dom(
605+
screen.getByRole('heading', {
606+
name: 'Mode focus',
607+
level: 1,
608+
}),
609+
)
610+
.exists();
611+
612+
// when
613+
await click(screen.getByRole('button', { name: 'Je suis prêt' }));
614+
615+
// then
616+
assert
617+
.dom(
618+
screen.getByRole('heading', {
619+
name: 'Vous disposerez de 1 minute pour réussir la question suivante.',
620+
level: 1,
621+
}),
622+
)
623+
.exists();
624+
625+
// when
626+
await click(screen.getByRole('button', { name: `Commencer l'épreuve` }));
627+
628+
// then
629+
assert.dom(screen.getByRole('heading', { name: 'Mode Focus', level: 3 })).exists();
630+
assert.dom(screen.getByText('1:00')).exists();
631+
});
632+
});
575633
});
576634

577635
module('when assessment is v2 certification', function (hooks) {

0 commit comments

Comments
 (0)