diff --git a/src/web/app/pages-static/request-page/instructor-request-form/instructor-request-form.component.spec.ts b/src/web/app/pages-static/request-page/instructor-request-form/instructor-request-form.component.spec.ts index a0c9bbac2f2..ff055296c3c 100644 --- a/src/web/app/pages-static/request-page/instructor-request-form/instructor-request-form.component.spec.ts +++ b/src/web/app/pages-static/request-page/instructor-request-form/instructor-request-form.component.spec.ts @@ -114,4 +114,24 @@ describe('InstructorRequestFormComponent', () => { expect(accountService.createAccountRequest).toHaveBeenCalledTimes(1); expect(accountService.createAccountRequest).toHaveBeenCalledWith(expect.objectContaining(typicalCreateRequest)); }); + + it('should auto-unify country when applicable', () => { + jest.spyOn(accountService, 'createAccountRequest').mockReturnValue( + new Observable((subscriber) => { subscriber.next(); })); + const unitedStatesModel: InstructorRequestFormModel = { + ...typicalModel, + country: 'españa', + }; + const unitedStatesCreateRequest: AccountCreateRequest = { + ...typicalCreateRequest, + instructorInstitution: `${unitedStatesModel.institution}, Spain`, + }; + fillFormWith(unitedStatesModel); + component.onSubmit(); + + expect(accountService.createAccountRequest).toHaveBeenCalledTimes(1); + expect(accountService.createAccountRequest).toHaveBeenCalledWith( + expect.objectContaining(unitedStatesCreateRequest)); + }); + }); diff --git a/src/web/app/pages-static/request-page/instructor-request-form/instructor-request-form.component.ts b/src/web/app/pages-static/request-page/instructor-request-form/instructor-request-form.component.ts index 7caa14e3bd9..a5fd36e8e38 100644 --- a/src/web/app/pages-static/request-page/instructor-request-form/instructor-request-form.component.ts +++ b/src/web/app/pages-static/request-page/instructor-request-form/instructor-request-form.component.ts @@ -115,11 +115,24 @@ export class InstructorRequestFormComponent { const name = this.name.value!.trim(); const email = this.email.value!.trim(); const comments = this.comments.value!.trim(); - + // Country Mapping + const countryMapping: { [key: string]: string } = { + 'united states': 'USA', + us: 'USA', + america: 'USA', + uk: 'United Kingdom', + deutschland: 'Germany', + 'united arab emirates': 'UAE', + españa: 'Spain', + méxico: 'Mexico', + belgië: 'Belgium', + holland: 'Netherlands', + }; // Combine country and institution const country = this.country.value!.trim(); + const mappedCountry = countryMapping[country.toLowerCase()] || country; const institution = this.institution.value!.trim(); - const combinedInstitution = `${institution}, ${country}`; + const combinedInstitution = `${institution}, ${mappedCountry}`; const requestData: AccountCreateRequest = { instructorEmail: email,