mirror of
https://github.com/apache/superset.git
synced 2024-09-16 10:39:55 -04:00
test: Fix act errors in SelectFilterPlugin test (#21396)
This commit is contained in:
parent
a2ea5efe25
commit
584f2e63d1
@ -24,6 +24,8 @@ import { NULL_STRING } from 'src/utils/common';
|
|||||||
import SelectFilterPlugin from './SelectFilterPlugin';
|
import SelectFilterPlugin from './SelectFilterPlugin';
|
||||||
import transformProps from './transformProps';
|
import transformProps from './transformProps';
|
||||||
|
|
||||||
|
jest.useFakeTimers();
|
||||||
|
|
||||||
const selectMultipleProps = {
|
const selectMultipleProps = {
|
||||||
formData: {
|
formData: {
|
||||||
sortAscending: true,
|
sortAscending: true,
|
||||||
@ -86,7 +88,7 @@ describe('SelectFilterPlugin', () => {
|
|||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Add multiple values with first render', () => {
|
test('Add multiple values with first render', async () => {
|
||||||
getWrapper();
|
getWrapper();
|
||||||
expect(setDataMask).toHaveBeenCalledWith({
|
expect(setDataMask).toHaveBeenCalledWith({
|
||||||
extraFormData: {},
|
extraFormData: {},
|
||||||
@ -114,6 +116,7 @@ describe('SelectFilterPlugin', () => {
|
|||||||
});
|
});
|
||||||
userEvent.click(screen.getByRole('combobox'));
|
userEvent.click(screen.getByRole('combobox'));
|
||||||
userEvent.click(screen.getByTitle('girl'));
|
userEvent.click(screen.getByTitle('girl'));
|
||||||
|
expect(await screen.findByTitle(/girl/i)).toBeInTheDocument();
|
||||||
expect(setDataMask).toHaveBeenCalledWith({
|
expect(setDataMask).toHaveBeenCalledWith({
|
||||||
__cache: {
|
__cache: {
|
||||||
value: ['boy'],
|
value: ['boy'],
|
||||||
@ -134,9 +137,14 @@ describe('SelectFilterPlugin', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Remove multiple values when required', () => {
|
test('Remove multiple values when required', () => {
|
||||||
getWrapper();
|
getWrapper();
|
||||||
userEvent.click(document.querySelector('[data-icon="close"]')!);
|
userEvent.click(
|
||||||
|
screen.getByRole('img', {
|
||||||
|
name: /close-circle/i,
|
||||||
|
hidden: true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
expect(setDataMask).toHaveBeenCalledWith({
|
expect(setDataMask).toHaveBeenCalledWith({
|
||||||
__cache: {
|
__cache: {
|
||||||
value: ['boy'],
|
value: ['boy'],
|
||||||
@ -157,9 +165,14 @@ describe('SelectFilterPlugin', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Remove multiple values when not required', () => {
|
test('Remove multiple values when not required', () => {
|
||||||
getWrapper({ enableEmptyFilter: false });
|
getWrapper({ enableEmptyFilter: false });
|
||||||
userEvent.click(document.querySelector('[data-icon="close"]')!);
|
userEvent.click(
|
||||||
|
screen.getByRole('img', {
|
||||||
|
name: /close-circle/i,
|
||||||
|
hidden: true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
expect(setDataMask).toHaveBeenCalledWith({
|
expect(setDataMask).toHaveBeenCalledWith({
|
||||||
__cache: {
|
__cache: {
|
||||||
value: ['boy'],
|
value: ['boy'],
|
||||||
@ -172,9 +185,10 @@ describe('SelectFilterPlugin', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Select single values with inverse', () => {
|
test('Select single values with inverse', async () => {
|
||||||
getWrapper({ multiSelect: false, inverseSelection: true });
|
getWrapper({ multiSelect: false, inverseSelection: true });
|
||||||
userEvent.click(screen.getByRole('combobox'));
|
userEvent.click(screen.getByRole('combobox'));
|
||||||
|
expect(await screen.findByTitle('girl')).toBeInTheDocument();
|
||||||
userEvent.click(screen.getByTitle('girl'));
|
userEvent.click(screen.getByTitle('girl'));
|
||||||
expect(setDataMask).toHaveBeenCalledWith({
|
expect(setDataMask).toHaveBeenCalledWith({
|
||||||
__cache: {
|
__cache: {
|
||||||
@ -196,9 +210,10 @@ describe('SelectFilterPlugin', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Select single null (empty) value', () => {
|
test('Select single null (empty) value', async () => {
|
||||||
getWrapper();
|
getWrapper();
|
||||||
userEvent.click(screen.getByRole('combobox'));
|
userEvent.click(screen.getByRole('combobox'));
|
||||||
|
expect(await screen.findByRole('combobox')).toBeInTheDocument();
|
||||||
userEvent.click(screen.getByTitle(NULL_STRING));
|
userEvent.click(screen.getByTitle(NULL_STRING));
|
||||||
expect(setDataMask).toHaveBeenLastCalledWith({
|
expect(setDataMask).toHaveBeenLastCalledWith({
|
||||||
__cache: {
|
__cache: {
|
||||||
@ -220,9 +235,10 @@ describe('SelectFilterPlugin', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Add ownState with column types when search all options', () => {
|
test('Add ownState with column types when search all options', async () => {
|
||||||
getWrapper({ searchAllOptions: true, multiSelect: false });
|
getWrapper({ searchAllOptions: true, multiSelect: false });
|
||||||
userEvent.click(screen.getByRole('combobox'));
|
userEvent.click(screen.getByRole('combobox'));
|
||||||
|
expect(await screen.findByRole('combobox')).toBeInTheDocument();
|
||||||
userEvent.click(screen.getByTitle('girl'));
|
userEvent.click(screen.getByTitle('girl'));
|
||||||
expect(setDataMask).toHaveBeenCalledWith({
|
expect(setDataMask).toHaveBeenCalledWith({
|
||||||
__cache: {
|
__cache: {
|
||||||
|
Loading…
Reference in New Issue
Block a user