Skip to content

Commit 3019ec1

Browse files
committed
✅(tests) adds customization for translations
Part of customization PoC
1 parent 5f4b3a5 commit 3019ec1

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

src/frontend/apps/e2e/__tests__/app-impress/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const CONFIG = {
77
ENVIRONMENT: 'development',
88
FRONTEND_CSS_URL: null,
99
FRONTEND_HOMEPAGE_FEATURE_ENABLED: true,
10+
FRONTEND_CUSTOM_TRANSLATIONS_URL: null,
1011
FRONTEND_FOOTER_FEATURE_ENABLED: true,
1112
FRONTEND_THEME: 'default',
1213
MEDIA_BASE_URL: 'http://localhost:8083',

src/frontend/apps/e2e/__tests__/app-impress/config.spec.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,67 @@ test.describe('Config', () => {
170170
.first(),
171171
).toBeAttached();
172172
});
173+
174+
test('it checks FRONTEND_CUSTOM_TRANSLATIONS_URL config', async ({
175+
page,
176+
}) => {
177+
// Create mock URL for translations
178+
const mockTranslationsUrl =
179+
'http://dummyhost.example.com/translations/custom.json';
180+
181+
// Mock the config endpoint to include the custom translations URL
182+
await page.route('**/api/v1.0/config/', async (route) => {
183+
const request = route.request();
184+
if (request.method().includes('GET')) {
185+
await route.fulfill({
186+
json: {
187+
...config,
188+
FRONTEND_CUSTOM_TRANSLATIONS_URL: mockTranslationsUrl,
189+
},
190+
});
191+
} else {
192+
await route.continue();
193+
}
194+
});
195+
196+
// Mock the translations endpoint to return our custom translations
197+
await page.route(mockTranslationsUrl, async (route) => {
198+
await route.fulfill({
199+
json: {
200+
en: {
201+
translation: {
202+
Docs: 'CustomDocsEn',
203+
},
204+
},
205+
fr: {
206+
translation: {
207+
Docs: 'CustomDocsFR',
208+
},
209+
},
210+
},
211+
status: 200,
212+
headers: {
213+
'Content-Type': 'application/json',
214+
'Access-Control-Allow-Origin': '*',
215+
},
216+
});
217+
});
218+
219+
// Intercept requests to the translations URL
220+
const translationsPromise = page.waitForRequest((req) => {
221+
return req.url() === mockTranslationsUrl;
222+
});
223+
224+
// Navigate to the page
225+
await page.goto('/');
226+
227+
// Verify that the application attempted to load the translations
228+
const translationsRequest = await translationsPromise;
229+
expect(translationsRequest).toBeTruthy();
230+
231+
// Extra test to prove that the translations were applied
232+
await expect(page.getByText('CustomDocsEn')).toBeAttached();
233+
});
173234
});
174235

175236
test.describe('Config: Not loggued', () => {

0 commit comments

Comments
 (0)