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:
Sebastian Malton committed 2021-02-02 08:48:01 -05:00
1 parent 21adda2c64
commit 8430b67d55
23 files changed
+983 -106

No files matched your search

+37 -10
View 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 = {