mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
add debug statemets to integration tests
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
b36d9ff418
commit
81ed697313
@ -2,6 +2,7 @@ import { Application } from "spectron";
|
||||
import * as utils from "../helpers/utils";
|
||||
import { listHelmRepositories } from "../helpers/utils";
|
||||
import { fail } from "assert";
|
||||
import { click, send, waitUntilTextExists } from "../helpers/client";
|
||||
|
||||
|
||||
jest.setTimeout(60000);
|
||||
@ -10,6 +11,10 @@ jest.setTimeout(60000);
|
||||
describe("Lens integration tests", () => {
|
||||
let app: Application;
|
||||
|
||||
beforeEach(() => {
|
||||
console.debug(`startig: ${expect.getState().currentTestName}`);
|
||||
});
|
||||
|
||||
describe("app start", () => {
|
||||
beforeAll(async () => app = await utils.appStart(), 20000);
|
||||
|
||||
@ -24,16 +29,16 @@ describe("Lens integration tests", () => {
|
||||
});
|
||||
|
||||
it('shows "add cluster"', async () => {
|
||||
await app.electron.ipcRenderer.send("test-menu-item-click", "File", "Add Cluster");
|
||||
await app.client.waitUntilTextExists("h2", "Add Cluster");
|
||||
send(app.electron.ipcRenderer, "test-menu-item-click", "File", "Add Cluster");
|
||||
await waitUntilTextExists(app.client, "h2", "Add Cluster");
|
||||
});
|
||||
|
||||
describe("preferences page", () => {
|
||||
it('shows "preferences"', async () => {
|
||||
const appName: string = process.platform === "darwin" ? "Lens" : "File";
|
||||
|
||||
await app.electron.ipcRenderer.send("test-menu-item-click", appName, "Preferences");
|
||||
await app.client.waitUntilTextExists("h2", "Preferences");
|
||||
send(app.electron.ipcRenderer, "test-menu-item-click", appName, "Preferences");
|
||||
await waitUntilTextExists(app.client, "h2", "Preferences");
|
||||
});
|
||||
|
||||
it("ensures helm repos", async () => {
|
||||
@ -43,9 +48,9 @@ describe("Lens integration tests", () => {
|
||||
fail("Lens failed to add Bitnami repository");
|
||||
}
|
||||
|
||||
await app.client.waitUntilTextExists("div.repos #message-bitnami", repos[0].name); // wait for the helm-cli to fetch the repo(s)
|
||||
await app.client.click("#HelmRepoSelect"); // click the repo select to activate the drop-down
|
||||
await app.client.waitUntilTextExists("div.Select__option", ""); // wait for at least one option to appear (any text)
|
||||
await waitUntilTextExists(app.client, "div.repos #message-bitnami", repos[0].name); // wait for the helm-cli to fetch the repo(s)
|
||||
await click(app.client, "#HelmRepoSelect"); // click the repo select to activate the drop-down
|
||||
await waitUntilTextExists(app.client, "div.Select__option", ""); // wait for at least one option to appear (any text)
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import * as utils from "../helpers/utils";
|
||||
import { addMinikubeCluster, minikubeReady, waitForMinikubeDashboard } from "../helpers/minikube";
|
||||
import { exec } from "child_process";
|
||||
import * as util from "util";
|
||||
import { click, waitForEnabled, waitForExist, waitForVisible, waitUntilTextExists } from "../helpers/client";
|
||||
|
||||
export const promiseExec = util.promisify(exec);
|
||||
|
||||
@ -21,14 +22,18 @@ describe("Lens cluster pages", () => {
|
||||
let app: Application;
|
||||
const ready = minikubeReady(TEST_NAMESPACE);
|
||||
|
||||
beforeEach(() => {
|
||||
console.debug(`startig: ${expect.getState().currentTestName}`);
|
||||
});
|
||||
|
||||
utils.describeIf(ready)("test common pages", () => {
|
||||
let clusterAdded = false;
|
||||
const addCluster = async () => {
|
||||
await utils.clickWhatsNew(app);
|
||||
await addMinikubeCluster(app);
|
||||
await waitForMinikubeDashboard(app);
|
||||
await app.client.click('a[href="/nodes"]');
|
||||
await app.client.waitUntilTextExists("div.TableCell", "Ready");
|
||||
await click(app.client, 'a[href="/nodes"]');
|
||||
await waitUntilTextExists(app.client, "div.TableCell", "Ready");
|
||||
};
|
||||
|
||||
describe("cluster add", () => {
|
||||
@ -313,15 +318,15 @@ describe("Lens cluster pages", () => {
|
||||
if (drawer !== "") {
|
||||
it(`shows ${drawer} drawer`, async () => {
|
||||
expect(clusterAdded).toBe(true);
|
||||
await app.client.click(`.sidebar-nav [data-test-id="${drawerId}"] span.link-text`);
|
||||
await app.client.waitUntilTextExists(`a[href^="/${pages[0].href}"]`, pages[0].name);
|
||||
await click(app.client, `.sidebar-nav [data-test-id="${drawerId}"] span.link-text`);
|
||||
await waitUntilTextExists(app.client, `a[href^="/${pages[0].href}"]`, pages[0].name);
|
||||
});
|
||||
}
|
||||
pages.forEach(({ name, href, expectedSelector, expectedText }) => {
|
||||
it(`shows ${drawer}->${name} page`, async () => {
|
||||
expect(clusterAdded).toBe(true);
|
||||
await app.client.click(`a[href^="/${href}"]`);
|
||||
await app.client.waitUntilTextExists(expectedSelector, expectedText);
|
||||
await click(app.client, `a[href^="/${href}"]`);
|
||||
await waitUntilTextExists(app.client, expectedSelector, expectedText);
|
||||
});
|
||||
});
|
||||
|
||||
@ -329,8 +334,8 @@ describe("Lens cluster pages", () => {
|
||||
// hide the drawer
|
||||
it(`hides ${drawer} drawer`, async () => {
|
||||
expect(clusterAdded).toBe(true);
|
||||
await app.client.click(`.sidebar-nav [data-test-id="${drawerId}"] span.link-text`);
|
||||
await expect(app.client.waitUntilTextExists(`a[href^="/${pages[0].href}"]`, pages[0].name, 100)).rejects.toThrow();
|
||||
await click(app.client, `.sidebar-nav [data-test-id="${drawerId}"] span.link-text`);
|
||||
await expect(waitUntilTextExists(app.client, `a[href^="/${pages[0].href}"]`, pages[0].name, 100)).rejects.toThrow();
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -348,13 +353,13 @@ describe("Lens cluster pages", () => {
|
||||
it(`shows a logs for a pod`, async () => {
|
||||
expect(clusterAdded).toBe(true);
|
||||
// Go to Pods page
|
||||
await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text");
|
||||
await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods");
|
||||
await app.client.click('a[href^="/pods"]');
|
||||
await app.client.click(".NamespaceSelect");
|
||||
await click(app.client, ".sidebar-nav [data-test-id='workloads'] span.link-text");
|
||||
await waitUntilTextExists(app.client, 'a[href^="/pods"]', "Pods");
|
||||
await click(app.client, 'a[href^="/pods"]');
|
||||
await click(app.client, ".NamespaceSelect");
|
||||
await app.client.keys("kube-system");
|
||||
await app.client.keys("Enter");// "\uE007"
|
||||
await app.client.waitUntilTextExists("div.TableCell", "kube-apiserver");
|
||||
await waitUntilTextExists(app.client, "div.TableCell", "kube-apiserver");
|
||||
let podMenuItemEnabled = false;
|
||||
|
||||
// Wait until extensions are enabled on renderer
|
||||
@ -369,20 +374,19 @@ describe("Lens cluster pages", () => {
|
||||
}
|
||||
await new Promise(r => setTimeout(r, 500)); // Give some extra time to prepare extensions
|
||||
// Open logs tab in dock
|
||||
await app.client.click(".list .TableRow:first-child");
|
||||
await app.client.waitForVisible(".Drawer");
|
||||
await app.client.click(".drawer-title .Menu li:nth-child(2)");
|
||||
await click(app.client, ".list .TableRow:first-child");
|
||||
await waitForVisible(app.client, ".Drawer");
|
||||
await click(app.client, ".drawer-title .Menu li:nth-child(2)");
|
||||
// Check if controls are available
|
||||
await app.client.waitForVisible(".LogList .VirtualList");
|
||||
await app.client.waitForVisible(".LogResourceSelector");
|
||||
//await app.client.waitForVisible(".LogSearch .SearchInput");
|
||||
await app.client.waitForVisible(".LogSearch .SearchInput input");
|
||||
await waitForVisible(app.client, ".LogList .VirtualList");
|
||||
await waitForVisible(app.client, ".LogResourceSelector");
|
||||
await waitForVisible(app.client, ".LogSearch .SearchInput input");
|
||||
// Search for semicolon
|
||||
await app.client.keys(":");
|
||||
await app.client.waitForVisible(".LogList .list span.active");
|
||||
await waitForVisible(app.client, ".LogList .list span.active");
|
||||
// Click through controls
|
||||
await app.client.click(".LogControls .show-timestamps");
|
||||
await app.client.click(".LogControls .show-previous");
|
||||
await click(app.client, ".LogControls .show-timestamps");
|
||||
await click(app.client, ".LogControls .show-previous");
|
||||
});
|
||||
});
|
||||
|
||||
@ -397,35 +401,35 @@ describe("Lens cluster pages", () => {
|
||||
|
||||
it("shows default namespace", async () => {
|
||||
expect(clusterAdded).toBe(true);
|
||||
await app.client.click('a[href="/namespaces"]');
|
||||
await app.client.waitUntilTextExists("div.TableCell", "default");
|
||||
await app.client.waitUntilTextExists("div.TableCell", "kube-system");
|
||||
await click(app.client, 'a[href="/namespaces"]');
|
||||
await waitUntilTextExists(app.client, "div.TableCell", "default");
|
||||
await waitUntilTextExists(app.client, "div.TableCell", "kube-system");
|
||||
});
|
||||
|
||||
it(`creates ${TEST_NAMESPACE} namespace`, async () => {
|
||||
expect(clusterAdded).toBe(true);
|
||||
await app.client.click('a[href="/namespaces"]');
|
||||
await app.client.waitUntilTextExists("div.TableCell", "default");
|
||||
await app.client.waitUntilTextExists("div.TableCell", "kube-system");
|
||||
await app.client.click("button.add-button");
|
||||
await app.client.waitUntilTextExists("div.AddNamespaceDialog", "Create Namespace");
|
||||
await click(app.client, 'a[href="/namespaces"]');
|
||||
await waitUntilTextExists(app.client, "div.TableCell", "default");
|
||||
await waitUntilTextExists(app.client, "div.TableCell", "kube-system");
|
||||
await click(app.client, "button.add-button");
|
||||
await waitUntilTextExists(app.client, "div.AddNamespaceDialog", "Create Namespace");
|
||||
await app.client.keys(`${TEST_NAMESPACE}\n`);
|
||||
await app.client.waitForExist(`.name=${TEST_NAMESPACE}`);
|
||||
await waitForExist(app.client, `.name=${TEST_NAMESPACE}`);
|
||||
});
|
||||
|
||||
it(`creates a pod in ${TEST_NAMESPACE} namespace`, async () => {
|
||||
expect(clusterAdded).toBe(true);
|
||||
await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text");
|
||||
await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods");
|
||||
await app.client.click('a[href^="/pods"]');
|
||||
await click(app.client, ".sidebar-nav [data-test-id='workloads'] span.link-text");
|
||||
await waitUntilTextExists(app.client, 'a[href^="/pods"]', "Pods");
|
||||
await click(app.client, 'a[href^="/pods"]');
|
||||
|
||||
await app.client.click(".NamespaceSelect");
|
||||
await click(app.client, ".NamespaceSelect");
|
||||
await app.client.keys(TEST_NAMESPACE);
|
||||
await app.client.keys("Enter");// "\uE007"
|
||||
await app.client.click(".Icon.new-dock-tab");
|
||||
await app.client.waitUntilTextExists("li.MenuItem.create-resource-tab", "Create resource");
|
||||
await app.client.click("li.MenuItem.create-resource-tab");
|
||||
await app.client.waitForVisible(".CreateResource div.ace_content");
|
||||
await click(app.client, ".Icon.new-dock-tab");
|
||||
await waitUntilTextExists(app.client, "li.MenuItem.create-resource-tab", "Create resource");
|
||||
await click(app.client, "li.MenuItem.create-resource-tab");
|
||||
await waitForVisible(app.client, ".CreateResource div.ace_content");
|
||||
// Write pod manifest to editor
|
||||
await app.client.keys("apiVersion: v1\n");
|
||||
await app.client.keys("kind: Pod\n");
|
||||
@ -437,13 +441,13 @@ describe("Lens cluster pages", () => {
|
||||
await app.client.keys("- name: nginx-create-pod-test\n");
|
||||
await app.client.keys(" image: nginx:alpine\n");
|
||||
// Create deployment
|
||||
await app.client.waitForEnabled("button.Button=Create & Close");
|
||||
await app.client.click("button.Button=Create & Close");
|
||||
await waitForEnabled(app.client, "button.Button=Create & Close");
|
||||
await click(app.client, "button.Button=Create & Close");
|
||||
// Wait until first bits of pod appears on dashboard
|
||||
await app.client.waitForExist(".name=nginx-create-pod-test");
|
||||
await waitForExist(app.client, ".name=nginx-create-pod-test");
|
||||
// Open pod details
|
||||
await app.client.click(".name=nginx-create-pod-test");
|
||||
await app.client.waitUntilTextExists("div.drawer-title-text", "Pod: nginx-create-pod-test");
|
||||
await click(app.client, ".name=nginx-create-pod-test");
|
||||
await waitUntilTextExists(app.client, "div.drawer-title-text", "Pod: nginx-create-pod-test");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { Application } from "spectron";
|
||||
import { send, waitUntilTextExists } from "../helpers/client";
|
||||
import * as utils from "../helpers/utils";
|
||||
|
||||
jest.setTimeout(60000);
|
||||
@ -6,6 +7,10 @@ jest.setTimeout(60000);
|
||||
describe("Lens command palette", () => {
|
||||
let app: Application;
|
||||
|
||||
beforeEach(() => {
|
||||
console.debug(`startig: ${expect.getState().currentTestName}`);
|
||||
});
|
||||
|
||||
describe("menu", () => {
|
||||
beforeAll(async () => app = await utils.appStart(), 20000);
|
||||
|
||||
@ -17,8 +22,8 @@ describe("Lens command palette", () => {
|
||||
|
||||
it("opens command dialog from menu", async () => {
|
||||
await utils.clickWhatsNew(app);
|
||||
await app.electron.ipcRenderer.send("test-menu-item-click", "View", "Command Palette...");
|
||||
await app.client.waitUntilTextExists(".Select__option", "Preferences: Open");
|
||||
await send(app.electron.ipcRenderer, "test-menu-item-click", "View", "Command Palette...");
|
||||
await waitUntilTextExists(app.client, ".Select__option", "Preferences: Open");
|
||||
await app.client.keys("Escape");
|
||||
});
|
||||
});
|
||||
|
||||
@ -3,6 +3,7 @@ import * as utils from "../helpers/utils";
|
||||
import { addMinikubeCluster, minikubeReady } from "../helpers/minikube";
|
||||
import { exec } from "child_process";
|
||||
import * as util from "util";
|
||||
import { click, waitForExist, waitForVisible, waitUntilTextExists } from "../helpers/client";
|
||||
|
||||
export const promiseExec = util.promisify(exec);
|
||||
|
||||
@ -12,6 +13,10 @@ describe("Lens integration tests", () => {
|
||||
let app: Application;
|
||||
const ready = minikubeReady("workspace-int-tests");
|
||||
|
||||
beforeEach(() => {
|
||||
console.debug(`startig: ${expect.getState().currentTestName}`);
|
||||
});
|
||||
|
||||
utils.describeIf(ready)("workspaces", () => {
|
||||
beforeAll(async () => {
|
||||
app = await utils.appStart();
|
||||
@ -25,51 +30,51 @@ describe("Lens integration tests", () => {
|
||||
});
|
||||
|
||||
const switchToWorkspace = async (name: string) => {
|
||||
await app.client.click("[data-test-id=current-workspace]");
|
||||
await click(app.client, "[data-test-id=current-workspace]");
|
||||
await app.client.keys(name);
|
||||
await app.client.keys("Enter");
|
||||
await app.client.waitUntilTextExists("[data-test-id=current-workspace-name]", name);
|
||||
await waitUntilTextExists(app.client, "[data-test-id=current-workspace-name]", name);
|
||||
};
|
||||
|
||||
const createWorkspace = async (name: string) => {
|
||||
await app.client.click("[data-test-id=current-workspace]");
|
||||
await click(app.client, "[data-test-id=current-workspace]");
|
||||
await app.client.keys("add workspace");
|
||||
await app.client.keys("Enter");
|
||||
await app.client.keys(name);
|
||||
await app.client.keys("Enter");
|
||||
await app.client.waitUntilTextExists("[data-test-id=current-workspace-name]", name);
|
||||
await waitUntilTextExists(app.client, "[data-test-id=current-workspace-name]", name);
|
||||
};
|
||||
|
||||
it("creates new workspace", async () => {
|
||||
const name = "test-workspace";
|
||||
|
||||
await createWorkspace(name);
|
||||
await app.client.waitUntilTextExists("[data-test-id=current-workspace-name]", name);
|
||||
await waitUntilTextExists(app.client, "[data-test-id=current-workspace-name]", name);
|
||||
});
|
||||
|
||||
it("edits current workspaces", async () => {
|
||||
await createWorkspace("to-be-edited");
|
||||
await app.client.click("[data-test-id=current-workspace]");
|
||||
await click(app.client, "[data-test-id=current-workspace]");
|
||||
await app.client.keys("edit current workspace");
|
||||
await app.client.keys("Enter");
|
||||
await app.client.keys("edited-workspace");
|
||||
await app.client.keys("Enter");
|
||||
await app.client.waitUntilTextExists("[data-test-id=current-workspace-name]", "edited-workspace");
|
||||
await waitUntilTextExists(app.client, "[data-test-id=current-workspace-name]", "edited-workspace");
|
||||
});
|
||||
|
||||
it("adds cluster in default workspace", async () => {
|
||||
await switchToWorkspace("default");
|
||||
await addMinikubeCluster(app);
|
||||
await app.client.waitUntilTextExists("pre.kube-auth-out", "Authentication proxy started");
|
||||
await app.client.waitForExist(`iframe[name="minikube"]`);
|
||||
await app.client.waitForVisible(".ClustersMenu .ClusterIcon.active");
|
||||
await waitUntilTextExists(app.client, "pre.kube-auth-out", "Authentication proxy started");
|
||||
await waitForExist(app.client, `iframe[name="minikube"]`);
|
||||
await waitForVisible(app.client, ".ClustersMenu .ClusterIcon.active");
|
||||
});
|
||||
|
||||
it("adds cluster in test-workspace", async () => {
|
||||
await switchToWorkspace("test-workspace");
|
||||
await addMinikubeCluster(app);
|
||||
await app.client.waitUntilTextExists("pre.kube-auth-out", "Authentication proxy started");
|
||||
await app.client.waitForExist(`iframe[name="minikube"]`);
|
||||
await waitUntilTextExists(app.client, "pre.kube-auth-out", "Authentication proxy started");
|
||||
await waitForExist(app.client, `iframe[name="minikube"]`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
37
integration/helpers/client.ts
Normal file
37
integration/helpers/client.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { SpectronClient } from "spectron";
|
||||
|
||||
export async function click(client: SpectronClient, ...args: any[]): Promise<void> {
|
||||
console.debug("click", { args });
|
||||
|
||||
await client.click(...args);
|
||||
}
|
||||
|
||||
export async function waitUntilTextExists(client: SpectronClient, ...args: any[]): Promise<void> {
|
||||
console.debug("waitUntilTextExists", { args });
|
||||
|
||||
await (client.waitUntilTextExists as any)(...args);
|
||||
}
|
||||
|
||||
export async function waitForExist(client: SpectronClient, ...args: any[]): Promise<void> {
|
||||
console.debug("waitForExist", { args });
|
||||
|
||||
await (client.waitForExist as any)(...args);
|
||||
}
|
||||
|
||||
export async function waitForEnabled(client: SpectronClient, ...args: any[]): Promise<void> {
|
||||
console.debug("waitForEnabled", { args });
|
||||
|
||||
await (client.waitForEnabled as any)(...args);
|
||||
}
|
||||
|
||||
export async function waitForVisible(client: SpectronClient, ...args: any[]): Promise<void> {
|
||||
console.debug("waitForVisible", { args });
|
||||
|
||||
await (client.waitForVisible as any)(...args);
|
||||
}
|
||||
|
||||
export async function send(ipc: Electron.IpcRenderer, ...args: any[]): Promise<void> {
|
||||
console.debug("send", { args });
|
||||
|
||||
await (ipc.send as any)(...args);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user