mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Add cluster modals registrator Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Add ClusterModal components and injection token Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Add clusterModals tests Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Update snapshots and use css modules Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Linter fixes Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Setting 0 height as an inline style Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Update snapshots Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Do not export clusterModalsInjectionToken to extensions Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Testing changing visibility flag Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Linter fix Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Refactor cluster modals registrator and injectable Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Linter fixes Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Harder linter fix Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Fix linter again Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Using clusterFrameChildComponentsInjectionToken for specific extension elements Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Removing unused files Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Removing unused modal registration Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Improving tests Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Fix linting Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Update snapshots Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Rename test suite for consistency Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>
79 lines
2.5 KiB
TypeScript
79 lines
2.5 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import type { RenderResult } from "@testing-library/react";
|
|
import { act } from "@testing-library/react";
|
|
import type { IObservableValue } from "mobx";
|
|
import { computed, observable, runInAction } from "mobx";
|
|
import React from "react";
|
|
import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
|
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
|
|
|
describe("legacy extension adding cluster frame components", () => {
|
|
let builder: ApplicationBuilder;
|
|
let rendered: RenderResult;
|
|
|
|
beforeEach(() => {
|
|
builder = getApplicationBuilder();
|
|
builder.setEnvironmentToClusterFrame();
|
|
});
|
|
|
|
describe("given custom components for cluster view available", () => {
|
|
let someObservable: IObservableValue<boolean>;
|
|
|
|
beforeEach(async () => {
|
|
someObservable = observable.box(false);
|
|
|
|
const testExtension = {
|
|
id: "some-extension-id",
|
|
name: "some-extension-name",
|
|
|
|
rendererOptions: {
|
|
clusterFrameComponents: [
|
|
{
|
|
id: "test-modal-id",
|
|
Component: () => <div data-testid="test-modal">test modal</div>,
|
|
shouldRender: computed(() => true),
|
|
},
|
|
{
|
|
id: "dialog-with-observable-visibility-id",
|
|
Component: () => <div data-testid="dialog-with-observable-visibility">dialog contents</div>,
|
|
shouldRender: computed(() => someObservable.get()),
|
|
},
|
|
],
|
|
},
|
|
};
|
|
|
|
rendered = await builder.render();
|
|
builder.extensions.enable(testExtension);
|
|
});
|
|
|
|
it("renders", () => {
|
|
expect(rendered.container).toMatchSnapshot();
|
|
});
|
|
|
|
it("renders provided component html", () => {
|
|
const modal = rendered.getByTestId("test-modal");
|
|
|
|
expect(modal).toBeInTheDocument();
|
|
});
|
|
|
|
it("doesn't render component which should be invisible", () => {
|
|
const dialog = rendered.queryByTestId("dialog-with-observable-visibility");
|
|
|
|
expect(dialog).not.toBeInTheDocument();
|
|
});
|
|
|
|
it("when injectable component becomes visible, shows it", () => {
|
|
runInAction(() => {
|
|
act(() => someObservable.set(true));
|
|
});
|
|
|
|
const dialog = rendered.getByTestId("dialog-with-observable-visibility");
|
|
|
|
expect(dialog).toBeInTheDocument();
|
|
});
|
|
});
|
|
});
|