Skip to content

Commit e5b2a14

Browse files
committed
✅(tests) adds customization for translations
Part of customization PoC
1 parent a47af11 commit e5b2a14

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

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

+61
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,67 @@ test.describe('Config', () => {
190190
.first(),
191191
).toBeAttached();
192192
});
193+
194+
test('it checks FRONTEND_CUSTOM_TRANSLATIONS_URL config', async ({
195+
page,
196+
}) => {
197+
// Create mock URL for translations
198+
const mockTranslationsUrl =
199+
'http://dummyhost.example.com/translations/custom.json';
200+
201+
// Mock the config endpoint to include the custom translations URL
202+
await page.route('**/api/v1.0/config/', async (route) => {
203+
const request = route.request();
204+
if (request.method().includes('GET')) {
205+
await route.fulfill({
206+
json: {
207+
...config,
208+
FRONTEND_CUSTOM_TRANSLATIONS_URL: mockTranslationsUrl,
209+
},
210+
});
211+
} else {
212+
await route.continue();
213+
}
214+
});
215+
216+
// Mock the translations endpoint to return our custom translations
217+
await page.route(mockTranslationsUrl, async (route) => {
218+
await route.fulfill({
219+
json: {
220+
en: {
221+
translation: {
222+
Docs: 'CustomDocsEn',
223+
},
224+
},
225+
fr: {
226+
translation: {
227+
Docs: 'CustomDocsFR',
228+
},
229+
},
230+
},
231+
status: 200,
232+
headers: {
233+
'Content-Type': 'application/json',
234+
'Access-Control-Allow-Origin': '*',
235+
},
236+
});
237+
});
238+
239+
// Intercept requests to the translations URL
240+
const translationsPromise = page.waitForRequest((req) => {
241+
return req.url() === mockTranslationsUrl;
242+
});
243+
244+
// Navigate to the page
245+
await page.goto('/');
246+
247+
// Verify that the application attempted to load the translations
248+
const translationsRequest = await translationsPromise;
249+
expect(translationsRequest).toBeTruthy();
250+
251+
// Extra test to prove that the translations were applied
252+
await expect(page.getByText('CustomDocsEn')).toBeAttached();
253+
});
193254
});
194255

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

0 commit comments

Comments
 (0)