From e87ef882d5d7978b9cbc1b1054b25464be7ea4b6 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 11 Aug 2024 15:38:47 +0300 Subject: [PATCH] client: Fix restoring language on mobile --- integration-tests/i18n.spec.ts | 19 ++++++++++++++++++- src/public/app/mobile.js | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/integration-tests/i18n.spec.ts b/integration-tests/i18n.spec.ts index b7fc6f95b..0e700ad47 100644 --- a/integration-tests/i18n.spec.ts +++ b/integration-tests/i18n.spec.ts @@ -15,7 +15,7 @@ test("User can change language from settings", async ({ page }) => { // Check that the default value (English) is set. await expect(page.locator('#center-pane')).toContainText('Theme'); const languageCombobox = await page.getByRole('combobox').first(); - expect(languageCombobox).toHaveValue("en"); + await expect(languageCombobox).toHaveValue("en"); // Select Chinese and ensure the translation is set. languageCombobox.selectOption("cn"); @@ -23,4 +23,21 @@ test("User can change language from settings", async ({ page }) => { // Select English again. languageCombobox.selectOption("en"); +}); + +test("Restores language on start-up on desktop", async ({ page, context }) => { + await page.goto('http://localhost:8082'); + await expect(page.locator('#launcher-pane').first()).toContainText("Open New Window"); +}); + +test("Restores language on start-up on mobile", async ({ page, context }) => { + await context.addCookies([ + { + url: "http://localhost:8082", + name: "trilium-device", + value: "mobile" + } + ]); + await page.goto('http://localhost:8082'); + await expect(page.locator('#launcher-pane div').first()).toContainText("Open New Window"); }); \ No newline at end of file diff --git a/src/public/app/mobile.js b/src/public/app/mobile.js index 3b03c3322..1c95324f5 100644 --- a/src/public/app/mobile.js +++ b/src/public/app/mobile.js @@ -3,7 +3,7 @@ import glob from "./services/glob.js"; glob.setupGlobs() -appContext.earlyInit(); +await appContext.earlyInit(); // A dynamic import is required for layouts since they initialize components which require translations. const MobileLayout = (await import("./layouts/mobile_layout.js")).default;