mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-11 00:08:30 +01:00
fix: show popover on empty state (#5611)
This commit is contained in:
parent
43c563af57
commit
850b78a699
@ -5,7 +5,7 @@ import { FilterDateItem, IFilterDateItemProps } from './FilterDateItem';
|
|||||||
|
|
||||||
const getDate = (option: string) => screen.getByText(option);
|
const getDate = (option: string) => screen.getByText(option);
|
||||||
|
|
||||||
const setup = (initialState: FilterItemParams) => {
|
const setup = (initialState: FilterItemParams | null) => {
|
||||||
const recordedChanges: FilterItemParams[] = [];
|
const recordedChanges: FilterItemParams[] = [];
|
||||||
const mockProps: IFilterDateItemProps = {
|
const mockProps: IFilterDateItemProps = {
|
||||||
label: 'Test Label',
|
label: 'Test Label',
|
||||||
@ -51,6 +51,14 @@ describe('FilterDateItem Component', () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('renders initial popover when no existing value', async () => {
|
||||||
|
const mockState = null;
|
||||||
|
|
||||||
|
const recordedChanges = setup(mockState);
|
||||||
|
|
||||||
|
await screen.findByText('21');
|
||||||
|
});
|
||||||
|
|
||||||
it('switches operator', async () => {
|
it('switches operator', async () => {
|
||||||
const mockState = {
|
const mockState = {
|
||||||
operator: 'IS_ON_OR_AFTER',
|
operator: 'IS_ON_OR_AFTER',
|
||||||
|
@ -33,7 +33,9 @@ export const FilterDateItem: FC<IFilterDateItemProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
open();
|
if (!state) {
|
||||||
|
open();
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onClose = () => {
|
const onClose = () => {
|
||||||
|
@ -5,7 +5,7 @@ import { FilterItem, FilterItemParams, IFilterItemProps } from './FilterItem';
|
|||||||
const getOption = (option: string) =>
|
const getOption = (option: string) =>
|
||||||
screen.getByText(option).closest('li')!.querySelector('input')!;
|
screen.getByText(option).closest('li')!.querySelector('input')!;
|
||||||
|
|
||||||
const setup = (initialState: FilterItemParams) => {
|
const setup = (initialState: FilterItemParams | null) => {
|
||||||
const recordedChanges: FilterItemParams[] = [];
|
const recordedChanges: FilterItemParams[] = [];
|
||||||
const mockProps: IFilterItemProps = {
|
const mockProps: IFilterItemProps = {
|
||||||
label: 'Test Label',
|
label: 'Test Label',
|
||||||
@ -67,6 +67,14 @@ describe('FilterItem Component', () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('renders initial popover when no existing value', async () => {
|
||||||
|
const mockState = null;
|
||||||
|
|
||||||
|
const recordedChanges = setup(mockState);
|
||||||
|
|
||||||
|
await screen.findByPlaceholderText('Search');
|
||||||
|
});
|
||||||
|
|
||||||
it('renders explicit and extra options', async () => {
|
it('renders explicit and extra options', async () => {
|
||||||
const mockState = {
|
const mockState = {
|
||||||
operator: 'IS_ANY_OF',
|
operator: 'IS_ANY_OF',
|
||||||
|
@ -46,7 +46,9 @@ export const FilterItem: FC<IFilterItemProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
open();
|
if (!state) {
|
||||||
|
open();
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onClose = () => {
|
const onClose = () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user