mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
- Has better typing
- Removes use of unnusual unique symbol
- Fix welcome banner tests
- Update associated snapshots
- Start converting custom column tests to use ApplicationBuilder
- Remove old and unnused RecursiveTreeView
- Introduce new TreeView for use in CatalogMenu to fix tests
Signed-off-by: Sebastian Malton <sebastian@malton.name>
92 lines
2.9 KiB
TypeScript
92 lines
2.9 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
|
|
import React from "react";
|
|
import type { RenderResult } from "@testing-library/react";
|
|
import { screen } from "@testing-library/react";
|
|
import { defaultWidth } from "../../renderer/components/+welcome/welcome";
|
|
import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
|
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
|
|
|
describe("Banners from extensions", () => {
|
|
let builder: ApplicationBuilder;
|
|
let renderResult: RenderResult;
|
|
|
|
beforeEach(async () => {
|
|
builder = getApplicationBuilder();
|
|
renderResult = await builder.render();
|
|
});
|
|
|
|
it("initially renderes welcome page", () => {
|
|
expect(renderResult.queryByTestId("welcome-page")).toBeInTheDocument();
|
|
});
|
|
|
|
it("shows the empty welcome banner icon", () => {
|
|
expect(renderResult.queryByTestId("no-welcome-banners-icon")).toBeInTheDocument();
|
|
});
|
|
|
|
describe("when an extension is enabled with a single welcome banner", () => {
|
|
beforeEach(() => {
|
|
builder.extensions.enable({
|
|
id: "some-id",
|
|
name: "some-name",
|
|
rendererOptions: {
|
|
welcomeBanners: [
|
|
{
|
|
Banner: () => <div data-testid="some-test-id" />,
|
|
},
|
|
],
|
|
},
|
|
});
|
|
});
|
|
|
|
it("renders the banner from the extension", () => {
|
|
expect(renderResult.queryByTestId("some-test-id")).toBeInTheDocument();
|
|
});
|
|
|
|
it("no longer shows the empty welcome banner icon", () => {
|
|
expect(renderResult.queryByTestId("no-welcome-banners-icon")).not.toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
describe("when an extension is enabled with multiple banners with custom widths", () => {
|
|
beforeEach(() => {
|
|
builder.extensions.enable({
|
|
id: "some-id",
|
|
name: "some-name",
|
|
rendererOptions: {
|
|
welcomeBanners: [
|
|
{
|
|
width: 100,
|
|
Banner: () => <div />,
|
|
},
|
|
{
|
|
width: 800,
|
|
Banner: () => <div />,
|
|
},
|
|
],
|
|
},
|
|
});
|
|
});
|
|
|
|
it("no longer shows the empty welcome banner icon", () => {
|
|
expect(renderResult.queryByTestId("no-welcome-banners-icon")).not.toBeInTheDocument();
|
|
});
|
|
|
|
it("computes an opropriate width for the carosel", () => {
|
|
expect(screen.queryByTestId("welcome-banner-container")).toHaveStyle({
|
|
// should take the max width of the banners (if > defaultWidth)
|
|
width: `800px`,
|
|
});
|
|
expect(screen.queryByTestId("welcome-text-container")).toHaveStyle({
|
|
width: `${defaultWidth}px`,
|
|
});
|
|
expect(screen.queryByTestId("welcome-menu-container")).toHaveStyle({
|
|
width: `${defaultWidth}px`,
|
|
});
|
|
});
|
|
});
|
|
});
|