From 7e4b5249f8165ed845a9ea340308d376c029cb57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Jel=C3=ADnek?= Date: Fri, 6 Oct 2023 11:45:30 +0200 Subject: [PATCH] Bump 'max' placeholder to latest VS Code 1.83.0 (#962) Signed-off-by: Dominik Jelinek --- .github/workflows/insiders.yml | 2 +- .github/workflows/main.yml | 4 +- .../src/components/editor/SettingsEditor.ts | 58 ++++++++++--------- src/extester.ts | 4 +- .../src/test/editor/settingsEditor-test.ts | 2 +- 5 files changed, 36 insertions(+), 34 deletions(-) diff --git a/.github/workflows/insiders.yml b/.github/workflows/insiders.yml index 13f2520ba..0c22f7b44 100644 --- a/.github/workflows/insiders.yml +++ b/.github/workflows/insiders.yml @@ -29,7 +29,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 18.15.0 + node-version: 18.15.x cache: npm - name: Run Tests (macOS, windows) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 729d23730..1e02848b1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] - version: [ min, 1.81.1, max ] + version: [ min, 1.82.3, max ] fail-fast: false env: @@ -30,7 +30,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 18.15.0 + node-version: 18.15.x cache: npm - name: Run Tests (macOS, windows) diff --git a/page-objects/src/components/editor/SettingsEditor.ts b/page-objects/src/components/editor/SettingsEditor.ts index af485e06e..ef0623a52 100644 --- a/page-objects/src/components/editor/SettingsEditor.ts +++ b/page-objects/src/components/editor/SettingsEditor.ts @@ -8,6 +8,8 @@ import { EditorView, EditorGroup } from "../.."; * Page object representing the internal VSCode settings editor */ export class SettingsEditor extends Editor { + + private divider = SettingsEditor.versionInfo.version >= '1.83.0' ? '›' : ' › '; constructor(view: EditorView | EditorGroup = new EditorView()) { super(view); @@ -26,21 +28,12 @@ export class SettingsEditor extends Editor { * @returns Promise resolving to a Setting object if found, undefined otherwise */ async findSetting(title: string, ...categories: string[]): Promise { - const category = categories.join(' › '); + const category = categories.join(this.divider); const searchBox = await this.findElement(SettingsEditor.locators.Editor.inputArea); await searchBox.sendKeys(Key.chord(SettingsEditor.ctlKey, 'a')); - await searchBox.sendKeys(`${category}: ${title}`); - - let setting!: Setting; - const items = await this._getSettingItems(); + await searchBox.sendKeys(`${category}${this.divider}${title}`); - for (const item of items) { - try { - return await (await this.createSetting(item, title, category)).wait(); - } catch (err) { - } - } - return setting; + return await this._getSettingItem(title, category); } /** @@ -56,25 +49,14 @@ export class SettingsEditor extends Editor { await searchBox.sendKeys(Key.chord(SettingsEditor.ctlKey, 'a')); await searchBox.sendKeys(id); - let setting!: Setting; - const items = await this._getSettingItems(); - - for (const item of items) { - try { - const category = (await (await item.findElement(SettingsEditor.locators.SettingsEditor.settingCategory)).getText()).replace(':', ''); - const title = await (await item.findElement(SettingsEditor.locators.SettingsEditor.settingLabel)).getText(); - return await (await this.createSetting(item, title, category)).wait(); - } catch (err) { - } - } - return setting; + const title = id.split('.').pop(); + return await this._getSettingItem(title); } - private async _getSettingItems(): Promise { + private async _getSettingItem(title: string = '', category: string = ''): Promise { const count = await this.findElement(SettingsEditor.locators.SettingsEditor.itemCount); let textCount = await count.getText(); - - await this.getDriver().wait(async() => { + await this.getDriver().wait(async function() { await new Promise(res => setTimeout(res, 1500)); const text = await count.getText(); if (text !== textCount) { @@ -84,7 +66,27 @@ export class SettingsEditor extends Editor { return true; }); - return await this.findElements(SettingsEditor.locators.SettingsEditor.itemRow); + let setting!: Setting; + const items = await this.findElements(SettingsEditor.locators.SettingsEditor.itemRow); + for (const item of items) { + try { + const _category = (await (await item.findElement(SettingsEditor.locators.SettingsEditor.settingCategory)).getText()).replace(':', ''); + const _title = await (await item.findElement(SettingsEditor.locators.SettingsEditor.settingLabel)).getText(); + if(category !== '') { + if(category.toLowerCase().replace(this.divider, '').replace(/\s/g, '').trim() !== _category.toLowerCase().replace(this.divider, '').replace(/\s/g, '').trim()) { + continue; + } + } + if(title !== '') { + if(title.toLowerCase().replace(/\s/g, '').trim() !== _title.toLowerCase().replace(/\s/g, '').trim()) { + continue; + } + } + return await (await this.createSetting(item, _title, _category)).wait(); + } catch (err) { + } + } + return setting; } /** diff --git a/src/extester.ts b/src/extester.ts index 066e0898b..54bc2c65e 100644 --- a/src/extester.ts +++ b/src/extester.ts @@ -26,8 +26,8 @@ export const DEFAULT_SETUP_OPTIONS = { installDependencies: false } -export const VSCODE_VERSION_MIN = '1.80.2'; -export const VSCODE_VERSION_MAX = '1.82.3'; +export const VSCODE_VERSION_MIN = '1.81.1'; +export const VSCODE_VERSION_MAX = '1.83.0'; /** * VSCode Extension Tester diff --git a/test/test-project/src/test/editor/settingsEditor-test.ts b/test/test-project/src/test/editor/settingsEditor-test.ts index 54519ac02..86f95fb62 100644 --- a/test/test-project/src/test/editor/settingsEditor-test.ts +++ b/test/test-project/src/test/editor/settingsEditor-test.ts @@ -21,7 +21,7 @@ describe('Settings Editor', function () { it('findSetting by ID works', async function () { this.timeout(15000); - const setting = await editor.findSettingByID('testProject.general.helloWorld'); + const setting = await editor.findSettingByID('workbench.editor.enablePreview'); expect(setting).not.undefined; });