mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-23 09:35:39 -05:00
Try to make smoke tests more stable (#15212)
* make sure dialog buttons are not disabled * use 'enter' to close connect dialog * retry clikcing the Connect button * wait for dialog gone after reclicking * pr comments + add logging * use debug to log * close toasts before clicking dialog buttons * await close notification toast call * click python wizard buttons instead of enter
This commit is contained in:
@@ -5,12 +5,13 @@
|
||||
|
||||
import { Code } from '../code';
|
||||
import { Dialog } from './dialog';
|
||||
import { NotificationToast } from './notificationToast';
|
||||
|
||||
const CONFIGURE_PYTHON_DIALOG_TITLE = 'Configure Python to run Python 3 kernel';
|
||||
|
||||
export class ConfigurePythonDialog extends Dialog {
|
||||
|
||||
constructor(code: Code) {
|
||||
constructor(code: Code, private notificationToast: NotificationToast) {
|
||||
super(CONFIGURE_PYTHON_DIALOG_TITLE, code);
|
||||
}
|
||||
|
||||
@@ -25,13 +26,23 @@ export class ConfigurePythonDialog extends Dialog {
|
||||
const newPythonInstallation = '.modal .modal-body input[aria-label="New Python installation"]';
|
||||
await this.code.waitAndClick(newPythonInstallation);
|
||||
|
||||
// Wait for the python install location to be loaded before clicking the next button.
|
||||
// There may be a timing issue where the smoke test attempts to go to the next page before
|
||||
// the contents are loaded, causing the test to fail.
|
||||
const pythonInstallLocationDropdownValue = `${dialog} select[aria-label="Python Install Location"] option`;
|
||||
await this.code.waitForElement(pythonInstallLocationDropdownValue);
|
||||
|
||||
await this.notificationToast.closeNotificationToasts();
|
||||
|
||||
const nextButton = '.modal-dialog .modal-content .modal-footer .right-footer .footer-button a[aria-label="Next"][aria-disabled="false"]';
|
||||
await this.code.waitForElement(nextButton);
|
||||
await this.code.dispatchKeybinding('enter');
|
||||
await this.code.waitAndClick(dialog);
|
||||
await this.code.waitAndClick(nextButton);
|
||||
|
||||
await this.notificationToast.closeNotificationToasts();
|
||||
|
||||
const installButton = '.modal-dialog .modal-content .modal-footer .right-footer .footer-button a[aria-label="Install"][aria-disabled="false"]';
|
||||
await this.code.waitForElement(installButton);
|
||||
await this.code.dispatchKeybinding('enter');
|
||||
await this.code.waitAndClick(dialog);
|
||||
await this.code.waitAndClick(installButton);
|
||||
|
||||
await this.waitForDialogGone();
|
||||
return this._waitForInstallationComplete();
|
||||
|
||||
@@ -5,12 +5,13 @@
|
||||
|
||||
import { Code } from '../code';
|
||||
import { Dialog } from './dialog';
|
||||
import { NotificationToast } from './notificationToast';
|
||||
|
||||
const CONNECTION_DIALOG_TITLE = 'Connection';
|
||||
|
||||
export class ConnectionDialog extends Dialog {
|
||||
|
||||
constructor(code: Code) {
|
||||
constructor(code: Code, private notificationToast: NotificationToast) {
|
||||
super(CONNECTION_DIALOG_TITLE, code);
|
||||
}
|
||||
|
||||
@@ -30,8 +31,10 @@ export class ConnectionDialog extends Dialog {
|
||||
|
||||
private static readonly CONNECT_BUTTON_SELECTOR = '.modal .modal-footer a[aria-label="Connect"]:not(.disabled)';
|
||||
async connect(): Promise<void> {
|
||||
await this.notificationToast.closeNotificationToasts();
|
||||
|
||||
await this.code.waitAndClick(ConnectionDialog.CONNECT_BUTTON_SELECTOR);
|
||||
|
||||
return this.waitForDialogGone();
|
||||
await this.waitForDialogGone();
|
||||
}
|
||||
}
|
||||
|
||||
27
test/automation/src/sql/notificationToast.ts
Normal file
27
test/automation/src/sql/notificationToast.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Code } from '../code';
|
||||
|
||||
export class NotificationToast {
|
||||
|
||||
constructor(private readonly code: Code) { }
|
||||
|
||||
async closeNotificationToasts() {
|
||||
const notificationToastSelector = 'div[class="notifications-toasts visible"]';
|
||||
const notificationToastCloseButton = `a[class="action-label codicon codicon-notifications-clear"][role="button"]`;
|
||||
let numberOfToasts = 0;
|
||||
|
||||
await this.code.waitForElements(notificationToastSelector, false, result => {
|
||||
numberOfToasts = result.length;
|
||||
return true;
|
||||
});
|
||||
|
||||
for (let i = 0; i < numberOfToasts; i++) {
|
||||
await this.code.waitAndClick(notificationToastSelector);
|
||||
await this.code.waitAndClick(notificationToastCloseButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user