Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extensions smoke test #195264

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { URI } from 'vs/base/common/uri';
import { localize } from 'vs/nls';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { IDialogService, IPromptButton } from 'vs/platform/dialogs/common/dialogs';
import { registerWindowDriver } from 'vs/platform/driver/browser/driver';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ILabelService } from 'vs/platform/label/common/label';
import { IOpenerService, matchesScheme } from 'vs/platform/opener/common/opener';
Expand All @@ -27,6 +26,7 @@ import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/la
import { BrowserLifecycleService } from 'vs/workbench/services/lifecycle/browser/lifecycleService';
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { IHostService } from 'vs/workbench/services/host/browser/host';
import { registerWindowDriver } from 'vs/workbench/services/driver/browser/driver';

export class BrowserWindow extends Disposable {

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/electron-sandbox/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ import { whenEditorClosed } from 'vs/workbench/browser/editor';
import { ISharedProcessService } from 'vs/platform/ipc/electron-sandbox/services';
import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { registerWindowDriver } from 'vs/platform/driver/electron-sandbox/driver';
import { ILabelService } from 'vs/platform/label/common/label';
import { dirname } from 'vs/base/common/resources';
import { IBannerService } from 'vs/workbench/services/banner/browser/bannerService';
import { Codicon } from 'vs/base/common/codicons';
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { IUtilityProcessWorkerWorkbenchService } from 'vs/workbench/services/utilityProcess/electron-sandbox/utilityProcessWorkerWorkbenchService';
import { registerWindowDriver } from 'vs/workbench/services/driver/electron-sandbox/driver';

export class NativeWindow extends Disposable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,31 @@
import { getClientArea, getTopLeftOffset } from 'vs/base/browser/dom';
import { coalesce } from 'vs/base/common/arrays';
import { language, locale } from 'vs/base/common/platform';
import { IElement, ILocaleInfo, ILocalizedStrings, ILogFile, IWindowDriver } from 'vs/platform/driver/common/driver';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IFileService } from 'vs/platform/files/common/files';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import localizedStrings from 'vs/platform/languagePacks/common/localizedStrings';
import { getLogs } from 'vs/platform/log/browser/log';
import { ILogFile, getLogs } from 'vs/platform/log/browser/log';
import { IWindowDriver, IElement, ILocaleInfo, ILocalizedStrings } from 'vs/workbench/services/driver/common/driver';
import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';

