chore(fe): replace deprecate aliased Jest matchers with corresponding substituents (#30355)
Signed-off-by: hainenber <dotronghai96@gmail.com> Co-authored-by: Evan Rusackas <evan@preset.io>
This commit is contained in:
parent
f2a9f31135
commit
576ad85eb4
|
|
@ -280,7 +280,6 @@ module.exports = {
|
|||
'theme-colors/no-literal-colors': 0,
|
||||
'translation-vars/no-template-vars': 0,
|
||||
'no-restricted-imports': 0,
|
||||
'jest/no-alias-methods': 0,
|
||||
'react/no-void-elements': 0,
|
||||
},
|
||||
},
|
||||
|
|
@ -371,7 +370,6 @@ module.exports = {
|
|||
'react-prefer-function-component/react-prefer-function-component': 1,
|
||||
'prettier/prettier': 'error',
|
||||
// disabling some things that come with the eslint 7->8 upgrade. Will address these in a separate PR
|
||||
'jest/no-alias-methods': 0,
|
||||
'react/no-unknown-property': 0,
|
||||
'react/no-void-elements': 0,
|
||||
'react/function-component-definition': [
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ test('call callback the first time with undefined and value', () => {
|
|||
renderHook(props => useChangeEffect(props.value, props.callback), {
|
||||
initialProps: { value: 'value', callback },
|
||||
});
|
||||
expect(callback).toBeCalledTimes(1);
|
||||
expect(callback).nthCalledWith(1, undefined, 'value');
|
||||
expect(callback).toHaveBeenCalledTimes(1);
|
||||
expect(callback).toHaveBeenNthCalledWith(1, undefined, 'value');
|
||||
});
|
||||
|
||||
test('do not call callback 2 times if the value do not change', () => {
|
||||
|
|
@ -37,7 +37,7 @@ test('do not call callback 2 times if the value do not change', () => {
|
|||
},
|
||||
);
|
||||
hook.rerender({ value: 'value', callback });
|
||||
expect(callback).toBeCalledTimes(1);
|
||||
expect(callback).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('call callback whenever the value changes', () => {
|
||||
|
|
@ -49,6 +49,6 @@ test('call callback whenever the value changes', () => {
|
|||
},
|
||||
);
|
||||
hook.rerender({ value: 'value-2', callback });
|
||||
expect(callback).toBeCalledTimes(2);
|
||||
expect(callback).nthCalledWith(2, 'value', 'value-2');
|
||||
expect(callback).toHaveBeenCalledTimes(2);
|
||||
expect(callback).toHaveBeenNthCalledWith(2, 'value', 'value-2');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import { useComponentDidMount } from './useComponentDidMount';
|
|||
test('the effect should only be executed on the first render', () => {
|
||||
const effect = jest.fn();
|
||||
const hook = renderHook(() => useComponentDidMount(effect));
|
||||
expect(effect).toBeCalledTimes(1);
|
||||
expect(effect).toHaveBeenCalledTimes(1);
|
||||
hook.rerender();
|
||||
expect(effect).toBeCalledTimes(1);
|
||||
expect(effect).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ test('the effect should not be executed on the first render', () => {
|
|||
const hook = renderHook(props => useComponentDidUpdate(props.effect), {
|
||||
initialProps: { effect },
|
||||
});
|
||||
expect(effect).toBeCalledTimes(0);
|
||||
expect(effect).toHaveBeenCalledTimes(0);
|
||||
const changedEffect = jest.fn();
|
||||
hook.rerender({ effect: changedEffect });
|
||||
expect(changedEffect).toBeCalledTimes(1);
|
||||
expect(changedEffect).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ describe('LabelsColorMap', () => {
|
|||
labelsColorMap.updateColorMap(categoricalNamespace, 'testColors');
|
||||
const colorMap = labelsColorMap.getColorMap();
|
||||
expect(Object.fromEntries(colorMap)).not.toEqual({});
|
||||
expect(getAnalogousColorsSpy).not.toBeCalled();
|
||||
expect(getAnalogousColorsSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should use analagous colors', () => {
|
||||
|
|
@ -207,7 +207,7 @@ describe('LabelsColorMap', () => {
|
|||
labelsColorMap.updateColorMap(categoricalNamespace, 'testColors');
|
||||
const colorMap = labelsColorMap.getColorMap();
|
||||
expect(Object.fromEntries(colorMap)).not.toEqual({});
|
||||
expect(getAnalogousColorsSpy).toBeCalled();
|
||||
expect(getAnalogousColorsSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -396,31 +396,31 @@ describe('Registry', () => {
|
|||
|
||||
it('calls the listener when a value is registered', () => {
|
||||
registry.registerValue('foo', 'bar');
|
||||
expect(listener).toBeCalledWith(['foo']);
|
||||
expect(listener).toHaveBeenCalledWith(['foo']);
|
||||
});
|
||||
|
||||
it('calls the listener when a loader is registered', () => {
|
||||
registry.registerLoader('foo', () => 'bar');
|
||||
expect(listener).toBeCalledWith(['foo']);
|
||||
expect(listener).toHaveBeenCalledWith(['foo']);
|
||||
});
|
||||
|
||||
it('calls the listener when a value is overridden', () => {
|
||||
registry.registerValue('foo', 'bar');
|
||||
listener.mockClear();
|
||||
registry.registerValue('foo', 'baz');
|
||||
expect(listener).toBeCalledWith(['foo']);
|
||||
expect(listener).toHaveBeenCalledWith(['foo']);
|
||||
});
|
||||
|
||||
it('calls the listener when a value is removed', () => {
|
||||
registry.registerValue('foo', 'bar');
|
||||
listener.mockClear();
|
||||
registry.remove('foo');
|
||||
expect(listener).toBeCalledWith(['foo']);
|
||||
expect(listener).toHaveBeenCalledWith(['foo']);
|
||||
});
|
||||
|
||||
it('does not call the listener when a value is not actually removed', () => {
|
||||
registry.remove('foo');
|
||||
expect(listener).not.toBeCalled();
|
||||
expect(listener).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('calls the listener when registry is cleared', () => {
|
||||
|
|
@ -428,13 +428,13 @@ describe('Registry', () => {
|
|||
registry.registerLoader('fluz', () => 'baz');
|
||||
listener.mockClear();
|
||||
registry.clear();
|
||||
expect(listener).toBeCalledWith(['foo', 'fluz']);
|
||||
expect(listener).toHaveBeenCalledWith(['foo', 'fluz']);
|
||||
});
|
||||
|
||||
it('removes listeners correctly', () => {
|
||||
registry.removeListener(listener);
|
||||
registry.registerValue('foo', 'bar');
|
||||
expect(listener).not.toBeCalled();
|
||||
expect(listener).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe('with a broken listener', () => {
|
||||
|
|
@ -456,10 +456,10 @@ describe('Registry', () => {
|
|||
registry.addListener(lastListener);
|
||||
registry.registerValue('foo', 'bar');
|
||||
|
||||
expect(listener).toBeCalledWith(['foo']);
|
||||
expect(errorListener).toBeCalledWith(['foo']);
|
||||
expect(lastListener).toBeCalledWith(['foo']);
|
||||
expect(console.error).toBeCalled();
|
||||
expect(listener).toHaveBeenCalledWith(['foo']);
|
||||
expect(errorListener).toHaveBeenCalledWith(['foo']);
|
||||
expect(lastListener).toHaveBeenCalledWith(['foo']);
|
||||
expect(console.error).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ describe('buildQueryContext', () => {
|
|||
},
|
||||
() => [{}],
|
||||
);
|
||||
expect(spyNormalizeTimeColumn).toBeCalled();
|
||||
expect(spyNormalizeTimeColumn).toHaveBeenCalled();
|
||||
spyNormalizeTimeColumn.mockRestore();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ describe('TranslatorSingleton', () => {
|
|||
expect(t('second')).toEqual('second');
|
||||
resetTranslation();
|
||||
expect(t('second')).toEqual('second');
|
||||
expect(console.warn).toBeCalledTimes(2);
|
||||
expect(console.warn).toHaveBeenCalledTimes(2);
|
||||
restoreConsole();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ describe('comms', () => {
|
|||
});
|
||||
port2.start();
|
||||
|
||||
await expect(ours.get('someMethod')).rejects.toThrowError(
|
||||
await expect(ours.get('someMethod')).rejects.toThrow(
|
||||
'Unexpected response message',
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ describe('ShareSqlLabQuery', () => {
|
|||
const storeQuerySpy = jest.spyOn(utils, 'storeQuery');
|
||||
userEvent.click(button);
|
||||
expect(storeQuerySpy.mock.calls).toHaveLength(1);
|
||||
expect(storeQuerySpy).toBeCalledWith(expected);
|
||||
expect(storeQuerySpy).toHaveBeenCalledWith(expected);
|
||||
storeQuerySpy.mockRestore();
|
||||
});
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ describe('ShareSqlLabQuery', () => {
|
|||
const storeQuerySpy = jest.spyOn(utils, 'storeQuery');
|
||||
userEvent.click(button);
|
||||
expect(storeQuerySpy.mock.calls).toHaveLength(1);
|
||||
expect(storeQuerySpy).toBeCalledWith(expected);
|
||||
expect(storeQuerySpy).toHaveBeenCalledWith(expected);
|
||||
storeQuerySpy.mockRestore();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ test('Should send correct props to ReactCronPicker', () => {
|
|||
myCustomProp: 'myCustomProp',
|
||||
};
|
||||
render(<CronPicker {...(props as any)} />);
|
||||
expect(spy).toBeCalledWith(
|
||||
expect(spy).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
className: expect.any(String),
|
||||
locale: expect.anything(),
|
||||
|
|
|
|||
|
|
@ -219,9 +219,9 @@ test('Refresh should work', async () => {
|
|||
await waitFor(() => {
|
||||
expect(fetchMock.calls(databaseApiRoute).length).toBe(1);
|
||||
expect(fetchMock.calls(schemaApiRoute).length).toBe(1);
|
||||
expect(props.handleError).toBeCalledTimes(0);
|
||||
expect(props.onDbChange).toBeCalledTimes(0);
|
||||
expect(props.onSchemaChange).toBeCalledTimes(0);
|
||||
expect(props.handleError).toHaveBeenCalledTimes(0);
|
||||
expect(props.onDbChange).toHaveBeenCalledTimes(0);
|
||||
expect(props.onSchemaChange).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
// click schema reload
|
||||
|
|
@ -230,9 +230,9 @@ test('Refresh should work', async () => {
|
|||
await waitFor(() => {
|
||||
expect(fetchMock.calls(databaseApiRoute).length).toBe(1);
|
||||
expect(fetchMock.calls(schemaApiRoute).length).toBe(2);
|
||||
expect(props.handleError).toBeCalledTimes(0);
|
||||
expect(props.onDbChange).toBeCalledTimes(0);
|
||||
expect(props.onSchemaChange).toBeCalledTimes(0);
|
||||
expect(props.handleError).toHaveBeenCalledTimes(0);
|
||||
expect(props.onDbChange).toHaveBeenCalledTimes(0);
|
||||
expect(props.onSchemaChange).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ test('Calling "onHide"', () => {
|
|||
};
|
||||
const modal = <DeleteModal {...props} />;
|
||||
render(modal);
|
||||
expect(props.onHide).toBeCalledTimes(0);
|
||||
expect(props.onConfirm).toBeCalledTimes(0);
|
||||
expect(props.onHide).toHaveBeenCalledTimes(0);
|
||||
expect(props.onConfirm).toHaveBeenCalledTimes(0);
|
||||
|
||||
// type "del" in the input
|
||||
userEvent.type(screen.getByTestId('delete-modal-input'), 'del');
|
||||
|
|
@ -55,8 +55,8 @@ test('Calling "onHide"', () => {
|
|||
// close the modal
|
||||
expect(screen.getByText('×')).toBeVisible();
|
||||
userEvent.click(screen.getByText('×'));
|
||||
expect(props.onHide).toBeCalledTimes(1);
|
||||
expect(props.onConfirm).toBeCalledTimes(0);
|
||||
expect(props.onHide).toHaveBeenCalledTimes(1);
|
||||
expect(props.onConfirm).toHaveBeenCalledTimes(0);
|
||||
|
||||
// confirm input has been cleared
|
||||
expect(screen.getByTestId('delete-modal-input')).toHaveValue('');
|
||||
|
|
@ -71,19 +71,19 @@ test('Calling "onConfirm" only after typing "delete" in the input', () => {
|
|||
open: true,
|
||||
};
|
||||
render(<DeleteModal {...props} />);
|
||||
expect(props.onHide).toBeCalledTimes(0);
|
||||
expect(props.onConfirm).toBeCalledTimes(0);
|
||||
expect(props.onHide).toHaveBeenCalledTimes(0);
|
||||
expect(props.onConfirm).toHaveBeenCalledTimes(0);
|
||||
expect(screen.getByTestId('delete-modal-input')).toBeVisible();
|
||||
expect(props.onConfirm).toBeCalledTimes(0);
|
||||
expect(props.onConfirm).toHaveBeenCalledTimes(0);
|
||||
|
||||
// do not execute "onConfirm" if you have not typed "delete"
|
||||
userEvent.click(screen.getByText('Delete'));
|
||||
expect(props.onConfirm).toBeCalledTimes(0);
|
||||
expect(props.onConfirm).toHaveBeenCalledTimes(0);
|
||||
|
||||
// execute "onConfirm" if you have typed "delete"
|
||||
userEvent.type(screen.getByTestId('delete-modal-input'), 'delete');
|
||||
userEvent.click(screen.getByText('Delete'));
|
||||
expect(props.onConfirm).toBeCalledTimes(1);
|
||||
expect(props.onConfirm).toHaveBeenCalledTimes(1);
|
||||
|
||||
// confirm input has been cleared
|
||||
expect(screen.getByTestId('delete-modal-input')).toHaveValue('');
|
||||
|
|
|
|||
|
|
@ -37,20 +37,20 @@ test('render right content', async () => {
|
|||
screen.getByRole('img', { name: 'favorite-selected' }),
|
||||
).toBeInTheDocument();
|
||||
|
||||
expect(props.saveFaveStar).toBeCalledTimes(0);
|
||||
expect(props.saveFaveStar).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button'));
|
||||
expect(props.saveFaveStar).toBeCalledTimes(1);
|
||||
expect(props.saveFaveStar).toBeCalledWith(props.itemId, true);
|
||||
expect(props.saveFaveStar).toHaveBeenCalledTimes(1);
|
||||
expect(props.saveFaveStar).toHaveBeenCalledWith(props.itemId, true);
|
||||
|
||||
rerender(<FaveStar {...props} />);
|
||||
expect(
|
||||
await findByRole('img', { name: 'favorite-unselected' }),
|
||||
).toBeInTheDocument();
|
||||
|
||||
expect(props.saveFaveStar).toBeCalledTimes(1);
|
||||
expect(props.saveFaveStar).toHaveBeenCalledTimes(1);
|
||||
userEvent.click(screen.getByRole('button'));
|
||||
expect(props.saveFaveStar).toBeCalledTimes(2);
|
||||
expect(props.saveFaveStar).toBeCalledWith(props.itemId, false);
|
||||
expect(props.saveFaveStar).toHaveBeenCalledTimes(2);
|
||||
expect(props.saveFaveStar).toHaveBeenCalledWith(props.itemId, false);
|
||||
});
|
||||
|
||||
test('render content on tooltip', async () => {
|
||||
|
|
@ -87,9 +87,9 @@ test('Call fetchFaveStar on first render and on itemId change', async () => {
|
|||
expect(
|
||||
await findByRole('img', { name: 'favorite-unselected' }),
|
||||
).toBeInTheDocument();
|
||||
expect(props.fetchFaveStar).toBeCalledTimes(1);
|
||||
expect(props.fetchFaveStar).toBeCalledWith(props.itemId);
|
||||
expect(props.fetchFaveStar).toHaveBeenCalledTimes(1);
|
||||
expect(props.fetchFaveStar).toHaveBeenCalledWith(props.itemId);
|
||||
|
||||
rerender(<FaveStar {...{ ...props, itemId: 2 }} />);
|
||||
expect(props.fetchFaveStar).toBeCalledTimes(2);
|
||||
expect(props.fetchFaveStar).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ test('redirects to first page when page index is invalid', async () => {
|
|||
});
|
||||
await waitFor(() => {
|
||||
expect(window.location.search).toEqual('?pageIndex=0');
|
||||
expect(fetchData).toBeCalledTimes(2);
|
||||
expect(fetchData).toHaveBeenCalledTimes(2);
|
||||
expect(fetchData).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ pageIndex: 9 }),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -24,15 +24,15 @@ import { Ellipsis } from './Ellipsis';
|
|||
test('Ellipsis - click when the button is enabled', () => {
|
||||
const click = jest.fn();
|
||||
render(<Ellipsis onClick={click} />);
|
||||
expect(click).toBeCalledTimes(0);
|
||||
expect(click).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button'));
|
||||
expect(click).toBeCalledTimes(1);
|
||||
expect(click).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('Ellipsis - click when the button is disabled', () => {
|
||||
const click = jest.fn();
|
||||
render(<Ellipsis onClick={click} disabled />);
|
||||
expect(click).toBeCalledTimes(0);
|
||||
expect(click).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button'));
|
||||
expect(click).toBeCalledTimes(0);
|
||||
expect(click).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ test('Item - click when the item is not active', () => {
|
|||
<div data-test="test" />
|
||||
</Item>,
|
||||
);
|
||||
expect(click).toBeCalledTimes(0);
|
||||
expect(click).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button'));
|
||||
expect(click).toBeCalledTimes(1);
|
||||
expect(click).toHaveBeenCalledTimes(1);
|
||||
expect(screen.getByTestId('test')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
|
@ -41,8 +41,8 @@ test('Item - click when the item is active', () => {
|
|||
<div data-test="test" />
|
||||
</Item>,
|
||||
);
|
||||
expect(click).toBeCalledTimes(0);
|
||||
expect(click).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button'));
|
||||
expect(click).toBeCalledTimes(0);
|
||||
expect(click).toHaveBeenCalledTimes(0);
|
||||
expect(screen.getByTestId('test')).toBeInTheDocument();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -24,15 +24,15 @@ import { Next } from './Next';
|
|||
test('Next - click when the button is enabled', () => {
|
||||
const click = jest.fn();
|
||||
render(<Next onClick={click} />);
|
||||
expect(click).toBeCalledTimes(0);
|
||||
expect(click).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button'));
|
||||
expect(click).toBeCalledTimes(1);
|
||||
expect(click).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('Next - click when the button is disabled', () => {
|
||||
const click = jest.fn();
|
||||
render(<Next onClick={click} disabled />);
|
||||
expect(click).toBeCalledTimes(0);
|
||||
expect(click).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button'));
|
||||
expect(click).toBeCalledTimes(0);
|
||||
expect(click).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -24,15 +24,15 @@ import { Prev } from './Prev';
|
|||
test('Prev - click when the button is enabled', () => {
|
||||
const click = jest.fn();
|
||||
render(<Prev onClick={click} />);
|
||||
expect(click).toBeCalledTimes(0);
|
||||
expect(click).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button'));
|
||||
expect(click).toBeCalledTimes(1);
|
||||
expect(click).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('Prev - click when the button is disabled', () => {
|
||||
const click = jest.fn();
|
||||
render(<Prev onClick={click} disabled />);
|
||||
expect(click).toBeCalledTimes(0);
|
||||
expect(click).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button'));
|
||||
expect(click).toBeCalledTimes(0);
|
||||
expect(click).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -123,10 +123,10 @@ test('Should render "appliedCrossFilterIndicators"', async () => {
|
|||
screen.getByRole('button', { name: 'Clinical Stage' }),
|
||||
).toBeInTheDocument();
|
||||
|
||||
expect(props.onHighlightFilterSource).toBeCalledTimes(0);
|
||||
expect(props.onHighlightFilterSource).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button', { name: 'Clinical Stage' }));
|
||||
expect(props.onHighlightFilterSource).toBeCalledTimes(1);
|
||||
expect(props.onHighlightFilterSource).toBeCalledWith([
|
||||
expect(props.onHighlightFilterSource).toHaveBeenCalledTimes(1);
|
||||
expect(props.onHighlightFilterSource).toHaveBeenCalledWith([
|
||||
'ROOT_ID',
|
||||
'TABS-wUKya7eQ0Z',
|
||||
'TAB-BCIJF4NvgQ',
|
||||
|
|
@ -153,10 +153,10 @@ test('Should render "appliedIndicators"', async () => {
|
|||
expect(await screen.findByText('Applied filters (1)')).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Country' })).toBeInTheDocument();
|
||||
|
||||
expect(props.onHighlightFilterSource).toBeCalledTimes(0);
|
||||
expect(props.onHighlightFilterSource).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button', { name: 'Country' }));
|
||||
expect(props.onHighlightFilterSource).toBeCalledTimes(1);
|
||||
expect(props.onHighlightFilterSource).toBeCalledWith([
|
||||
expect(props.onHighlightFilterSource).toHaveBeenCalledTimes(1);
|
||||
expect(props.onHighlightFilterSource).toHaveBeenCalledWith([
|
||||
'ROOT_ID',
|
||||
'TABS-wUKya7eQ0Z',
|
||||
'TAB-BCIJF4NvgQ',
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ test('Should call "onClick"', () => {
|
|||
const props = createProps();
|
||||
render(<FilterIndicator {...props} />);
|
||||
|
||||
expect(props.onClick).toBeCalledTimes(0);
|
||||
expect(props.onClick).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button', { name: 'Vaccine Approach' }));
|
||||
expect(props.onClick).toBeCalledTimes(1);
|
||||
expect(props.onClick).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('Should render "value"', () => {
|
||||
|
|
|
|||
|
|
@ -315,10 +315,10 @@ test('should NOT render the fave icon on anonymous user', () => {
|
|||
setup(anonymousUserProps);
|
||||
expect(() =>
|
||||
screen.getByRole('img', { name: 'favorite-unselected' }),
|
||||
).toThrowError('Unable to find');
|
||||
expect(() =>
|
||||
screen.getByRole('img', { name: 'favorite-selected' }),
|
||||
).toThrowError('Unable to find');
|
||||
).toThrow('Unable to find');
|
||||
expect(() => screen.getByRole('img', { name: 'favorite-selected' })).toThrow(
|
||||
'Unable to find',
|
||||
);
|
||||
});
|
||||
|
||||
test('should fave', async () => {
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ describe.skip('PropertiesModal', () => {
|
|||
const spy = jest.spyOn(Modal, 'error');
|
||||
expect(() =>
|
||||
modalInstance.onColorSchemeChange('THIS_WILL_NOT_WORK'),
|
||||
).toThrowError('A valid color scheme is required');
|
||||
).toThrow('A valid color scheme is required');
|
||||
expect(spy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ test('should render - FeatureFlag disabled', async () => {
|
|||
expect(screen.getAllByRole('textbox')).toHaveLength(4);
|
||||
expect(screen.getByRole('combobox')).toBeInTheDocument();
|
||||
|
||||
expect(spyColorSchemeControlWrapper).toBeCalledWith(
|
||||
expect(spyColorSchemeControlWrapper).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ colorScheme: 'supersetColors' }),
|
||||
{},
|
||||
);
|
||||
|
|
@ -222,7 +222,7 @@ test('should render - FeatureFlag enabled', async () => {
|
|||
expect(screen.getAllByRole('textbox')).toHaveLength(4);
|
||||
expect(screen.getAllByRole('combobox')).toHaveLength(3);
|
||||
|
||||
expect(spyColorSchemeControlWrapper).toBeCalledWith(
|
||||
expect(spyColorSchemeControlWrapper).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ colorScheme: 'supersetColors' }),
|
||||
{},
|
||||
);
|
||||
|
|
@ -255,11 +255,11 @@ test('should close modal', async () => {
|
|||
await screen.findByTestId('dashboard-edit-properties-form'),
|
||||
).toBeInTheDocument();
|
||||
|
||||
expect(props.onHide).not.toBeCalled();
|
||||
expect(props.onHide).not.toHaveBeenCalled();
|
||||
userEvent.click(screen.getByRole('button', { name: 'Cancel' }));
|
||||
expect(props.onHide).toBeCalledTimes(1);
|
||||
expect(props.onHide).toHaveBeenCalledTimes(1);
|
||||
userEvent.click(screen.getByRole('button', { name: 'Close' }));
|
||||
expect(props.onHide).toBeCalledTimes(2);
|
||||
expect(props.onHide).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
test('submitting with onlyApply:false', async () => {
|
||||
|
|
@ -293,13 +293,13 @@ test('submitting with onlyApply:false', async () => {
|
|||
await screen.findByTestId('dashboard-edit-properties-form'),
|
||||
).toBeInTheDocument();
|
||||
|
||||
expect(props.onHide).not.toBeCalled();
|
||||
expect(props.onSubmit).not.toBeCalled();
|
||||
expect(props.onHide).not.toHaveBeenCalled();
|
||||
expect(props.onSubmit).not.toHaveBeenCalled();
|
||||
|
||||
userEvent.click(screen.getByRole('button', { name: 'Save' }));
|
||||
await waitFor(() => {
|
||||
expect(props.onSubmit).toBeCalledTimes(1);
|
||||
expect(props.onSubmit).toBeCalledWith({
|
||||
expect(props.onSubmit).toHaveBeenCalledTimes(1);
|
||||
expect(props.onSubmit).toHaveBeenCalledWith({
|
||||
certificationDetails: 'Sample certification',
|
||||
certifiedBy: 'John Doe',
|
||||
colorScheme: 'supersetColors',
|
||||
|
|
@ -332,12 +332,12 @@ test('submitting with onlyApply:true', async () => {
|
|||
await screen.findByTestId('dashboard-edit-properties-form'),
|
||||
).toBeInTheDocument();
|
||||
|
||||
expect(props.onHide).not.toBeCalled();
|
||||
expect(props.onSubmit).not.toBeCalled();
|
||||
expect(props.onHide).not.toHaveBeenCalled();
|
||||
expect(props.onSubmit).not.toHaveBeenCalled();
|
||||
|
||||
userEvent.click(screen.getByRole('button', { name: 'Apply' }));
|
||||
await waitFor(() => {
|
||||
expect(props.onSubmit).toBeCalledTimes(1);
|
||||
expect(props.onSubmit).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -444,33 +444,33 @@ test('Correct actions to "SliceHeaderControls"', () => {
|
|||
const props = createProps();
|
||||
render(<SliceHeader {...props} />, { useRedux: true, useRouter: true });
|
||||
|
||||
expect(props.toggleExpandSlice).toBeCalledTimes(0);
|
||||
expect(props.toggleExpandSlice).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByTestId('toggleExpandSlice'));
|
||||
expect(props.toggleExpandSlice).toBeCalledTimes(1);
|
||||
expect(props.toggleExpandSlice).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(props.forceRefresh).toBeCalledTimes(0);
|
||||
expect(props.forceRefresh).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByTestId('forceRefresh'));
|
||||
expect(props.forceRefresh).toBeCalledTimes(1);
|
||||
expect(props.forceRefresh).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(props.logExploreChart).toBeCalledTimes(0);
|
||||
expect(props.logExploreChart).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByTestId('exploreChart'));
|
||||
expect(props.logExploreChart).toBeCalledTimes(1);
|
||||
expect(props.logExploreChart).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(props.exportCSV).toBeCalledTimes(0);
|
||||
expect(props.exportCSV).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByTestId('exportCSV'));
|
||||
expect(props.exportCSV).toBeCalledTimes(1);
|
||||
expect(props.exportCSV).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(props.addSuccessToast).toBeCalledTimes(0);
|
||||
expect(props.addSuccessToast).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByTestId('addSuccessToast'));
|
||||
expect(props.addSuccessToast).toBeCalledTimes(1);
|
||||
expect(props.addSuccessToast).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(props.addDangerToast).toBeCalledTimes(0);
|
||||
expect(props.addDangerToast).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByTestId('addDangerToast'));
|
||||
expect(props.addDangerToast).toBeCalledTimes(1);
|
||||
expect(props.addDangerToast).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(props.handleToggleFullSize).toBeCalledTimes(0);
|
||||
expect(props.handleToggleFullSize).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByTestId('handleToggleFullSize'));
|
||||
expect(props.handleToggleFullSize).toBeCalledTimes(1);
|
||||
expect(props.handleToggleFullSize).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('Add extension to SliceHeader', () => {
|
||||
|
|
|
|||
|
|
@ -180,21 +180,21 @@ test('Should render default props', () => {
|
|||
test('Should "export to CSV"', async () => {
|
||||
const props = createProps();
|
||||
renderWrapper(props);
|
||||
expect(props.exportCSV).toBeCalledTimes(0);
|
||||
expect(props.exportCSV).toHaveBeenCalledTimes(0);
|
||||
userEvent.hover(screen.getByText('Download'));
|
||||
userEvent.click(await screen.findByText('Export to .CSV'));
|
||||
expect(props.exportCSV).toBeCalledTimes(1);
|
||||
expect(props.exportCSV).toBeCalledWith(371);
|
||||
expect(props.exportCSV).toHaveBeenCalledTimes(1);
|
||||
expect(props.exportCSV).toHaveBeenCalledWith(371);
|
||||
});
|
||||
|
||||
test('Should "export to Excel"', async () => {
|
||||
const props = createProps();
|
||||
renderWrapper(props);
|
||||
expect(props.exportXLSX).toBeCalledTimes(0);
|
||||
expect(props.exportXLSX).toHaveBeenCalledTimes(0);
|
||||
userEvent.hover(screen.getByText('Download'));
|
||||
userEvent.click(await screen.findByText('Export to Excel'));
|
||||
expect(props.exportXLSX).toBeCalledTimes(1);
|
||||
expect(props.exportXLSX).toBeCalledWith(371);
|
||||
expect(props.exportXLSX).toHaveBeenCalledTimes(1);
|
||||
expect(props.exportXLSX).toHaveBeenCalledWith(371);
|
||||
});
|
||||
|
||||
test('Export full CSV is under featureflag', async () => {
|
||||
|
|
@ -214,11 +214,11 @@ test('Should "export full CSV"', async () => {
|
|||
};
|
||||
const props = createProps('table');
|
||||
renderWrapper(props);
|
||||
expect(props.exportFullCSV).toBeCalledTimes(0);
|
||||
expect(props.exportFullCSV).toHaveBeenCalledTimes(0);
|
||||
userEvent.hover(screen.getByText('Download'));
|
||||
userEvent.click(await screen.findByText('Export to full .CSV'));
|
||||
expect(props.exportFullCSV).toBeCalledTimes(1);
|
||||
expect(props.exportFullCSV).toBeCalledWith(371);
|
||||
expect(props.exportFullCSV).toHaveBeenCalledTimes(1);
|
||||
expect(props.exportFullCSV).toHaveBeenCalledWith(371);
|
||||
});
|
||||
|
||||
test('Should not show export full CSV if report is not table', async () => {
|
||||
|
|
@ -248,11 +248,11 @@ test('Should "export full Excel"', async () => {
|
|||
};
|
||||
const props = createProps('table');
|
||||
renderWrapper(props);
|
||||
expect(props.exportFullXLSX).toBeCalledTimes(0);
|
||||
expect(props.exportFullXLSX).toHaveBeenCalledTimes(0);
|
||||
userEvent.hover(screen.getByText('Download'));
|
||||
userEvent.click(await screen.findByText('Export to full Excel'));
|
||||
expect(props.exportFullXLSX).toBeCalledTimes(1);
|
||||
expect(props.exportFullXLSX).toBeCalledWith(371);
|
||||
expect(props.exportFullXLSX).toHaveBeenCalledTimes(1);
|
||||
expect(props.exportFullXLSX).toHaveBeenCalledWith(371);
|
||||
});
|
||||
|
||||
test('Should not show export full Excel if report is not table', async () => {
|
||||
|
|
@ -268,29 +268,29 @@ test('Should not show export full Excel if report is not table', async () => {
|
|||
test('Should "Show chart description"', () => {
|
||||
const props = createProps();
|
||||
renderWrapper(props);
|
||||
expect(props.toggleExpandSlice).toBeCalledTimes(0);
|
||||
expect(props.toggleExpandSlice).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByText('Show chart description'));
|
||||
expect(props.toggleExpandSlice).toBeCalledTimes(1);
|
||||
expect(props.toggleExpandSlice).toBeCalledWith(371);
|
||||
expect(props.toggleExpandSlice).toHaveBeenCalledTimes(1);
|
||||
expect(props.toggleExpandSlice).toHaveBeenCalledWith(371);
|
||||
});
|
||||
|
||||
test('Should "Force refresh"', () => {
|
||||
const props = createProps();
|
||||
renderWrapper(props);
|
||||
expect(props.forceRefresh).toBeCalledTimes(0);
|
||||
expect(props.forceRefresh).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByText('Force refresh'));
|
||||
expect(props.forceRefresh).toBeCalledTimes(1);
|
||||
expect(props.forceRefresh).toBeCalledWith(371, 26);
|
||||
expect(props.addSuccessToast).toBeCalledTimes(1);
|
||||
expect(props.forceRefresh).toHaveBeenCalledTimes(1);
|
||||
expect(props.forceRefresh).toHaveBeenCalledWith(371, 26);
|
||||
expect(props.addSuccessToast).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('Should "Enter fullscreen"', () => {
|
||||
const props = createProps();
|
||||
renderWrapper(props);
|
||||
|
||||
expect(props.handleToggleFullSize).toBeCalledTimes(0);
|
||||
expect(props.handleToggleFullSize).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByText('Enter fullscreen'));
|
||||
expect(props.handleToggleFullSize).toBeCalledTimes(1);
|
||||
expect(props.handleToggleFullSize).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('Drill to detail modal is under featureflag', () => {
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ test('Render tab (no content)', () => {
|
|||
useDnd: true,
|
||||
});
|
||||
expect(screen.getByText('🚀 Aspiring Developers')).toBeInTheDocument();
|
||||
expect(EditableTitle).toBeCalledTimes(1);
|
||||
expect(EditableTitle).toHaveBeenCalledTimes(1);
|
||||
expect(getByTestId('dragdroppable-object')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ test('Render tab (no content) editMode:true', () => {
|
|||
useDnd: true,
|
||||
});
|
||||
expect(screen.getByText('🚀 Aspiring Developers')).toBeInTheDocument();
|
||||
expect(EditableTitle).toBeCalledTimes(1);
|
||||
expect(EditableTitle).toHaveBeenCalledTimes(1);
|
||||
expect(getByTestId('dragdroppable-object')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
|
@ -222,12 +222,12 @@ test('Edit table title', () => {
|
|||
useDnd: true,
|
||||
});
|
||||
|
||||
expect(EditableTitle).toBeCalledTimes(1);
|
||||
expect(EditableTitle).toHaveBeenCalledTimes(1);
|
||||
expect(getByTestId('dragdroppable-object')).toBeInTheDocument();
|
||||
|
||||
expect(props.updateComponents).not.toBeCalled();
|
||||
expect(props.updateComponents).not.toHaveBeenCalled();
|
||||
userEvent.click(screen.getByText('🚀 Aspiring Developers'));
|
||||
expect(props.updateComponents).toBeCalled();
|
||||
expect(props.updateComponents).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('Render tab (with content)', () => {
|
||||
|
|
@ -237,7 +237,7 @@ test('Render tab (with content)', () => {
|
|||
useRedux: true,
|
||||
useDnd: true,
|
||||
});
|
||||
expect(DashboardComponent).toBeCalledTimes(2);
|
||||
expect(DashboardComponent).toHaveBeenCalledTimes(2);
|
||||
expect(DashboardComponent).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
expect.objectContaining({
|
||||
|
|
@ -316,7 +316,7 @@ test('Render tab (with content) editMode:true', () => {
|
|||
useRedux: true,
|
||||
useDnd: true,
|
||||
});
|
||||
expect(DashboardComponent).toBeCalledTimes(2);
|
||||
expect(DashboardComponent).toHaveBeenCalledTimes(2);
|
||||
expect(DashboardComponent).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
expect.objectContaining({
|
||||
|
|
@ -369,14 +369,14 @@ test('Should call "handleDrop" and "handleTopDropTargetDrop"', () => {
|
|||
},
|
||||
);
|
||||
|
||||
expect(props.handleComponentDrop).not.toBeCalled();
|
||||
expect(props.handleComponentDrop).not.toHaveBeenCalled();
|
||||
userEvent.click(getAllByTestId('MockDroppable')[0]);
|
||||
expect(props.handleComponentDrop).toBeCalledTimes(1);
|
||||
expect(props.onDropOnTab).not.toBeCalled();
|
||||
expect(props.handleComponentDrop).toHaveBeenCalledTimes(1);
|
||||
expect(props.onDropOnTab).not.toHaveBeenCalled();
|
||||
rerender(<Tab {...props} />);
|
||||
userEvent.click(getAllByTestId('MockDroppable')[1]);
|
||||
expect(props.onDropOnTab).toBeCalledTimes(1);
|
||||
expect(props.handleComponentDrop).toBeCalledTimes(2);
|
||||
expect(props.onDropOnTab).toHaveBeenCalledTimes(1);
|
||||
expect(props.handleComponentDrop).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
test('Render tab content with no children, editMode: true, canEdit: true', () => {
|
||||
|
|
|
|||
|
|
@ -47,15 +47,15 @@ test('Should call download image on click', async () => {
|
|||
const props = createProps();
|
||||
renderComponent();
|
||||
await waitFor(() => {
|
||||
expect(downloadAsImage).toBeCalledTimes(0);
|
||||
expect(props.addDangerToast).toBeCalledTimes(0);
|
||||
expect(downloadAsImage).toHaveBeenCalledTimes(0);
|
||||
expect(props.addDangerToast).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
userEvent.click(screen.getByRole('button', { name: 'Download as Image' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(downloadAsImage).toBeCalledTimes(1);
|
||||
expect(props.addDangerToast).toBeCalledTimes(0);
|
||||
expect(downloadAsImage).toHaveBeenCalledTimes(1);
|
||||
expect(props.addDangerToast).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ test('should call onHover when mouse enters and leaves', () => {
|
|||
const hoverMenu = screen.getByTestId('hover-menu');
|
||||
|
||||
userEvent.hover(hoverMenu);
|
||||
expect(onHover).toBeCalledWith({ isHovered: true });
|
||||
expect(onHover).toHaveBeenCalledWith({ isHovered: true });
|
||||
|
||||
userEvent.unhover(hoverMenu);
|
||||
expect(onHover).toBeCalledWith({ isHovered: false });
|
||||
expect(onHover).toHaveBeenCalledWith({ isHovered: false });
|
||||
});
|
||||
|
|
|
|||
|
|
@ -96,20 +96,20 @@ test('Click on "Copy dashboard URL" and succeed', async () => {
|
|||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(spy).toBeCalledTimes(0);
|
||||
expect(props.addSuccessToast).toBeCalledTimes(0);
|
||||
expect(props.addDangerToast).toBeCalledTimes(0);
|
||||
expect(spy).toHaveBeenCalledTimes(0);
|
||||
expect(props.addSuccessToast).toHaveBeenCalledTimes(0);
|
||||
expect(props.addDangerToast).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
userEvent.click(screen.getByRole('button', { name: 'Copy dashboard URL' }));
|
||||
|
||||
await waitFor(async () => {
|
||||
expect(spy).toBeCalledTimes(1);
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
const value = await spy.mock.calls[0][0]();
|
||||
expect(value).toBe('http://localhost/superset/dashboard/p/123/');
|
||||
expect(props.addSuccessToast).toBeCalledTimes(1);
|
||||
expect(props.addSuccessToast).toBeCalledWith('Copied to clipboard!');
|
||||
expect(props.addDangerToast).toBeCalledTimes(0);
|
||||
expect(props.addSuccessToast).toHaveBeenCalledTimes(1);
|
||||
expect(props.addSuccessToast).toHaveBeenCalledWith('Copied to clipboard!');
|
||||
expect(props.addDangerToast).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -124,20 +124,20 @@ test('Click on "Copy dashboard URL" and fail', async () => {
|
|||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(spy).toBeCalledTimes(0);
|
||||
expect(props.addSuccessToast).toBeCalledTimes(0);
|
||||
expect(props.addDangerToast).toBeCalledTimes(0);
|
||||
expect(spy).toHaveBeenCalledTimes(0);
|
||||
expect(props.addSuccessToast).toHaveBeenCalledTimes(0);
|
||||
expect(props.addDangerToast).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
userEvent.click(screen.getByRole('button', { name: 'Copy dashboard URL' }));
|
||||
|
||||
await waitFor(async () => {
|
||||
expect(spy).toBeCalledTimes(1);
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
const value = await spy.mock.calls[0][0]();
|
||||
expect(value).toBe('http://localhost/superset/dashboard/p/123/');
|
||||
expect(props.addSuccessToast).toBeCalledTimes(0);
|
||||
expect(props.addDangerToast).toBeCalledTimes(1);
|
||||
expect(props.addDangerToast).toBeCalledWith(
|
||||
expect(props.addSuccessToast).toHaveBeenCalledTimes(0);
|
||||
expect(props.addDangerToast).toHaveBeenCalledTimes(1);
|
||||
expect(props.addDangerToast).toHaveBeenCalledWith(
|
||||
'Sorry, something went wrong. Try again later.',
|
||||
);
|
||||
});
|
||||
|
|
@ -153,7 +153,7 @@ test('Click on "Share dashboard by email" and succeed', async () => {
|
|||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(props.addDangerToast).toBeCalledTimes(0);
|
||||
expect(props.addDangerToast).toHaveBeenCalledTimes(0);
|
||||
expect(window.location.href).toBe('');
|
||||
});
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ test('Click on "Share dashboard by email" and succeed', async () => {
|
|||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(props.addDangerToast).toBeCalledTimes(0);
|
||||
expect(props.addDangerToast).toHaveBeenCalledTimes(0);
|
||||
expect(window.location.href).toBe(
|
||||
'mailto:?Subject=Superset%20dashboard%20COVID%20Vaccine%20Dashboard%20&Body=Check%20out%20this%20dashboard%3A%20http%3A%2F%2Flocalhost%2Fsuperset%2Fdashboard%2Fp%2F123%2F',
|
||||
);
|
||||
|
|
@ -184,7 +184,7 @@ test('Click on "Share dashboard by email" and fail', async () => {
|
|||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(props.addDangerToast).toBeCalledTimes(0);
|
||||
expect(props.addDangerToast).toHaveBeenCalledTimes(0);
|
||||
expect(window.location.href).toBe('');
|
||||
});
|
||||
|
||||
|
|
@ -194,8 +194,8 @@ test('Click on "Share dashboard by email" and fail', async () => {
|
|||
|
||||
await waitFor(() => {
|
||||
expect(window.location.href).toBe('');
|
||||
expect(props.addDangerToast).toBeCalledTimes(1);
|
||||
expect(props.addDangerToast).toBeCalledWith(
|
||||
expect(props.addDangerToast).toHaveBeenCalledTimes(1);
|
||||
expect(props.addDangerToast).toHaveBeenCalledWith(
|
||||
'Sorry, something went wrong. Try again later.',
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -84,12 +84,12 @@ test('Should call "setFields" when "datasetId" changes', () => {
|
|||
const { rerender } = render(<ColumnSelect {...(props as any)} />, {
|
||||
useRedux: true,
|
||||
});
|
||||
expect(props.form.setFields).not.toBeCalled();
|
||||
expect(props.form.setFields).not.toHaveBeenCalled();
|
||||
|
||||
props.datasetId = 456;
|
||||
rerender(<ColumnSelect {...(props as any)} />);
|
||||
|
||||
expect(props.form.setFields).toBeCalled();
|
||||
expect(props.form.setFields).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('Should call "getClientErrorObject" when api returns an error', async () => {
|
||||
|
|
@ -98,12 +98,12 @@ test('Should call "getClientErrorObject" when api returns an error', async () =>
|
|||
props.datasetId = 789;
|
||||
const spy = jest.spyOn(uiCore, 'getClientErrorObject');
|
||||
|
||||
expect(spy).not.toBeCalled();
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
render(<ColumnSelect {...(props as any)} />, {
|
||||
useRedux: true,
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(spy).toBeCalled();
|
||||
expect(spy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -18058,7 +18058,7 @@ describe('Ensure buildTree does not throw runtime errors when encountering an in
|
|||
initiallyExcludedCharts,
|
||||
() => 'Fake title',
|
||||
);
|
||||
}).not.toThrowError();
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it('Avoids runtime error with invalid inputs', () => {
|
||||
|
|
@ -18073,7 +18073,7 @@ describe('Ensure buildTree does not throw runtime errors when encountering an in
|
|||
initiallyExcludedCharts,
|
||||
() => 'Fake title',
|
||||
);
|
||||
}).not.toThrowError();
|
||||
}).not.toThrow();
|
||||
|
||||
expect(() => {
|
||||
buildTree(
|
||||
|
|
@ -18086,7 +18086,7 @@ describe('Ensure buildTree does not throw runtime errors when encountering an in
|
|||
initiallyExcludedCharts,
|
||||
() => 'Fake title',
|
||||
);
|
||||
}).not.toThrowError();
|
||||
}).not.toThrow();
|
||||
|
||||
expect(() => {
|
||||
buildTree(
|
||||
|
|
@ -18099,7 +18099,7 @@ describe('Ensure buildTree does not throw runtime errors when encountering an in
|
|||
initiallyExcludedCharts,
|
||||
() => 'Fake title',
|
||||
);
|
||||
}).not.toThrowError();
|
||||
}).not.toThrow();
|
||||
|
||||
expect(() => {
|
||||
buildTree(
|
||||
|
|
@ -18112,7 +18112,7 @@ describe('Ensure buildTree does not throw runtime errors when encountering an in
|
|||
initiallyExcludedCharts,
|
||||
() => 'Fake title',
|
||||
);
|
||||
}).not.toThrowError();
|
||||
}).not.toThrow();
|
||||
|
||||
expect(() => {
|
||||
buildTree(
|
||||
|
|
@ -18125,7 +18125,7 @@ describe('Ensure buildTree does not throw runtime errors when encountering an in
|
|||
initiallyExcludedCharts,
|
||||
() => 'Fake title',
|
||||
);
|
||||
}).not.toThrowError();
|
||||
}).not.toThrow();
|
||||
|
||||
expect(() => {
|
||||
buildTree(
|
||||
|
|
@ -18138,6 +18138,6 @@ describe('Ensure buildTree does not throw runtime errors when encountering an in
|
|||
null,
|
||||
() => 'Fake title',
|
||||
);
|
||||
}).not.toThrowError();
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -160,11 +160,11 @@ test('Clicking on checkbox', () => {
|
|||
(getControlItems as jest.Mock).mockReturnValue(createControlItems());
|
||||
const controlItemsMap = getControlItemsMap(props);
|
||||
renderControlItems(controlItemsMap);
|
||||
expect(props.forceUpdate).not.toBeCalled();
|
||||
expect(setNativeFilterFieldValues).not.toBeCalled();
|
||||
expect(props.forceUpdate).not.toHaveBeenCalled();
|
||||
expect(setNativeFilterFieldValues).not.toHaveBeenCalled();
|
||||
userEvent.click(screen.getByRole('checkbox'));
|
||||
expect(setNativeFilterFieldValues).toBeCalled();
|
||||
expect(props.forceUpdate).toBeCalled();
|
||||
expect(setNativeFilterFieldValues).toHaveBeenCalled();
|
||||
expect(props.forceUpdate).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('Clicking on checkbox when resetConfig:false', () => {
|
||||
|
|
@ -174,9 +174,9 @@ test('Clicking on checkbox when resetConfig:false', () => {
|
|||
]);
|
||||
const controlItemsMap = getControlItemsMap(props);
|
||||
renderControlItems(controlItemsMap);
|
||||
expect(props.forceUpdate).not.toBeCalled();
|
||||
expect(setNativeFilterFieldValues).not.toBeCalled();
|
||||
expect(props.forceUpdate).not.toHaveBeenCalled();
|
||||
expect(setNativeFilterFieldValues).not.toHaveBeenCalled();
|
||||
userEvent.click(screen.getByRole('checkbox'));
|
||||
expect(props.forceUpdate).toBeCalled();
|
||||
expect(setNativeFilterFieldValues).not.toBeCalled();
|
||||
expect(props.forceUpdate).toHaveBeenCalled();
|
||||
expect(setNativeFilterFieldValues).not.toHaveBeenCalled();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -131,6 +131,6 @@ describe('dashboardFilters reducer', () => {
|
|||
|
||||
// when UPDATE_DASHBOARD_FILTERS_SCOPE is changed, applicable filters to a chart
|
||||
// might be changed.
|
||||
expect(activeDashboardFilters.buildActiveFilters).toBeCalled();
|
||||
expect(activeDashboardFilters.buildActiveFilters).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -76,9 +76,9 @@ test('call setControlValue if isVisible is false', async () => {
|
|||
default: false,
|
||||
}),
|
||||
);
|
||||
expect(defaultProps.actions.setControlValue).not.toBeCalled();
|
||||
expect(defaultProps.actions.setControlValue).not.toHaveBeenCalled();
|
||||
rerender(setup({ isVisible: false, default: false }));
|
||||
await waitFor(() =>
|
||||
expect(defaultProps.actions.setControlValue).toBeCalled(),
|
||||
expect(defaultProps.actions.setControlValue).toHaveBeenCalled(),
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ test('Render a FilterInput', async () => {
|
|||
render(<FilterInput onChangeHandler={onChangeHandler} />);
|
||||
expect(await screen.findByRole('textbox')).toBeInTheDocument();
|
||||
|
||||
expect(onChangeHandler).toBeCalledTimes(0);
|
||||
expect(onChangeHandler).toHaveBeenCalledTimes(0);
|
||||
userEvent.type(screen.getByRole('textbox'), 'test');
|
||||
|
||||
expect(onChangeHandler).toBeCalledTimes(4);
|
||||
expect(onChangeHandler).toHaveBeenCalledTimes(4);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -124,8 +124,8 @@ test('can collapse metrics and columns', () => {
|
|||
{ useDnd: true },
|
||||
);
|
||||
fireEvent.click(getByRole('button'));
|
||||
expect(mockData.onCollapseMetricsChange).toBeCalled();
|
||||
expect(mockData.onCollapseColumnsChange).not.toBeCalled();
|
||||
expect(mockData.onCollapseMetricsChange).toHaveBeenCalled();
|
||||
expect(mockData.onCollapseColumnsChange).not.toHaveBeenCalled();
|
||||
|
||||
const startIndexOfColumnSection = mockData.metricSlice.length + 3;
|
||||
rerender(
|
||||
|
|
@ -136,7 +136,7 @@ test('can collapse metrics and columns', () => {
|
|||
/>,
|
||||
);
|
||||
fireEvent.click(getByRole('button'));
|
||||
expect(mockData.onCollapseColumnsChange).toBeCalled();
|
||||
expect(mockData.onCollapseColumnsChange).toHaveBeenCalled();
|
||||
|
||||
rerender(
|
||||
<DatasourcePanelItem
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ describe('Additional actions tests', () => {
|
|||
render(<ExploreHeader {...props} />, {
|
||||
useRedux: true,
|
||||
});
|
||||
expect(props.actions.redirectSQLLab).toBeCalledTimes(0);
|
||||
expect(props.actions.redirectSQLLab).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByLabelText('Menu actions trigger'));
|
||||
userEvent.click(
|
||||
screen.getByRole('menuitem', { name: 'Edit chart properties' }),
|
||||
|
|
@ -309,14 +309,14 @@ describe('Additional actions tests', () => {
|
|||
useRedux: true,
|
||||
});
|
||||
|
||||
expect(getChartDataRequest).toBeCalledTimes(0);
|
||||
expect(getChartDataRequest).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByLabelText('Menu actions trigger'));
|
||||
expect(getChartDataRequest).toBeCalledTimes(0);
|
||||
expect(getChartDataRequest).toHaveBeenCalledTimes(0);
|
||||
|
||||
const menuItem = screen.getByText('View query').parentElement!;
|
||||
userEvent.click(menuItem);
|
||||
|
||||
await waitFor(() => expect(getChartDataRequest).toBeCalledTimes(1));
|
||||
await waitFor(() => expect(getChartDataRequest).toHaveBeenCalledTimes(1));
|
||||
});
|
||||
|
||||
test('Should call onOpenInEditor when click on "Run in SQL Lab"', async () => {
|
||||
|
|
@ -326,12 +326,12 @@ describe('Additional actions tests', () => {
|
|||
});
|
||||
expect(await screen.findByText('Save')).toBeInTheDocument();
|
||||
|
||||
expect(props.actions.redirectSQLLab).toBeCalledTimes(0);
|
||||
expect(props.actions.redirectSQLLab).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByLabelText('Menu actions trigger'));
|
||||
expect(props.actions.redirectSQLLab).toBeCalledTimes(0);
|
||||
expect(props.actions.redirectSQLLab).toHaveBeenCalledTimes(0);
|
||||
|
||||
userEvent.click(screen.getByRole('menuitem', { name: 'Run in SQL Lab' }));
|
||||
expect(props.actions.redirectSQLLab).toBeCalledTimes(1);
|
||||
expect(props.actions.redirectSQLLab).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
describe('Download', () => {
|
||||
|
|
@ -354,16 +354,16 @@ describe('Additional actions tests', () => {
|
|||
useRedux: true,
|
||||
});
|
||||
|
||||
expect(spy).toBeCalledTimes(0);
|
||||
expect(spy).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByLabelText('Menu actions trigger'));
|
||||
expect(spy).toBeCalledTimes(0);
|
||||
expect(spy).toHaveBeenCalledTimes(0);
|
||||
|
||||
userEvent.hover(screen.getByText('Download'));
|
||||
const downloadAsImageElement =
|
||||
await screen.findByText('Download as image');
|
||||
userEvent.click(downloadAsImageElement);
|
||||
|
||||
expect(spy).toBeCalledTimes(1);
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('Should not export to CSV if canDownload=false', async () => {
|
||||
|
|
|
|||
|
|
@ -171,14 +171,14 @@ test('"Close" button should call "onHide"', async () => {
|
|||
renderModal(props);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(props.onHide).toBeCalledTimes(0);
|
||||
expect(props.onHide).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
userEvent.click(screen.getByRole('button', { name: 'Close' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(props.onHide).toBeCalledTimes(1);
|
||||
expect(props.onSave).toBeCalledTimes(0);
|
||||
expect(props.onHide).toHaveBeenCalledTimes(1);
|
||||
expect(props.onSave).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -229,14 +229,14 @@ test('"Cancel" button should call "onHide"', async () => {
|
|||
renderModal(props);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(props.onHide).toBeCalledTimes(0);
|
||||
expect(props.onHide).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
userEvent.click(screen.getByRole('button', { name: 'Cancel' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(props.onHide).toBeCalledTimes(1);
|
||||
expect(props.onSave).toBeCalledTimes(0);
|
||||
expect(props.onHide).toHaveBeenCalledTimes(1);
|
||||
expect(props.onSave).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -244,16 +244,16 @@ test('"Save" button should call only "onSave"', async () => {
|
|||
const props = createProps();
|
||||
renderModal(props);
|
||||
await waitFor(() => {
|
||||
expect(props.onSave).toBeCalledTimes(0);
|
||||
expect(props.onHide).toBeCalledTimes(0);
|
||||
expect(props.onSave).toHaveBeenCalledTimes(0);
|
||||
expect(props.onHide).toHaveBeenCalledTimes(0);
|
||||
|
||||
expect(screen.getByRole('button', { name: 'Save' })).toBeEnabled();
|
||||
});
|
||||
userEvent.click(screen.getByRole('button', { name: 'Save' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(props.onSave).toBeCalledTimes(1);
|
||||
expect(props.onHide).toBeCalledTimes(1);
|
||||
expect(props.onSave).toHaveBeenCalledTimes(1);
|
||||
expect(props.onHide).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -289,7 +289,7 @@ test('"Name" should not be empty', async () => {
|
|||
userEvent.click(screen.getByRole('button', { name: 'Save' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(props.onSave).toBeCalledTimes(0);
|
||||
expect(props.onSave).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -307,8 +307,8 @@ test('"Name" should not be empty when saved', async () => {
|
|||
userEvent.click(screen.getByRole('button', { name: 'Save' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(props.onSave).toBeCalledTimes(1);
|
||||
expect(props.onSave).toBeCalledWith(
|
||||
expect(props.onSave).toHaveBeenCalledTimes(1);
|
||||
expect(props.onSave).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ slice_name: 'Test chart new name' }),
|
||||
);
|
||||
});
|
||||
|
|
@ -328,8 +328,8 @@ test('"Cache timeout" should not be empty when saved', async () => {
|
|||
userEvent.click(screen.getByRole('button', { name: 'Save' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(props.onSave).toBeCalledTimes(1);
|
||||
expect(props.onSave).toBeCalledWith(
|
||||
expect(props.onSave).toHaveBeenCalledTimes(1);
|
||||
expect(props.onSave).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ cache_timeout: '1000' }),
|
||||
);
|
||||
});
|
||||
|
|
@ -349,8 +349,8 @@ test('"Description" should not be empty when saved', async () => {
|
|||
userEvent.click(screen.getByRole('button', { name: 'Save' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(props.onSave).toBeCalledTimes(1);
|
||||
expect(props.onSave).toBeCalledWith(
|
||||
expect(props.onSave).toHaveBeenCalledTimes(1);
|
||||
expect(props.onSave).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ description: 'Test description' }),
|
||||
);
|
||||
});
|
||||
|
|
@ -370,8 +370,8 @@ test('"Certified by" should not be empty when saved', async () => {
|
|||
userEvent.click(screen.getByRole('button', { name: 'Save' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(props.onSave).toBeCalledTimes(1);
|
||||
expect(props.onSave).toBeCalledWith(
|
||||
expect(props.onSave).toHaveBeenCalledTimes(1);
|
||||
expect(props.onSave).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ certified_by: 'Test certified by' }),
|
||||
);
|
||||
});
|
||||
|
|
@ -393,8 +393,8 @@ test('"Certification details" should not be empty when saved', async () => {
|
|||
userEvent.click(screen.getByRole('button', { name: 'Save' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(props.onSave).toBeCalledTimes(1);
|
||||
expect(props.onSave).toBeCalledWith(
|
||||
expect(props.onSave).toHaveBeenCalledTimes(1);
|
||||
expect(props.onSave).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
certification_details: 'Test certification details',
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -108,9 +108,12 @@ test('Should have add button', async () => {
|
|||
expect(
|
||||
await screen.findByRole('button', { name: 'plus-large' }),
|
||||
).toBeInTheDocument();
|
||||
expect(props.onChange).toBeCalledTimes(0);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button', { name: 'plus-large' }));
|
||||
expect(props.onChange).toBeCalledWith([{ key: 'hrYAZ5iBH' }, undefined]);
|
||||
expect(props.onChange).toHaveBeenCalledWith([
|
||||
{ key: 'hrYAZ5iBH' },
|
||||
undefined,
|
||||
]);
|
||||
});
|
||||
|
||||
test('Should have remove button', async () => {
|
||||
|
|
@ -120,9 +123,9 @@ test('Should have remove button', async () => {
|
|||
expect(
|
||||
await screen.findByRole('button', { name: 'remove-item' }),
|
||||
).toBeInTheDocument();
|
||||
expect(props.onChange).toBeCalledTimes(0);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button', { name: 'remove-item' }));
|
||||
expect(props.onChange).toBeCalledWith([]);
|
||||
expect(props.onChange).toHaveBeenCalledWith([]);
|
||||
});
|
||||
|
||||
test('Should have SortableDragger icon', async () => {
|
||||
|
|
@ -136,7 +139,7 @@ test('Should call Control component', async () => {
|
|||
render(<CollectionControl {...props} />);
|
||||
|
||||
expect(await screen.findByTestId('TestControl')).toBeInTheDocument();
|
||||
expect(props.onChange).toBeCalledTimes(0);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByTestId('TestControl'));
|
||||
expect(props.onChange).toBeCalledWith([{ key: 'hrYAZ5iBH' }]);
|
||||
expect(props.onChange).toHaveBeenCalledWith([{ key: 'hrYAZ5iBH' }]);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -117,16 +117,16 @@ test('Should render correct elements for disallow ad-hoc metrics', () => {
|
|||
test('Clicking on "Close" should call onClose', () => {
|
||||
const props = createProps();
|
||||
render(<AdhocMetricEditPopover {...props} />);
|
||||
expect(props.onClose).toBeCalledTimes(0);
|
||||
expect(props.onClose).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button', { name: 'Close' }));
|
||||
expect(props.onClose).toBeCalledTimes(1);
|
||||
expect(props.onClose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('Clicking on "Save" should call onChange and onClose', async () => {
|
||||
const props = createProps();
|
||||
render(<AdhocMetricEditPopover {...props} />);
|
||||
expect(props.onChange).toBeCalledTimes(0);
|
||||
expect(props.onClose).toBeCalledTimes(0);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(0);
|
||||
expect(props.onClose).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(
|
||||
screen.getByRole('combobox', {
|
||||
name: 'Select saved metrics',
|
||||
|
|
@ -134,38 +134,38 @@ test('Clicking on "Save" should call onChange and onClose', async () => {
|
|||
);
|
||||
await selectOption('sum');
|
||||
userEvent.click(screen.getByRole('button', { name: 'Save' }));
|
||||
expect(props.onChange).toBeCalledTimes(1);
|
||||
expect(props.onClose).toBeCalledTimes(1);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(1);
|
||||
expect(props.onClose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('Clicking on "Save" should not call onChange and onClose', () => {
|
||||
const props = createProps();
|
||||
render(<AdhocMetricEditPopover {...props} />);
|
||||
expect(props.onChange).toBeCalledTimes(0);
|
||||
expect(props.onClose).toBeCalledTimes(0);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(0);
|
||||
expect(props.onClose).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button', { name: 'Save' }));
|
||||
expect(props.onChange).toBeCalledTimes(0);
|
||||
expect(props.onClose).toBeCalledTimes(0);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(0);
|
||||
expect(props.onClose).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
test('Clicking on "Save" should call onChange and onClose for new metric', () => {
|
||||
const props = createProps();
|
||||
render(<AdhocMetricEditPopover {...props} isNewMetric />);
|
||||
expect(props.onChange).toBeCalledTimes(0);
|
||||
expect(props.onClose).toBeCalledTimes(0);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(0);
|
||||
expect(props.onClose).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button', { name: 'Save' }));
|
||||
expect(props.onChange).toBeCalledTimes(1);
|
||||
expect(props.onClose).toBeCalledTimes(1);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(1);
|
||||
expect(props.onClose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('Clicking on "Save" should call onChange and onClose for new title', () => {
|
||||
const props = createProps();
|
||||
render(<AdhocMetricEditPopover {...props} isLabelModified />);
|
||||
expect(props.onChange).toBeCalledTimes(0);
|
||||
expect(props.onClose).toBeCalledTimes(0);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(0);
|
||||
expect(props.onClose).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(screen.getByRole('button', { name: 'Save' }));
|
||||
expect(props.onChange).toBeCalledTimes(1);
|
||||
expect(props.onClose).toBeCalledTimes(1);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(1);
|
||||
expect(props.onClose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('Should switch to tab:Simple', () => {
|
||||
|
|
@ -180,11 +180,11 @@ test('Should switch to tab:Simple', () => {
|
|||
screen.queryByRole('tabpanel', { name: 'Simple' }),
|
||||
).not.toBeInTheDocument();
|
||||
|
||||
expect(props.getCurrentTab).toBeCalledTimes(1);
|
||||
expect(props.getCurrentTab).toHaveBeenCalledTimes(1);
|
||||
const tab = screen.getByRole('tab', { name: 'Simple' }).parentElement!;
|
||||
userEvent.click(tab);
|
||||
|
||||
expect(props.getCurrentTab).toBeCalledTimes(2);
|
||||
expect(props.getCurrentTab).toHaveBeenCalledTimes(2);
|
||||
|
||||
expect(
|
||||
screen.queryByRole('tabpanel', { name: 'Saved' }),
|
||||
|
|
@ -218,11 +218,11 @@ test('Should switch to tab:Custom SQL', () => {
|
|||
screen.queryByRole('tabpanel', { name: 'Custom SQL' }),
|
||||
).not.toBeInTheDocument();
|
||||
|
||||
expect(props.getCurrentTab).toBeCalledTimes(1);
|
||||
expect(props.getCurrentTab).toHaveBeenCalledTimes(1);
|
||||
const tab = screen.getByRole('tab', { name: 'Custom SQL' }).parentElement!;
|
||||
userEvent.click(tab);
|
||||
|
||||
expect(props.getCurrentTab).toBeCalledTimes(2);
|
||||
expect(props.getCurrentTab).toHaveBeenCalledTimes(2);
|
||||
|
||||
expect(
|
||||
screen.queryByRole('tabpanel', { name: 'Saved' }),
|
||||
|
|
|
|||
|
|
@ -91,9 +91,9 @@ test('Should send correct props to Select component - value props', async () =>
|
|||
test('Should send correct props to Select component - function onChange multi:true', async () => {
|
||||
const props = createProps();
|
||||
render(<SelectAsyncControl {...props} />, { useRedux: true });
|
||||
expect(props.onChange).toBeCalledTimes(0);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(await screen.findByText('onChange'));
|
||||
expect(props.onChange).toBeCalledTimes(1);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('Should send correct props to Select component - function onChange multi:false', async () => {
|
||||
|
|
@ -101,7 +101,7 @@ test('Should send correct props to Select component - function onChange multi:fa
|
|||
render(<SelectAsyncControl {...{ ...props, multi: false }} />, {
|
||||
useRedux: true,
|
||||
});
|
||||
expect(props.onChange).toBeCalledTimes(0);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(0);
|
||||
userEvent.click(await screen.findByText('onChange'));
|
||||
expect(props.onChange).toBeCalledTimes(1);
|
||||
expect(props.onChange).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ describe('VizTypeControl', () => {
|
|||
const visualizations = screen.getByTestId(getTestId('viz-row'));
|
||||
userEvent.click(within(visualizations).getByText('Bar Chart'));
|
||||
|
||||
expect(defaultProps.onChange).not.toBeCalled();
|
||||
expect(defaultProps.onChange).not.toHaveBeenCalled();
|
||||
userEvent.dblClick(within(visualizations).getByText('Line Chart'));
|
||||
|
||||
expect(defaultProps.onChange).toHaveBeenCalledWith(
|
||||
|
|
|
|||
|
|
@ -94,8 +94,8 @@ describe('VerifiedMetricsControl', () => {
|
|||
|
||||
expect(wrapper.find(MetricsControl).length).toBe(1);
|
||||
|
||||
expect(verifier).toBeCalledTimes(1);
|
||||
expect(verifier).toBeCalledWith(
|
||||
expect(verifier).toHaveBeenCalledTimes(1);
|
||||
expect(verifier).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ savedMetrics: props.savedMetrics }),
|
||||
);
|
||||
|
||||
|
|
@ -104,8 +104,8 @@ describe('VerifiedMetricsControl', () => {
|
|||
wrapper.setProps({ validMetric: ['abc'] });
|
||||
});
|
||||
|
||||
expect(verifier).toBeCalledTimes(2);
|
||||
expect(verifier).toBeCalledWith(
|
||||
expect(verifier).toHaveBeenCalledTimes(2);
|
||||
expect(verifier).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ validMetric: ['abc'] }),
|
||||
);
|
||||
});
|
||||
|
|
@ -123,8 +123,8 @@ describe('VerifiedMetricsControl', () => {
|
|||
child.props().onChange?.(['abc']);
|
||||
|
||||
expect(child.length).toBe(1);
|
||||
expect(mockOnChange).toBeCalledTimes(1);
|
||||
expect(mockOnChange).toBeCalledWith(['abc'], {
|
||||
expect(mockOnChange).toHaveBeenCalledTimes(1);
|
||||
expect(mockOnChange).toHaveBeenCalledWith(['abc'], {
|
||||
actions: defaultProps.actions,
|
||||
columns: defaultProps.columns,
|
||||
datasourceType: defaultProps.datasourceType,
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ describe('exploreUtils', () => {
|
|||
const v1RequestPayload = buildV1ChartDataPayload({
|
||||
formData: { ...formData, viz_type: 'my_custom_viz' },
|
||||
});
|
||||
expect(v1RequestPayload).hasOwnProperty('queries');
|
||||
expect(v1RequestPayload.hasOwnProperty('queries')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -289,7 +289,7 @@ describe('exploreUtils', () => {
|
|||
exploreChart({
|
||||
formData: { ...formData, viz_type: 'my_custom_viz' },
|
||||
});
|
||||
expect(postFormSpy).toBeCalledTimes(1);
|
||||
expect(postFormSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@ test('Should return false', () => {
|
|||
const spy = jest.spyOn(Core, 'getChartMetadataRegistry');
|
||||
const get = jest.fn();
|
||||
spy.mockReturnValue({ get } as any);
|
||||
expect(get).toBeCalledTimes(0);
|
||||
expect(get).toHaveBeenCalledTimes(0);
|
||||
const [useLegacyApi] = getQuerySettings({ viz_type: 'name_test' });
|
||||
expect(useLegacyApi).toBe(false);
|
||||
expect(get).toBeCalledTimes(1);
|
||||
expect(get).toBeCalledWith('name_test');
|
||||
expect(get).toHaveBeenCalledTimes(1);
|
||||
expect(get).toHaveBeenCalledWith('name_test');
|
||||
});
|
||||
|
||||
test('Should return true', () => {
|
||||
|
|
@ -35,11 +35,11 @@ test('Should return true', () => {
|
|||
const get = jest.fn();
|
||||
get.mockReturnValue({ useLegacyApi: true });
|
||||
spy.mockReturnValue({ get } as any);
|
||||
expect(get).toBeCalledTimes(0);
|
||||
expect(get).toHaveBeenCalledTimes(0);
|
||||
const [useLegacyApi] = getQuerySettings({ viz_type: 'name_test' });
|
||||
expect(useLegacyApi).toBe(true);
|
||||
expect(get).toBeCalledTimes(1);
|
||||
expect(get).toBeCalledWith('name_test');
|
||||
expect(get).toHaveBeenCalledTimes(1);
|
||||
expect(get).toHaveBeenCalledWith('name_test');
|
||||
});
|
||||
|
||||
test('Should return false when useLegacyApi:false', () => {
|
||||
|
|
@ -47,9 +47,9 @@ test('Should return false when useLegacyApi:false', () => {
|
|||
const get = jest.fn();
|
||||
get.mockReturnValue({ useLegacyApi: false });
|
||||
spy.mockReturnValue({ get } as any);
|
||||
expect(get).toBeCalledTimes(0);
|
||||
expect(get).toHaveBeenCalledTimes(0);
|
||||
const [useLegacyApi] = getQuerySettings({ viz_type: 'name_test' });
|
||||
expect(useLegacyApi).toBe(false);
|
||||
expect(get).toBeCalledTimes(1);
|
||||
expect(get).toBeCalledWith('name_test');
|
||||
expect(get).toHaveBeenCalledTimes(1);
|
||||
expect(get).toHaveBeenCalledWith('name_test');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ describe('cacheWrapper', () => {
|
|||
const returnedValue = wrappedFn(1, 2);
|
||||
|
||||
expect(returnedValue).toEqual(fnResult);
|
||||
expect(fn).toBeCalledTimes(1);
|
||||
expect(fn).toBeCalledWith(1, 2);
|
||||
expect(fn).toHaveBeenCalledTimes(1);
|
||||
expect(fn).toHaveBeenCalledWith(1, 2);
|
||||
});
|
||||
|
||||
describe('subsequent calls', () => {
|
||||
|
|
@ -48,14 +48,14 @@ describe('cacheWrapper', () => {
|
|||
|
||||
expect(returnedValue1).toEqual(fnResult);
|
||||
expect(returnedValue2).toEqual(fnResult);
|
||||
expect(fn).toBeCalledTimes(1);
|
||||
expect(fn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('fn is called multiple times for different arguments', () => {
|
||||
wrappedFn(1, 2);
|
||||
wrappedFn(1, 3);
|
||||
|
||||
expect(fn).toBeCalledTimes(2);
|
||||
expect(fn).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ describe('cacheWrapper', () => {
|
|||
wrappedFn(1, 2);
|
||||
wrappedFn(1, 3);
|
||||
|
||||
expect(fn).toBeCalledTimes(1);
|
||||
expect(fn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -94,10 +94,10 @@ describe('server', () => {
|
|||
response as unknown as http.ServerResponse<http.IncomingMessage>,
|
||||
);
|
||||
|
||||
expect(writeHeadMock).toBeCalledTimes(1);
|
||||
expect(writeHeadMock).toHaveBeenCalledTimes(1);
|
||||
expect(writeHeadMock).toHaveBeenLastCalledWith(200);
|
||||
|
||||
expect(endMock).toBeCalledTimes(1);
|
||||
expect(endMock).toHaveBeenCalledTimes(1);
|
||||
expect(endMock).toHaveBeenLastCalledWith('OK');
|
||||
});
|
||||
|
||||
|
|
@ -123,10 +123,10 @@ describe('server', () => {
|
|||
response as unknown as http.ServerResponse<http.IncomingMessage>,
|
||||
);
|
||||
|
||||
expect(writeHeadMock).toBeCalledTimes(1);
|
||||
expect(writeHeadMock).toHaveBeenCalledTimes(1);
|
||||
expect(writeHeadMock).toHaveBeenLastCalledWith(404);
|
||||
|
||||
expect(endMock).toBeCalledTimes(1);
|
||||
expect(endMock).toHaveBeenCalledTimes(1);
|
||||
expect(endMock).toHaveBeenLastCalledWith('Not Found');
|
||||
});
|
||||
});
|
||||
|
|
@ -200,16 +200,16 @@ describe('server', () => {
|
|||
const sendMock = jest.spyOn(ws, 'send');
|
||||
const socketInstance = { ws: ws, channel: channelId, pongTs: Date.now() };
|
||||
|
||||
expect(statsdIncrementMock).toBeCalledTimes(0);
|
||||
expect(statsdIncrementMock).toHaveBeenCalledTimes(0);
|
||||
server.trackClient(channelId, socketInstance);
|
||||
expect(statsdIncrementMock).toBeCalledTimes(1);
|
||||
expect(statsdIncrementMock).toHaveBeenCalledTimes(1);
|
||||
expect(statsdIncrementMock).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'ws_connected_client',
|
||||
);
|
||||
|
||||
server.processStreamResults(streamReturnValue);
|
||||
expect(statsdIncrementMock).toBeCalledTimes(1);
|
||||
expect(statsdIncrementMock).toHaveBeenCalledTimes(1);
|
||||
|
||||
const message1 = `{"id":"1615426152415-0","channel_id":"${channelId}","job_id":"c9b99965-8f1e-4ce5-aa43-d6fc94d6a510","user_id":"1","status":"done","errors":[],"result_url":"/superset/explore_json/data/ejr-37281682b1282cdb8f25e0de0339b386"}`;
|
||||
const message2 = `{"id":"1615426152516-0","channel_id":"${channelId}","job_id":"f1e5bb1f-f2f1-4f21-9b2f-c9b91dcc9b59","user_id":"1","status":"done","errors":[],"result_url":"/api/v1/chart/data/qc-64e8452dc9907dd77746cb75a19202de"}`;
|
||||
|
|
@ -221,9 +221,9 @@ describe('server', () => {
|
|||
const ws = new wsMock('localhost');
|
||||
const sendMock = jest.spyOn(ws, 'send');
|
||||
|
||||
expect(statsdIncrementMock).toBeCalledTimes(0);
|
||||
expect(statsdIncrementMock).toHaveBeenCalledTimes(0);
|
||||
server.processStreamResults(streamReturnValue);
|
||||
expect(statsdIncrementMock).toBeCalledTimes(0);
|
||||
expect(statsdIncrementMock).toHaveBeenCalledTimes(0);
|
||||
|
||||
expect(sendMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
|
@ -236,16 +236,16 @@ describe('server', () => {
|
|||
const cleanChannelMock = jest.spyOn(server, 'cleanChannel');
|
||||
const socketInstance = { ws: ws, channel: channelId, pongTs: Date.now() };
|
||||
|
||||
expect(statsdIncrementMock).toBeCalledTimes(0);
|
||||
expect(statsdIncrementMock).toHaveBeenCalledTimes(0);
|
||||
server.trackClient(channelId, socketInstance);
|
||||
expect(statsdIncrementMock).toBeCalledTimes(1);
|
||||
expect(statsdIncrementMock).toHaveBeenCalledTimes(1);
|
||||
expect(statsdIncrementMock).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'ws_connected_client',
|
||||
);
|
||||
|
||||
server.processStreamResults(streamReturnValue);
|
||||
expect(statsdIncrementMock).toBeCalledTimes(2);
|
||||
expect(statsdIncrementMock).toHaveBeenCalledTimes(2);
|
||||
expect(statsdIncrementMock).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
'ws_client_send_error',
|
||||
|
|
|
|||
Loading…
Reference in New Issue