diff --git a/.github/workflows/template-main.yaml b/.github/workflows/template-main.yaml index 940227b1a..3e09aaaab 100644 --- a/.github/workflows/template-main.yaml +++ b/.github/workflows/template-main.yaml @@ -51,6 +51,9 @@ jobs: - name: 🔧 Install - Test Project run: npm install --workspace=extester-test + - name: 🔧 Install RU langauge pack + run: code --install-extension ms-ceintl.vscode-language-pack-ru + - name: 🔍 Run Tests (macOS, windows) if: ${{ ! startsWith(matrix.os, 'ubuntu') }} run: npm test diff --git a/packages/extester/src/browser.ts b/packages/extester/src/browser.ts index 1631025f5..774135b6e 100644 --- a/packages/extester/src/browser.ts +++ b/packages/extester/src/browser.ts @@ -35,6 +35,7 @@ export class VSBrowser { private codeVersion: string; private releaseType: ReleaseQuality; private logLevel: logging.Level; + private locale: string; private static _instance: VSBrowser; private readonly _startTimestamp: string; @@ -43,13 +44,20 @@ export class VSBrowser { return `${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}T${pad(date.getHours())}${pad(date.getMinutes())}${pad(date.getSeconds())}`; } - constructor(codeVersion: string, releaseType: ReleaseQuality, customSettings: object = {}, logLevel: logging.Level = logging.Level.INFO) { + constructor( + codeVersion: string, + releaseType: ReleaseQuality, + customSettings: object = {}, + logLevel: logging.Level = logging.Level.INFO, + locale: string = '', + ) { this.storagePath = process.env.TEST_RESOURCES ? process.env.TEST_RESOURCES : path.resolve(DEFAULT_STORAGE_FOLDER); this.extensionsFolder = process.env.EXTENSIONS_FOLDER ? process.env.EXTENSIONS_FOLDER : undefined; this.customSettings = customSettings; this.codeVersion = codeVersion; this.releaseType = releaseType; this.logLevel = logLevel; + this.locale = locale; this._startTimestamp = this.formatTimestamp(new Date()); VSBrowser._instance = this; @@ -87,7 +95,12 @@ export class VSBrowser { fs.writeJSONSync(path.join(userSettings, 'settings.json'), defaultSettings); console.log(`Writing code settings to ${path.join(userSettings, 'settings.json')}`); - const args = ['--no-sandbox', '--disable-dev-shm-usage', `--user-data-dir=${path.join(this.storagePath, 'settings')}`]; + const args = ['--no-sandbox', '--disable-dev-shm-usage', `--user-data-dir=${path.join(this.storagePath, 'settings')}`]; // sem pridam locale + + if (this.locale) { + console.log('locale is in args with value ' + this.locale); + args.push(`--locale ${this.locale}`); + } if (this.extensionsFolder) { args.push(`--extensions-dir=${this.extensionsFolder}`); @@ -102,10 +115,14 @@ export class VSBrowser { args.push(`--extensionDevelopmentPath=${process.env.EXTENSION_DEV_PATH}`); } + console.log('args', args); + let options = new Options().setChromeBinaryPath(codePath).addArguments(...args) as any; options['options_'].windowTypes = ['webview']; options = options as Options; + console.log('options', options); + const prefs = new logging.Preferences(); prefs.setLevel(logging.Type.DRIVER, this.logLevel); options.setLoggingPrefs(prefs); @@ -117,6 +134,9 @@ export class VSBrowser { } console.log('Launching browser...'); + // Print the full launch command for debugging + console.log('Launching VS Code with command:', `"${codePath}" ${args.join(' ')}`); + this._driver = await new Builder() .setChromeService(new ServiceBuilder(chromeDriverBinaryPath)) .forBrowser(Browser.CHROME) diff --git a/packages/extester/src/cli.ts b/packages/extester/src/cli.ts index c32947571..b618331fe 100644 --- a/packages/extester/src/cli.ts +++ b/packages/extester/src/cli.ts @@ -129,6 +129,7 @@ program .option('-f, --offline', 'Attempt to run without internet connection, make sure to have all requirements downloaded', false) .option('-C, --coverage', 'Enable code coverage using c8') .option('-r, --open_resource ', 'Open resources in VS Code. Multiple files and folders can be specified.') + .option('-L, --locale ', 'to be defined') .action( withErrors(async (testFiles, cmd) => { const extest = new ExTester(cmd.storage, codeStream(cmd.type), cmd.extensions_dir, cmd.coverage); @@ -140,6 +141,7 @@ program logLevel: cmd.log_level, offline: cmd.offline, resources: cmd.open_resource ?? [], + locale: cmd.locale, }); }), ); @@ -161,6 +163,7 @@ program .option('-C, --coverage', 'Enable code coverage using c8') .option('-r, --open_resource ', 'Open resources in VS Code. Multiple files and folders can be specified.') .option('-n, --no_cache', 'Skip using cached version and download fresh copy without caching it', false) + .option('-L, --locale ', 'to be defined22') .action( withErrors(async (testFiles, cmd) => { const extest = new ExTester(cmd.storage, codeStream(cmd.type), cmd.extensions_dir, cmd.coverage); @@ -178,6 +181,7 @@ program config: cmd.mocha_config, logLevel: cmd.log_level, resources: cmd.open_resource ?? [], + locale: cmd.locale, }, ); }), diff --git a/packages/extester/src/extester.ts b/packages/extester/src/extester.ts index 652c141e3..1c05bac13 100644 --- a/packages/extester/src/extester.ts +++ b/packages/extester/src/extester.ts @@ -232,6 +232,10 @@ export class ExTester { setupOptions: Omit = DEFAULT_SETUP_OPTIONS, runOptions: Omit = DEFAULT_RUN_OPTIONS, ): Promise { + console.log('setupAndRunTests'); + console.log('setup options:', JSON.stringify(setupOptions, null, 2)); + console.log('run options:', JSON.stringify(runOptions, null, 2)); + await this.setupRequirements({ ...setupOptions, vscodeVersion }, runOptions.offline, runOptions.cleanup); return await this.runTests(testFilesPattern, { ...runOptions, @@ -247,6 +251,9 @@ export class ExTester { * @returns Promise resolving to the mocha process exit code - 0 for no failures, 1 otherwise */ async runTests(testFilesPattern: string | string[], runOptions: RunOptions = DEFAULT_RUN_OPTIONS): Promise { + console.log('runTests'); + console.log('run options:', JSON.stringify(runOptions, null, 2)); + runOptions.vscodeVersion = loadCodeVersion(runOptions.vscodeVersion); const patterns = typeof testFilesPattern === 'string' ? [testFilesPattern] : testFilesPattern; return await this.code.runTests(patterns, runOptions); diff --git a/packages/extester/src/suite/runner.ts b/packages/extester/src/suite/runner.ts index 51898c2b6..a274e2d16 100644 --- a/packages/extester/src/suite/runner.ts +++ b/packages/extester/src/suite/runner.ts @@ -38,8 +38,17 @@ export class VSRunner { private cleanup: boolean; private tmpLink = path.join(os.tmpdir(), 'extest-code'); private releaseType: ReleaseQuality; - - constructor(bin: string, codeVersion: string, customSettings: object = {}, cleanup: boolean = false, releaseType: ReleaseQuality, config?: string) { + private locale: string | undefined; + + constructor( + bin: string, + codeVersion: string, + customSettings: object = {}, + cleanup: boolean = false, + releaseType: ReleaseQuality, + config?: string, + locale?: string, + ) { const conf = this.loadConfig(config); this.mocha = new Mocha(conf); this.chromeBin = bin; @@ -47,6 +56,7 @@ export class VSRunner { this.codeVersion = codeVersion; this.cleanup = cleanup; this.releaseType = releaseType; + this.locale = locale; } /** @@ -58,7 +68,7 @@ export class VSRunner { runTests(testFilesPattern: string[], code: CodeUtil, logLevel: logging.Level = logging.Level.INFO, resources: string[]): Promise { return new Promise((resolve) => { const self = this; - const browser: VSBrowser = new VSBrowser(this.codeVersion, this.releaseType, this.customSettings, logLevel); + const browser: VSBrowser = new VSBrowser(this.codeVersion, this.releaseType, this.customSettings, logLevel, this.locale); let coverage: Coverage | undefined; const testFiles = new Set(); diff --git a/packages/extester/src/util/codeUtil.ts b/packages/extester/src/util/codeUtil.ts index b34fc22cf..d4bbc4cc3 100644 --- a/packages/extester/src/util/codeUtil.ts +++ b/packages/extester/src/util/codeUtil.ts @@ -46,6 +46,8 @@ export interface RunOptions { offline?: boolean; /** list of resources to be opened by VS Code */ resources: string[]; + /** tbd */ + locale?: string; } /** defaults for the [[RunOptions]] */ @@ -55,7 +57,7 @@ export const DEFAULT_RUN_OPTIONS = { logLevel: logging.Level.INFO, offline: false, resources: [], - noCache: false, + noCache: false, //??? }; /** @@ -321,6 +323,7 @@ export class CodeUtil { runOptions.cleanup, this.releaseType, runOptions.config, + runOptions.locale, ); return await runner.runTests(testFilesPattern, this, runOptions.logLevel, runOptions.resources); } diff --git a/tests/test-project/package.json b/tests/test-project/package.json index 39486e534..ac0d6d7fe 100644 --- a/tests/test-project/package.json +++ b/tests/test-project/package.json @@ -250,7 +250,7 @@ "compile": "tsc -p ./ && npm run lint", "lint": "eslint --fix --fix-type layout src", "cb-init": "echo hello_ExTester | clipboard", - "ui-test": "npm run cb-init && extest setup-and-run './out/test/cli/order-3.test.js' './out/test/cli/order-2.test.js' './out/test/cli/order-1.test.js' './out/test/**/!(clipboard)*.test.js' './out/test/system/clipboard.test.js' -u -i -r . -e ./test-extensions", + "ui-test": "npm run cb-init && extest setup-and-run --locale ru './out/test/cli/order-3.test.js' './out/test/cli/order-2.test.js' './out/test/cli/order-1.test.js' './out/test/**/!(clipboard)*.test.js' './out/test/system/clipboard.test.js' -u -i -r . -e ./test-extensions", "ui-test:coverage": "MOCHA_GREP='order|clipboard|ExtensionsView|TitleBar' MOCHA_INVERT=true extest setup-and-run './out/test/**/*.test.js' -i -r . -e ./test-extensions --coverage" }, "devDependencies": {