mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add lens:// protocol handling with a routing mechanism
- document the methods in an extension guide - add integration test to make sure that all tested OSes work as intended Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
21adda2c64
commit
8430b67d55
23 files changed
+983
-106
No files matched your search
@@ -2,6 +2,7 @@ import { Application } from "spectron";
|
||||
import * as utils from "../helpers/utils";
|
||||
import { listHelmRepositories } from "../helpers/utils";
|
||||
import { fail } from "assert";
|
||||
import open from "open";
|
||||
|
||||
|
||||
jest.setTimeout(60000);
|
||||
@@ -28,6 +29,17 @@ describe("Lens integration tests", () => {
|
||||
await app.client.waitUntilTextExists("h2", "Add Cluster");
|
||||
});
|
||||
|
||||
describe("protocol app start", () => {
|
||||
it ("should handle opening lens:// links", async () => {
|
||||
await open("lens://internal/foobar?");
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
|
||||
const logs = await app.client.getMainProcessLogs();
|
||||
|
||||
expect(logs.some(log => log.includes("no handler") || log.includes("lens://internal/foobar?"))).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("preferences page", () => {
|
||||
it('shows "preferences"', async () => {
|
||||
const appName: string = process.platform === "darwin" ? "Lens" : "File";
|
||||
|
||||
@@ -1,12 +1,35 @@
|
||||
import { Application } from "spectron";
|
||||
import { AppConstructorOptions, Application } from "spectron";
|
||||
import * as util from "util";
|
||||
import { exec } from "child_process";
|
||||
import fse from "fs-extra";
|
||||
import path from "path";
|
||||
|
||||
const AppPaths: Partial<Record<NodeJS.Platform, string>> = {
|
||||
"win32": "./dist/win-unpacked/Lens.exe",
|
||||
"linux": "./dist/linux-unpacked/lens",
|
||||
"darwin": "./dist/mac/Lens.app/Contents/MacOS/Lens",
|
||||
};
|
||||
interface AppTestingPaths {
|
||||
testingPath: string,
|
||||
libraryPath: string,
|
||||
}
|
||||
|
||||
function getAppTestingPaths(): AppTestingPaths {
|
||||
switch (process.platform) {
|
||||
case "win32":
|
||||
return {
|
||||
testingPath: "./dist/win-unpacked/Lens.exe",
|
||||
libraryPath: path.join(process.env.APPDATA, "Lens"),
|
||||
};
|
||||
case "linux":
|
||||
return {
|
||||
testingPath: "./dist/linux-unpacked/lens",
|
||||
libraryPath: path.join(process.env.XDG_CONFIG_HOME || path.join(process.env.HOME, ".config"), "Lens"),
|
||||
};
|
||||
case "darwin":
|
||||
return {
|
||||
testingPath: "./dist/mac/Lens.app/Contents/MacOS/Lens",
|
||||
libraryPath: path.join(process.env.HOME, "Library/Application\ Support/Lens"),
|
||||
};
|
||||
default:
|
||||
throw new TypeError(`platform ${process.platform} is not supported`);
|
||||
}
|
||||
}
|
||||
|
||||
export function itIf(condition: boolean) {
|
||||
return condition ? it : it.skip;
|
||||
@@ -16,16 +39,20 @@ export function describeIf(condition: boolean) {
|
||||
return condition ? describe : describe.skip;
|
||||
}
|
||||
|
||||
export function setup(): Application {
|
||||
return new Application({
|
||||
path: AppPaths[process.platform], // path to electron app
|
||||
export function setup(): AppConstructorOptions {
|
||||
const appPath = getAppTestingPaths();
|
||||
|
||||
fse.removeSync(appPath.libraryPath); // remove old install config
|
||||
|
||||
return {
|
||||
path: appPath.testingPath,
|
||||
args: [],
|
||||
startTimeout: 30000,
|
||||
waitTimeout: 60000,
|
||||
env: {
|
||||
CICD: "true"
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const keys = {
|
||||
|
||||
Reference in new issue
Block a user