Skip to content

Commit

Permalink
Fix integration tests for Theia 1.37
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy Johnson <[email protected]>
  • Loading branch information
t1m0thyj committed Jul 13, 2023
1 parent ba1648d commit d39538c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("Locate Tree Nodes", () => {
afterEach(screenshotIfFailed(driverFirefox));

it("should open Zowe Explorer and find the Favorites node", async () => {
const favoriteLink = await driverFirefox.getFavouritesNode();
const favoriteLink = await driverFirefox.getFavoritesNode();
expect(favoriteLink).to.equal("Favorites");
}).timeout(TIMEOUT);

Expand Down Expand Up @@ -186,7 +186,7 @@ describe("Test Adding and Removing Favorites", () => {
await driverChrome.sleepTime(SHORTSLEEPTIME);
await driverChrome.clickOnFavoriteTabInDatasets();
await driverChrome.sleepTime(SHORTSLEEPTIME);
const favoriteProfile = await driverChrome.getFavoritePrfileNameFromDatasets();
const favoriteProfile = await driverChrome.getFavoriteProfileNameFromDatasets();
expect(favoriteProfile).to.equal("TestSeleniumProfile");
});

Expand All @@ -206,7 +206,7 @@ describe("Test Adding and Removing Favorites", () => {
await driverChrome.sleepTime(SHORTSLEEPTIME);
await driverChrome.clickOnFavoriteTabInUss();
await driverChrome.sleepTime(SHORTSLEEPTIME);
const favoriteProfile = await driverChrome.getFavoritePrfileNameFromUss();
const favoriteProfile = await driverChrome.getFavoriteProfileNameFromUss();
expect(favoriteProfile).to.equal("TestSeleniumProfile");
});

Expand All @@ -226,7 +226,7 @@ describe("Test Adding and Removing Favorites", () => {
await driverChrome.sleepTime(SHORTSLEEPTIME);
await driverChrome.clickOnFavoriteTabInJobs();
await driverChrome.sleepTime(SHORTSLEEPTIME);
const favoriteProfile = await driverChrome.getFavoritePrfileNameFromJobs();
const favoriteProfile = await driverChrome.getFavoriteProfileNameFromJobs();
expect(favoriteProfile).to.equal("TestSeleniumProfile");
});

Expand Down
38 changes: 15 additions & 23 deletions packages/zowe-explorer/__tests__/__theia__/theia/Locators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

export const TheiaLocator = {
theiaUrl: "http://localhost:3000",

zoweExplorerxId: "shell-tab-plugin-view-container:zowe",
};

Expand All @@ -21,16 +20,14 @@ export const DatasetsLocators = {
datasetsPanelId: "plugin-view:zowe.ds.explorer",
datasetsAddSessionId: "zowe.ds.addSession-as-tabbar-toolbar-item",
emptyInputBoxXpath: "//*[@class='input empty']",
createNewConnectionListXpath: "//*[@class='monaco-list-row'][1]",
createNewConnectionListXpath: "//*[@class='monaco-list-row focused'][1]",
inputBoxXpath: "//*[@class='input']",
defaultDatasetsProfileId: "/iDefaultProfile",
secondDatasetProfileId: "/iTestSeleniumProfile",
favoriteTabId: "/iFavorites",
favoriteProfileInDatasetId: "/iFavorites/iTestSeleniumProfile",
defaultDatasetsProfileXpath: "(//div[contains(@id,'DefaultProfile')])[1]",
secondDatasetProfileXpath: "(//div[contains(@id,'TestSeleniumProfile')])[1]",
favoriteTabXpath: "(//div[contains(@id,'Favorites')])[1]",
favoriteProfileInDatasetXpath: "(//div[contains(@id,'Favorites') and contains(@id,'TestSeleniumProfile')])",
addToFavoriteOptionXpath: "//li[@data-command='zowe.ds.saveSearch']",
searchSymbolInFavoriteXpath: "//*[@id='/iFavorites/iTestSeleniumProfile/i']",
removeFavoriteProfileFromDatasetsOptionXpath: "//li[@data-command='zowe.ds.removeFavProfile']",
secondDatasetProfileBeforeDeletingId: "/iTestSeleniumProfile",
deleteProfileFromDatasetsXpath: "(//li[@data-command='zowe.ds.deleteProfile'])",
};

Expand All @@ -40,15 +37,14 @@ export const UssLocators = {
ussPanelId: "plugin-view:zowe.uss.explorer",
ussAddSessionId: "zowe.uss.addSession-as-tabbar-toolbar-item",
emptyInputBoxXpath: "//*[@class='input empty']",
defaultUssProfileXpath: "(//div[@id='/iDefaultProfile'])[2]",
secondUssProfileXpath: "(//div[@id='/iTestSeleniumProfile'])[2]",
favoriteTabXpath: "(//div[@id='/iFavorites'])[2]",
favoriteProfileInUssXpath: "(//div[@id='/iFavorites/iTestSeleniumProfile'])",
defaultUssProfileXpath: "(//div[contains(@id,'DefaultProfile')])[2]",
secondUssProfileXpath: "(//div[contains(@id,'TestSeleniumProfile')])[2]",
favoriteTabXpath: "(//div[contains(@id,'Favorites')])[2]",
favoriteProfileInUssXpath: "(//div[contains(@id,'Favorites') and contains(@id,'TestSeleniumProfile')])",
addToFavoriteOptionXpath: "//li[@data-command='zowe.uss.addFavorite']",
favoriteProfileInUssBeforeRemovingXpath: "(//div[@id='/iFavorites/iTestSeleniumProfile'])",
removeFavoriteProfileFromUssOptionXpath: "//li[@data-command='zowe.uss.removeFavProfile']",
hideProfileFromUssOptionXpath: "//li[@data-command='zowe.uss.removeSession']",
searchSymbolInFavoriteXpath: "//*[@id='/iFavorites/iTestSeleniumProfile/i']",
secondUssProfileBeforeHidingXpath: "(//div[contains(@id,'TestSeleniumProfile')])[1]",
};

export const JobsLocators = {
Expand All @@ -57,18 +53,14 @@ export const JobsLocators = {
jobsPanelId: "zowe.jobs.explorer",
jobsAddSessionId: "zowe.jobs.addJobsSession-as-tabbar-toolbar-item",
emptyInputBoxXpath: "//*[@class='input empty']",
defaultJobsProfileXpath: "(//div[@id='/iDefaultProfile'])[3]",
secondJobsProfileXpath: "(//div[@id='/iTestSeleniumProfile'])[3]",
favoriteTabXpath: "(//div[@id='/iFavorites'])[3]",
favoriteTabAfterRefreshXpath: "(//div[@id='/iFavorites'])[2]",
favoriteProfileInJobsXpath: "(//div[@id='/iFavorites/iTestSeleniumProfile'])",
favoriteprofile: "(//div[@id='/iFavorites/iTestSeleniumProfile'])",
defaultJobsProfileXpath: "(//div[contains(@id,'DefaultProfile')])[3]",
secondJobsProfileXpath: "(//div[contains(@id,'TestSeleniumProfile')])[3]",
favoriteTabXpath: "(//div[contains(@id,'Favorites')])[3]",
favoriteProfileInJobsXpath: "(//div[contains(@id,'Favorites') and contains(@id,'TestSeleniumProfile')])",
addToFavoriteOptionXpath: "//li[@data-command='zowe.jobs.addFavorite']",
favoriteProfileInJobsBeforeRemovingXpath: "//div[@id='/iFavorites/iTestSeleniumProfile/iPrefix:*']",
removeFavoriteProfileFromJobsOptionXpath: "//li[@data-command='zowe.jobs.removeFavProfile']",
hideProfileFromJobsOptionXpath: "//li[@data-command='zowe.jobs.removeJobsSession']",
secondJobsProfileIdBeforeHidingXpath: "(//div[@id='/iTestSeleniumProfile'])[2]",
favoriteprofilexpath: "//div[@id='/iFavorites/iTestSeleniumProfile']",
secondJobsProfileBeforeHidingXpath: "(//div[contains(@id,'TestSeleniumProfile')])[1]",
};

export const TheiaNotificationMessages = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function clickOnZoweExplorer() {
}

export async function clickOnFavoriteTabInDatasets() {
await driverChrome.wait(until.elementLocated(By.id(DatasetsLocators.favoriteTabId)), WAITTIME).click();
await driverChrome.wait(until.elementLocated(By.xpath(DatasetsLocators.favoriteTabXpath)), WAITTIME).click();
}

export async function clickOnFavoriteTabInUss() {
Expand All @@ -54,10 +54,6 @@ export async function clickOnFavoriteTabInJobs() {
await driverChrome.wait(until.elementLocated(By.xpath(JobsLocators.favoriteTabXpath)), WAITTIME).click();
}

export async function clickOnFavoriteTabInJobsAfterRefresh() {
await driverChrome.wait(until.elementLocated(By.xpath(JobsLocators.favoriteTabAfterRefreshXpath)), WAITTIME).click();
}

export async function clickOnDatasetsTab() {
await driverChrome.findElement(By.xpath(DatasetsLocators.datasetTabXpath)).click();
}
Expand All @@ -74,22 +70,24 @@ export async function clickOnJobsTab() {
await driverChrome.findElement(By.id(JobsLocators.jobTabId)).click();
}

export async function getFavoritePrfileNameFromDatasets() {
const favoriteProfile = await driverChrome.wait(until.elementLocated(By.id(DatasetsLocators.favoriteProfileInDatasetId)), WAITTIME).getText();
export async function getFavoriteProfileNameFromDatasets() {
const favoriteProfile = await driverChrome
.wait(until.elementLocated(By.xpath(DatasetsLocators.favoriteProfileInDatasetXpath)), WAITTIME)
.getText();
return favoriteProfile;
}

export async function getFavoritePrfileNameFromUss() {
export async function getFavoriteProfileNameFromUss() {
const favoriteProfile = await driverChrome.wait(until.elementLocated(By.xpath(UssLocators.favoriteProfileInUssXpath)), WAITTIME).getText();
return favoriteProfile;
}

export async function getFavoritePrfileNameFromJobs() {
export async function getFavoriteProfileNameFromJobs() {
return driverChrome.wait(until.elementLocated(By.xpath(JobsLocators.favoriteProfileInJobsXpath)), WAITTIME).getText();
}

export async function removeFavoriteProfileFromDatasets() {
const removeFromFavorite = await driverChrome.wait(until.elementLocated(By.id(DatasetsLocators.favoriteProfileInDatasetId)), WAITTIME);
const removeFromFavorite = await driverChrome.wait(until.elementLocated(By.xpath(DatasetsLocators.favoriteProfileInDatasetXpath)), WAITTIME);
await driverChrome.actions().click(removeFromFavorite, Button.RIGHT).perform();
await driverChrome.sleep(SHORTSLEEPTIME);
await driverChrome.wait(until.elementLocated(By.xpath(DatasetsLocators.removeFavoriteProfileFromDatasetsOptionXpath)), WAITTIME).click();
Expand All @@ -98,7 +96,7 @@ export async function removeFavoriteProfileFromDatasets() {
}

export async function removeFavoriteProfileFromUss() {
const removeFromFavorite = await driverChrome.wait(until.elementLocated(By.xpath(UssLocators.favoriteProfileInUssBeforeRemovingXpath)), WAITTIME);
const removeFromFavorite = await driverChrome.wait(until.elementLocated(By.xpath(UssLocators.favoriteProfileInUssXpath)), WAITTIME);
await driverChrome.actions().click(removeFromFavorite, Button.RIGHT).perform();
await driverChrome.sleep(SHORTSLEEPTIME);
await driverChrome.wait(until.elementLocated(By.xpath(UssLocators.removeFavoriteProfileFromUssOptionXpath)), WAITTIME).click();
Expand All @@ -107,7 +105,7 @@ export async function removeFavoriteProfileFromUss() {
}

export async function removeFavoriteProfileFromJobs() {
const removeFromFavorite = await driverChrome.wait(until.elementLocated(By.xpath(JobsLocators.favoriteprofile)), WAITTIME);
const removeFromFavorite = await driverChrome.wait(until.elementLocated(By.xpath(JobsLocators.favoriteProfileInJobsXpath)), WAITTIME);
await driverChrome.actions().click(removeFromFavorite, Button.RIGHT).perform();
await driverChrome.sleep(SHORTSLEEPTIME);
await driverChrome.wait(until.elementLocated(By.xpath(JobsLocators.removeFavoriteProfileFromJobsOptionXpath)), WAITTIME).click();
Expand All @@ -116,7 +114,7 @@ export async function removeFavoriteProfileFromJobs() {
}

export async function addProfileToFavoritesInDatasets() {
const addTofavorite = await driverChrome.wait(until.elementLocated(By.id(DatasetsLocators.secondDatasetProfileId)), WAITTIME);
const addTofavorite = await driverChrome.wait(until.elementLocated(By.xpath(DatasetsLocators.secondDatasetProfileXpath)), WAITTIME);
await driverChrome.actions().click(addTofavorite, Button.RIGHT).perform();
await driverChrome.sleep(SHORTSLEEPTIME);
await driverChrome.wait(until.elementLocated(By.xpath(DatasetsLocators.addToFavoriteOptionXpath)), WAITTIME).click();
Expand All @@ -138,13 +136,13 @@ export async function addProfileToFavoritesInJobs() {
}

export async function hideProfileInUss() {
const hideProfileFromUss = await driverChrome.wait(until.elementLocated(By.xpath(UssLocators.secondUssProfileXpath)), WAITTIME);
const hideProfileFromUss = await driverChrome.wait(until.elementLocated(By.xpath(UssLocators.secondUssProfileBeforeHidingXpath)), WAITTIME);
await driverChrome.actions().click(hideProfileFromUss, Button.RIGHT).perform();
await driverChrome.wait(until.elementLocated(By.xpath(UssLocators.hideProfileFromUssOptionXpath)), WAITTIME).click();
}

export async function hideProfileInJobs() {
const hideProfileFromJobs = await driverChrome.wait(until.elementLocated(By.xpath(JobsLocators.secondJobsProfileIdBeforeHidingXpath)), WAITTIME);
const hideProfileFromJobs = await driverChrome.wait(until.elementLocated(By.xpath(JobsLocators.secondJobsProfileBeforeHidingXpath)), WAITTIME);
await driverChrome.actions().click(hideProfileFromJobs, Button.RIGHT).perform();
await driverChrome.wait(until.elementLocated(By.xpath(JobsLocators.hideProfileFromJobsOptionXpath)), WAITTIME).click();
}
Expand All @@ -160,7 +158,7 @@ export async function verifyProfileIsHideInUss() {

export async function verifyProfileIsHideInJobs() {
const hideProfileFromJobs = await driverChrome
.findElements(By.xpath(JobsLocators.secondJobsProfileIdBeforeHidingXpath))
.findElements(By.xpath(JobsLocators.secondJobsProfileBeforeHidingXpath))
.then((found) => !!found.length);
if (!hideProfileFromJobs) {
return true;
Expand All @@ -170,7 +168,7 @@ export async function verifyProfileIsHideInJobs() {
}

export async function deleteDefaultProfileInDatasets() {
const profileName = await driverChrome.wait(until.elementLocated(By.id(DatasetsLocators.defaultDatasetsProfileId)), WAITTIME);
const profileName = await driverChrome.wait(until.elementLocated(By.xpath(DatasetsLocators.defaultDatasetsProfileXpath)), WAITTIME);
await driverChrome.actions().click(profileName, Button.RIGHT).perform();
await driverChrome.wait(until.elementLocated(By.xpath(DatasetsLocators.deleteProfileFromDatasetsXpath)), WAITTIME).click();
await driverChrome.sleep(SHORTSLEEPTIME);
Expand All @@ -181,7 +179,7 @@ export async function deleteDefaultProfileInDatasets() {
}

export async function deleteProfileInDatasets() {
const favprofile = await driverChrome.wait(until.elementLocated(By.id(DatasetsLocators.secondDatasetProfileBeforeDeletingId)), WAITTIME);
const favprofile = await driverChrome.wait(until.elementLocated(By.xpath(DatasetsLocators.secondDatasetProfileXpath)), WAITTIME);
await driverChrome.actions().click(favprofile, Button.RIGHT).perform();
await driverChrome.wait(until.elementLocated(By.xpath(DatasetsLocators.deleteProfileFromDatasetsXpath)), WAITTIME).click();
await driverChrome.sleep(SHORTSLEEPTIME);
Expand All @@ -192,7 +190,7 @@ export async function deleteProfileInDatasets() {
}

export async function verifyRemovedFavoriteProfileInDatasets() {
const favoriteProfile = await driverChrome.findElements(By.id(DatasetsLocators.favoriteProfileInDatasetId)).then((found) => !!found.length);
const favoriteProfile = await driverChrome.findElements(By.xpath(DatasetsLocators.favoriteProfileInDatasetXpath)).then((found) => !!found.length);
if (!favoriteProfile) {
return true;
} else {
Expand All @@ -219,7 +217,7 @@ export async function verifyRemovedFavoriteProfileInJobs() {
}

export async function verifyRemovedDefaultProfileInDataSet() {
const defaultProfile = await driverChrome.findElements(By.id(DatasetsLocators.defaultDatasetsProfileId)).then((found) => !!found.length);
const defaultProfile = await driverChrome.findElements(By.xpath(DatasetsLocators.defaultDatasetsProfileXpath)).then((found) => !!found.length);
if (!defaultProfile) {
return true;
} else {
Expand All @@ -228,7 +226,7 @@ export async function verifyRemovedDefaultProfileInDataSet() {
}

export async function verifyRemovedOtherProfileInDataSet() {
const defaultProfile = await driverChrome.findElements(By.id(DatasetsLocators.secondDatasetProfileId)).then((found) => !!found.length);
const defaultProfile = await driverChrome.findElements(By.xpath(DatasetsLocators.secondDatasetProfileXpath)).then((found) => !!found.length);
if (!defaultProfile) {
return true;
} else {
Expand Down Expand Up @@ -319,11 +317,11 @@ export async function clickOnAddSessionInDatasets() {
}

export async function getDatasetsDefaultProfilename() {
const datasetProfile = await driverChrome.wait(until.elementLocated(By.id(DatasetsLocators.defaultDatasetsProfileId)), WAITTIME).getText();
const datasetProfile = await driverChrome.wait(until.elementLocated(By.xpath(DatasetsLocators.defaultDatasetsProfileXpath)), WAITTIME).getText();
return datasetProfile;
}

export async function getDatasetsProfilename() {
const datasetProfile = await driverChrome.wait(until.elementLocated(By.id(DatasetsLocators.secondDatasetProfileId)), WAITTIME).getText();
const datasetProfile = await driverChrome.wait(until.elementLocated(By.xpath(DatasetsLocators.secondDatasetProfileXpath)), WAITTIME).getText();
return datasetProfile;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
*/

import { writeFileSync } from "fs";
import { Builder, By, Key, until, Button } from "selenium-webdriver";
import { Builder, By, Key, until } from "selenium-webdriver";
import * as firefox from "selenium-webdriver/firefox";
import { TheiaLocator, DatasetsLocators, UssLocators, JobsLocators } from "./Locators";

const WAITTIME = 30000;
const SHORTSLEEPTIME = 2000;
const wait5sec = 5000;
let driverFirefox: any;

export async function openBrowser() {
Expand Down Expand Up @@ -102,8 +100,8 @@ export async function getJobsProfilename() {
return jobsProfile;
}

export async function getFavouritesNode() {
const favoriteLink = await driverFirefox.wait(until.elementLocated(By.id(DatasetsLocators.favoriteTabId)), WAITTIME).getAttribute("title");
export async function getFavoritesNode() {
const favoriteLink = await driverFirefox.wait(until.elementLocated(By.xpath(DatasetsLocators.favoriteTabXpath)), WAITTIME).getAttribute("title");
return favoriteLink;
}

Expand Down

0 comments on commit d39538c

Please sign in to comment.