Skip to content

Commit

Permalink
Try to fix update credentials test
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy Johnson <[email protected]>
  • Loading branch information
t1m0thyj committed Nov 18, 2024
1 parent 2c17edf commit 72c4764
Showing 1 changed file with 19 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { AfterAll, Then, When } from "@cucumber/cucumber";
import { paneDivForTree } from "../../../../__common__/shared.wdio";
import quickPick from "../../../../__pageobjects__/QuickPick";
import { Key } from "webdriverio";
import { TreeItem } from "wdio-vscode-service";

const USER_CONFIG_FILE = path.join(process.env.ZOWE_CLI_HOME, "zowe.config.user.json");

Expand All @@ -25,45 +26,29 @@ When(/a user who has profile with (.*) auth in team config/, function (authType:
// TODO: We need to copy from Global Config until Imperative API is fixed
// See https://github.com/zowe/zowe-cli/issues/2273
this.authType = authType;
const tempCfg = JSON.parse(fs.readFileSync(USER_CONFIG_FILE.replace(".user", ""), "utf-8"));
const testConfig = {
$schema: "./zowe.schema.json",
profiles: {
...tempCfg.profiles,
zosmf1: {
type: null, // Disable default global zosmf profile
},
[`zosmf_${authType}`]: {
type: "zosmf",
properties: {},
secure: [],
},
},
defaults: {
...tempCfg.defaults,
zosmf: `zosmf_${authType}`,
},
const testConfig = JSON.parse(fs.readFileSync(USER_CONFIG_FILE.replace(".user", ""), "utf-8"));
testConfig.profile[`zosmf_${authType}`] = {
type: "zosmf",
properties: {},
secure: authType === "basic" ? ["user", "password"] : ["tokenValue"],
};
if (authType === "basic") {
testConfig.profiles.zosmf_basic.secure.push("user", "password");
} else if (authType === "token") {
testConfig.profiles.zosmf_token.secure.push("tokenValue");
}
fs.writeFileSync(USER_CONFIG_FILE, JSON.stringify(testConfig, null, 2));
});
When("the user has a profile in their Data Sets tree", async function () {
// add profile via quick pick
this.treePane = await paneDivForTree("Data Sets");
await browser.waitUntil(async () => {
const visibleItems = await this.treePane.getVisibleItems();
for (const item of visibleItems) {
if ((await item.getLabel()) === `zosmf_${this.authType as string}`) {
this.profileNode = item;
return true;
}
}

return false;
});
await this.treePane.elem.moveTo();
const plusIcon = await this.treePane.getAction(`Add Profile to Data Sets View`);
await expect(plusIcon).toBeDefined();
await plusIcon.elem.click();
await browser.waitUntil((): Promise<boolean> => quickPick.isClickable());
const firstProfileEntry = await quickPick.findItemByIndex(2);
await expect(firstProfileEntry).toBeClickable();
await firstProfileEntry.click();
this.yesOpt = await quickPick.findItem("Yes, Apply to all trees");
await expect(this.yesOpt).toBeClickable();
await this.yesOpt.click();
this.profileNode = (await this.treePane.findItem(`zosmf_${this.authType as string}`)) as TreeItem;
});
When("a user clicks search button for the profile", async function () {
await this.profileNode.elem.moveTo();
Expand Down

0 comments on commit 72c4764

Please sign in to comment.