Skip to content

Commit 729b314

Browse files
committed
fix: remove client-side cookie setting to prevent duplication
1 parent b0b7b34 commit 729b314

File tree

2 files changed

+2
-25
lines changed

2 files changed

+2
-25
lines changed

src/i18n/languageManager.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { getConfig } from '../config';
2-
import { getCookies, handleRtl, LOCALE_CHANGED } from './lib';
1+
import { handleRtl, LOCALE_CHANGED } from './lib';
32
import { publish } from '../pubSub';
43
import { logError } from '../logging';
54
import { updateAuthenticatedUserPreferences, setSessionLanguage } from './languageApi';
@@ -23,10 +22,6 @@ export async function changeUserSessionLanguage(
2322
languageCode,
2423
forceReload = false,
2524
) {
26-
const cookies = getCookies();
27-
const cookieName = getConfig().LANGUAGE_PREFERENCE_COOKIE_NAME;
28-
cookies.set(cookieName, languageCode);
29-
3025
try {
3126
await updateAuthenticatedUserPreferences({ prefLang: languageCode });
3227
await setSessionLanguage(languageCode);

src/i18n/languageManager.test.js

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,19 @@
11
import { changeUserSessionLanguage } from './languageManager';
2-
import { getConfig } from '../config';
3-
import { getCookies, handleRtl, LOCALE_CHANGED } from './lib';
2+
import { handleRtl, LOCALE_CHANGED } from './lib';
43
import { logError } from '../logging';
54
import { publish } from '../pubSub';
65
import { updateAuthenticatedUserPreferences, setSessionLanguage } from './languageApi';
76

8-
jest.mock('../config');
97
jest.mock('./lib');
108
jest.mock('../logging');
119
jest.mock('../pubSub');
1210
jest.mock('./languageApi');
1311

14-
const LMS_BASE_URL = 'http://test.lms';
15-
const LANGUAGE_PREFERENCE_COOKIE_NAME = 'lang';
16-
1712
describe('languageManager', () => {
18-
let mockCookies;
1913
let mockReload;
2014

2115
beforeEach(() => {
2216
jest.clearAllMocks();
23-
getConfig.mockReturnValue({
24-
LMS_BASE_URL,
25-
LANGUAGE_PREFERENCE_COOKIE_NAME,
26-
});
27-
28-
mockCookies = { set: jest.fn() };
29-
getCookies.mockReturnValue(mockCookies);
3017

3118
mockReload = jest.fn();
3219
Object.defineProperty(window, 'location', {
@@ -42,11 +29,6 @@ describe('languageManager', () => {
4229
describe('changeUserSessionLanguage', () => {
4330
it('should perform complete language change process', async () => {
4431
await changeUserSessionLanguage('fr');
45-
46-
expect(getCookies().set).toHaveBeenCalledWith(
47-
LANGUAGE_PREFERENCE_COOKIE_NAME,
48-
'fr',
49-
);
5032
expect(updateAuthenticatedUserPreferences).toHaveBeenCalledWith({
5133
prefLang: 'fr',
5234
});

0 commit comments

Comments
 (0)