mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Introduce helper for opening and selecting values of select
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
e213e2d314
commit
7a83cd0329
@ -233,7 +233,9 @@ class NonInjectedSelect<
|
||||
Menu: ({ className, ...props }) => (
|
||||
<WrappedMenu
|
||||
{...props}
|
||||
className={cssNames(menuClass, this.themeClass, className)}
|
||||
className={cssNames(menuClass, this.themeClass, className, {
|
||||
[`${inputId}-options`]: !!inputId,
|
||||
})}
|
||||
/>
|
||||
),
|
||||
}}
|
||||
|
||||
@ -15,7 +15,7 @@ import { Observer } from "mobx-react";
|
||||
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
||||
import allowedResourcesInjectable from "../../../common/cluster-store/allowed-resources.injectable";
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import { fireEvent } from "@testing-library/react";
|
||||
import { getByText, fireEvent } from "@testing-library/react";
|
||||
import type { KubeResource } from "../../../common/rbac";
|
||||
import { Sidebar } from "../layout/sidebar";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
@ -52,6 +52,9 @@ import { getDiForUnitTesting as getMainDi } from "../../../main/getDiForUnitTest
|
||||
import { overrideChannels } from "../../../test-utils/channel-fakes/override-channels";
|
||||
import type { TrayMenuItem } from "../../../main/tray/tray-menu-item/tray-menu-item-injection-token";
|
||||
import trayIconPathsInjectable from "../../../main/tray/tray-icon-path.injectable";
|
||||
import assert from "assert";
|
||||
import { openMenu } from "react-select-event";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
|
||||
type Callback = (dis: DiContainers) => void | Promise<void>;
|
||||
|
||||
@ -85,6 +88,11 @@ export interface ApplicationBuilder {
|
||||
helmCharts: {
|
||||
navigate: () => void;
|
||||
};
|
||||
|
||||
select: {
|
||||
openMenu: (id: string) => void;
|
||||
selectOption: (menuId: string, labelText: string) => void;
|
||||
};
|
||||
}
|
||||
|
||||
interface DiContainers {
|
||||
@ -433,6 +441,30 @@ export const getApplicationBuilder = () => {
|
||||
|
||||
return rendered;
|
||||
},
|
||||
|
||||
select: {
|
||||
openMenu: (menuId) => {
|
||||
const selector = rendered.container.querySelector<HTMLElement>(
|
||||
`#${menuId}`,
|
||||
);
|
||||
|
||||
assert(selector);
|
||||
|
||||
openMenu(selector);
|
||||
},
|
||||
|
||||
selectOption: (menuId, labelText) => {
|
||||
const menuOptions = rendered.baseElement.querySelector<HTMLElement>(
|
||||
`.${menuId}-options`,
|
||||
);
|
||||
|
||||
assert(menuOptions);
|
||||
|
||||
const option = getByText(menuOptions, labelText);
|
||||
|
||||
userEvent.click(option);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return builder;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user