diff --git a/src/renderer/components/+catalog/catalog-previous-active-tab-storage/catalog-previous-active-tab-storage.injectable.ts b/src/renderer/components/+catalog/catalog-previous-active-tab-storage/catalog-previous-active-tab-storage.injectable.ts index e0ab887393..36c57ba29a 100644 --- a/src/renderer/components/+catalog/catalog-previous-active-tab-storage/catalog-previous-active-tab-storage.injectable.ts +++ b/src/renderer/components/+catalog/catalog-previous-active-tab-storage/catalog-previous-active-tab-storage.injectable.ts @@ -12,7 +12,7 @@ const catalogPreviousActiveTabStorageInjectable = getInjectable({ instantiate: (di) => { const createStorage = di.inject(createStorageInjectable); - return createStorage( + return createStorage( "catalog-previous-active-tab", browseCatalogTab, ); diff --git a/src/renderer/components/+catalog/catalog.test.tsx b/src/renderer/components/+catalog/catalog.test.tsx index 1ba13ce0ba..4bd9a1bc1f 100644 --- a/src/renderer/components/+catalog/catalog.test.tsx +++ b/src/renderer/components/+catalog/catalog.test.tsx @@ -61,28 +61,25 @@ class MockCatalogEntity extends CatalogEntity { constructor(data: CatalogEntityData, public onRun: (context: CatalogEntityActionContext) => void | Promise) { super(data); } +} - public onContextMenuOpen(): void | Promise {} - public onSettingsOpen(): void | Promise {} +function createMockCatalogEntity(onRun: (context: CatalogEntityActionContext) => void | Promise) { + return new MockCatalogEntity({ + metadata: { + uid: "a_catalogEntity_uid", + name: "a catalog entity", + labels: { + test: "label", + }, + }, + status: { + phase: "", + }, + spec: {}, + }, onRun); } describe("", () => { - function createMockCatalogEntity(onRun: (context: CatalogEntityActionContext) => void | Promise) { - return new MockCatalogEntity({ - metadata: { - uid: "a_catalogEntity_uid", - name: "a catalog entity", - labels: { - test: "label", - }, - }, - status: { - phase: "", - }, - spec: {}, - }, onRun); - } - let di: DiContainer; let catalogEntityStore: CatalogEntityStore; let catalogEntityRegistry: CatalogEntityRegistry; @@ -95,14 +92,12 @@ describe("", () => { di = getDiForUnitTesting({ doGeneralOverrides: true }); di.override(directoryForUserDataInjectable, () => "some-directory-for-user-data"); - di.permitSideEffects(getConfigurationFileModelInjectable); di.permitSideEffects(appVersionInjectable); await di.runSetups(); mockFs(); - UserStore.createInstance(); ThemeStore.createInstance(); CatalogEntityDetailRegistry.createInstance(); @@ -133,7 +128,6 @@ describe("", () => { UserStore.resetInstance(); ThemeStore.resetInstance(); CatalogEntityDetailRegistry.resetInstance(); - jest.clearAllMocks(); jest.restoreAllMocks(); mockFs.restore(); @@ -152,9 +146,7 @@ describe("", () => { }, ); - render( - , - ); + render(); userEvent.click(screen.getByTestId("detail-panel-hot-bar-icon")); }); diff --git a/src/renderer/components/+catalog/catalog.tsx b/src/renderer/components/+catalog/catalog.tsx index ff47c484f3..13776a216f 100644 --- a/src/renderer/components/+catalog/catalog.tsx +++ b/src/renderer/components/+catalog/catalog.tsx @@ -19,6 +19,7 @@ import type { CatalogCategory, CatalogCategoryRegistry, CatalogEntity } from ".. import { CatalogAddButton } from "./catalog-add-button"; import { Notifications } from "../notifications"; import { MainLayout } from "../layout/main-layout"; +import type { StorageLayer } from "../../utils"; import { prevDefault } from "../../utils"; import { CatalogEntityDetails } from "./catalog-entity-details"; import { CatalogMenu } from "./catalog-menu"; @@ -47,7 +48,7 @@ import catalogCategoryRegistryInjectable from "../../../common/catalog/category- import onContextMenuOpenInjectable from "../../../common/catalog/on-context-menu-open.injectable"; interface Dependencies { - catalogPreviousActiveTabStorage: { set: (value: string ) => void; get: () => string }; + catalogPreviousActiveTabStorage: StorageLayer; catalogEntityStore: CatalogEntityStore; getCategoryColumns: (params: GetCategoryColumnsParams) => CategoryColumns; customCategoryViews: IComputedValue>>; diff --git a/src/renderer/components/avatar/avatar.tsx b/src/renderer/components/avatar/avatar.tsx index c6c35eed22..a3b9837295 100644 --- a/src/renderer/components/avatar/avatar.tsx +++ b/src/renderer/components/avatar/avatar.tsx @@ -25,6 +25,7 @@ export interface AvatarProps { className?: string; id?: string; onClick?: MouseEventHandler; + "data-testid"?: string; } function getNameParts(name: string): string[] { @@ -61,40 +62,48 @@ function getLabelFromTitle(title: string) { ].filter(isDefined).join(""); } -export function Avatar(props: AvatarProps) { - const { title, variant = "rounded", size = 32, colorHash, children, background, imgProps, src, className, disabled, id, onClick } = props; - const colorFromHash = randomColor({ seed: colorHash, luminosity: "dark" }); - - const renderContents = () => { - if (src) { - return ( +export const Avatar = ({ + title, + variant = "rounded", + size = 32, + colorHash, + children, + background, + imgProps, + src, + className, + disabled, + id, + onClick, + "data-testid": dataTestId, +}: AvatarProps) => ( +
+ {src + ? ( {title} - ); - } - - return children || getLabelFromTitle(title); - }; - - return ( -
- {renderContents()} -
- ); -} + ) + : children || getLabelFromTitle(title)} +
+);