Skip to content

Commit

Permalink
馃寪(lib_components) add the language in the request header
Browse files Browse the repository at this point in the history
The language sent to the backend was the browser one, we now send the
the language setted in the app to get the backend messages
internationalized.
  • Loading branch information
AntoLC committed Sep 4, 2023
1 parent f767f1b commit 8ffa619
Show file tree
Hide file tree
Showing 103 changed files with 339 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Add the language to header of most of the http request (#2394)

## [4.3.1] - 2023-08-31

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ describe('<DashboardInstructor />', () => {
headers: {
Authorization: 'Bearer json web token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'PATCH',
body: JSON.stringify({ title: 'My file depository title updated' }),
Expand Down Expand Up @@ -346,6 +347,7 @@ describe('<DashboardInstructor />', () => {
headers: {
Authorization: 'Bearer json web token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'PATCH',
body: JSON.stringify({
Expand Down Expand Up @@ -401,6 +403,7 @@ describe('<DashboardInstructor />', () => {
headers: {
Authorization: 'Bearer json web token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'PATCH',
body: JSON.stringify({
Expand Down Expand Up @@ -453,6 +456,7 @@ describe('<DashboardInstructor />', () => {
headers: {
Authorization: 'Bearer json web token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'PATCH',
body: JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('<DepositedFileRow />', () => {
headers: {
Authorization: 'Bearer json web token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'PATCH',
body: JSON.stringify({ read: true }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toEqual(fileDepositories);
Expand All @@ -82,6 +83,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toEqual(undefined);
Expand Down Expand Up @@ -115,6 +117,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toEqual(fileDepository);
Expand Down Expand Up @@ -143,6 +146,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toEqual(undefined);
Expand Down Expand Up @@ -172,6 +176,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'POST',
body: JSON.stringify({
Expand Down Expand Up @@ -204,6 +209,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'POST',
body: JSON.stringify({
Expand Down Expand Up @@ -245,6 +251,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'PATCH',
body: JSON.stringify({
Expand Down Expand Up @@ -279,6 +286,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'PATCH',
body: JSON.stringify({
Expand Down Expand Up @@ -319,6 +327,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toEqual(depositedFiles.slice(0, 3));
Expand Down Expand Up @@ -353,6 +362,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toEqual(depositedFiles.slice(3, 4));
Expand Down Expand Up @@ -387,6 +397,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toEqual(undefined);
Expand Down Expand Up @@ -426,6 +437,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'PATCH',
body: JSON.stringify({
Expand Down Expand Up @@ -467,6 +479,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'PATCH',
body: JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('sideEffects/createDepositedFile', () => {
expect(fetchArgs.headers).toEqual({
Authorization: 'Bearer token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
});
expect(fetchArgs.method).toEqual('POST');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe('<DashboardDocument />', () => {
);
expect(fetchMock.lastCall()![1]!.headers).toEqual({
Authorization: 'Bearer cool_token_m8',
'Accept-Language': 'en',
});
screen.getByText('Processing');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe('<PlaylistPortability />', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});

Expand Down Expand Up @@ -101,6 +102,7 @@ describe('<PlaylistPortability />', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'PATCH',
body: JSON.stringify({
Expand All @@ -117,6 +119,7 @@ describe('<PlaylistPortability />', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});

Expand Down
14 changes: 14 additions & 0 deletions src/frontend/apps/lti_site/data/queries/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toEqual(organization);
Expand All @@ -80,6 +81,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toBeUndefined();
Expand All @@ -106,6 +108,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toEqual(playlist);
Expand All @@ -131,6 +134,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toEqual(undefined);
Expand Down Expand Up @@ -160,6 +164,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'PATCH',
body: JSON.stringify({
Expand Down Expand Up @@ -191,6 +196,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'PATCH',
body: JSON.stringify({
Expand Down Expand Up @@ -221,6 +227,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toEqual(playlists);
Expand All @@ -245,6 +252,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toEqual(undefined);
Expand Down Expand Up @@ -278,6 +286,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toEqual(thumbnail);
Expand Down Expand Up @@ -309,6 +318,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toEqual(undefined);
Expand Down Expand Up @@ -337,6 +347,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'POST',
body: JSON.stringify({
Expand Down Expand Up @@ -370,6 +381,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'POST',
body: JSON.stringify({
Expand Down Expand Up @@ -405,6 +417,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'POST',
body: JSON.stringify({
Expand Down Expand Up @@ -441,6 +454,7 @@ describe('queries', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'POST',
body: JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('sideEffects/deleteTimedTextTrack', () => {

expect(fetchMock.lastCall()![1]!.headers).toEqual({
Authorization: 'Bearer some token',
'Accept-Language': 'en',
});
expect(response).toBe(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('useConfig', () => {
expect(fetchMock.lastCall()![1]).toEqual({
headers: {
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
});
expect(result.current.data).toEqual({
Expand All @@ -55,6 +56,7 @@ describe('useConfig', () => {
expect(fetchMock.lastCall()![0]).toEqual('/api/config/');
expect(fetchMock.lastCall()![1]).toEqual({
headers: {
'Accept-Language': 'en',
'Content-Type': 'application/json',
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('features/PortabilityRequests/api/useLtiUserAssociations', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'POST',
body: JSON.stringify({
Expand Down Expand Up @@ -65,6 +66,7 @@ describe('features/PortabilityRequests/api/useLtiUserAssociations', () => {
headers: {
Authorization: 'Bearer some token',
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'POST',
body: JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('features/Authentication/api/basicLogin', () => {
expect(fetchMock.lastCall()![1]).toEqual({
headers: {
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'POST',
body: JSON.stringify({
Expand Down Expand Up @@ -70,6 +71,7 @@ describe('features/Authentication/api/basicLogin', () => {
expect(fetchMock.lastCall()![1]).toEqual({
headers: {
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'POST',
body: JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('features/Authentication/api/usePasswordReset', () => {
expect(fetchMock.lastCall()![1]).toEqual({
headers: {
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'POST',
body: JSON.stringify({
Expand Down Expand Up @@ -64,6 +65,7 @@ describe('features/Authentication/api/usePasswordReset', () => {
expect(fetchMock.lastCall()![1]).toEqual({
headers: {
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'POST',
body: JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('features/Authentication/api/usePasswordResetConfirm', () => {
expect(fetchMock.lastCall()![1]).toEqual({
headers: {
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'POST',
body: JSON.stringify({
Expand Down Expand Up @@ -74,6 +75,7 @@ describe('features/Authentication/api/usePasswordResetConfirm', () => {
expect(fetchMock.lastCall()![1]).toEqual({
headers: {
'Content-Type': 'application/json',
'Accept-Language': 'en',
},
method: 'POST',
body: JSON.stringify({
Expand Down
Loading

0 comments on commit 8ffa619

Please sign in to comment.