Skip to content

Commit f69b6cc

Browse files
authored
fix: smoke tests for stable with editcontext enabled (microsoft#251056)
(Reland) fix: smoke tests for stable with editcontext enabled (microsoft#251074)
1 parent 8a0f412 commit f69b6cc

File tree

10 files changed

+29
-25
lines changed

10 files changed

+29
-25
lines changed

test/automation/src/code.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface LaunchOptions {
3030
readonly headless?: boolean;
3131
readonly browser?: 'chromium' | 'webkit' | 'firefox' | 'chromium-msedge' | 'chromium-chrome';
3232
readonly quality: Quality;
33+
version: { major: number; minor: number; patch: number };
3334
}
3435

3536
interface ICodeInstance {
@@ -89,15 +90,15 @@ export async function launch(options: LaunchOptions): Promise<Code> {
8990
const { serverProcess, driver } = await measureAndLog(() => launchPlaywrightBrowser(options), 'launch playwright (browser)', options.logger);
9091
registerInstance(serverProcess, options.logger, 'server');
9192

92-
return new Code(driver, options.logger, serverProcess, undefined, options.quality);
93+
return new Code(driver, options.logger, serverProcess, undefined, options.quality, options.version);
9394
}
9495

9596
// Electron smoke tests (playwright)
9697
else {
9798
const { electronProcess, driver } = await measureAndLog(() => launchPlaywrightElectron(options), 'launch playwright (electron)', options.logger);
9899
const { safeToKill } = registerInstance(electronProcess, options.logger, 'electron');
99100

100-
return new Code(driver, options.logger, electronProcess, safeToKill, options.quality);
101+
return new Code(driver, options.logger, electronProcess, safeToKill, options.quality, options.version);
101102
}
102103
}
103104

@@ -110,7 +111,8 @@ export class Code {
110111
readonly logger: Logger,
111112
private readonly mainProcess: cp.ChildProcess,
112113
private readonly safeToKill: Promise<void> | undefined,
113-
readonly quality: Quality
114+
readonly quality: Quality,
115+
readonly version: { major: number; minor: number; patch: number }
114116
) {
115117
this.driver = new Proxy(driver, {
116118
get(target, prop) {
@@ -131,6 +133,10 @@ export class Code {
131133
});
132134
}
133135

136+
get editContextEnabled(): boolean {
137+
return !(this.quality === Quality.Stable && this.version.major === 1 && this.version.minor < 101);
138+
}
139+
134140
async startTracing(name: string): Promise<void> {
135141
return await this.driver.startTracing(name);
136142
}

test/automation/src/debug.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { Code, findElement } from './code';
99
import { Editors } from './editors';
1010
import { Editor } from './editor';
1111
import { IElement } from './driver';
12-
import { Quality } from './application';
1312

1413
const VIEWLET = 'div[id="workbench.view.debug"]';
1514
const DEBUG_VIEW = `${VIEWLET}`;
@@ -133,7 +132,7 @@ export class Debug extends Viewlet {
133132

134133
async waitForReplCommand(text: string, accept: (result: string) => boolean): Promise<void> {
135134
await this.commands.runCommand('Debug: Focus on Debug Console View');
136-
const selector = this.code.quality === Quality.Stable ? REPL_FOCUSED_TEXTAREA : REPL_FOCUSED_NATIVE_EDIT_CONTEXT;
135+
const selector = !this.code.editContextEnabled ? REPL_FOCUSED_TEXTAREA : REPL_FOCUSED_NATIVE_EDIT_CONTEXT;
137136
await this.code.waitForActiveElement(selector);
138137
await this.code.waitForSetValue(selector, text);
139138

test/automation/src/editor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { References } from './peek';
77
import { Commands } from './workbench';
88
import { Code } from './code';
9-
import { Quality } from './application';
109

1110
const RENAME_BOX = '.monaco-editor .monaco-editor.rename-box';
1211
const RENAME_INPUT = `${RENAME_BOX} .rename-input`;
@@ -107,7 +106,7 @@ export class Editor {
107106
}
108107

109108
private _editContextSelector() {
110-
return this.code.quality === Quality.Stable ? 'textarea' : '.native-edit-context';
109+
return !this.code.editContextEnabled ? 'textarea' : '.native-edit-context';
111110
}
112111

113112
async waitForEditorContents(filename: string, accept: (contents: string) => boolean, selectorPrefix = ''): Promise<any> {

test/automation/src/editors.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { Quality } from './application';
76
import { Code } from './code';
87

98
export class Editors {
@@ -53,7 +52,7 @@ export class Editors {
5352
}
5453

5554
async waitForActiveEditor(fileName: string, retryCount?: number): Promise<any> {
56-
const selector = `.editor-instance .monaco-editor[data-uri$="${fileName}"] ${this.code.quality === Quality.Stable ? 'textarea' : '.native-edit-context'}`;
55+
const selector = `.editor-instance .monaco-editor[data-uri$="${fileName}"] ${!this.code.editContextEnabled ? 'textarea' : '.native-edit-context'}`;
5756
return this.code.waitForActiveElement(selector, retryCount);
5857
}
5958

test/automation/src/extensions.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { Code } from './code';
88
import { ncp } from 'ncp';
99
import { promisify } from 'util';
1010
import { Commands } from './workbench';
11-
import { Quality } from './application';
1211
import path = require('path');
1312
import fs = require('fs');
1413

@@ -21,7 +20,7 @@ export class Extensions extends Viewlet {
2120

2221
async searchForExtension(id: string): Promise<any> {
2322
await this.commands.runCommand('Extensions: Focus on Extensions View', { exactLabelMatch: true });
24-
await this.code.waitForTypeInEditor(`div.extensions-viewlet[id="workbench.view.extensions"] .monaco-editor ${this.code.quality === Quality.Stable ? 'textarea' : '.native-edit-context'}`, `@id:${id}`);
23+
await this.code.waitForTypeInEditor(`div.extensions-viewlet[id="workbench.view.extensions"] .monaco-editor ${!this.code.editContextEnabled ? 'textarea' : '.native-edit-context'}`, `@id:${id}`);
2524
await this.code.waitForTextContent(`div.part.sidebar div.composite.title h2`, 'Extensions: Marketplace');
2625

2726
let retrials = 1;

test/automation/src/notebook.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { Quality } from './application';
76
import { Code } from './code';
87
import { QuickAccess } from './quickaccess';
98
import { QuickInput } from './quickinput';
@@ -47,7 +46,7 @@ export class Notebook {
4746

4847
await this.code.waitForElement(editor);
4948

50-
const editContext = `${editor} ${this.code.quality === Quality.Stable ? 'textarea' : '.native-edit-context'}`;
49+
const editContext = `${editor} ${!this.code.editContextEnabled ? 'textarea' : '.native-edit-context'}`;
5150
await this.code.waitForActiveElement(editContext);
5251

5352
await this.code.waitForTypeInEditor(editContext, text);

test/automation/src/scm.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { Viewlet } from './viewlet';
77
import { IElement } from './driver';
88
import { findElement, findElements, Code } from './code';
9-
import { Quality } from './application';
109

1110
const VIEWLET = 'div[id="workbench.view.scm"]';
1211
const SCM_INPUT_NATIVE_EDIT_CONTEXT = `${VIEWLET} .scm-editor .native-edit-context`;
@@ -79,6 +78,6 @@ export class SCM extends Viewlet {
7978
}
8079

8180
private _editContextSelector(): string {
82-
return this.code.quality === Quality.Stable ? SCM_INPUT_TEXTAREA : SCM_INPUT_NATIVE_EDIT_CONTEXT;
81+
return !this.code.editContextEnabled ? SCM_INPUT_TEXTAREA : SCM_INPUT_NATIVE_EDIT_CONTEXT;
8382
}
8483
}

test/automation/src/settings.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { Editor } from './editor';
77
import { Editors } from './editors';
88
import { Code } from './code';
99
import { QuickAccess } from './quickaccess';
10-
import { Quality } from './application';
1110

1211
const SEARCH_BOX_NATIVE_EDIT_CONTEXT = '.settings-editor .suggest-input-container .monaco-editor .native-edit-context';
1312
const SEARCH_BOX_TEXTAREA = '.settings-editor .suggest-input-container .monaco-editor textarea';
@@ -26,7 +25,7 @@ export class SettingsEditor {
2625

2726
await this.editors.selectTab('settings.json');
2827
await this.code.sendKeybinding('right', () =>
29-
this.editor.waitForEditorSelection('settings.json', (s) => this._acceptEditorSelection(this.code.quality, s)));
28+
this.editor.waitForEditorSelection('settings.json', (s) => this._acceptEditorSelection(this.code.editContextEnabled, s)));
3029
await this.editor.waitForTypeInEditor('settings.json', `"${setting}": ${value},`);
3130
await this.editors.saveOpenedFile();
3231
}
@@ -42,7 +41,7 @@ export class SettingsEditor {
4241

4342
await this.editors.selectTab('settings.json');
4443
await this.code.sendKeybinding('right', () =>
45-
this.editor.waitForEditorSelection('settings.json', (s) => this._acceptEditorSelection(this.code.quality, s)));
44+
this.editor.waitForEditorSelection('settings.json', (s) => this._acceptEditorSelection(this.code.editContextEnabled, s)));
4645
await this.editor.waitForTypeInEditor('settings.json', settings.map(v => `"${v[0]}": ${v[1]},`).join(''));
4746
await this.editors.saveOpenedFile();
4847
}
@@ -85,11 +84,11 @@ export class SettingsEditor {
8584
}
8685

8786
private _editContextSelector() {
88-
return this.code.quality === Quality.Stable ? SEARCH_BOX_TEXTAREA : SEARCH_BOX_NATIVE_EDIT_CONTEXT;
87+
return !this.code.editContextEnabled ? SEARCH_BOX_TEXTAREA : SEARCH_BOX_NATIVE_EDIT_CONTEXT;
8988
}
9089

91-
private _acceptEditorSelection(quality: Quality, s: { selectionStart: number; selectionEnd: number }): boolean {
92-
if (quality === Quality.Stable) {
90+
private _acceptEditorSelection(editContextEnabled: boolean, s: { selectionStart: number; selectionEnd: number }): boolean {
91+
if (!editContextEnabled) {
9392
return true;
9493
}
9594
return s.selectionStart === 1 && s.selectionEnd === 1;

test/smoke/src/areas/workbench/data-loss.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { join } from 'path';
77
import { Application, ApplicationOptions, Logger, Quality } from '../../../../automation';
88
import { createApp, timeout, installDiagnosticsHandler, installAppAfterHandler, getRandomUserDataDir, suiteLogsPath, suiteCrashPath } from '../../utils';
99

10-
export function setup(ensureStableCode: () => string | undefined, logger: Logger) {
10+
export function setup(ensureStableCode: () => { stableCodePath: string | undefined; stableCodeVersion: { major: number; minor: number; patch: number } | undefined }, logger: Logger) {
1111
describe('Data Loss (insiders -> insiders)', function () {
1212

1313
// Double the timeout since these tests involve 2 startups
@@ -146,7 +146,7 @@ export function setup(ensureStableCode: () => string | undefined, logger: Logger
146146
installAppAfterHandler(() => insidersApp ?? stableApp, async () => stableApp?.stop());
147147

148148
it('verifies opened editors are restored', async function () {
149-
const stableCodePath = ensureStableCode();
149+
const { stableCodePath, stableCodeVersion } = ensureStableCode();
150150
if (!stableCodePath) {
151151
this.skip();
152152
}
@@ -170,6 +170,7 @@ export function setup(ensureStableCode: () => string | undefined, logger: Logger
170170
stableOptions.quality = Quality.Stable;
171171
stableOptions.logsPath = logsPath;
172172
stableOptions.crashesPath = crashesPath;
173+
stableOptions.version = stableCodeVersion ?? { major: 0, minor: 0, patch: 0 };
173174

174175
stableApp = new Application(stableOptions);
175176
await stableApp.start();
@@ -210,7 +211,7 @@ export function setup(ensureStableCode: () => string | undefined, logger: Logger
210211
});
211212

212213
async function testHotExit(this: import('mocha').Context, title: string, restartDelay: number | undefined) {
213-
const stableCodePath = ensureStableCode();
214+
const { stableCodePath, stableCodeVersion } = ensureStableCode();
214215
if (!stableCodePath) {
215216
this.skip();
216217
}
@@ -225,6 +226,7 @@ export function setup(ensureStableCode: () => string | undefined, logger: Logger
225226
stableOptions.quality = Quality.Stable;
226227
stableOptions.logsPath = logsPath;
227228
stableOptions.crashesPath = crashesPath;
229+
stableOptions.version = stableCodeVersion ?? { major: 0, minor: 0, patch: 0 };
228230

229231
stableApp = new Application(stableOptions);
230232
await stableApp.start();

test/smoke/src/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ async function ensureStableCode(): Promise<void> {
322322
// VSCode/Code.exe (Windows) | VSCode/code (Linux)
323323
stableCodePath = path.dirname(stableCodeExecutable);
324324
}
325+
326+
opts['stable-version'] = parseVersion(stableVersion);
325327
}
326328

327329
if (!fs.existsSync(stableCodePath)) {
@@ -352,6 +354,7 @@ before(async function () {
352354

353355
this.defaultOptions = {
354356
quality,
357+
version: parseVersion(version ?? '0.0.0'),
355358
codePath: opts.build,
356359
workspacePath,
357360
userDataDir,
@@ -396,7 +399,7 @@ after(async function () {
396399
});
397400

398401
describe(`VSCode Smoke Tests (${opts.web ? 'Web' : 'Electron'})`, () => {
399-
if (!opts.web) { setupDataLossTests(() => opts['stable-build'] /* Do not change, deferred for a reason! */, logger); }
402+
if (!opts.web) { setupDataLossTests(() => { return { stableCodePath: opts['stable-build'], stableCodeVersion: opts['stable-version'] } /* Do not change, deferred for a reason! */; }, logger); }
400403
setupPreferencesTests(logger);
401404
setupSearchTests(logger);
402405
if (!opts.web) { setupNotebookTests(logger); }

0 commit comments

Comments
 (0)