mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Switch to using newer tool for a job
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
7d7ae86245
commit
ba5d76a49f
@ -16,10 +16,9 @@ import readJsonFileInjectable from "../../common/fs/read-json-file.injectable";
|
|||||||
import type { DiContainer } from "@ogre-tools/injectable";
|
import type { DiContainer } from "@ogre-tools/injectable";
|
||||||
import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token";
|
import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token";
|
||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
import type { FakeExtensionData } from "../../renderer/components/test-utils/get-renderer-extension-fake";
|
|
||||||
import { getRendererExtensionFakeFor } from "../../renderer/components/test-utils/get-renderer-extension-fake";
|
|
||||||
import hostedClusterIdInjectable from "../../renderer/cluster-frame-context/hosted-cluster-id.injectable";
|
import hostedClusterIdInjectable from "../../renderer/cluster-frame-context/hosted-cluster-id.injectable";
|
||||||
import { advanceFakeTime, useFakeTime } from "../../common/test-utils/use-fake-time";
|
import { advanceFakeTime, useFakeTime } from "../../common/test-utils/use-fake-time";
|
||||||
|
import { getExtensionFakeFor } from "../../renderer/components/test-utils/get-extension-fake";
|
||||||
|
|
||||||
// TODO: Make tooltips free of side effects by making it deterministic
|
// TODO: Make tooltips free of side effects by making it deterministic
|
||||||
jest.mock("../../renderer/components/tooltip/withTooltip", () => ({
|
jest.mock("../../renderer/components/tooltip/withTooltip", () => ({
|
||||||
@ -51,10 +50,75 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
|
|||||||
|
|
||||||
describe("given extension with cluster pages and cluster page menus", () => {
|
describe("given extension with cluster pages and cluster page menus", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
|
const getExtensionFake = getExtensionFakeFor(applicationBuilder);
|
||||||
const testExtension = getRendererExtensionFake(extensionStubWithSidebarItems);
|
|
||||||
|
|
||||||
applicationBuilder.extensions.renderer.enable(testExtension);
|
const testExtension = getExtensionFake({
|
||||||
|
id: "some-extension-id",
|
||||||
|
name: "some-extension-name",
|
||||||
|
|
||||||
|
rendererOptions: {
|
||||||
|
clusterPages: [
|
||||||
|
{
|
||||||
|
components: {
|
||||||
|
Page: () => {
|
||||||
|
throw new Error("should never come here");
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "some-child-page-id",
|
||||||
|
|
||||||
|
components: {
|
||||||
|
Page: () => <div data-testid="some-child-page">Some child page</div>,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "some-other-child-page-id",
|
||||||
|
|
||||||
|
components: {
|
||||||
|
Page: () => (
|
||||||
|
<div data-testid="some-other-child-page">Some other child page</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
clusterPageMenus: [
|
||||||
|
{
|
||||||
|
id: "some-parent-id",
|
||||||
|
title: "Parent",
|
||||||
|
|
||||||
|
components: {
|
||||||
|
Icon: () => <div>Some icon</div>,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
id: "some-child-id",
|
||||||
|
target: { pageId: "some-child-page-id" },
|
||||||
|
parentId: "some-parent-id",
|
||||||
|
title: "Child 1",
|
||||||
|
|
||||||
|
components: {
|
||||||
|
Icon: null as never,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
id: "some-other-child-id",
|
||||||
|
target: { pageId: "some-other-child-page-id" },
|
||||||
|
parentId: "some-parent-id",
|
||||||
|
title: "Child 2",
|
||||||
|
|
||||||
|
components: {
|
||||||
|
Icon: null as never,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
applicationBuilder.extensions.enable(testExtension);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("given no state for expanded sidebar items exists, and navigated to child sidebar item, when rendered", () => {
|
describe("given no state for expanded sidebar items exists, and navigated to child sidebar item, when rendered", () => {
|
||||||
@ -355,65 +419,3 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const extensionStubWithSidebarItems: FakeExtensionData = {
|
|
||||||
id: "some-extension-id",
|
|
||||||
name: "some-extension-name",
|
|
||||||
clusterPages: [
|
|
||||||
{
|
|
||||||
components: {
|
|
||||||
Page: () => {
|
|
||||||
throw new Error("should never come here");
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "some-child-page-id",
|
|
||||||
|
|
||||||
components: {
|
|
||||||
Page: () => <div data-testid="some-child-page">Some child page</div>,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "some-other-child-page-id",
|
|
||||||
|
|
||||||
components: {
|
|
||||||
Page: () => (
|
|
||||||
<div data-testid="some-other-child-page">Some other child page</div>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
clusterPageMenus: [
|
|
||||||
{
|
|
||||||
id: "some-parent-id",
|
|
||||||
title: "Parent",
|
|
||||||
|
|
||||||
components: {
|
|
||||||
Icon: () => <div>Some icon</div>,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id: "some-child-id",
|
|
||||||
target: { pageId: "some-child-page-id" },
|
|
||||||
parentId: "some-parent-id",
|
|
||||||
title: "Child 1",
|
|
||||||
|
|
||||||
components: {
|
|
||||||
Icon: null as never,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id: "some-other-child-id",
|
|
||||||
target: { pageId: "some-other-child-page-id" },
|
|
||||||
parentId: "some-parent-id",
|
|
||||||
title: "Child 2",
|
|
||||||
|
|
||||||
components: {
|
|
||||||
Icon: null as never,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|||||||
@ -20,12 +20,17 @@ import type { DiContainer } from "@ogre-tools/injectable";
|
|||||||
export class TestExtensionMain extends LensMainExtension {}
|
export class TestExtensionMain extends LensMainExtension {}
|
||||||
export class TestExtensionRenderer extends LensRendererExtension {}
|
export class TestExtensionRenderer extends LensRendererExtension {}
|
||||||
|
|
||||||
export type GetExtensionFake = (arg: {
|
export interface FakeExtensionOptions {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
rendererOptions?: Partial<LensRendererExtension>;
|
rendererOptions?: Partial<LensRendererExtension>;
|
||||||
mainOptions?: Partial<LensMainExtension>;
|
mainOptions?: Partial<LensMainExtension>;
|
||||||
}) => { main: TestExtensionMain; renderer: TestExtensionRenderer };
|
}
|
||||||
|
|
||||||
|
export type GetExtensionFake = (arg: FakeExtensionOptions) => {
|
||||||
|
main: TestExtensionMain;
|
||||||
|
renderer: TestExtensionRenderer;
|
||||||
|
};
|
||||||
|
|
||||||
export const getExtensionFakeFor =
|
export const getExtensionFakeFor =
|
||||||
(builder: ApplicationBuilder): GetExtensionFake =>
|
(builder: ApplicationBuilder): GetExtensionFake =>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user