mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
get protocol handling working for linux
Signed-off-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
parent
bce07796b1
commit
aa5909bdd1
@ -4,7 +4,6 @@ import { listHelmRepositories } from "../helpers/utils";
|
|||||||
import { fail } from "assert";
|
import { fail } from "assert";
|
||||||
import open from "open";
|
import open from "open";
|
||||||
|
|
||||||
|
|
||||||
jest.setTimeout(60000);
|
jest.setTimeout(60000);
|
||||||
|
|
||||||
// FIXME (!): improve / simplify all css-selectors + use [data-test-id="some-id"] (already used in some tests below)
|
// FIXME (!): improve / simplify all css-selectors + use [data-test-id="some-id"] (already used in some tests below)
|
||||||
@ -29,7 +28,7 @@ describe("Lens integration tests", () => {
|
|||||||
await app.client.waitUntilTextExists("h2", "Add Cluster");
|
await app.client.waitUntilTextExists("h2", "Add Cluster");
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("protocol app start", () => {
|
describe.only("protocol app start", () => {
|
||||||
it("should handle opening lens:// links", async () => {
|
it("should handle opening lens:// links", async () => {
|
||||||
await open("lens://app/foobar");
|
await open("lens://app/foobar");
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import { AppConstructorOptions, Application } from "spectron";
|
import { AppConstructorOptions, Application } from "spectron";
|
||||||
import * as util from "util";
|
import * as util from "util";
|
||||||
import { exec } from "child_process";
|
import { exec, spawnSync } from "child_process";
|
||||||
import fse from "fs-extra";
|
import fse, { writeFile } from "fs-extra";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import os from "os";
|
||||||
import { delay } from "../../src/common/utils";
|
import { delay } from "../../src/common/utils";
|
||||||
|
|
||||||
interface AppTestingPaths {
|
interface AppTestingPaths {
|
||||||
@ -10,7 +11,7 @@ interface AppTestingPaths {
|
|||||||
libraryPath: string,
|
libraryPath: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAppTestingPaths(): AppTestingPaths {
|
export function getAppTestingPaths(): AppTestingPaths {
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "win32":
|
case "win32":
|
||||||
return {
|
return {
|
||||||
@ -69,6 +70,27 @@ export async function appStart() {
|
|||||||
await app.client.windowByIndex(0);
|
await app.client.windowByIndex(0);
|
||||||
await app.client.waitUntilWindowLoaded();
|
await app.client.waitUntilWindowLoaded();
|
||||||
|
|
||||||
|
if (process.platform === "linux") {
|
||||||
|
const testingDesktop = [
|
||||||
|
"[Desktop Entry]",
|
||||||
|
"Name=Lens",
|
||||||
|
`Exec=${path.resolve(getAppTestingPaths().testingPath)} %U`,
|
||||||
|
"Terminal=false",
|
||||||
|
"Type=Application",
|
||||||
|
"Icon=lens",
|
||||||
|
"StartupWMClass=Lens",
|
||||||
|
"Comment=Lens - The Kubernetes IDE",
|
||||||
|
"MimeType=x-scheme-handler/lens;",
|
||||||
|
"Categories=Network;"
|
||||||
|
].join("\n");
|
||||||
|
|
||||||
|
await writeFile(path.join(os.homedir(), ".local/share/applications/lens-testing.desktop"), testingDesktop);
|
||||||
|
|
||||||
|
const { status } = spawnSync("xdg-settings set default-url-scheme-handler lens lens-testing.desktop", { shell: true });
|
||||||
|
|
||||||
|
expect(status).toBe(0);
|
||||||
|
}
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,6 +156,8 @@ async function* splitLogs(app: Application): AsyncGenerator<LogLines, void, void
|
|||||||
const curLogs: string[] = (app as any).chromeDriver.getLogs();
|
const curLogs: string[] = (app as any).chromeDriver.getLogs();
|
||||||
const newLogs = curLogs.slice(lastLogLineCount);
|
const newLogs = curLogs.slice(lastLogLineCount);
|
||||||
|
|
||||||
|
console.log(curLogs);
|
||||||
|
|
||||||
lastLogLineCount = curLogs.length;
|
lastLogLineCount = curLogs.length;
|
||||||
|
|
||||||
const item: LogLines = {
|
const item: LogLines = {
|
||||||
|
|||||||
@ -174,7 +174,10 @@
|
|||||||
},
|
},
|
||||||
"protocols": {
|
"protocols": {
|
||||||
"name": "Lens Protocol Handler",
|
"name": "Lens Protocol Handler",
|
||||||
"schemes": "lens"
|
"schemes": [
|
||||||
|
"lens"
|
||||||
|
],
|
||||||
|
"role": "Viewer"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lens": {
|
"lens": {
|
||||||
|
|||||||
@ -52,12 +52,28 @@ if (app.commandLine.getSwitchValue("proxy-server") !== "") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!app.requestSingleInstanceLock()) {
|
if (!app.requestSingleInstanceLock()) {
|
||||||
console.log(process.argv);
|
|
||||||
app.exit();
|
app.exit();
|
||||||
|
} else {
|
||||||
|
const lprm = LensProtocolRouterMain.getInstance<LensProtocolRouterMain>();
|
||||||
|
|
||||||
|
for (const arg of process.argv) {
|
||||||
|
if (arg.toLowerCase().startsWith("lens://")) {
|
||||||
|
lprm.route(arg)
|
||||||
|
.catch(error => logger.error(`${LensProtocolRouterMain.LoggingPrefix}: an error occured`, { error, rawUrl: arg }));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app.on("second-instance", () => {
|
app.on("second-instance", (event, argv) => {
|
||||||
console.log(process.argv);
|
const lprm = LensProtocolRouterMain.getInstance<LensProtocolRouterMain>();
|
||||||
|
|
||||||
|
for (const arg of argv) {
|
||||||
|
if (arg.toLowerCase().startsWith("lens://")) {
|
||||||
|
lprm.route(arg)
|
||||||
|
.catch(error => logger.error(`${LensProtocolRouterMain.LoggingPrefix}: an error occured`, { error, rawUrl: arg }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
windowManager?.ensureMainWindow();
|
windowManager?.ensureMainWindow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user