export class BrowserWindowDriver implements IWindowDriver {

constructor(
@IFileService private readonly fileService: IFileService,
@IEnvironmentService private readonly environmentService: IEnvironmentService
@IEnvironmentService private readonly environmentService: IEnvironmentService,
@ILifecycleService private readonly lifecycleService: ILifecycleService,
) {
}

async getLogs(): Promise<ILogFile[]> {
return getLogs(this.fileService, this.environmentService);
}

whenWorkbenchRestored(): Promise<void> {
return this.lifecycleService.when(LifecyclePhase.Restored);
}

async setValue(selector: string, text: string): Promise<void> {
const element = document.querySelector(selector);

Expand Down Expand Up @@ -211,6 +217,7 @@ export class BrowserWindowDriver implements IWindowDriver {
async exitApplication(): Promise<void> {
// No-op in web
}

}

export function registerWindowDriver(instantiationService: IInstantiationService): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface IWindowDriver {
getLocaleInfo(): Promise<ILocaleInfo>;
getLocalizedStrings(): Promise<ILocalizedStrings>;
getLogs(): Promise<ILogFile[]>;
whenWorkbenchRestored(): Promise<void>;
exitApplication(): Promise<void>;
}
//*END
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { BrowserWindowDriver } from 'vs/platform/driver/browser/driver';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IFileService } from 'vs/platform/files/common/files';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { BrowserWindowDriver } from 'vs/workbench/services/driver/browser/driver';
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';

interface INativeWindowDriverHelper {
exitApplication(): Promise<void>;
Expand All @@ -17,9 +18,10 @@ class NativeWindowDriver extends BrowserWindowDriver {
constructor(
private readonly helper: INativeWindowDriverHelper,
@IFileService fileService: IFileService,
@IEnvironmentService environmentService: IEnvironmentService
@IEnvironmentService environmentService: IEnvironmentService,
@ILifecycleService lifecycleService: ILifecycleService
) {
super(fileService, environmentService);
super(fileService, environmentService, lifecycleService);
}

override exitApplication(): Promise<void> {
Expand Down
4 changes: 4 additions & 0 deletions test/automation/src/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ export class Code {
await this.poll(() => this.driver.writeInTerminal(selector, value), () => true, `writeInTerminal '${selector}'`);
}

whenWorkbenchRestored(): Promise<void> {
return this.driver.whenWorkbenchRestored();
}

getLocaleInfo(): Promise<ILocaleInfo> {
return this.driver.getLocaleInfo();
}
Expand Down
4 changes: 4 additions & 0 deletions test/automation/src/playwrightDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ export class PlaywrightDriver {
return new Promise<void>(resolve => setTimeout(resolve, ms));
}

whenWorkbenchRestored(): Promise<void> {
return this.evaluateWithDriver(([driver]) => driver.whenWorkbenchRestored());
}

private async getDriverHandle(): Promise<playwright.JSHandle<IWindowDriver>> {
return this.page.evaluateHandle('window.driver');
}
Expand Down
34 changes: 18 additions & 16 deletions test/automation/src/quickaccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,36 +171,38 @@ export class QuickAccess {
}

async runCommand(commandId: string, options?: { keepOpen?: boolean; exactLabelMatch?: boolean }): Promise<void> {
let retries = 0;

const keepOpen = options?.keepOpen;
const exactLabelMatch = options?.exactLabelMatch;

while (++retries < 5) {

const openCommandPalletteAndTypeCommand = async (): Promise<string> => {
// open commands picker
await this.openQuickAccessWithRetry(QuickAccessKind.Commands, `>${commandId}`);

// wait for best choice to be focused
await this.quickInput.waitForQuickInputElementFocused();

// Retry for as long as the command not found
const text = await this.quickInput.waitForQuickInputElementText();
if (text === 'No matching commands' || (exactLabelMatch && text !== commandId)) {
this.code.logger.log(`QuickAccess: No matching commands, will retry...`);
await this.quickInput.closeQuickInput();
await this.code.wait(1000);
continue;
}
return await this.quickInput.waitForQuickInputElementText();
};

// wait and click on best choice
await this.quickInput.selectQuickInputElement(0, keepOpen);
let text = await openCommandPalletteAndTypeCommand();

return;
}
if (text === 'No matching commands' || (exactLabelMatch && text !== commandId)) {
this.code.logger.log(`QuickAccess: No matching commands, will retry...`);
await this.quickInput.closeQuickInput();

// Wait for workbench to be restored
await this.code.whenWorkbenchRestored();

throw new Error(`Command: ${commandId} Not found`);
// Retry after workbench is restored
text = await openCommandPalletteAndTypeCommand();
if (text === 'No matching commands' || (exactLabelMatch && text !== commandId)) {
throw new Error(`Command: ${commandId} Not found`);
}
}

// wait and click on best choice
await this.quickInput.selectQuickInputElement(0, keepOpen);
}

async openQuickOutline(): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion test/automation/tools/copy-driver-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const fs = require('fs');
const path = require('path');

const root = path.dirname(path.dirname(path.dirname(__dirname)));
const driverPath = path.join(root, 'src/vs/platform/driver/common/driver.ts');
const driverPath = path.join(root, 'src/vs/workbench/services/driver/common/driver.ts');

let contents = fs.readFileSync(driverPath, 'utf8');
contents = /\/\/\*START([\s\S]*)\/\/\*END/mi.exec(contents)[1].trim();
Expand Down