1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Merge branch 'master' into feature/command-palette

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-01-26 18:04:18 +02:00
commit 089d928cb3
6 changed files with 72 additions and 22 deletions

View File

@ -1,9 +1,8 @@
import { Application } from "spectron"; import { Application } from "spectron";
import * as utils from "../helpers/utils"; import * as utils from "../helpers/utils";
import { exec } from "child_process"; import { listHelmRepositories } from "../helpers/utils";
import * as util from "util"; import { fail } from "assert";
export const promiseExec = util.promisify(exec);
jest.setTimeout(60000); jest.setTimeout(60000);
@ -38,7 +37,13 @@ describe("Lens integration tests", () => {
}); });
it("ensures helm repos", async () => { it("ensures helm repos", async () => {
await app.client.waitUntilTextExists("div.repos #message-bitnami", "bitnami"); // wait for the helm-cli to fetch the repo(s) const repos = await listHelmRepositories();
if (!repos[0]) {
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.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.Select__option", ""); // wait for at least one option to appear (any text)
}); });

View File

@ -351,19 +351,35 @@ describe("Lens cluster pages", () => {
await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text"); await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text");
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.keys("kube-system");
await app.client.keys("Enter");// "\uE007"
await app.client.waitUntilTextExists("div.TableCell", "kube-apiserver"); await app.client.waitUntilTextExists("div.TableCell", "kube-apiserver");
let podMenuItemEnabled = false;
// Wait until extensions are enabled on renderer
while (!podMenuItemEnabled) {
const logs = await app.client.getRenderProcessLogs();
podMenuItemEnabled = !!logs.find(entry => entry.message.includes("[EXTENSION]: enabled lens-pod-menu@"));
if (!podMenuItemEnabled) {
await new Promise(r => setTimeout(r, 1000));
}
}
await new Promise(r => setTimeout(r, 500)); // Give some extra time to prepare extensions
// Open logs tab in dock // Open logs tab in dock
await app.client.click(".list .TableRow:first-child"); await app.client.click(".list .TableRow:first-child");
await app.client.waitForVisible(".Drawer"); await app.client.waitForVisible(".Drawer");
await app.client.click(".drawer-title .Menu li:nth-child(2)"); await app.client.click(".drawer-title .Menu li:nth-child(2)");
// Check if controls are available // Check if controls are available
await app.client.waitForVisible(".Logs .VirtualList"); await app.client.waitForVisible(".LogList .VirtualList");
await app.client.waitForVisible(".LogResourceSelector"); await app.client.waitForVisible(".LogResourceSelector");
await app.client.waitForVisible(".LogResourceSelector .SearchInput"); //await app.client.waitForVisible(".LogSearch .SearchInput");
await app.client.waitForVisible(".LogResourceSelector .SearchInput input"); await app.client.waitForVisible(".LogSearch .SearchInput input");
// Search for semicolon // Search for semicolon
await app.client.keys(":"); await app.client.keys(":");
await app.client.waitForVisible(".Logs .list span.active"); await app.client.waitForVisible(".LogList .list span.active");
// Click through controls // Click through controls
await app.client.click(".LogControls .show-timestamps"); await app.client.click(".LogControls .show-timestamps");
await app.client.click(".LogControls .show-previous"); await app.client.click(".LogControls .show-previous");
@ -402,7 +418,10 @@ describe("Lens cluster pages", () => {
await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text"); await app.client.click(".sidebar-nav [data-test-id='workloads'] span.link-text");
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.waitUntilTextExists("div.TableCell", "kube-apiserver");
await app.client.click(".NamespaceSelect");
await app.client.keys(TEST_NAMESPACE);
await app.client.keys("Enter");// "\uE007"
await app.client.click(".Icon.new-dock-tab"); await app.client.click(".Icon.new-dock-tab");
await app.client.waitUntilTextExists("li.MenuItem.create-resource-tab", "Create resource"); await app.client.waitUntilTextExists("li.MenuItem.create-resource-tab", "Create resource");
await app.client.click("li.MenuItem.create-resource-tab"); await app.client.click("li.MenuItem.create-resource-tab");

View File

@ -37,6 +37,7 @@ describe("Lens integration tests", () => {
await app.client.keys("Enter"); await app.client.keys("Enter");
await app.client.keys(name); await app.client.keys(name);
await app.client.keys("Enter"); await app.client.keys("Enter");
await app.client.waitUntilTextExists("[data-test-id=current-workspace-name]", name);
}; };
it("creates new workspace", async () => { it("creates new workspace", async () => {

View File

@ -1,4 +1,6 @@
import { Application } from "spectron"; import { Application } from "spectron";
import * as util from "util";
import { exec } from "child_process";
const AppPaths: Partial<Record<NodeJS.Platform, string>> = { const AppPaths: Partial<Record<NodeJS.Platform, string>> = {
"win32": "./dist/win-unpacked/Lens.exe", "win32": "./dist/win-unpacked/Lens.exe",
@ -61,3 +63,26 @@ export async function tearDown(app: Application) {
console.error(e); console.error(e);
} }
} }
export const promiseExec = util.promisify(exec);
type HelmRepository = {
name: string;
url: string;
};
export async function listHelmRepositories(retries = 0): Promise<HelmRepository[]>{
if (retries < 5) {
try {
const { stdout: reposJson } = await promiseExec("helm repo list -o json");
return JSON.parse(reposJson);
} catch {
await new Promise(r => setTimeout(r, 2000)); // if no repositories, wait for Lens adding bitnami repository
return await listHelmRepositories((retries + 1));
}
}
return [];
}

View File

@ -200,7 +200,7 @@
"jsonpath": "^1.0.2", "jsonpath": "^1.0.2",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"mac-ca": "^1.0.4", "mac-ca": "^1.0.4",
"marked": "^1.1.0", "marked": "^1.2.7",
"md5-file": "^5.0.0", "md5-file": "^5.0.0",
"mobx": "^5.15.7", "mobx": "^5.15.7",
"mobx-observable-history": "^1.0.3", "mobx-observable-history": "^1.0.3",
@ -313,7 +313,7 @@
"jest-canvas-mock": "^2.3.0", "jest-canvas-mock": "^2.3.0",
"jest-fetch-mock": "^3.0.3", "jest-fetch-mock": "^3.0.3",
"jest-mock-extended": "^1.0.10", "jest-mock-extended": "^1.0.10",
"make-plural": "^6.2.1", "make-plural": "^6.2.2",
"mini-css-extract-plugin": "^0.9.0", "mini-css-extract-plugin": "^0.9.0",
"moment": "^2.26.0", "moment": "^2.26.0",
"node-loader": "^0.6.0", "node-loader": "^0.6.0",

View File

@ -4811,9 +4811,9 @@ electron@^9.4.0:
extract-zip "^1.0.3" extract-zip "^1.0.3"
elliptic@^6.0.0, elliptic@^6.5.2: elliptic@^6.0.0, elliptic@^6.5.2:
version "6.5.2" version "6.5.3"
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.2.tgz#05c5678d7173c049d8ca433552224a495d0e3762" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.3.tgz#cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6"
integrity sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw== integrity sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==
dependencies: dependencies:
bn.js "^4.4.0" bn.js "^4.4.0"
brorand "^1.0.1" brorand "^1.0.1"
@ -8766,10 +8766,10 @@ make-fetch-happen@^5.0.0:
socks-proxy-agent "^4.0.0" socks-proxy-agent "^4.0.0"
ssri "^6.0.0" ssri "^6.0.0"
make-plural@^6.2.1: make-plural@^6.2.2:
version "6.2.1" version "6.2.2"
resolved "https://registry.yarnpkg.com/make-plural/-/make-plural-6.2.1.tgz#2790af1d05fb2fc35a111ce759ffdb0aca1339a3" resolved "https://registry.yarnpkg.com/make-plural/-/make-plural-6.2.2.tgz#beb5fd751355e72660eeb2218bb98eec92853c6c"
integrity sha512-AmkruwJ9EjvyTv6AM8MBMK3TAeOJvhgTv5YQXzF0EP2qawhpvMjDpHvsdOIIT0Vn+BB0+IogmYZ1z+Ulm/m0Fg== integrity sha512-8iTuFioatnTTmb/YJjywkVIHLjcwkFD9Ms0JpxjEm9Mo8eQYkh1z+55dwv4yc1jQ8ftVBxWQbihvZL1DfzGGWA==
makeerror@1.0.x: makeerror@1.0.x:
version "1.0.11" version "1.0.11"
@ -8807,10 +8807,10 @@ marked@^0.8.0:
resolved "https://registry.yarnpkg.com/marked/-/marked-0.8.2.tgz#4faad28d26ede351a7a1aaa5fec67915c869e355" resolved "https://registry.yarnpkg.com/marked/-/marked-0.8.2.tgz#4faad28d26ede351a7a1aaa5fec67915c869e355"
integrity sha512-EGwzEeCcLniFX51DhTpmTom+dSA/MG/OBUDjnWtHbEnjAH180VzUeAw+oE4+Zv+CoYBWyRlYOTR0N8SO9R1PVw== integrity sha512-EGwzEeCcLniFX51DhTpmTom+dSA/MG/OBUDjnWtHbEnjAH180VzUeAw+oE4+Zv+CoYBWyRlYOTR0N8SO9R1PVw==
marked@^1.1.0: marked@^1.2.7:
version "1.1.0" version "1.2.7"
resolved "https://registry.yarnpkg.com/marked/-/marked-1.1.0.tgz#62504ad4d11550c942935ccc5e39d64e5a4c4e50" resolved "https://registry.yarnpkg.com/marked/-/marked-1.2.7.tgz#6e14b595581d2319cdcf033a24caaf41455a01fb"
integrity sha512-EkE7RW6KcXfMHy2PA7Jg0YJE1l8UPEZE8k45tylzmZM30/r1M1MUXWQfJlrSbsTeh7m/XTwHbWUENvAJZpp1YA== integrity sha512-No11hFYcXr/zkBvL6qFmAp1z6BKY3zqLMHny/JN/ey+al7qwCM2+CMBL9BOgqMxZU36fz4cCWfn2poWIf7QRXA==
matcher@^3.0.0: matcher@^3.0.0:
version "3.0.0" version "3.0.0"