integration tests: refactoring & fixes

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman committed 2021-03-09 18:42:40 +02:00
1 parent 30f900fd5e
commit be3bd7937e
10 files changed
+457 -490

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
// Common utils for integration tests
export const BACKSPACE = "\uE003";
export * from "./utils";
export * from "./minikube";
export * from "./selectors";
+7
View File
@@ -1,5 +1,6 @@
import { spawnSync } from "child_process";
import { Application } from "spectron";
import { clickWhatsNew } from "./utils";
export function minikubeReady(testNamespace: string): boolean {
// determine if minikube is running
@@ -57,3 +58,9 @@ export async function waitForMinikubeDashboard(app: Application) {
await app.client.frame("minikube");
await app.client.waitUntilTextExists("span.link-text", "Cluster");
}
export async function addClusterAndOpen(app: Application) {
await clickWhatsNew(app);
await addMinikubeCluster(app);
await waitForMinikubeDashboard(app);
}
+13
View File
@@ -0,0 +1,13 @@
// CSS-selectors for searching elements to interact in tests
export function getMainMenuSelectors(itemId: string) {
const baseSelector = `.Sidebar [data-test-id="${itemId}"]`;
return {
sidebarItemRoot: baseSelector,
expandIcon: `${baseSelector} .expand-icon`,
pageLink(href: string) {
return `${baseSelector} a[href^="/${href}"]`;
}
};
}
+21 -2
View File
@@ -37,7 +37,7 @@ export async function appStart() {
await app.start();
// Wait for splash screen to be closed
while (await app.client.getWindowCount() > 1);
while (await app.client.getWindowCount() > 1) ;
await app.client.windowByIndex(0);
await app.client.waitUntilWindowLoaded();
@@ -71,7 +71,7 @@ type HelmRepository = {
url: string;
};
export async function listHelmRepositories(retries = 0): Promise<HelmRepository[]>{
export async function listHelmRepositories(retries = 0): Promise<HelmRepository[]> {
if (retries < 5) {
try {
const { stdout: reposJson } = await promiseExec("helm repo list -o json");
@@ -86,3 +86,22 @@ export async function listHelmRepositories(retries = 0): Promise<HelmRepository
return [];
}
export function setupAppLifecycle(onStart?: (app: Application) => void, timeoutMs?: number) {
const runtime = {
app: null as Application,
};
beforeAll(async () => {
runtime.app = await appStart();
await onStart?.(runtime.app);
}, timeoutMs);
afterAll(async () => {
if (runtime.app?.isRunning()) {
await tearDown(runtime.app);
}
});
return runtime;
}