mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
integration tests: refactoring & fixes
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
30f900fd5e
commit
be3bd7937e
10 files changed
+457
-490
No files matched your search
@@ -0,0 +1,7 @@
|
||||
// Common utils for integration tests
|
||||
|
||||
export const BACKSPACE = "\uE003";
|
||||
|
||||
export * from "./utils";
|
||||
export * from "./minikube";
|
||||
export * from "./selectors";
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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}"]`;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user