Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ 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();

if (await languageDropdown.isEnabled()) {
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/,
});
Expand Down
9 changes: 8 additions & 1 deletion mon-pix/app/components/certification-starter.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading