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

Fix app paths tests by making the tests run in "production" mode

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-01-04 15:44:52 -05:00
parent 93d5f73089
commit 120e8ba0c1
5 changed files with 60 additions and 84 deletions

View File

@ -19,23 +19,23 @@ describe("app-paths", () => {
builder = getApplicationBuilder(); builder = getApplicationBuilder();
const defaultAppPathsStub: AppPaths = { const defaultAppPathsStub: AppPaths = {
currentApp: "some-current-app", currentApp: "/some-current-app",
appData: "some-app-data", appData: "/some-app-data",
cache: "some-cache", cache: "/some-cache",
crashDumps: "some-crash-dumps", crashDumps: "/some-crash-dumps",
desktop: "some-desktop", desktop: "/some-desktop",
documents: "some-documents", documents: "/some-documents",
downloads: "some-downloads", downloads: "/some-downloads",
exe: "some-exe", exe: "/some-exe",
home: "some-home-path", home: "/some-home-path",
logs: "some-logs", logs: "/some-logs",
module: "some-module", module: "/some-module",
music: "some-music", music: "/some-music",
pictures: "some-pictures", pictures: "/some-pictures",
recent: "some-recent", recent: "/some-recent",
temp: "some-temp", temp: "/some-temp",
videos: "some-videos", videos: "/some-videos",
userData: "some-irrelevant-user-data", userData: "/some-irrelevant-user-data",
}; };
builder.beforeApplicationStart((mainDi) => { builder.beforeApplicationStart((mainDi) => {
@ -71,23 +71,23 @@ describe("app-paths", () => {
const actual = windowDi.inject(appPathsInjectable); const actual = windowDi.inject(appPathsInjectable);
expect(actual).toEqual({ expect(actual).toEqual({
currentApp: "some-current-app", currentApp: "/some-current-app",
appData: "some-app-data", appData: "/some-app-data",
cache: "some-cache", cache: "/some-cache",
crashDumps: "some-crash-dumps", crashDumps: "/some-crash-dumps",
desktop: "some-desktop", desktop: "/some-desktop",
documents: "some-documents", documents: "/some-documents",
downloads: "some-downloads", downloads: "/some-downloads",
exe: "some-exe", exe: "/some-exe",
home: "some-home-path", home: "/some-home-path",
logs: "some-logs", logs: "/some-logs",
module: "some-module", module: "/some-module",
music: "some-music", music: "/some-music",
pictures: "some-pictures", pictures: "/some-pictures",
recent: "some-recent", recent: "/some-recent",
temp: "some-temp", temp: "/some-temp",
videos: "some-videos", videos: "/some-videos",
userData: "some-app-data/some-product-name", userData: "/some-app-data/some-product-name",
}); });
}); });
@ -95,23 +95,23 @@ describe("app-paths", () => {
const actual = mainDi.inject(appPathsInjectable); const actual = mainDi.inject(appPathsInjectable);
expect(actual).toEqual({ expect(actual).toEqual({
currentApp: "some-current-app", currentApp: "/some-current-app",
appData: "some-app-data", appData: "/some-app-data",
cache: "some-cache", cache: "/some-cache",
crashDumps: "some-crash-dumps", crashDumps: "/some-crash-dumps",
desktop: "some-desktop", desktop: "/some-desktop",
documents: "some-documents", documents: "/some-documents",
downloads: "some-downloads", downloads: "/some-downloads",
exe: "some-exe", exe: "/some-exe",
home: "some-home-path", home: "/some-home-path",
logs: "some-logs", logs: "/some-logs",
module: "some-module", module: "/some-module",
music: "some-music", music: "/some-music",
pictures: "some-pictures", pictures: "/some-pictures",
recent: "some-recent", recent: "/some-recent",
temp: "some-temp", temp: "/some-temp",
videos: "some-videos", videos: "/some-videos",
userData: "some-app-data/some-product-name", userData: "/some-app-data/some-product-name",
}); });
}); });
}); });
@ -123,7 +123,7 @@ describe("app-paths", () => {
builder.beforeApplicationStart((mainDi) => { builder.beforeApplicationStart((mainDi) => {
mainDi.override( mainDi.override(
directoryForIntegrationTestingInjectable, directoryForIntegrationTestingInjectable,
() => "some-integration-testing-app-data", () => "/some-integration-testing-app-data",
); );
}); });
@ -136,8 +136,8 @@ describe("app-paths", () => {
const { appData, userData } = windowDi.inject(appPathsInjectable); const { appData, userData } = windowDi.inject(appPathsInjectable);
expect({ appData, userData }).toEqual({ expect({ appData, userData }).toEqual({
appData: "some-integration-testing-app-data", appData: "/some-integration-testing-app-data",
userData: `some-integration-testing-app-data/some-product-name`, userData: "/some-integration-testing-app-data/some-product-name",
}); });
}); });
@ -145,8 +145,8 @@ describe("app-paths", () => {
const { appData, userData } = windowDi.inject(appPathsInjectable); const { appData, userData } = windowDi.inject(appPathsInjectable);
expect({ appData, userData }).toEqual({ expect({ appData, userData }).toEqual({
appData: "some-integration-testing-app-data", appData: "/some-integration-testing-app-data",
userData: "some-integration-testing-app-data/some-product-name", userData: "/some-integration-testing-app-data/some-product-name",
}); });
}); });
}); });

View File

@ -3,8 +3,8 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getGlobalOverride } from "../../common/test-utils/get-global-override"; import { getGlobalOverride } from "../test-utils/get-global-override";
import applicationInformationInjectable from "../../common/vars/application-information-injectable"; import applicationInformationInjectable from "./application-information-injectable";
export default getGlobalOverride(applicationInformationInjectable, () => ({ export default getGlobalOverride(applicationInformationInjectable, () => ({
name: "some-product-name", name: "some-product-name",

View File

@ -63,7 +63,7 @@ export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {})
di.register(getInjectable({ di.register(getInjectable({
id: "node-env", id: "node-env",
instantiate: () => "test", instantiate: () => "production",
injectionToken: nodeEnvInjectionToken, injectionToken: nodeEnvInjectionToken,
})); }));

View File

@ -37,7 +37,7 @@ export const getDiForUnitTesting = (
di.register(getInjectable({ di.register(getInjectable({
id: "node-env", id: "node-env",
instantiate: () => "test", instantiate: () => "production",
injectionToken: nodeEnvInjectionToken, injectionToken: nodeEnvInjectionToken,
})); }));

View File

@ -1,24 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getGlobalOverride } from "../../common/test-utils/get-global-override";
import applicationInformationInjectable from "../../common/vars/application-information-injectable";
export default getGlobalOverride(applicationInformationInjectable, () => ({
name: "some-product-name",
productName: "some-product-name",
version: "6.0.0",
build: {} as any,
config: {
k8sProxyVersion: "0.2.1",
bundledKubectlVersion: "1.23.3",
bundledHelmVersion: "3.7.2",
sentryDsn: "",
contentSecurityPolicy: "script-src 'unsafe-eval' 'self'; frame-src http://*.localhost:*/; img-src * data:",
welcomeRoute: "/welcome",
},
copyright: "some-copyright-information",
description: "some-descriptive-text",
}));