diff --git a/high-level-tests/e2e-playwright/pages/pix-app/CertificationAccessCodePage.ts b/high-level-tests/e2e-playwright/pages/pix-app/CertificationAccessCodePage.ts index 8e9f83918f5..6aa2c936984 100644 --- a/high-level-tests/e2e-playwright/pages/pix-app/CertificationAccessCodePage.ts +++ b/high-level-tests/e2e-playwright/pages/pix-app/CertificationAccessCodePage.ts @@ -8,9 +8,6 @@ export class CertificationAccessCodePage { const languageDropdown = this.page.getByRole('button', { name: 'Langue de certification' }); if (await languageDropdown.isVisible()) { - await languageDropdown.click(); - await this.page.getByRole('option', { name: 'français - FR' }).click(); - const languageConfirmationCheckbox = this.page.getByRole('checkbox', { name: /Je confirme être à l'aise dans la langue sélectionnée/, }); diff --git a/mon-pix/app/components/certification-starter.gjs b/mon-pix/app/components/certification-starter.gjs index 8adee793ac7..9e31b63fb6d 100644 --- a/mon-pix/app/components/certification-starter.gjs +++ b/mon-pix/app/components/certification-starter.gjs @@ -43,6 +43,13 @@ export default class CertificationStarter extends Component { : VALID_CERTIFICATION_LOCALES.FRENCH_FRANCE; @tracked hasCandidateConfirmedLanguage = !this._isOrgDomain; + get _certificationLocale() { + if (this._isOrgDomain && this.args.model.certificationCandidate.hasPixPlusSubscription) { + return VALID_CERTIFICATION_LOCALES.FRENCH_FRANCE; + } + return this.selectedLanguage; + } + get accessCode() { return this.inputAccessCode.toUpperCase(); } @@ -134,7 +141,7 @@ export default class CertificationStarter extends Component { const newCertificationCourse = this.store.createRecord('certification-course', { accessCode: this.accessCode, sessionId: this.args.model.certificationCandidate.sessionId, - locale: this.selectedLanguage, + locale: this._certificationLocale, }); try { await newCertificationCourse.save(); diff --git a/mon-pix/tests/integration/components/certification-starter-test.gjs b/mon-pix/tests/integration/components/certification-starter-test.gjs index 1d46bc3f8df..0687278a067 100644 --- a/mon-pix/tests/integration/components/certification-starter-test.gjs +++ b/mon-pix/tests/integration/components/certification-starter-test.gjs @@ -351,6 +351,43 @@ module('Integration | Component | certification-starter', function (hooks) { assert.ok(certificationCourse.save.calledOnce); }); + test('should submit with fr-fr locale when candidate has a Pix+ subscription on org domain', async function (assert) { + // given + const certificationCourse = { + id: '456', + save: sinon.stub(), + deleteRecord: sinon.stub(), + }; + + const createRecordStub = sinon.stub().returns(certificationCourse); + + class StoreServiceStub extends Service { + createRecord = createRecordStub; + } + + this.owner.register('service:store', StoreServiceStub); + + stubFranceDomain(this.owner, false); + + model = { + certificationCandidate: { hasStartedTest: false, sessionId: 123, hasPixPlusSubscription: true }, + }; + const screen = await renderComponent(); + await fillAccessCode(screen, 'ABC123'); + await confirmLanguageSelection(screen); + + // when + await submitForm(); + + // then + sinon.assert.calledWithExactly(createRecordStub, 'certification-course', { + accessCode: 'ABC123', + sessionId: 123, + locale: 'fr-fr', + }); + assert.ok(true); + }); + module('when the creation of certification course is in error', function (hooks) { hooks.beforeEach(function () { class RouterServiceStub extends Service {