mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix catalog.test.tsx
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
dc3dffc2fc
commit
bc30edade0
@ -3,11 +3,11 @@
|
|||||||
* 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 { app, ipcMain } from "electron";
|
import { app } from "electron";
|
||||||
import semver, { SemVer } from "semver";
|
import semver, { SemVer } from "semver";
|
||||||
import { action, computed, observable, reaction, makeObservable, isObservableArray, isObservableSet, isObservableMap } from "mobx";
|
import { action, computed, observable, reaction, makeObservable, isObservableArray, isObservableSet, isObservableMap } from "mobx";
|
||||||
import { BaseStore } from "../base-store";
|
import { BaseStore } from "../base-store";
|
||||||
import migrations, { fileNameMigration } from "../../migrations/user-store";
|
import migrations from "../../migrations/user-store";
|
||||||
import { getAppVersion } from "../utils/app-version";
|
import { getAppVersion } from "../utils/app-version";
|
||||||
import { kubeConfigDefaultPath } from "../kube-helpers";
|
import { kubeConfigDefaultPath } from "../kube-helpers";
|
||||||
import { appEventBus } from "../app-event-bus/event-bus";
|
import { appEventBus } from "../app-event-bus/event-bus";
|
||||||
@ -30,11 +30,6 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
|||||||
});
|
});
|
||||||
|
|
||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
|
|
||||||
if (ipcMain) {
|
|
||||||
fileNameMigration();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.load();
|
this.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -63,6 +63,7 @@ import hotbarStoreInjectable from "../common/hotbar-store.injectable";
|
|||||||
import applicationMenuItemsInjectable from "./menu/application-menu-items.injectable";
|
import applicationMenuItemsInjectable from "./menu/application-menu-items.injectable";
|
||||||
import type { DiContainer } from "@ogre-tools/injectable";
|
import type { DiContainer } from "@ogre-tools/injectable";
|
||||||
import { init } from "@sentry/electron/main";
|
import { init } from "@sentry/electron/main";
|
||||||
|
import { userStoreFileNameMigration } from "../migrations/user-store";
|
||||||
|
|
||||||
async function main(di: DiContainer) {
|
async function main(di: DiContainer) {
|
||||||
app.setName(appName);
|
app.setName(appName);
|
||||||
@ -71,6 +72,9 @@ async function main(di: DiContainer) {
|
|||||||
* Note: this MUST be called before electron's "ready" event has been emitted.
|
* Note: this MUST be called before electron's "ready" event has been emitted.
|
||||||
*/
|
*/
|
||||||
initializeSentryReporting(init);
|
initializeSentryReporting(init);
|
||||||
|
|
||||||
|
// TODO make this part of the UserStore setup
|
||||||
|
await userStoreFileNameMigration();
|
||||||
await di.runSetups();
|
await di.runSetups();
|
||||||
await app.whenReady();
|
await app.whenReady();
|
||||||
|
|
||||||
|
|||||||
@ -6,11 +6,10 @@
|
|||||||
import fse from "fs-extra";
|
import fse from "fs-extra";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { getLegacyGlobalDiForExtensionApi } from "../../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
import { getLegacyGlobalDiForExtensionApi } from "../../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||||
import directoryForUserDataInjectable
|
import directoryForUserDataInjectable from "../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||||
from "../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
|
||||||
import { isErrnoException } from "../../common/utils";
|
import { isErrnoException } from "../../common/utils";
|
||||||
|
|
||||||
export function fileNameMigration() {
|
export async function userStoreFileNameMigration() {
|
||||||
const di = getLegacyGlobalDiForExtensionApi();
|
const di = getLegacyGlobalDiForExtensionApi();
|
||||||
|
|
||||||
const userDataPath = di.inject(directoryForUserDataInjectable);
|
const userDataPath = di.inject(directoryForUserDataInjectable);
|
||||||
@ -18,10 +17,10 @@ export function fileNameMigration() {
|
|||||||
const lensUserStoreJsonPath = path.join(userDataPath, "lens-user-store.json");
|
const lensUserStoreJsonPath = path.join(userDataPath, "lens-user-store.json");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fse.moveSync(configJsonPath, lensUserStoreJsonPath);
|
await fse.move(configJsonPath, lensUserStoreJsonPath);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof Error && error.message === "dest already exists.") {
|
if (error instanceof Error && error.message === "dest already exists.") {
|
||||||
fse.removeSync(configJsonPath);
|
await fse.remove(configJsonPath);
|
||||||
} else if (isErrnoException(error) && error.code === "ENOENT" && error.path === configJsonPath) {
|
} else if (isErrnoException(error) && error.code === "ENOENT" && error.path === configJsonPath) {
|
||||||
// (No such file or directory)
|
// (No such file or directory)
|
||||||
return; // file already moved
|
return; // file already moved
|
||||||
|
|||||||
@ -10,10 +10,10 @@ import { joinMigrations } from "../helpers";
|
|||||||
import version210Beta4 from "./2.1.0-beta.4";
|
import version210Beta4 from "./2.1.0-beta.4";
|
||||||
import version500Alpha3 from "./5.0.0-alpha.3";
|
import version500Alpha3 from "./5.0.0-alpha.3";
|
||||||
import version503Beta1 from "./5.0.3-beta.1";
|
import version503Beta1 from "./5.0.3-beta.1";
|
||||||
import { fileNameMigration } from "./file-name-migration";
|
import { userStoreFileNameMigration } from "./file-name-migration";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
fileNameMigration,
|
userStoreFileNameMigration,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default joinMigrations(
|
export default joinMigrations(
|
||||||
|
|||||||
@ -124,9 +124,9 @@ describe("<Catalog />", () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
catalogEntityStore = di.inject(catalogEntityStoreInjectable);
|
catalogEntityStore = di.inject(catalogEntityStoreInjectable);
|
||||||
jest
|
Object.assign(catalogEntityStore, {
|
||||||
.spyOn(catalogEntityStore, "selectedItem", "get")
|
selectedItem: computed(() => catalogEntityItem),
|
||||||
.mockImplementation(() => computed(() => catalogEntityItem));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user