1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

fix helm repos integration tests

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-08-26 11:09:42 +03:00
parent 2f8ff0220b
commit 65c8109d9d
2 changed files with 34 additions and 1 deletions

View File

@ -27,6 +27,7 @@
*/ */
import type { Page } from "playwright"; import type { Page } from "playwright";
import * as utils from "../helpers/utils"; import * as utils from "../helpers/utils";
import { listHelmRepositories } from "../helpers/utils";
describe("preferences page tests", () => { describe("preferences page tests", () => {
let window: Page, cleanup: () => Promise<void>; let window: Page, cleanup: () => Promise<void>;
@ -65,6 +66,12 @@ describe("preferences page tests", () => {
it("ensures helm repos", async () => { it("ensures helm repos", async () => {
await window.click("[data-testid=kubernetes-tab]"); await window.click("[data-testid=kubernetes-tab]");
const repos = await listHelmRepositories(); // wait for default helm repo to be added
if (repos.length === 0) {
fail("Lens failed to add any repositories");
}
await window.waitForSelector("[data-testid=repository-name]", { await window.waitForSelector("[data-testid=repository-name]", {
timeout: 100_000, timeout: 100_000,
}); });

View File

@ -25,6 +25,8 @@ import * as path from "path";
import * as uuid from "uuid"; import * as uuid from "uuid";
import { ElectronApplication, Frame, Page, _electron as electron } from "playwright"; import { ElectronApplication, Frame, Page, _electron as electron } from "playwright";
import { noop } from "lodash"; import { noop } from "lodash";
import { promisify } from "util";
import { exec } from "child_process";
export const AppPaths: Partial<Record<NodeJS.Platform, string>> = { export const AppPaths: Partial<Record<NodeJS.Platform, string>> = {
"win32": "./dist/win-unpacked/OpenLens.exe", "win32": "./dist/win-unpacked/OpenLens.exe",
@ -67,7 +69,10 @@ export async function start() {
args: ["--integration-testing"], // this argument turns off the blocking of quit args: ["--integration-testing"], // this argument turns off the blocking of quit
executablePath: AppPaths[process.platform], executablePath: AppPaths[process.platform],
bypassCSP: true, bypassCSP: true,
env: { CICD }, env: {
CICD,
...process.env
},
timeout: 100_000, timeout: 100_000,
} as Parameters<typeof electron["launch"]>[0]); } as Parameters<typeof electron["launch"]>[0]);
@ -114,3 +119,24 @@ export async function lauchMinikubeClusterFromCatalog(window: Page): Promise<Fra
return frame; return frame;
} }
export const promiseExec = promisify(exec);
type HelmRepository = {
name: string;
url: string;
};
export async function listHelmRepositories(): Promise<HelmRepository[]>{
for (let i = 0; i < 10; i += 1) {
try {
const { stdout } = await promiseExec("helm repo list -o json");
return JSON.parse(stdout);
} catch {
await new Promise(r => setTimeout(r, 2000)); // if no repositories, wait for Lens adding bitnami repository
}
}
return [];
}