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

test: Update ui test to fix logic for headless mode, add logs (#21361) #21362

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions ui-test/src/UiTestUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,20 @@ export default class UiTestUtilities {
*/
public static async init(): Promise<Navigation> {
const options = new chrome.Options();
if (process.env.IS_HEADLESS) {
UiTestUtilities.log('Env var IS_HEADLESS = ' + process.env.IS_HEADLESS);
if (process.env.IS_HEADLESS !== 'false') {
UiTestUtilities.log('Adding headless option');
options.addArguments('headless');
}
options.addArguments('window-size=1400x1200');
const driver = await new Builder()
.forBrowser('chrome')
.setChromeOptions(options)
.build();
const driver = await new Builder().forBrowser('chrome').setChromeOptions(options).build();

UiTestUtilities.log('Environment variables are:');
UiTestUtilities.log(require('dotenv').config({path: __dirname + '/../.env'}));

// Navigate to the ArgoCD URL
await driver.get(Configuration.ARGOCD_URL);

UiTestUtilities.log('Navigate to Argo CD URL successful: driver.get');
return new Navigation(driver);
}

Expand Down
39 changes: 25 additions & 14 deletions ui-test/src/application-create-panel/application-create-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export class ApplicationCreatePanel extends Base {
try {
const appNameField = await UiTestUtilities.findUiElement(this.driver, CREATE_APPLICATION_FIELD_APP_NAME);
await appNameField.sendKeys(appName);
} catch (err) {
} catch (err: any) {
UiTestUtilities.log('Error caught while setting app name: ' + err);
throw new Error(err);
}
}
Expand All @@ -40,7 +41,8 @@ export class ApplicationCreatePanel extends Base {
try {
const project = await UiTestUtilities.findUiElement(this.driver, CREATE_APPLICATION_FIELD_PROJECT);
await project.sendKeys(projectName);
} catch (err) {
} catch (err: any) {
UiTestUtilities.log('Error caught while setting project name: ' + err);
throw new Error(err);
}
}
Expand All @@ -49,7 +51,8 @@ export class ApplicationCreatePanel extends Base {
try {
const reposUrl = await UiTestUtilities.findUiElement(this.driver, CREATE_APPLICATION_FIELD_REPOSITORY_URL);
await reposUrl.sendKeys(sourceRepoUrl);
} catch (err) {
} catch (err: any) {
UiTestUtilities.log('Error caught while setting source repo URL: ' + err);
throw new Error(err);
}
}
Expand All @@ -58,7 +61,8 @@ export class ApplicationCreatePanel extends Base {
try {
const path = await UiTestUtilities.findUiElement(this.driver, CREATE_APPLICATION_FIELD_REPOSITORY_PATH);
await path.sendKeys(sourceRepoPath);
} catch (err) {
} catch (err: any) {
UiTestUtilities.log('Error caught while setting source repo path: ' + err);
throw new Error(err);
}
}
Expand All @@ -78,7 +82,8 @@ export class ApplicationCreatePanel extends Base {
if (destinationClusterFieldValue) {
await this.setDestinationClusterUrl(destinationClusterFieldValue);
}
} catch (err) {
} catch (err: any) {
UiTestUtilities.log('Error caught while selecting destination cluster URL menu: ' + err);
throw new Error(err);
}
}
Expand All @@ -98,7 +103,8 @@ export class ApplicationCreatePanel extends Base {
if (destinationClusterFieldValue) {
await this.setDestinationClusterName(destinationClusterFieldValue);
}
} catch (err) {
} catch (err: any) {
UiTestUtilities.log('Error caught while selecting destination cluster name menu: ' + err);
throw new Error(err);
}
}
Expand All @@ -108,7 +114,8 @@ export class ApplicationCreatePanel extends Base {
const clusterName = await UiTestUtilities.findUiElement(this.driver, CREATE_APPLICATION_FIELD_CLUSTER_NAME);
await clusterName.sendKeys(destinationClusterName);
// await clusterName.sendKeys('\r');
} catch (err) {
} catch (err: any) {
UiTestUtilities.log('Error caught while setting destination cluster name: ' + err);
throw new Error(err);
}
}
Expand All @@ -117,7 +124,8 @@ export class ApplicationCreatePanel extends Base {
try {
const clusterUrl = await UiTestUtilities.findUiElement(this.driver, CREATE_APPLICATION_FIELD_CLUSTER_URL);
await clusterUrl.sendKeys(destinationClusterUrl);
} catch (err) {
} catch (err: any) {
UiTestUtilities.log('Error caught while setting destination cluster URL: ' + err);
throw new Error(err);
}
}
Expand All @@ -126,7 +134,8 @@ export class ApplicationCreatePanel extends Base {
try {
const namespace = await UiTestUtilities.findUiElement(this.driver, CREATE_APPLICATION_FIELD_CLUSTER_NAMESPACE);
await namespace.sendKeys(destinationNamespace);
} catch (err) {
} catch (err: any) {
UiTestUtilities.log('Error caught while setting destination namespace: ' + err);
throw new Error(err);
}
}
Expand All @@ -140,12 +149,13 @@ export class ApplicationCreatePanel extends Base {
await createButton.click();

// Wait until the Create Application Sliding Panel disappears
await this.driver.wait(until.elementIsNotVisible(createButton), Const.TEST_SLIDING_PANEL_TIMEOUT).catch(e => {
await this.driver.wait(until.elementIsNotVisible(createButton), Const.TEST_SLIDING_PANEL_TIMEOUT).catch((e) => {
UiTestUtilities.logError('The Create Application Sliding Panel did not disappear');
throw e;
});
await this.driver.sleep(1000);
} catch (err) {
} catch (err: any) {
UiTestUtilities.log('Error caught while clicking Create button: ' + err);
throw new Error(err);
}
}
Expand All @@ -159,11 +169,12 @@ export class ApplicationCreatePanel extends Base {
await cancelButton.click();

// Wait until the Create Application Sliding Panel disappears
await this.driver.wait(until.elementIsNotVisible(cancelButton), Const.TEST_SLIDING_PANEL_TIMEOUT).catch(e => {
await this.driver.wait(until.elementIsNotVisible(cancelButton), Const.TEST_SLIDING_PANEL_TIMEOUT).catch((e) => {
UiTestUtilities.logError('The Create Application Sliding Panel did not disappear');
throw e;
});
} catch (err) {
} catch (err: any) {
UiTestUtilities.log('Error caught while clicking Cancel button: ' + err);
throw new Error(err);
}
}
Expand Down Expand Up @@ -198,7 +209,7 @@ export class ApplicationCreatePanel extends Base {
await this.selectDestinationClusterNameMenu(destinationClusterName);
await this.setDestinationNamespace(destinationNamespace);
await this.clickCreateButton();
} catch (err) {
} catch (err: any) {
throw new Error(err);
}
}
Expand Down
14 changes: 7 additions & 7 deletions ui-test/src/applications-list/applications-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ApplicationsList extends Base {
try {
const tile = await UiTestUtilities.findUiElement(this.driver, this.getApplicationTileLocator(appName));
await tile.click();
} catch (err) {
} catch (err: any) {
throw new Error(err);
}
}
Expand All @@ -39,7 +39,7 @@ export class ApplicationsList extends Base {
try {
const newAppButton = await UiTestUtilities.findUiElement(this.driver, NEW_APP_BUTTON);
await newAppButton.click();
} catch (err) {
} catch (err: any) {
throw new Error(err);
}
return this.applicationCreatePanel;
Expand All @@ -57,7 +57,7 @@ export class ApplicationsList extends Base {
// Wait until the Synchronize sliding panel appears
const synchronizeButton = await this.driver.wait(until.elementLocated(SYNC_PANEL_SYNCHRONIZE_BUTTON), Const.TEST_TIMEOUT);
await this.driver.wait(until.elementIsVisible(synchronizeButton), Const.TEST_TIMEOUT);
} catch (err) {
} catch (err: any) {
throw new Error(err);
}
return this.applicationsSyncPanel;
Expand All @@ -72,7 +72,7 @@ export class ApplicationsList extends Base {
try {
const deleteButton = await UiTestUtilities.findUiElement(this.driver, this.getDeleteButtonLocatorForApp(appName));
await deleteButton.click();
} catch (err) {
} catch (err: any) {
throw new Error(err);
}
return this.popupManager;
Expand All @@ -95,7 +95,7 @@ export class ApplicationsList extends Base {
const refreshButton = await UiTestUtilities.findUiElement(this.driver, this.getRefreshButtonLocatorForApp(appName));
await this.driver.wait(until.elementIsVisible(refreshButton), Const.TEST_TIMEOUT);
await refreshButton.click();
} catch (err) {
} catch (err: any) {
throw new Error(err);
}
}
Expand All @@ -111,7 +111,7 @@ export class ApplicationsList extends Base {
await this.driver.wait(async () => {
return UiTestUtilities.untilAttributeIs(healthStatusElement, 'title', 'Healthy');
}, Const.TEST_TIMEOUT);
} catch (err) {
} catch (err: any) {
throw new Error(err);
}
}
Expand All @@ -127,7 +127,7 @@ export class ApplicationsList extends Base {
await this.driver.wait(async () => {
return UiTestUtilities.untilAttributeIs(statusElement, 'title', 'Synced');
}, Const.TEST_TIMEOUT);
} catch (err) {
} catch (err: any) {
throw new Error(err);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export class ApplicationsSyncPanel extends Base {
await this.driver.wait(until.elementIsEnabled(synchronizeButton), Const.TEST_TIMEOUT);
await synchronizeButton.click();

await this.driver.wait(until.elementIsNotVisible(synchronizeButton), Const.TEST_SLIDING_PANEL_TIMEOUT).catch(e => {
await this.driver.wait(until.elementIsNotVisible(synchronizeButton), Const.TEST_SLIDING_PANEL_TIMEOUT).catch((e) => {
UiTestUtilities.logError('The Synchronization Sliding Panel did not disappear');
throw e;
});
UiTestUtilities.log('Synchronize sliding panel disappeared');
} catch (err) {
} catch (err: any) {
throw new Error(err);
}
}
Expand Down
8 changes: 4 additions & 4 deletions ui-test/src/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class Navigation extends Base {
try {
const navBarButton = await UiTestUtilities.findUiElement(this.driver, NAVBAR_APPLICATIONS_BUTTON);
await navBarButton.click();
} catch (err) {
} catch (err: any) {
throw new Error(err);
}
return this.applicationsList;
Expand All @@ -45,7 +45,7 @@ export class Navigation extends Base {
try {
const navBarButton = await UiTestUtilities.findUiElement(this.driver, NAVBAR_SETTINGS_BUTTON);
await navBarButton.click();
} catch (err) {
} catch (err: any) {
throw new Error(err);
}
}
Expand All @@ -58,7 +58,7 @@ export class Navigation extends Base {
try {
const navBarButton = await UiTestUtilities.findUiElement(this.driver, NAVBAR_USER_INFO_BUTTON);
await navBarButton.click();
} catch (err) {
} catch (err: any) {
throw new Error(err);
}
}
Expand All @@ -71,7 +71,7 @@ export class Navigation extends Base {
try {
const navBarButton = await UiTestUtilities.findUiElement(this.driver, NAVBAR_DOCS_BUTTON);
await navBarButton.click();
} catch (err) {
} catch (err: any) {
throw new Error(err);
}
}
Expand Down
Loading