mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add a few missing folders to be linted.
Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
1 parent
1477bb8274
commit
0b182ccf6f
29 files changed
+376
-374
No files matched your search
+164
-164
@@ -4,159 +4,159 @@
|
||||
TEST_NAMESPACE namespace. This is done to minimize destructive impact of the cluster tests on an existing minikube
|
||||
cluster and vice versa.
|
||||
*/
|
||||
import { Application } from "spectron"
|
||||
import * as util from "../helpers/utils"
|
||||
import { spawnSync } from "child_process"
|
||||
import { Application } from "spectron";
|
||||
import * as util from "../helpers/utils";
|
||||
import { spawnSync } from "child_process";
|
||||
|
||||
const describeif = (condition: boolean) => condition ? describe : describe.skip
|
||||
const itif = (condition: boolean) => condition ? it : it.skip
|
||||
const describeif = (condition: boolean) => condition ? describe : describe.skip;
|
||||
const itif = (condition: boolean) => condition ? it : it.skip;
|
||||
|
||||
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", () => {
|
||||
const TEST_NAMESPACE = "integration-tests"
|
||||
const TEST_NAMESPACE = "integration-tests";
|
||||
|
||||
const BACKSPACE = "\uE003"
|
||||
let app: Application
|
||||
const BACKSPACE = "\uE003";
|
||||
let app: Application;
|
||||
|
||||
const appStart = async () => {
|
||||
app = util.setup()
|
||||
await app.start()
|
||||
app = util.setup();
|
||||
await app.start();
|
||||
// Wait for splash screen to be closed
|
||||
while (await app.client.getWindowCount() > 1);
|
||||
await app.client.windowByIndex(0)
|
||||
await app.client.waitUntilWindowLoaded()
|
||||
}
|
||||
await app.client.windowByIndex(0);
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
};
|
||||
|
||||
const clickWhatsNew = async (app: Application) => {
|
||||
await app.client.waitUntilTextExists("h1", "What's new?")
|
||||
await app.client.click("button.primary")
|
||||
await app.client.waitUntilTextExists("h1", "Welcome")
|
||||
}
|
||||
await app.client.waitUntilTextExists("h1", "What's new?");
|
||||
await app.client.click("button.primary");
|
||||
await app.client.waitUntilTextExists("h1", "Welcome");
|
||||
};
|
||||
|
||||
describe("app start", () => {
|
||||
beforeAll(appStart, 20000)
|
||||
beforeAll(appStart, 20000);
|
||||
|
||||
afterAll(async () => {
|
||||
if (app && app.isRunning()) {
|
||||
return util.tearDown(app)
|
||||
return util.tearDown(app);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
it('shows "whats new"', async () => {
|
||||
await clickWhatsNew(app)
|
||||
})
|
||||
await clickWhatsNew(app);
|
||||
});
|
||||
|
||||
it('shows "add cluster"', async () => {
|
||||
await app.electron.ipcRenderer.send('test-menu-item-click', "File", "Add Cluster")
|
||||
await app.client.waitUntilTextExists("h2", "Add Cluster")
|
||||
})
|
||||
await app.electron.ipcRenderer.send('test-menu-item-click', "File", "Add Cluster");
|
||||
await app.client.waitUntilTextExists("h2", "Add Cluster");
|
||||
});
|
||||
|
||||
describe("preferences page", () => {
|
||||
it('shows "preferences"', async () => {
|
||||
let appName: string = process.platform === "darwin" ? "Lens" : "File"
|
||||
await app.electron.ipcRenderer.send('test-menu-item-click', appName, "Preferences")
|
||||
await app.client.waitUntilTextExists("h2", "Preferences")
|
||||
})
|
||||
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");
|
||||
});
|
||||
|
||||
it('ensures helm repos', async () => {
|
||||
await app.client.waitUntilTextExists("div.repos #message-stable", "stable") // wait for the helm-cli to fetch the stable repo
|
||||
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 app.client.waitUntilTextExists("div.repos #message-stable", "stable"); // wait for the helm-cli to fetch the stable repo
|
||||
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)
|
||||
});
|
||||
});
|
||||
|
||||
it.skip('quits Lens"', async () => {
|
||||
await app.client.keys(['Meta', 'Q'])
|
||||
await app.client.keys('Meta')
|
||||
})
|
||||
})
|
||||
await app.client.keys(['Meta', 'Q']);
|
||||
await app.client.keys('Meta');
|
||||
});
|
||||
});
|
||||
|
||||
const minikubeReady = (): boolean => {
|
||||
// determine if minikube is running
|
||||
let status = spawnSync("minikube status", { shell: true })
|
||||
let status = spawnSync("minikube status", { shell: true });
|
||||
if (status.status !== 0) {
|
||||
console.warn("minikube not running")
|
||||
return false
|
||||
console.warn("minikube not running");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove TEST_NAMESPACE if it already exists
|
||||
status = spawnSync(`minikube kubectl -- get namespace ${TEST_NAMESPACE}`, { shell: true })
|
||||
status = spawnSync(`minikube kubectl -- get namespace ${TEST_NAMESPACE}`, { shell: true });
|
||||
if (status.status === 0) {
|
||||
console.warn(`Removing existing ${TEST_NAMESPACE} namespace`)
|
||||
status = spawnSync(`minikube kubectl -- delete namespace ${TEST_NAMESPACE}`, { shell: true })
|
||||
console.warn(`Removing existing ${TEST_NAMESPACE} namespace`);
|
||||
status = spawnSync(`minikube kubectl -- delete namespace ${TEST_NAMESPACE}`, { shell: true });
|
||||
if (status.status !== 0) {
|
||||
console.warn(`Error removing ${TEST_NAMESPACE} namespace: ${status.stderr.toString()}`)
|
||||
return false
|
||||
console.warn(`Error removing ${TEST_NAMESPACE} namespace: ${status.stderr.toString()}`);
|
||||
return false;
|
||||
}
|
||||
console.log(status.stdout.toString())
|
||||
console.log(status.stdout.toString());
|
||||
}
|
||||
return true
|
||||
}
|
||||
const ready = minikubeReady()
|
||||
return true;
|
||||
};
|
||||
const ready = minikubeReady();
|
||||
|
||||
const addMinikubeCluster = async (app: Application) => {
|
||||
await app.client.click("div.add-cluster")
|
||||
await app.client.waitUntilTextExists("div", "Select kubeconfig file")
|
||||
await app.client.click("div.Select__control") // show the context drop-down list
|
||||
await app.client.waitUntilTextExists("div", "minikube")
|
||||
await app.client.click("div.add-cluster");
|
||||
await app.client.waitUntilTextExists("div", "Select kubeconfig file");
|
||||
await app.client.click("div.Select__control"); // show the context drop-down list
|
||||
await app.client.waitUntilTextExists("div", "minikube");
|
||||
if (!await app.client.$("button.primary").isEnabled()) {
|
||||
await app.client.click("div.minikube") // select minikube context
|
||||
await app.client.click("div.minikube"); // select minikube context
|
||||
} // else the only context, which must be 'minikube', is automatically selected
|
||||
await app.client.click("div.Select__control") // hide the context drop-down list (it might be obscuring the Add cluster(s) button)
|
||||
await app.client.click("button.primary") // add minikube cluster
|
||||
}
|
||||
await app.client.click("div.Select__control"); // hide the context drop-down list (it might be obscuring the Add cluster(s) button)
|
||||
await app.client.click("button.primary"); // add minikube cluster
|
||||
};
|
||||
|
||||
const waitForMinikubeDashboard = async (app: Application) => {
|
||||
await app.client.waitUntilTextExists("pre.kube-auth-out", "Authentication proxy started")
|
||||
await app.client.waitForExist(`iframe[name="minikube"]`)
|
||||
await app.client.frame("minikube")
|
||||
await app.client.waitUntilTextExists("span.link-text", "Cluster")
|
||||
}
|
||||
await app.client.waitUntilTextExists("pre.kube-auth-out", "Authentication proxy started");
|
||||
await app.client.waitForExist(`iframe[name="minikube"]`);
|
||||
await app.client.frame("minikube");
|
||||
await app.client.waitUntilTextExists("span.link-text", "Cluster");
|
||||
};
|
||||
|
||||
describeif(ready)("cluster tests", () => {
|
||||
let clusterAdded = false
|
||||
let clusterAdded = false;
|
||||
|
||||
const addCluster = async () => {
|
||||
await clickWhatsNew(app)
|
||||
await addMinikubeCluster(app)
|
||||
await waitForMinikubeDashboard(app)
|
||||
await app.client.click('a[href="/nodes"]')
|
||||
await app.client.waitUntilTextExists("div.TableCell", "Ready")
|
||||
}
|
||||
await clickWhatsNew(app);
|
||||
await addMinikubeCluster(app);
|
||||
await waitForMinikubeDashboard(app);
|
||||
await app.client.click('a[href="/nodes"]');
|
||||
await app.client.waitUntilTextExists("div.TableCell", "Ready");
|
||||
};
|
||||
|
||||
describe("cluster add", () => {
|
||||
beforeAll(appStart, 20000)
|
||||
beforeAll(appStart, 20000);
|
||||
|
||||
afterAll(async () => {
|
||||
if (app && app.isRunning()) {
|
||||
return util.tearDown(app)
|
||||
return util.tearDown(app);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
it('allows to add a cluster', async () => {
|
||||
await addCluster()
|
||||
clusterAdded = true
|
||||
})
|
||||
})
|
||||
await addCluster();
|
||||
clusterAdded = true;
|
||||
});
|
||||
});
|
||||
|
||||
const appStartAddCluster = async () => {
|
||||
if (clusterAdded) {
|
||||
await appStart()
|
||||
await addCluster()
|
||||
await appStart();
|
||||
await addCluster();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
describe("cluster pages", () => {
|
||||
|
||||
beforeAll(appStartAddCluster, 40000)
|
||||
beforeAll(appStartAddCluster, 40000);
|
||||
|
||||
afterAll(async () => {
|
||||
if (app && app.isRunning()) {
|
||||
return util.tearDown(app)
|
||||
return util.tearDown(app);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
const tests: {
|
||||
drawer?: string
|
||||
@@ -394,119 +394,119 @@ describe("Lens integration tests", () => {
|
||||
tests.forEach(({ drawer = "", drawerId = "", 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)
|
||||
})
|
||||
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);
|
||||
});
|
||||
}
|
||||
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)
|
||||
})
|
||||
})
|
||||
expect(clusterAdded).toBe(true);
|
||||
await app.client.click(`a[href^="/${href}"]`);
|
||||
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()
|
||||
})
|
||||
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();
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe("viewing pod logs", () => {
|
||||
beforeEach(appStartAddCluster, 40000)
|
||||
beforeEach(appStartAddCluster, 40000);
|
||||
|
||||
afterEach(async () => {
|
||||
if (app && app.isRunning()) {
|
||||
return util.tearDown(app)
|
||||
return util.tearDown(app);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
it(`shows a logs for a pod`, async () => {
|
||||
expect(clusterAdded).toBe(true)
|
||||
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.waitUntilTextExists("div.TableCell", "kube-apiserver")
|
||||
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.waitUntilTextExists("div.TableCell", "kube-apiserver");
|
||||
// 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 app.client.click(".list .TableRow:first-child");
|
||||
await app.client.waitForVisible(".Drawer");
|
||||
await app.client.click(".drawer-title .Menu li:nth-child(2)");
|
||||
// Check if controls are available
|
||||
await app.client.waitForVisible(".PodLogs .VirtualList")
|
||||
await app.client.waitForVisible(".PodLogControls")
|
||||
await app.client.waitForVisible(".PodLogControls .SearchInput")
|
||||
await app.client.waitForVisible(".PodLogControls .SearchInput input")
|
||||
await app.client.waitForVisible(".PodLogs .VirtualList");
|
||||
await app.client.waitForVisible(".PodLogControls");
|
||||
await app.client.waitForVisible(".PodLogControls .SearchInput");
|
||||
await app.client.waitForVisible(".PodLogControls .SearchInput input");
|
||||
// Search for semicolon
|
||||
await app.client.keys(":")
|
||||
await app.client.waitForVisible(".PodLogs .list span.active")
|
||||
await app.client.keys(":");
|
||||
await app.client.waitForVisible(".PodLogs .list span.active");
|
||||
// Click through controls
|
||||
await app.client.click(".PodLogControls .timestamps-icon")
|
||||
await app.client.click(".PodLogControls .undo-icon")
|
||||
})
|
||||
})
|
||||
await app.client.click(".PodLogControls .timestamps-icon");
|
||||
await app.client.click(".PodLogControls .undo-icon");
|
||||
});
|
||||
});
|
||||
|
||||
describe("cluster operations", () => {
|
||||
beforeEach(appStartAddCluster, 40000)
|
||||
beforeEach(appStartAddCluster, 40000);
|
||||
|
||||
afterEach(async () => {
|
||||
if (app && app.isRunning()) {
|
||||
return util.tearDown(app)
|
||||
return util.tearDown(app);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
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")
|
||||
})
|
||||
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");
|
||||
});
|
||||
|
||||
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 app.client.keys(`${TEST_NAMESPACE}\n`)
|
||||
await app.client.waitForExist(`.name=${TEST_NAMESPACE}`)
|
||||
})
|
||||
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 app.client.keys(`${TEST_NAMESPACE}\n`);
|
||||
await app.client.waitForExist(`.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 app.client.waitUntilTextExists("div.TableCell", "kube-apiserver")
|
||||
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")
|
||||
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 app.client.waitUntilTextExists("div.TableCell", "kube-apiserver");
|
||||
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");
|
||||
// Write pod manifest to editor
|
||||
await app.client.keys("apiVersion: v1\n")
|
||||
await app.client.keys("kind: Pod\n")
|
||||
await app.client.keys("metadata:\n")
|
||||
await app.client.keys(" name: nginx-create-pod-test\n")
|
||||
await app.client.keys(`namespace: ${TEST_NAMESPACE}\n`)
|
||||
await app.client.keys(BACKSPACE + "spec:\n")
|
||||
await app.client.keys(" containers:\n")
|
||||
await app.client.keys("- name: nginx-create-pod-test\n")
|
||||
await app.client.keys(" image: nginx:alpine\n")
|
||||
await app.client.keys("apiVersion: v1\n");
|
||||
await app.client.keys("kind: Pod\n");
|
||||
await app.client.keys("metadata:\n");
|
||||
await app.client.keys(" name: nginx-create-pod-test\n");
|
||||
await app.client.keys(`namespace: ${TEST_NAMESPACE}\n`);
|
||||
await app.client.keys(BACKSPACE + "spec:\n");
|
||||
await app.client.keys(" containers:\n");
|
||||
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 app.client.waitForEnabled("button.Button=Create & Close");
|
||||
await app.client.click("button.Button=Create & Close");
|
||||
// Wait until first bits of pod appears on dashboard
|
||||
await app.client.waitForExist(".name=nginx-create-pod-test")
|
||||
await app.client.waitForExist(".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 app.client.click(".name=nginx-create-pod-test");
|
||||
await app.client.waitUntilTextExists("div.drawer-title-text", "Pod: nginx-create-pod-test");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -4,7 +4,7 @@ const AppPaths: Partial<Record<NodeJS.Platform, string>> = {
|
||||
"win32": "./dist/win-unpacked/Lens.exe",
|
||||
"linux": "./dist/linux-unpacked/kontena-lens",
|
||||
"darwin": "./dist/mac/Lens.app/Contents/MacOS/Lens",
|
||||
}
|
||||
};
|
||||
|
||||
export function setup(): Application {
|
||||
return new Application({
|
||||
@@ -16,16 +16,16 @@ export function setup(): Application {
|
||||
env: {
|
||||
CICD: "true"
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export async function tearDown(app: Application) {
|
||||
let mpid: any = app.mainProcess.pid
|
||||
let pid = await mpid()
|
||||
await app.stop()
|
||||
const mpid: any = app.mainProcess.pid;
|
||||
const pid = await mpid();
|
||||
await app.stop();
|
||||
try {
|
||||
process.kill(pid, "SIGKILL");
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user