From 8a227d9fa100f1500d6205f0b44b4e60542cc470 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Wed, 31 Aug 2022 13:28:36 -0700 Subject: [PATCH] feat: add displayLang test (#5495) * feat(e2e): add language extension to setup This adds a slimmed-down version of the Spanish Language Pack and also adds a `languagepacks.json` to the e2e `workspaceDir` which allows use to run a test suite passing the `--locale es` flags to simulate a different display language. * feat: add e2e test for display language patch This tests loading code-server in Spanish using the `--locale` flag. * fixup!: use JSON.stringify for readability * fixup!: add comment about langaugepacks temp fix * fixup!: slim down translations * fixup!: slim down package.json for lang. ext --- test/e2e/displayLang.test.ts | 14 ++++++++ .../package.json | 32 +++++++++++++++++++ .../translations/main.i18n.json | 15 +++++++++ test/e2e/models/CodeServer.ts | 24 ++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 test/e2e/displayLang.test.ts create mode 100644 test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/package.json create mode 100644 test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/translations/main.i18n.json diff --git a/test/e2e/displayLang.test.ts b/test/e2e/displayLang.test.ts new file mode 100644 index 000000000..d440d8a95 --- /dev/null +++ b/test/e2e/displayLang.test.ts @@ -0,0 +1,14 @@ +import * as path from "path" +import { describe, test, expect } from "./baseFixture" + +// Given a code-server environment with Spanish Language Pack extension installed +// and a languagepacks.json in the data-dir +describe("--locale es", ["--extensions-dir", path.join(__dirname, "./extensions"), "--locale", "es"], {}, () => { + test("should load code-server in Spanish", async ({ codeServerPage }) => { + // When + const visible = await codeServerPage.page.isVisible("text=Explorador") + + // Then + expect(visible).toBe(true) + }) +}) diff --git a/test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/package.json b/test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/package.json new file mode 100644 index 000000000..4f4aff17b --- /dev/null +++ b/test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/package.json @@ -0,0 +1,32 @@ +{ + "name": "vscode-language-pack-es", + "displayName": "Spanish Language Pack for Visual Studio Code", + "description": "Language pack extension for Spanish", + "version": "1.70.0", + "publisher": "MS-CEINTL", + "repository": { + "type": "git", + "url": "https://github.com/Microsoft/vscode-loc" + }, + "engines": { + "vscode": "^1.70.0" + }, + "categories": [ + "Language Packs" + ], + "contributes": { + "localizations": [ + { + "languageId": "es", + "languageName": "Spanish", + "localizedLanguageName": "español", + "translations": [ + { + "id": "vscode", + "path": "./translations/main.i18n.json" + } + ] + } + ] + } +} diff --git a/test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/translations/main.i18n.json b/test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/translations/main.i18n.json new file mode 100644 index 000000000..e0f43689c --- /dev/null +++ b/test/e2e/extensions/ms-ceintl.vscode-language-pack-es-1.70.0/translations/main.i18n.json @@ -0,0 +1,15 @@ +{ + "": [ + "--------------------------------------------------------------------------------------------", + "Copyright (c) Microsoft Corporation. All rights reserved.", + "Licensed under the MIT License. See License.txt in the project root for license information.", + "--------------------------------------------------------------------------------------------", + "Do not edit this file. It is machine generated." + ], + "version": "1.0.0", + "contents": { + "vs/workbench/contrib/files/browser/explorerViewlet": { + "explore": "Explorador" + } + } +} diff --git a/test/e2e/models/CodeServer.ts b/test/e2e/models/CodeServer.ts index d5c00b96e..5e5806670 100644 --- a/test/e2e/models/CodeServer.ts +++ b/test/e2e/models/CodeServer.ts @@ -88,6 +88,30 @@ export class CodeServer { }), "utf8", ) + + const extensionsDir = path.join(__dirname, "../extensions") + const languagepacksContent = { + es: { + hash: "8d919a946475223861fa0c62665a4c50", + extensions: [ + { + extensionIdentifier: { + id: "ms-ceintl.vscode-language-pack-es", + uuid: "47e020a1-33db-4cc0-a1b4-42f97781749a", + }, + version: "1.70.0", + }, + ], + translations: { + vscode: `${extensionsDir}/ms-ceintl.vscode-language-pack-es-1.70.0/translations/main.i18n.json`, + }, + label: "español", + }, + } + + // NOTE@jsjoeio - code-server should automatically generate the languagepacks.json for + // using different display languages. This is a temporary workaround until we fix that. + await fs.writeFile(path.join(dir, "languagepacks.json"), JSON.stringify(languagepacksContent)) return dir }