diff --git a/.eslint-allowed-bracket-notation-files b/.eslint-allowed-bracket-notation-files index 8231ea35a7f52c..4f06ad658e78fe 100644 --- a/.eslint-allowed-bracket-notation-files +++ b/.eslint-allowed-bracket-notation-files @@ -508,26 +508,6 @@ extensions/git/src/ipc/ipcClient.ts extensions/git/src/ipc/ipcServer.ts extensions/git/src/util.ts -# Test infrastructure (18 files) -src/vs/platform/instantiation/test/common/instantiationServiceMock.ts -src/vs/workbench/test/browser/componentFixtures/chat/chatWidget.fixture.ts -src/vs/workbench/test/browser/componentFixtures/multiDiffEditorScroll.fixture.ts -src/vs/workbench/test/browser/componentFixtures/resizeObserver.fixture.ts -test/automation/src/electron.ts -test/automation/src/scm.ts -test/automation/src/search.ts -test/componentFixtures/playwright/tests/chatResizeObserver.spec.ts -test/componentFixtures/playwright/tests/utils.ts -test/monaco/esm-check/esm-check.js -test/sanity/src/context.ts -test/sanity/src/main.ts -test/smoke/src/areas/agentsWindow/agentsWindow.test.ts -test/smoke/src/areas/preferences/preferences.test.ts -test/smoke/test/index.js -test/unit/electron/index.js -test/unit/electron/preload.js -test/unit/electron/renderer.js - # Workbench UI and remaining services (23 files) src/vs/workbench/browser/parts/editor/editor.ts src/vs/workbench/browser/parts/editor/editorGroupView.ts diff --git a/src/vs/platform/instantiation/test/common/instantiationServiceMock.ts b/src/vs/platform/instantiation/test/common/instantiationServiceMock.ts index deaefef16e7d7f..47b7f5e1e6c318 100644 --- a/src/vs/platform/instantiation/test/common/instantiationServiceMock.ts +++ b/src/vs/platform/instantiation/test/common/instantiationServiceMock.ts @@ -122,10 +122,10 @@ export class TestInstantiationService extends InstantiationService implements ID private _getOrCreateService(serviceMock: IServiceMock, opts: SinonOptions, reset?: boolean): any { const service: any = this._serviceCollection.get(serviceMock.id); if (!reset && service) { - if (opts.mock && service['sinonOptions'] && !!service['sinonOptions'].mock) { + if (opts.mock && service.sinonOptions && !!service.sinonOptions.mock) { return service; } - if (opts.stub && service['sinonOptions'] && !!service['sinonOptions'].stub) { + if (opts.stub && service.sinonOptions && !!service.sinonOptions.stub) { return service; } } @@ -135,7 +135,7 @@ export class TestInstantiationService extends InstantiationService implements ID private _createService(serviceMock: IServiceMock, opts: SinonOptions): any { serviceMock.service = serviceMock.service ? serviceMock.service : this._servciesMap.get(serviceMock.id); const service = opts.mock ? sinon.mock(serviceMock.service) : this._createStub(serviceMock.service); - service['sinonOptions'] = opts; + service.sinonOptions = opts; return service; } diff --git a/src/vs/workbench/test/browser/componentFixtures/chat/chatWidget.fixture.ts b/src/vs/workbench/test/browser/componentFixtures/chat/chatWidget.fixture.ts index b3667b63df9f0c..1ea5f53a5e624d 100644 --- a/src/vs/workbench/test/browser/componentFixtures/chat/chatWidget.fixture.ts +++ b/src/vs/workbench/test/browser/componentFixtures/chat/chatWidget.fixture.ts @@ -482,7 +482,7 @@ export async function renderChatWidget(context: ComponentFixtureContext, options ? Math.max(0, Math.max(116, inputHeight) - inputHeight) : Math.max(0, height - inputHeight); listContainer.style.height = `${contentHeight}px`; - listContainer.dataset['expectedHeight'] = String(contentHeight); + listContainer.dataset.expectedHeight = String(contentHeight); listWidget.layout(contentHeight, width); } finally { layouting = false; @@ -807,7 +807,7 @@ async function renderResizeObserverLoopHarness(context: ComponentFixtureContext, if (event instanceof ErrorEvent && event.message.includes('ResizeObserver loop')) { warningCount++; warnings.textContent = `Warnings: ${warningCount}`; - warnings.dataset['observerContext'] = dom.getRecentDisposableResizeObserverContextForLoopError(event.message, targetWindow) ?? event.message; + warnings.dataset.observerContext = dom.getRecentDisposableResizeObserverContextForLoopError(event.message, targetWindow) ?? event.message; status.textContent = 'Captured ResizeObserver warning'; } })); @@ -908,11 +908,11 @@ async function renderDisabledPetResizeObserverProbe(context: ComponentFixtureCon const status = dom.append(context.container, dom.$('.disabled-pet-resize-observer-status')); status.role = 'status'; status.textContent = 'Running disabled pet observer probe'; - status.dataset['warningCount'] = '0'; + status.dataset.warningCount = '0'; context.disposableStore.add(dom.addDisposableListener(targetWindow, dom.EventType.ERROR, event => { if (event instanceof ErrorEvent && event.message.includes('ResizeObserver loop')) { - status.dataset['warningCount'] = String(Number(status.dataset['warningCount']) + 1); - status.dataset['observerContext'] = dom.getRecentDisposableResizeObserverContextForLoopError(event.message, targetWindow) ?? event.message; + status.dataset.warningCount = String(Number(status.dataset.warningCount) + 1); + status.dataset.observerContext = dom.getRecentDisposableResizeObserverContextForLoopError(event.message, targetWindow) ?? event.message; } })); diff --git a/src/vs/workbench/test/browser/componentFixtures/multiDiffEditorScroll.fixture.ts b/src/vs/workbench/test/browser/componentFixtures/multiDiffEditorScroll.fixture.ts index 7dd57baa92a262..46be783bf473b7 100644 --- a/src/vs/workbench/test/browser/componentFixtures/multiDiffEditorScroll.fixture.ts +++ b/src/vs/workbench/test/browser/componentFixtures/multiDiffEditorScroll.fixture.ts @@ -701,7 +701,7 @@ function parseSerializedFixtureState(text: string): ISerializedFixtureState { if (!isJsonObject(value)) { throw new Error('Fixture state must be a JSON object.'); } - const items = value['items']; + const items = value.items; if (!Array.isArray(items)) { throw new Error('Fixture state must contain an items array.'); } @@ -720,24 +720,24 @@ function parseSerializedFixtureItem(value: JsonValue, index: number): ISerialize if (!isJsonObject(value)) { throw new Error(`items[${index}] must be a JSON object.`); } - const bindingPhase = value['bindingPhase']; + const bindingPhase = value.bindingPhase; if (!isBindingPhase(bindingPhase)) { throw new Error(`items[${index}].bindingPhase must be unbound, binding, projecting, or active.`); } const path = `items[${index}]`; - const lineCount = value['lineCount'] === undefined + const lineCount = value.lineCount === undefined ? heightToLineCount(readNonNegativeNumber(value, 'fullHeight', true, path)) : readNonNegativeInteger(value, 'lineCount', path); - const geometryOscillationValue = value['geometryOscillation']; + const geometryOscillationValue = value.geometryOscillation; const geometryOscillation = geometryOscillationValue === undefined ? createDefaultGeometryOscillation() : parseSerializedGeometryOscillation(geometryOscillationValue, index, lineCount); - const topLineCountValue = value['topLineCount']; - const bottomLineCountValue = value['bottomLineCount']; - const legacyContentTopInset = value['contentTopInset']; - const mountLineCountsValue = value['mountLineCounts']; - const legacyMountHeightsValue = value['mountHeights']; - const unmountLineCountResetValue = value['unmountLineCountReset']; + const topLineCountValue = value.topLineCount; + const bottomLineCountValue = value.bottomLineCount; + const legacyContentTopInset = value.contentTopInset; + const mountLineCountsValue = value.mountLineCounts; + const legacyMountHeightsValue = value.mountHeights; + const unmountLineCountResetValue = value.unmountLineCountReset; return { label: readString(value, 'label', path), lineCount, @@ -787,12 +787,12 @@ function parseSerializedGeometryOscillation(value: JsonValue, index: number, lin if (!isJsonObject(value)) { throw new Error(`${path} must be a JSON object.`); } - const ordering = value['ordering']; + const ordering = value.ordering; if (!isGeometryChangeOrdering(ordering)) { throw new Error(`${path}.ordering must be atomic, lines-first, or offset-first.`); } const normalizedOrdering = ordering === 'height-first' ? 'lines-first' : ordering; - if (value['topLineCountA'] !== undefined) { + if (value.topLineCountA !== undefined) { return { enabled: readBoolean(value, 'enabled', path), topLineCountA: readNonNegativeInteger(value, 'topLineCountA', path), @@ -802,7 +802,7 @@ function parseSerializedGeometryOscillation(value: JsonValue, index: number, lin ordering: normalizedOrdering, }; } - const location = value['location']; + const location = value.location; if (location !== 'above' && location !== 'below') { throw new Error(`${path}.location must be above or below when importing legacy height geometry.`); } diff --git a/src/vs/workbench/test/browser/componentFixtures/resizeObserver.fixture.ts b/src/vs/workbench/test/browser/componentFixtures/resizeObserver.fixture.ts index 0e7442bd188b97..5552e4fd2dce5a 100644 --- a/src/vs/workbench/test/browser/componentFixtures/resizeObserver.fixture.ts +++ b/src/vs/workbench/test/browser/componentFixtures/resizeObserver.fixture.ts @@ -15,7 +15,7 @@ function renderLoopContextProbe(context: ComponentFixtureContext): void { const status = dom.append(context.container, dom.$('.resize-observer-context-status')); status.textContent = 'Waiting for ResizeObserver loop warning'; - status.dataset['warningCount'] = '0'; + status.dataset.warningCount = '0'; const observation = context.disposableStore.add(new MutableDisposable()); context.disposableStore.add(dom.addDisposableListener(targetWindow, dom.EventType.ERROR, event => { @@ -23,8 +23,8 @@ function renderLoopContextProbe(context: ComponentFixtureContext): void { return; } - status.dataset['warningCount'] = '1'; - status.dataset['observerContext'] = dom.getRecentDisposableResizeObserverContextForLoopError(event.message, targetWindow) ?? ''; + status.dataset.warningCount = '1'; + status.dataset.observerContext = dom.getRecentDisposableResizeObserverContextForLoopError(event.message, targetWindow) ?? ''; status.textContent = 'Captured ResizeObserver loop warning'; observation.clear(); })); diff --git a/test/automation/src/electron.ts b/test/automation/src/electron.ts index 89a1249b9d16e4..d1bb569ccedd8b 100644 --- a/test/automation/src/electron.ts +++ b/test/automation/src/electron.ts @@ -74,15 +74,15 @@ export async function resolveElectronConfiguration(options: LaunchOptions): Prom if (userDataDir) { const remoteDataDir = `${userDataDir}-server`; fs.mkdirSync(remoteDataDir, { recursive: true }); - env['TESTRESOLVER_DATA_FOLDER'] = remoteDataDir; + env.TESTRESOLVER_DATA_FOLDER = remoteDataDir; } - env['TESTRESOLVER_LOGS_FOLDER'] = join(logsPath, 'server'); + env.TESTRESOLVER_LOGS_FOLDER = join(logsPath, 'server'); // Exercise the remote server's exit diagnostics (see `installServerProcessExitDiagnostics` // in server-main.ts) so unexpected server exits are explained in the captured logs, // even when running smoke tests locally (where `isCI` is false). - env['VSCODE_SERVER_EXIT_DIAGNOSTICS'] = '1'; + env.VSCODE_SERVER_EXIT_DIAGNOSTICS = '1'; if (options.verbose) { - env['TESTRESOLVER_LOG_LEVEL'] = 'trace'; + env.TESTRESOLVER_LOG_LEVEL = 'trace'; } } diff --git a/test/automation/src/scm.ts b/test/automation/src/scm.ts index 3fdf89752dc226..7019e35b27fd89 100644 --- a/test/automation/src/scm.ts +++ b/test/automation/src/scm.ts @@ -27,7 +27,7 @@ function toChange(element: IElement): Change { const type = element.attributes['data-tooltip'] || ''; const actionElementList = findElements(element, e => /\baction-label\b/.test(e.className)); - const actions = actionElementList.map(e => e.attributes['title']); + const actions = actionElementList.map(e => e.attributes.title); return { name: name.textContent || '', diff --git a/test/automation/src/search.ts b/test/automation/src/search.ts index 8c8000c92dd1df..98440b4a86acea 100644 --- a/test/automation/src/search.ts +++ b/test/automation/src/search.ts @@ -49,8 +49,8 @@ export class Search extends Viewlet { } async getSearchTooltip(): Promise { - const icon = await this.code.waitForElement(`.activitybar .action-label.codicon.codicon-search-view-icon`, (el) => !!el?.attributes?.['title']); - return icon.attributes['title']; + const icon = await this.code.waitForElement(`.activitybar .action-label.codicon.codicon-search-view-icon`, (el) => !!el?.attributes?.title); + return icon.attributes.title; } async searchFor(text: string): Promise { diff --git a/test/componentFixtures/playwright/tests/chatResizeObserver.spec.ts b/test/componentFixtures/playwright/tests/chatResizeObserver.spec.ts index b90e06aa3d1e7f..ec92baaf8d8ee3 100644 --- a/test/componentFixtures/playwright/tests/chatResizeObserver.spec.ts +++ b/test/componentFixtures/playwright/tests/chatResizeObserver.spec.ts @@ -34,7 +34,7 @@ for (const scenario of scenarios) { const geometry = await page.locator('.interactive-list').evaluate(element => { const list = element.querySelector('.monaco-list'); return { - expectedHeight: Number((element as HTMLElement).dataset['expectedHeight']), + expectedHeight: Number((element as HTMLElement).dataset.expectedHeight), containerHeight: element.getBoundingClientRect().height, listHeight: list?.getBoundingClientRect().height, }; diff --git a/test/componentFixtures/playwright/tests/utils.ts b/test/componentFixtures/playwright/tests/utils.ts index 2fbbdb78dd0981..60d007d2c5b27a 100644 --- a/test/componentFixtures/playwright/tests/utils.ts +++ b/test/componentFixtures/playwright/tests/utils.ts @@ -6,7 +6,7 @@ import { Page } from '@playwright/test'; function getBaseURL(): string { - const port = process.env['COMPONENT_EXPLORER_PORT']; + const port = process.env.COMPONENT_EXPLORER_PORT; if (!port) { throw new Error('COMPONENT_EXPLORER_PORT is not set. Is the webServer running?'); } diff --git a/test/monaco/esm-check/esm-check.js b/test/monaco/esm-check/esm-check.js index 6b5fdf4fe93e70..6f634b0aa5e50f 100644 --- a/test/monaco/esm-check/esm-check.js +++ b/test/monaco/esm-check/esm-check.js @@ -23,7 +23,7 @@ async function run() { await extractSourcesWithoutCSS(); const server = await startServer(); - const browser = await playwright['chromium'].launch({ + const browser = await playwright.chromium.launch({ headless: !DEBUG_TESTS, devtools: DEBUG_TESTS // slowMo: DEBUG_TESTS ? 2000 : 0 diff --git a/test/sanity/src/context.ts b/test/sanity/src/context.ts index 7fb4ac6a8b0d71..3a0d092ff01394 100644 --- a/test/sanity/src/context.ts +++ b/test/sanity/src/context.ts @@ -896,9 +896,9 @@ export class TestContext { private getWindowsInstallDir(type: 'user' | 'system'): string { let parentDir: string; if (type === 'system') { - parentDir = process.env['ProgramW6432'] || process.env['PROGRAMFILES'] || ''; + parentDir = process.env.ProgramW6432 || process.env.PROGRAMFILES || ''; } else { - parentDir = path.join(process.env['LOCALAPPDATA'] || '', 'Programs'); + parentDir = path.join(process.env.LOCALAPPDATA || '', 'Programs'); } switch (this.options.quality) { @@ -1284,13 +1284,13 @@ export class TestContext { return await webkit.launch({ headless }); } case 'win32': { - const executablePath = process.env['PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH'] ?? 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe'; + const executablePath = process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH ?? 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe'; this.log(`Using Chromium executable at: ${executablePath}`); return await chromium.launch({ headless, executablePath }); } case 'linux': default: { - const executablePath = process.env['PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH'] ?? '/usr/bin/chromium-browser'; + const executablePath = process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH ?? '/usr/bin/chromium-browser'; this.log(`Using Chromium executable at: ${executablePath}`); return await chromium.launch({ headless, diff --git a/test/sanity/src/main.ts b/test/sanity/src/main.ts index 2b3822a019ebe6..bb6569479fed63 100644 --- a/test/sanity/src/main.ts +++ b/test/sanity/src/main.ts @@ -35,7 +35,7 @@ const context = new TestContext({ cleanup: options.cleanup, checkSigning: options['signing-check'], headlessBrowser: options.headless, - downloadOnly: !options['detection'], + downloadOnly: !options.detection, screenshotsDir: options['screenshots-dir'], crashDumpsDir: options['crash-dumps-dir'], artifactsDir: options['artifacts-dir'], diff --git a/test/smoke/src/areas/agentsWindow/agentsWindow.test.ts b/test/smoke/src/areas/agentsWindow/agentsWindow.test.ts index cecf302d772ae6..5e8b7476de91b4 100644 --- a/test/smoke/src/areas/agentsWindow/agentsWindow.test.ts +++ b/test/smoke/src/areas/agentsWindow/agentsWindow.test.ts @@ -366,10 +366,10 @@ export function setup(logger: Logger) { // "from source" signal: parseQuality() also returns Quality.Dev for // a `--build` product when VSCODE_QUALITY is unset, which would // wrongly hard-fail a packaged build that legitimately lacks Codex. - const isFromSource = process.env['VSCODE_DEV'] === '1'; - const isPublishBuild = (process.env['VSCODE_PUBLISH'] ?? '').toLowerCase() === 'true'; + const isFromSource = process.env.VSCODE_DEV === '1'; + const isPublishBuild = (process.env.VSCODE_PUBLISH ?? '').toLowerCase() === 'true'; if (isFromSource || isPublishBuild) { - throw new Error(`[Agents Window/Codex] Codex session type unexpectedly unavailable (VSCODE_DEV=${process.env['VSCODE_DEV'] ?? ''}, VSCODE_PUBLISH=${process.env['VSCODE_PUBLISH'] ?? ''}) — the SDK should be resolvable from node_modules (from source) or product.agentSdks.codex (publish build)`); + throw new Error(`[Agents Window/Codex] Codex session type unexpectedly unavailable (VSCODE_DEV=${process.env.VSCODE_DEV ?? ''}, VSCODE_PUBLISH=${process.env.VSCODE_PUBLISH ?? ''}) — the SDK should be resolvable from node_modules (from source) or product.agentSdks.codex (publish build)`); } logger.log('[Agents Window/Codex] Codex session type not available in this built product (no product.agentSdks.codex); skipping'); this.skip(); @@ -380,7 +380,7 @@ export function setup(logger: Logger) { // optional dependency that npm silently skips when its install fails. // A stale `node_modules` cache can thus have the shim but no binary, so // fail fast here (from source) instead of timing out at spawn time. - if (process.env['VSCODE_DEV'] === '1') { + if (process.env.VSCODE_DEV === '1') { const repoRoot = path.resolve(process.cwd(), '..', '..'); const platformPkgDir = path.join(repoRoot, 'node_modules', `@openai/codex-${process.platform}-${process.arch}`); const binaryName = process.platform === 'win32' ? 'codex.exe' : 'codex'; diff --git a/test/smoke/src/areas/preferences/preferences.test.ts b/test/smoke/src/areas/preferences/preferences.test.ts index a2088a2771743b..7ef9a85d5ba515 100644 --- a/test/smoke/src/areas/preferences/preferences.test.ts +++ b/test/smoke/src/areas/preferences/preferences.test.ts @@ -74,7 +74,7 @@ export function setup(logger: Logger) { await app.code.waitAndClick('.settings-editor .monaco-list-rows .setting-item-control select', 2, 2); await app.code.waitAndClick('.context-view .monaco-list-row:nth-child(1) .option-text', 2, 2); await app.workbench.settingsEditor.searchSettingsUI('test'); - await app.code.waitForElements('.settings-editor .settings-toc-container', false, elements => elements.length === 1 && elements[0].attributes['style'].includes('width: 0px')); + await app.code.waitForElements('.settings-editor .settings-toc-container', false, elements => elements.length === 1 && elements[0].attributes.style.includes('width: 0px')); await app.code.waitForElements('.settings-editor .settings-body .monaco-sash', false, elements => elements.length === 1 && elements[0].className.includes('disabled')); // Show ToC when searching @@ -82,7 +82,7 @@ export function setup(logger: Logger) { await app.code.waitAndClick('.settings-editor .monaco-list-rows .setting-item-control select', 2, 2); await app.code.waitAndClick('.context-view .monaco-list-row:nth-child(2) .option-text', 2, 2); await app.workbench.settingsEditor.searchSettingsUI('test'); - await app.code.waitForElements('.settings-editor .settings-toc-container', false, elements => elements.length === 1 && !elements[0].attributes['style'].includes('width: 0px')); + await app.code.waitForElements('.settings-editor .settings-toc-container', false, elements => elements.length === 1 && !elements[0].attributes.style.includes('width: 0px')); await app.code.waitForElements('.settings-editor .settings-body .monaco-sash', false, elements => elements.length === 1 && !elements[0].className.includes('disabled')); }); }); diff --git a/test/smoke/test/index.js b/test/smoke/test/index.js index d9115a3b2b478c..77a9f5fd3ab9bb 100644 --- a/test/smoke/test/index.js +++ b/test/smoke/test/index.js @@ -16,13 +16,13 @@ const opts = minimist(args, { string: ['f', 'g'] }); -const suite = opts['web'] ? 'Browser Smoke Tests' : 'Desktop Smoke Tests'; +const suite = opts.web ? 'Browser Smoke Tests' : 'Desktop Smoke Tests'; const options = { color: true, timeout: 2 * 60 * 1000, slow: 30 * 1000, - grep: opts['f'] || opts['g'], + grep: opts.f || opts.g, failZero: opts['fail-zero'] }; diff --git a/test/unit/electron/index.js b/test/unit/electron/index.js index 10678564d5c196..f2d9b7f3fdfb10 100644 --- a/test/unit/electron/index.js +++ b/test/unit/electron/index.js @@ -124,7 +124,7 @@ if (crashReporterDirectory) { crashReporter.start({ companyName: 'Microsoft', - productName: process.env['VSCODE_DEV'] ? `${product.nameShort} Dev` : product.nameShort, + productName: process.env.VSCODE_DEV ? `${product.nameShort} Dev` : product.nameShort, uploadToServer: false, compress: true }); diff --git a/test/unit/electron/preload.js b/test/unit/electron/preload.js index 04439d66ea15f3..265feef98ee375 100644 --- a/test/unit/electron/preload.js +++ b/test/unit/electron/preload.js @@ -65,7 +65,7 @@ get execPath() { return process.execPath; }, cwd() { - return process.env['VSCODE_CWD'] || process.execPath.substr(0, process.execPath.lastIndexOf(process.platform === 'win32' ? '\\' : '/')); + return process.env.VSCODE_CWD || process.execPath.substr(0, process.execPath.lastIndexOf(process.platform === 'win32' ? '\\' : '/')); }, getProcessMemoryInfo() { diff --git a/test/unit/electron/renderer.js b/test/unit/electron/renderer.js index ee563e715b51a5..9ca33031dd71d1 100644 --- a/test/unit/electron/renderer.js +++ b/test/unit/electron/renderer.js @@ -69,8 +69,8 @@ const coverage = require('../coverage'); const { pathToFileURL } = require('url'); // Disabled custom inspect. See #38847 -if (util.inspect && util.inspect['defaultOptions']) { - util.inspect['defaultOptions'].customInspect = false; +if (util.inspect && util.inspect.defaultOptions) { + util.inspect.defaultOptions.customInspect = false; } // VSCODE_GLOBALS: package/product.json