Add uninstall step to manage packages smoke test to clean up installed packages. (#19854)

This commit is contained in:
Cory Rivera
2022-06-29 10:23:29 -07:00
committed by GitHub
parent 96d29bcbc1
commit 24fc6dce9f
3 changed files with 72 additions and 6 deletions

View File

@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { Code } from '../code';
import { QuickInput } from '../quickinput';
import { Dialog } from './dialog';
const MANAGE_PACKAGES_DIALOG_TITLE = 'Manage Packages';
@@ -11,7 +12,7 @@ const MANAGE_PACKAGES_DIALOG_TITLE = 'Manage Packages';
export class ManagePackagesDialog extends Dialog {
private static readonly dialogPage = '.modal .modal-body .dialogModal-pane';
constructor(code: Code) {
constructor(code: Code, private readonly quickInput: QuickInput) {
super(MANAGE_PACKAGES_DIALOG_TITLE, code);
}
@@ -60,4 +61,44 @@ export class ManagePackagesDialog extends Dialog {
return packageVersion;
}
async removePackage(packageName: string, clickOnTab: boolean = false): Promise<void> {
// When the dialog is first opened, the Installed Packages tab is already open, which causes
// clicking on its page tab to fail. So we skip clicking on the page tab by default, but can
// re-enable it if mixing install and uninstall operations in the same test.
if (clickOnTab) {
const installedPkgTab = `${ManagePackagesDialog.dialogPage} div[class="tab-header"][aria-controls="dialogPane.Manage Packages.0"]`;
await this.code.waitAndClick(installedPkgTab);
}
// Wait for initial loading spinner to disappear
const loadingSpinner = `${ManagePackagesDialog.dialogPage} div.modelview-loadingComponent-spinner`;
await this.code.waitForElement(loadingSpinner);
await this.code.waitForElementGone(loadingSpinner);
// Click on package row in installed packages list to select it for uninstall
const packageRow = `${ManagePackagesDialog.dialogPage} div[role="gridcell"][aria-label="${packageName}"]`;
await this.code.waitAndClick(packageRow);
// Tab over to uninstall button on the right side of the row. Can't select the uninstall button
// directly since it doesn't have any package name info associated with it.
await this.code.dispatchKeybinding('tab');
await this.code.dispatchKeybinding('tab');
await this.code.dispatchKeybinding('enter');
// Click Yes on quick select
const quickInputAccept = 'Yes';
await this.quickInput.waitForQuickInputOpened();
await this.quickInput.waitForQuickInputElements(names => names[0] === quickInputAccept);
await this.quickInput.submit(quickInputAccept);
// Wait for uninstall loading spinner to disappear
await this.code.waitForElement(loadingSpinner);
await this.code.waitForElementGone(loadingSpinner);
// Close dialog
const closeButton = '.modal .modal-footer a[class="monaco-button monaco-text-button"][aria-label="Close"][aria-disabled="false"]';
await this.code.waitAndClick(closeButton);
await this.waitForDialogGone();
}
}