diff --git a/lib/management/user.test.ts b/lib/management/user.test.ts index 13c3ebdfb..c716272e4 100644 --- a/lib/management/user.test.ts +++ b/lib/management/user.test.ts @@ -308,6 +308,50 @@ describe('Management User', () => { }); }); + it('should send locale via the positional arguments overload', async () => { + const httpResponse = { + ok: true, + json: () => mockMgmtUserResponse, + clone: () => ({ + json: () => Promise.resolve(mockMgmtUserResponse), + }), + status: 200, + }; + mockHttpClient.post.mockResolvedValue(httpResponse); + + await management.user.invite( + 'loginId', + 'a@b.c', + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + 'en-US', + ); + + expect(mockHttpClient.post).toHaveBeenCalledWith( + apiPaths.user.create, + expect.objectContaining({ + loginId: 'loginId', + email: 'a@b.c', + locale: 'en-US', + invite: true, + }), + ); + }); + it('should send the correct request and receive correct response with options argument', async () => { const httpResponse = { ok: true, @@ -326,6 +370,7 @@ describe('Management User', () => { inviteUrl: 'https://invite.me', sendMail: true, templateOptions: { k1: 'v1' }, + locale: 'en-US', }); expect(mockHttpClient.post).toHaveBeenCalledWith(apiPaths.user.create, { @@ -337,6 +382,7 @@ describe('Management User', () => { inviteUrl: 'https://invite.me', sendMail: true, templateOptions: { k1: 'v1' }, + locale: 'en-US', }); expect(resp).toEqual({ @@ -407,6 +453,10 @@ describe('Management User', () => { ], 'https://invite.me', true, + undefined, + undefined, + undefined, + 'fr-FR', ); expect(mockHttpClient.post).toHaveBeenCalledWith(apiPaths.user.createBatch, { @@ -437,6 +487,7 @@ describe('Management User', () => { invite: true, inviteUrl: 'https://invite.me', sendMail: true, + locale: 'fr-FR', }); expect(resp).toEqual({ diff --git a/lib/management/user.ts b/lib/management/user.ts index 29fcc0be1..f7b0ec850 100644 --- a/lib/management/user.ts +++ b/lib/management/user.ts @@ -230,6 +230,7 @@ const withUser = (httpClient: HttpClient) => { sendSMS?: boolean; // send invite via text message, default is according to project settings templateOptions?: TemplateOptions; templateId?: string; + locale?: string; // locale for the invite message }, ): Promise>; function invite( @@ -251,6 +252,7 @@ const withUser = (httpClient: HttpClient) => { familyName?: string, additionalLoginIds?: string[], templateId?: string, + locale?: string, // locale for the invite message ): Promise>; function invite( @@ -272,6 +274,7 @@ const withUser = (httpClient: HttpClient) => { familyName?: string, additionalLoginIds?: string[], templateId?: string, + locale?: string, // locale for the invite message ): Promise> { // We support both the old and new parameters forms of invite user // 1. The new form - invite(loginIdOrUserId, { email, phone, ... }}) @@ -298,6 +301,7 @@ const withUser = (httpClient: HttpClient) => { sendSMS, additionalLoginIds, templateId, + locale, } : { loginId: loginIdOrUserId, @@ -511,6 +515,7 @@ const withUser = (httpClient: HttpClient) => { sendSMS?: boolean, // send invite via text message, default is according to project settings templateOptions?: TemplateOptions, templateId?: string, + locale?: string, // locale for the invite message ): Promise> => transformResponse( httpClient.post(apiPaths.user.createBatch, { @@ -521,6 +526,7 @@ const withUser = (httpClient: HttpClient) => { sendSMS, templateOptions, templateId, + locale, }), (data) => data, ),