mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix integration tests
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
6cc83bd353
commit
37e31b2f99
@ -3,10 +3,8 @@ import * as utils from "../helpers/utils";
|
|||||||
import { listHelmRepositories } from "../helpers/utils";
|
import { listHelmRepositories } from "../helpers/utils";
|
||||||
import { fail } from "assert";
|
import { fail } from "assert";
|
||||||
|
|
||||||
|
|
||||||
jest.setTimeout(60000);
|
jest.setTimeout(60000);
|
||||||
|
|
||||||
// FIXME (!): improve / simplify all css-selectors + use [data-test-id="some-id"] (already used in some tests below)
|
|
||||||
describe("Lens integration tests", () => {
|
describe("Lens integration tests", () => {
|
||||||
let app: Application;
|
let app: Application;
|
||||||
|
|
||||||
|
|||||||
@ -7,14 +7,9 @@
|
|||||||
import { Application } from "spectron";
|
import { Application } from "spectron";
|
||||||
import * as utils from "../helpers/utils";
|
import * as utils from "../helpers/utils";
|
||||||
import { addMinikubeCluster, minikubeReady, waitForMinikubeDashboard } from "../helpers/minikube";
|
import { addMinikubeCluster, minikubeReady, waitForMinikubeDashboard } from "../helpers/minikube";
|
||||||
import { exec } from "child_process";
|
|
||||||
import * as util from "util";
|
|
||||||
|
|
||||||
export const promiseExec = util.promisify(exec);
|
|
||||||
|
|
||||||
jest.setTimeout(60000);
|
jest.setTimeout(60000);
|
||||||
|
|
||||||
// FIXME (!): improve / simplify all css-selectors + use [data-test-id="some-id"] (already used in some tests below)
|
|
||||||
describe("Lens cluster pages", () => {
|
describe("Lens cluster pages", () => {
|
||||||
const TEST_NAMESPACE = "integration-tests";
|
const TEST_NAMESPACE = "integration-tests";
|
||||||
const BACKSPACE = "\uE003";
|
const BACKSPACE = "\uE003";
|
||||||
@ -53,6 +48,18 @@ describe("Lens cluster pages", () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getSidebarSelectors(testId: string) {
|
||||||
|
const baseSelector = `.Sidebar [data-test-id="${testId}"]`;
|
||||||
|
|
||||||
|
return {
|
||||||
|
sidebarItemRoot: baseSelector,
|
||||||
|
expandIcon: `${baseSelector} .expand-icon`,
|
||||||
|
pageLink(href: string){
|
||||||
|
return `${baseSelector} a[href^="/${href}"]`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
describe("cluster pages", () => {
|
describe("cluster pages", () => {
|
||||||
|
|
||||||
beforeAll(appStartAddCluster, 40000);
|
beforeAll(appStartAddCluster, 40000);
|
||||||
@ -63,275 +70,224 @@ describe("Lens cluster pages", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const tests: {
|
type SidebarItem = {
|
||||||
drawer?: string
|
testId: string;
|
||||||
drawerId?: string
|
expectedSelector?: string;
|
||||||
pages: {
|
expectedText?: string;
|
||||||
name: string,
|
subMenu?: Required<Omit<SidebarItem & { href: string }, "testId" | "subMenu">>[];
|
||||||
href: string,
|
};
|
||||||
expectedSelector: string,
|
|
||||||
expectedText: string
|
const sidebarMenu: SidebarItem[] = [
|
||||||
}[]
|
{
|
||||||
}[] = [{
|
testId: "cluster",
|
||||||
drawer: "",
|
|
||||||
drawerId: "",
|
|
||||||
pages: [{
|
|
||||||
name: "Cluster",
|
|
||||||
href: "cluster",
|
|
||||||
expectedSelector: "div.ClusterOverview div.label",
|
expectedSelector: "div.ClusterOverview div.label",
|
||||||
expectedText: "Master"
|
expectedText: "Master",
|
||||||
}]
|
},
|
||||||
},
|
{
|
||||||
{
|
testId: "nodes",
|
||||||
drawer: "",
|
|
||||||
drawerId: "",
|
|
||||||
pages: [{
|
|
||||||
name: "Nodes",
|
|
||||||
href: "nodes",
|
|
||||||
expectedSelector: "h5.title",
|
expectedSelector: "h5.title",
|
||||||
expectedText: "Nodes"
|
expectedText: "Nodes"
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "Workloads",
|
|
||||||
drawerId: "workloads",
|
|
||||||
pages: [{
|
|
||||||
name: "Overview",
|
|
||||||
href: "workloads",
|
|
||||||
expectedSelector: "h5.box",
|
|
||||||
expectedText: "Overview"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Pods",
|
testId: "workloads",
|
||||||
href: "pods",
|
subMenu: [
|
||||||
expectedSelector: "h5.title",
|
{
|
||||||
expectedText: "Pods"
|
href: "workloads",
|
||||||
|
expectedSelector: "h5",
|
||||||
|
expectedText: "Overview",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "pods",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Pods"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "deployments",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Deployments"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "daemonsets",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Daemon Sets"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "statefulsets",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Stateful Sets"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "replicasets",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Replica Sets"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "jobs",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Jobs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "cronjobs",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Cron Jobs"
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Deployments",
|
testId: "config",
|
||||||
href: "deployments",
|
subMenu: [
|
||||||
expectedSelector: "h5.title",
|
{
|
||||||
expectedText: "Deployments"
|
href: "configmaps",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Config Maps"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "secrets",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Secrets"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "resourcequotas",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Resource Quotas"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "limitranges",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Limit Ranges"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "hpa",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Horizontal Pod Autoscalers"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "poddisruptionbudgets",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Pod Disruption Budgets"
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "DaemonSets",
|
testId: "networks",
|
||||||
href: "daemonsets",
|
subMenu: [
|
||||||
expectedSelector: "h5.title",
|
{
|
||||||
expectedText: "Daemon Sets"
|
href: "services",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Services"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "endpoints",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Endpoints"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "ingresses",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Ingresses"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "network-policies",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Network Policies"
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "StatefulSets",
|
testId: "storage",
|
||||||
href: "statefulsets",
|
subMenu: [
|
||||||
expectedSelector: "h5.title",
|
{
|
||||||
expectedText: "Stateful Sets"
|
href: "persistent-volume-claims",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Persistent Volume Claims"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "persistent-volumes",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Persistent Volumes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "storage-classes",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Storage Classes"
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "ReplicaSets",
|
testId: "namespaces",
|
||||||
href: "replicasets",
|
|
||||||
expectedSelector: "h5.title",
|
expectedSelector: "h5.title",
|
||||||
expectedText: "Replica Sets"
|
expectedText: "Namespaces",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Jobs",
|
testId: "events",
|
||||||
href: "jobs",
|
|
||||||
expectedSelector: "h5.title",
|
expectedSelector: "h5.title",
|
||||||
expectedText: "Jobs"
|
expectedText: "Events",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "CronJobs",
|
testId: "apps",
|
||||||
href: "cronjobs",
|
subMenu: [
|
||||||
expectedSelector: "h5.title",
|
{
|
||||||
expectedText: "Cron Jobs"
|
href: "apps/charts",
|
||||||
}]
|
expectedSelector: "div.HelmCharts input",
|
||||||
},
|
expectedText: ""
|
||||||
{
|
},
|
||||||
drawer: "Configuration",
|
{
|
||||||
drawerId: "config",
|
href: "apps/releases",
|
||||||
pages: [{
|
expectedSelector: "h5.title",
|
||||||
name: "ConfigMaps",
|
expectedText: "Releases"
|
||||||
href: "configmaps",
|
}]
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Config Maps"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Secrets",
|
testId: "users",
|
||||||
href: "secrets",
|
subMenu: [
|
||||||
expectedSelector: "h5.title",
|
{
|
||||||
expectedText: "Secrets"
|
href: "service-accounts",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Service Accounts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "role-bindings",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Role Bindings"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "roles",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Roles"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "pod-security-policies",
|
||||||
|
expectedSelector: "h5.title",
|
||||||
|
expectedText: "Pod Security Policies"
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Resource Quotas",
|
testId: "custom-resources",
|
||||||
href: "resourcequotas",
|
subMenu: [{
|
||||||
expectedSelector: "h5.title",
|
href: "crd/definitions",
|
||||||
expectedText: "Resource Quotas"
|
expectedSelector: "h5.title",
|
||||||
},
|
expectedText: "Custom Resources"
|
||||||
{
|
}]
|
||||||
name: "Limit Ranges",
|
}];
|
||||||
href: "limitranges",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Limit Ranges"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "HPA",
|
|
||||||
href: "hpa",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Horizontal Pod Autoscalers"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Pod Disruption Budgets",
|
|
||||||
href: "poddisruptionbudgets",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Pod Disruption Budgets"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "Network",
|
|
||||||
drawerId: "networks",
|
|
||||||
pages: [{
|
|
||||||
name: "Services",
|
|
||||||
href: "services",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Services"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Endpoints",
|
|
||||||
href: "endpoints",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Endpoints"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Ingresses",
|
|
||||||
href: "ingresses",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Ingresses"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Network Policies",
|
|
||||||
href: "network-policies",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Network Policies"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "Storage",
|
|
||||||
drawerId: "storage",
|
|
||||||
pages: [{
|
|
||||||
name: "Persistent Volume Claims",
|
|
||||||
href: "persistent-volume-claims",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Persistent Volume Claims"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Persistent Volumes",
|
|
||||||
href: "persistent-volumes",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Persistent Volumes"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Storage Classes",
|
|
||||||
href: "storage-classes",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Storage Classes"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "",
|
|
||||||
drawerId: "",
|
|
||||||
pages: [{
|
|
||||||
name: "Namespaces",
|
|
||||||
href: "namespaces",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Namespaces"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "",
|
|
||||||
drawerId: "",
|
|
||||||
pages: [{
|
|
||||||
name: "Events",
|
|
||||||
href: "events",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Events"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "Apps",
|
|
||||||
drawerId: "apps",
|
|
||||||
pages: [{
|
|
||||||
name: "Charts",
|
|
||||||
href: "apps/charts",
|
|
||||||
expectedSelector: "div.HelmCharts input",
|
|
||||||
expectedText: ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Releases",
|
|
||||||
href: "apps/releases",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Releases"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "Access Control",
|
|
||||||
drawerId: "users",
|
|
||||||
pages: [{
|
|
||||||
name: "Service Accounts",
|
|
||||||
href: "service-accounts",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Service Accounts"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Role Bindings",
|
|
||||||
href: "role-bindings",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Role Bindings"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Roles",
|
|
||||||
href: "roles",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Roles"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Pod Security Policies",
|
|
||||||
href: "pod-security-policies",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Pod Security Policies"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
drawer: "Custom Resources",
|
|
||||||
drawerId: "custom-resources",
|
|
||||||
pages: [{
|
|
||||||
name: "Definitions",
|
|
||||||
href: "crd/definitions",
|
|
||||||
expectedSelector: "h5.title",
|
|
||||||
expectedText: "Custom Resources"
|
|
||||||
}]
|
|
||||||
}];
|
|
||||||
|
|
||||||
tests.forEach(({ drawer = "", drawerId = "", pages }) => {
|
sidebarMenu.forEach(({ testId, expectedSelector, expectedText, subMenu }) => {
|
||||||
if (drawer !== "") {
|
const { sidebarItemRoot, expandIcon, pageLink } = getSidebarSelectors(testId);
|
||||||
it(`shows ${drawer} drawer`, async () => {
|
|
||||||
|
if (subMenu) {
|
||||||
|
it(`expands submenu for pages in "${testId}"`, async () => {
|
||||||
expect(clusterAdded).toBe(true);
|
expect(clusterAdded).toBe(true);
|
||||||
await app.client.click(`.sidebar-nav [data-test-id="${drawerId}"] span.link-text`);
|
await app.client.click(expandIcon);
|
||||||
await app.client.waitUntilTextExists(`a[href^="/${pages[0].href}"]`, pages[0].name);
|
await app.client.waitForExist(pageLink(subMenu[0].href));
|
||||||
});
|
});
|
||||||
}
|
subMenu.forEach(({ href, expectedText, expectedSelector }) => {
|
||||||
pages.forEach(({ name, href, expectedSelector, expectedText }) => {
|
it(`opens page "${expectedText.toLowerCase() || href}"`, async () => {
|
||||||
it(`shows ${drawer}->${name} page`, async () => {
|
expect(clusterAdded).toBe(true);
|
||||||
|
await app.client.click(pageLink(href));
|
||||||
|
await app.client.waitUntilTextExists(expectedSelector, expectedText);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
it(`opens page "${testId}"`, async () => {
|
||||||
expect(clusterAdded).toBe(true);
|
expect(clusterAdded).toBe(true);
|
||||||
await app.client.click(`a[href^="/${href}"]`);
|
await app.client.click(sidebarItemRoot);
|
||||||
await app.client.waitUntilTextExists(expectedSelector, expectedText);
|
await app.client.waitUntilTextExists(expectedSelector, expectedText);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if (drawer !== "") {
|
|
||||||
// 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();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -348,7 +304,7 @@ describe("Lens cluster pages", () => {
|
|||||||
it(`shows a logs for a pod`, async () => {
|
it(`shows a logs for a pod`, async () => {
|
||||||
expect(clusterAdded).toBe(true);
|
expect(clusterAdded).toBe(true);
|
||||||
// Go to Pods page
|
// Go to Pods page
|
||||||
await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text");
|
await app.client.click(getSidebarSelectors("workloads").expandIcon);
|
||||||
await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods");
|
await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods");
|
||||||
await app.client.click('a[href^="/pods"]');
|
await app.client.click('a[href^="/pods"]');
|
||||||
await app.client.click(".NamespaceSelect");
|
await app.client.click(".NamespaceSelect");
|
||||||
@ -415,7 +371,7 @@ describe("Lens cluster pages", () => {
|
|||||||
|
|
||||||
it(`creates a pod in ${TEST_NAMESPACE} namespace`, async () => {
|
it(`creates a pod in ${TEST_NAMESPACE} namespace`, async () => {
|
||||||
expect(clusterAdded).toBe(true);
|
expect(clusterAdded).toBe(true);
|
||||||
await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text");
|
await app.client.click(getSidebarSelectors("workloads").expandIcon);
|
||||||
await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods");
|
await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods");
|
||||||
await app.client.click('a[href^="/pods"]');
|
await app.client.click('a[href^="/pods"]');
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,10 @@
|
|||||||
import { Application } from "spectron";
|
import { Application } from "spectron";
|
||||||
import * as utils from "../helpers/utils";
|
import * as utils from "../helpers/utils";
|
||||||
import { addMinikubeCluster, minikubeReady } from "../helpers/minikube";
|
import { addMinikubeCluster, minikubeReady } from "../helpers/minikube";
|
||||||
import { exec } from "child_process";
|
|
||||||
import * as util from "util";
|
|
||||||
|
|
||||||
export const promiseExec = util.promisify(exec);
|
|
||||||
|
|
||||||
jest.setTimeout(60000);
|
jest.setTimeout(60000);
|
||||||
|
|
||||||
describe("Lens integration tests", () => {
|
describe("Lens workspace tests", () => {
|
||||||
let app: Application;
|
let app: Application;
|
||||||
const ready = minikubeReady("workspace-int-tests");
|
const ready = minikubeReady("workspace-int-tests");
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user