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

Attempt to fix test timeout by using runInAction

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-08-26 18:05:24 -04:00
parent f596a40204
commit 924afde1d6
2 changed files with 9 additions and 3 deletions

View File

@ -10,7 +10,7 @@ import type { ExtensionDiscovery } from "../extension-discovery/extension-discov
import installExtensionInjectable from "../extension-installer/install-extension/install-extension.injectable"; import installExtensionInjectable from "../extension-installer/install-extension/install-extension.injectable";
import directoryForUserDataInjectable from "../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable"; import directoryForUserDataInjectable from "../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
import { delay } from "../../renderer/utils"; import { delay } from "../../renderer/utils";
import { observable, when } from "mobx"; import { observable, runInAction, when } from "mobx";
import readJsonFileInjectable from "../../common/fs/read-json-file.injectable"; import readJsonFileInjectable from "../../common/fs/read-json-file.injectable";
import pathExistsInjectable from "../../common/fs/path-exists.injectable"; import pathExistsInjectable from "../../common/fs/path-exists.injectable";
import watchInjectable from "../../common/fs/watch/watch.injectable"; import watchInjectable from "../../common/fs/watch/watch.injectable";
@ -101,7 +101,7 @@ describe("ExtensionDiscovery", () => {
}, },
manifestPath: "/some-directory-for-user-data/node_modules/my-extension/package.json", manifestPath: "/some-directory-for-user-data/node_modules/my-extension/package.json",
}); });
letTestFinish.set(true); runInAction(() => letTestFinish.set(true));
}); });
addHandler(joinPaths(extensionDiscovery.localFolderPath, "/my-extension/package.json")); addHandler(joinPaths(extensionDiscovery.localFolderPath, "/my-extension/package.json"));

View File

@ -31,6 +31,7 @@ import type { GetBasenameOfPath } from "../../common/path/get-basename.injectabl
import type { GetDirnameOfPath } from "../../common/path/get-dirname.injectable"; import type { GetDirnameOfPath } from "../../common/path/get-dirname.injectable";
import type { GetRelativePath } from "../../common/path/get-relative-path.injectable"; import type { GetRelativePath } from "../../common/path/get-relative-path.injectable";
import type { RemovePath } from "../../common/fs/remove-path.injectable"; import type { RemovePath } from "../../common/fs/remove-path.injectable";
import type TypedEventEmitter from "typed-emitter";
interface Dependencies { interface Dependencies {
readonly extensionLoader: ExtensionLoader; readonly extensionLoader: ExtensionLoader;
@ -94,6 +95,11 @@ interface LoadFromFolderOptions {
isBundled?: boolean; isBundled?: boolean;
} }
interface ExtensionDiscoveryEvents {
add: (ext: InstalledExtension) => void;
remove: (extId: LensExtensionId) => void;
}
/** /**
* Discovers installed bundled and local extensions from the filesystem. * Discovers installed bundled and local extensions from the filesystem.
* Also watches for added and removed local extensions by watching the directory. * Also watches for added and removed local extensions by watching the directory.
@ -117,7 +123,7 @@ export class ExtensionDiscovery {
return when(() => this.isLoaded); return when(() => this.isLoaded);
} }
public events = new EventEmitter(); public readonly events: TypedEventEmitter<ExtensionDiscoveryEvents> = new EventEmitter();
constructor(protected readonly dependencies: Dependencies) { constructor(protected readonly dependencies: Dependencies) {
makeObservable(this); makeObservable(this);