First commit of tests (setup)

This commit is contained in:
mfrachet 2021-06-29 09:37:01 +02:00
parent 321ed4041c
commit 5024d21327
5 changed files with 961 additions and 2 deletions

View File

@ -0,0 +1,483 @@
'use strict';
const addressCT = {
uid: 'application::address.address',
settings: {
bulkable: true,
filterable: true,
searchable: true,
pageSize: 10,
mainField: 'postal_coder',
defaultSortBy: 'postal_coder',
defaultSortOrder: 'ASC',
},
metadatas: {
id: { edit: {}, list: { label: 'Id', searchable: true, sortable: true } },
postal_coder: {
edit: {
label: 'Postal_coder',
description: '',
placeholder: '',
visible: true,
editable: true,
},
list: { label: 'Postal_coder', searchable: true, sortable: true },
},
categories: {
list: {
label: 'Categories',
searchable: false,
sortable: false,
mainField: { name: 'name', schema: { type: 'string' } },
},
edit: {
label: 'Categories',
description: '',
placeholder: '',
visible: true,
editable: true,
mainField: { name: 'name', schema: { type: 'string' } },
},
},
cover: {
edit: { label: 'Cover', description: '', placeholder: '', visible: true, editable: true },
list: { label: 'Cover', searchable: false, sortable: false },
},
images: {
edit: { label: 'Images', description: '', placeholder: '', visible: true, editable: true },
list: { label: 'Images', searchable: false, sortable: false },
},
city: {
edit: { label: 'City', description: '', placeholder: '', visible: true, editable: true },
list: { label: 'City', searchable: true, sortable: true },
},
likes: {
list: {
label: 'Likes',
searchable: false,
sortable: false,
mainField: { name: 'id', schema: { type: 'integer' } },
},
edit: {
label: 'Likes',
description: '',
placeholder: '',
visible: true,
editable: true,
mainField: { name: 'id', schema: { type: 'integer' } },
},
},
json: {
edit: { label: 'Json', description: '', placeholder: '', visible: true, editable: true },
list: { label: 'Json', searchable: false, sortable: false },
},
slug: {
edit: { label: 'Slug', description: '', placeholder: '', visible: true, editable: true },
list: { label: 'Slug', searchable: true, sortable: true },
},
notrepeat_req: {
edit: {
label: 'Notrepeat_req',
description: '',
placeholder: '',
visible: true,
editable: true,
},
list: { label: 'Notrepeat_req', searchable: false, sortable: false },
},
repeat_req: {
edit: {
label: 'Repeat_req',
description: '',
placeholder: '',
visible: true,
editable: true,
},
list: { label: 'Repeat_req', searchable: false, sortable: false },
},
repeat_req_min: {
edit: {
label: 'Repeat_req_min',
description: '',
placeholder: '',
visible: true,
editable: true,
},
list: { label: 'Repeat_req_min', searchable: false, sortable: false },
},
created_at: {
edit: {
label: 'Created_at',
description: '',
placeholder: '',
visible: false,
editable: true,
},
list: { label: 'Created_at', searchable: true, sortable: true },
},
updated_at: {
edit: {
label: 'Updated_at',
description: '',
placeholder: '',
visible: false,
editable: true,
},
list: { label: 'Updated_at', searchable: true, sortable: true },
},
},
layouts: {
list: [
{
key: '__id_key__',
name: 'id',
fieldSchema: { type: 'integer' },
metadatas: { label: 'Id', searchable: true, sortable: true },
},
{
key: '__postal_coder_key__',
name: 'postal_coder',
fieldSchema: { type: 'string', pluginOptions: { i18n: { localized: true } } },
metadatas: { label: 'Postal_coder', searchable: true, sortable: true },
},
{
key: '__categories_key__',
name: 'categories',
fieldSchema: {
collection: 'category',
via: 'addresses',
dominant: true,
attribute: 'category',
column: 'id',
isVirtual: true,
type: 'relation',
targetModel: 'application::category.category',
relationType: 'manyToMany',
},
metadatas: {
label: 'Categories',
searchable: false,
sortable: false,
mainField: { name: 'name', schema: { type: 'string' } },
},
queryInfos: {
endPoint: 'collection-types/application::address.address',
defaultParams: {},
},
},
{
key: '__cover_key__',
name: 'cover',
fieldSchema: {
type: 'media',
multiple: false,
required: false,
allowedTypes: ['files', 'images', 'videos'],
pluginOptions: { i18n: { localized: true } },
},
metadatas: { label: 'Cover', searchable: false, sortable: false },
},
],
edit: [
[
{
name: 'postal_coder',
size: 6,
fieldSchema: { type: 'string', pluginOptions: { i18n: { localized: true } } },
metadatas: {
label: 'Postal_coder',
description: '',
placeholder: '',
visible: true,
editable: true,
},
},
{
name: 'cover',
size: 6,
fieldSchema: {
type: 'media',
multiple: false,
required: false,
allowedTypes: ['files', 'images', 'videos'],
pluginOptions: { i18n: { localized: true } },
},
metadatas: {
label: 'Cover',
description: '',
placeholder: '',
visible: true,
editable: true,
},
},
],
[
{
name: 'images',
size: 6,
fieldSchema: {
type: 'media',
multiple: true,
required: false,
allowedTypes: ['images'],
pluginOptions: { i18n: { localized: true } },
},
metadatas: {
label: 'Images',
description: '',
placeholder: '',
visible: true,
editable: true,
},
},
{
name: 'city',
size: 6,
fieldSchema: {
type: 'string',
required: true,
maxLength: 200,
pluginOptions: { i18n: { localized: true } },
},
metadatas: {
label: 'City',
description: '',
placeholder: '',
visible: true,
editable: true,
},
},
],
[
{
name: 'json',
size: 12,
fieldSchema: { type: 'json', pluginOptions: { i18n: { localized: true } } },
metadatas: {
label: 'Json',
description: '',
placeholder: '',
visible: true,
editable: true,
},
},
],
[
{
name: 'slug',
size: 6,
fieldSchema: { type: 'uid', targetField: 'city' },
metadatas: {
label: 'Slug',
description: '',
placeholder: '',
visible: true,
editable: true,
},
},
],
[
{
name: 'notrepeat_req',
size: 12,
fieldSchema: {
type: 'component',
repeatable: false,
pluginOptions: { i18n: { localized: false } },
component: 'blog.test-como',
required: true,
},
metadatas: {
label: 'Notrepeat_req',
description: '',
placeholder: '',
visible: true,
editable: true,
},
},
],
[
{
name: 'repeat_req',
size: 12,
fieldSchema: {
type: 'component',
repeatable: true,
pluginOptions: { i18n: { localized: true } },
component: 'blog.test-como',
required: true,
},
metadatas: {
label: 'Repeat_req',
description: '',
placeholder: '',
visible: true,
editable: true,
},
},
],
[
{
name: 'repeat_req_min',
size: 12,
fieldSchema: {
type: 'component',
repeatable: true,
pluginOptions: { i18n: { localized: true } },
component: 'blog.test-como',
required: false,
min: 2,
},
metadatas: {
label: 'Repeat_req_min',
description: '',
placeholder: '',
visible: true,
editable: true,
},
},
],
],
editRelations: [
{
name: 'categories',
size: 6,
fieldSchema: {
collection: 'category',
via: 'addresses',
dominant: true,
attribute: 'category',
column: 'id',
isVirtual: true,
type: 'relation',
targetModel: 'application::category.category',
relationType: 'manyToMany',
},
metadatas: {
label: 'Categories',
description: '',
placeholder: '',
visible: true,
editable: true,
mainField: { name: 'name', schema: { type: 'string' } },
},
queryInfos: {
endPoint: '/content-manager/relations/application::address.address/categories',
containsKey: 'name_contains',
defaultParams: {},
shouldDisplayRelationLink: true,
},
targetModelPluginOptions: {},
},
{
name: 'likes',
size: 6,
fieldSchema: {
collection: 'like',
via: 'address',
isVirtual: true,
type: 'relation',
targetModel: 'application::like.like',
relationType: 'oneToMany',
},
metadatas: {
label: 'Likes',
description: '',
placeholder: '',
visible: true,
editable: true,
mainField: { name: 'id', schema: { type: 'integer' } },
},
queryInfos: {
endPoint: '/content-manager/relations/application::address.address/likes',
containsKey: 'id_contains',
defaultParams: {},
shouldDisplayRelationLink: true,
},
targetModelPluginOptions: {},
},
],
},
isDisplayed: true,
apiID: 'address',
kind: 'collectionType',
info: { name: 'address', description: '', label: 'Addresses' },
options: {
draftAndPublish: true,
increments: true,
timestamps: ['created_at', 'updated_at'],
comment: '',
},
pluginOptions: { i18n: { localized: true } },
attributes: {
id: { type: 'integer' },
postal_coder: { type: 'string', pluginOptions: { i18n: { localized: true } } },
categories: {
collection: 'category',
via: 'addresses',
dominant: true,
attribute: 'category',
column: 'id',
isVirtual: true,
type: 'relation',
targetModel: 'application::category.category',
relationType: 'manyToMany',
},
cover: {
type: 'media',
multiple: false,
required: false,
allowedTypes: ['files', 'images', 'videos'],
pluginOptions: { i18n: { localized: true } },
},
images: {
type: 'media',
multiple: true,
required: false,
allowedTypes: ['images'],
pluginOptions: { i18n: { localized: true } },
},
city: {
type: 'string',
required: true,
maxLength: 200,
pluginOptions: { i18n: { localized: true } },
},
likes: {
collection: 'like',
via: 'address',
isVirtual: true,
type: 'relation',
targetModel: 'application::like.like',
relationType: 'oneToMany',
},
json: { type: 'json', pluginOptions: { i18n: { localized: true } } },
slug: { type: 'uid', targetField: 'city' },
notrepeat_req: {
type: 'component',
repeatable: false,
pluginOptions: { i18n: { localized: false } },
component: 'blog.test-como',
required: true,
},
repeat_req: {
type: 'component',
repeatable: true,
pluginOptions: { i18n: { localized: true } },
component: 'blog.test-como',
required: true,
},
repeat_req_min: {
type: 'component',
repeatable: true,
pluginOptions: { i18n: { localized: true } },
component: 'blog.test-como',
required: false,
min: 2,
},
created_at: { type: 'timestamp' },
updated_at: { type: 'timestamp' },
},
};
module.exports = addressCT;

View File

@ -0,0 +1,101 @@
'use strict';
const addressMetaData = {
id: { edit: {}, list: { label: 'Id', searchable: true, sortable: true } },
postal_coder: {
edit: {
label: 'Postal_coder',
description: '',
placeholder: '',
visible: true,
editable: true,
},
list: { label: 'Postal_coder', searchable: true, sortable: true },
},
categories: {
list: {
label: 'Categories',
searchable: false,
sortable: false,
mainField: { name: 'name', schema: { type: 'string' } },
},
edit: {
label: 'Categories',
description: '',
placeholder: '',
visible: true,
editable: true,
mainField: { name: 'name', schema: { type: 'string' } },
},
},
cover: {
edit: { label: 'Cover', description: '', placeholder: '', visible: true, editable: true },
list: { label: 'Cover', searchable: false, sortable: false },
},
images: {
edit: { label: 'Images', description: '', placeholder: '', visible: true, editable: true },
list: { label: 'Images', searchable: false, sortable: false },
},
city: {
edit: { label: 'City', description: '', placeholder: '', visible: true, editable: true },
list: { label: 'City', searchable: true, sortable: true },
},
likes: {
list: {
label: 'Likes',
searchable: false,
sortable: false,
mainField: { name: 'id', schema: { type: 'integer' } },
},
edit: {
label: 'Likes',
description: '',
placeholder: '',
visible: true,
editable: true,
mainField: { name: 'id', schema: { type: 'integer' } },
},
},
json: {
edit: { label: 'Json', description: '', placeholder: '', visible: true, editable: true },
list: { label: 'Json', searchable: false, sortable: false },
},
slug: {
edit: { label: 'Slug', description: '', placeholder: '', visible: true, editable: true },
list: { label: 'Slug', searchable: true, sortable: true },
},
notrepeat_req: {
edit: {
label: 'Notrepeat_req',
description: '',
placeholder: '',
visible: true,
editable: true,
},
list: { label: 'Notrepeat_req', searchable: false, sortable: false },
},
repeat_req: {
edit: { label: 'Repeat_req', description: '', placeholder: '', visible: true, editable: true },
list: { label: 'Repeat_req', searchable: false, sortable: false },
},
repeat_req_min: {
edit: {
label: 'Repeat_req_min',
description: '',
placeholder: '',
visible: true,
editable: true,
},
list: { label: 'Repeat_req_min', searchable: false, sortable: false },
},
created_at: {
edit: { label: 'Created_at', description: '', placeholder: '', visible: false, editable: true },
list: { label: 'Created_at', searchable: true, sortable: true },
},
updated_at: {
edit: { label: 'Updated_at', description: '', placeholder: '', visible: false, editable: true },
list: { label: 'Updated_at', searchable: true, sortable: true },
},
};
module.exports = addressMetaData;

View File

@ -51,6 +51,8 @@ const AuthenticatedApp = () => {
return <div>error...</div>;
}
console.log('lol', permissions);
return (
<AppInfosContext.Provider
value={{ ...appInfos, latestStrapiReleaseTag: tag_name, shouldUpdateStrapi }}

View File

@ -54,9 +54,10 @@ const AttributeFilter = ({ contentType, slug, metaData }) => {
/**
* Pushing the filter in the URL for later refreshes or fast access
*/
const _where = query._where || [];
const actualQuery = query || {};
const _where = actualQuery._where || [];
_where.push(newFilter);
setQuery({ ...query, _where, page: 1 });
setQuery({ ...actualQuery, _where, page: 1 });
/**
* Tracking stuff

View File

@ -0,0 +1,372 @@
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import { BrowserRouter } from 'react-router-dom';
import AttributeFilter from '..';
import addressCt from '../../../../../../../../admin-test-utils/lib/fixtures/collectionTypes/address';
import addressMetaData from '../../../../../../../../admin-test-utils/lib/fixtures/metaData/address';
jest.mock('react-intl', () => ({
// eslint-disable-next-line react/prop-types
FormattedMessage: ({ id }) => <option value={id}>{id}</option>,
}));
jest.mock('@strapi/helper-plugin', () => ({
...jest.requireActual('@strapi/helper-plugin'),
useRBACProvider: () => ({
allPermissions: [
{
id: 198,
action: 'plugins::content-manager.explorer.create',
subject: 'application::address.address',
properties: {
fields: [
'postal_coder',
'categories',
'cover',
'images',
'city',
'likes',
'json',
'slug',
'notrepeat_req.name',
'repeat_req.name',
'repeat_req_min.name',
],
locales: ['en'],
},
conditions: [],
},
{
id: 199,
action: 'plugins::content-manager.explorer.read',
subject: 'application::address.address',
properties: {
fields: [
'postal_coder',
'categories',
'cover',
'images',
'city',
'likes',
'json',
'slug',
'notrepeat_req.name',
'repeat_req.name',
'repeat_req_min.name',
],
locales: ['en'],
},
conditions: [],
},
{
id: 200,
action: 'plugins::content-manager.explorer.update',
subject: 'application::address.address',
properties: {
fields: [
'postal_coder',
'categories',
'cover',
'images',
'city',
'likes',
'json',
'slug',
'notrepeat_req.name',
'repeat_req.name',
'repeat_req_min.name',
],
locales: ['en'],
},
conditions: [],
},
{
id: 258,
action: 'plugins::content-manager.explorer.delete',
subject: 'application::address.address',
properties: { locales: ['en'] },
conditions: [],
},
{
id: 269,
action: 'plugins::content-manager.explorer.publish',
subject: 'application::address.address',
properties: { locales: ['en'] },
conditions: [],
},
],
}),
}));
const renderComponent = () =>
render(
<BrowserRouter>
<AttributeFilter
contentType={addressCt}
metaData={addressMetaData}
slug="application::address.address"
/>
</BrowserRouter>
);
describe('AttributeFilter', () => {
it('snapshots the filter dropdown with a set of valid fields', () => {
const { container } = renderComponent();
expect(container.querySelector('#ct-filter')).toMatchInlineSnapshot(`
.c0 {
width: 100%;
height: 3.4rem;
padding: 0 1rem;
font-weight: 400;
font-size: 1.3rem;
cursor: pointer;
outline: 0;
border: 1px solid #E3E9F3;
border-radius: 2px;
color: #333740;
background-color: #ffffff;
padding-right: 30px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjMiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNLjAxOCAwaDIwYTIgMiAwIDAgMSAyIDJ2MjhhMiAyIDAgMCAxLTIgMmgtMjBWMHoiIGZpbGw9IiNGQUZBRkIiLz48ZyBmaWxsLXJ1bGU9Im5vbnplcm8iIGZpbGw9IiNCM0I1QjkiPjxwYXRoIGQ9Ik0xNC4wMTggMTguMzc1YS4zNi4zNiAwIDAgMS0uMTEyLjI2NGwtMi42MjUgMi42MjVhLjM2LjM2IDAgMCAxLS4yNjMuMTExLjM2LjM2IDAgMCAxLS4yNjQtLjExMWwtMi42MjUtMi42MjVhLjM2LjM2IDAgMCAxLS4xMTEtLjI2NC4zNi4zNiAwIDAgMSAuMTExLS4yNjQuMzYuMzYgMCAwIDEgLjI2NC0uMTExaDUuMjVhLjM2LjM2IDAgMCAxIC4yNjMuMTExLjM2LjM2IDAgMCAxIC4xMTIuMjY0ek04LjAxOCAxNWEuMzYuMzYgMCAwIDEgLjExMS0uMjY0bDIuNjI1LTIuNjI1YS4zNi4zNiAwIDAgMSAuMjY0LS4xMTEuMzYuMzYgMCAwIDEgLjI2My4xMTFsMi42MjUgMi42MjVhLjM2LjM2IDAgMCAxIC4xMTIuMjY0LjM2LjM2IDAgMCAxLS4xMTIuMjY0LjM2LjM2IDAgMCAxLS4yNjMuMTExaC01LjI1YS4zNi4zNiAwIDAgMS0uMjY0LS4xMTEuMzYuMzYgMCAwIDEtLjExMS0uMjY0eiIvPjwvZz48L2c+PC9zdmc+Cg==);
background-repeat: no-repeat;
background-position: right;
}
.c0::-webkit-input-placeholder {
color: #919BAE;
}
.c0:focus {
border-color: #78caff;
}
.c0:disabled {
background-color: #FAFAFB;
cursor: not-allowed;
color: #9ea7b8;
opacity: 1;
}
<select
autocomplete="off"
class="c0"
id="ct-filter"
name="ct-filter"
tabindex="0"
>
<option
value="categories"
>
categories
</option>
<option
value="city"
>
city
</option>
<option
value="created_at"
>
created_at
</option>
<option
value="id"
>
id
</option>
<option
value="likes"
>
likes
</option>
<option
value="postal_coder"
>
postal_coder
</option>
<option
value="slug"
>
slug
</option>
<option
value="updated_at"
>
updated_at
</option>
</select>
`);
});
it('snapshots the comparator dropdown with a set of valid comparator for the type', () => {
const { container } = renderComponent();
expect(container.querySelector('#comparator')).toMatchInlineSnapshot(`
.c0 {
width: 100%;
height: 3.4rem;
padding: 0 1rem;
font-weight: 400;
font-size: 1.3rem;
cursor: pointer;
outline: 0;
border: 1px solid #E3E9F3;
border-radius: 2px;
color: #333740;
background-color: #ffffff;
padding-right: 30px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjMiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNLjAxOCAwaDIwYTIgMiAwIDAgMSAyIDJ2MjhhMiAyIDAgMCAxLTIgMmgtMjBWMHoiIGZpbGw9IiNGQUZBRkIiLz48ZyBmaWxsLXJ1bGU9Im5vbnplcm8iIGZpbGw9IiNCM0I1QjkiPjxwYXRoIGQ9Ik0xNC4wMTggMTguMzc1YS4zNi4zNiAwIDAgMS0uMTEyLjI2NGwtMi42MjUgMi42MjVhLjM2LjM2IDAgMCAxLS4yNjMuMTExLjM2LjM2IDAgMCAxLS4yNjQtLjExMWwtMi42MjUtMi42MjVhLjM2LjM2IDAgMCAxLS4xMTEtLjI2NC4zNi4zNiAwIDAgMSAuMTExLS4yNjQuMzYuMzYgMCAwIDEgLjI2NC0uMTExaDUuMjVhLjM2LjM2IDAgMCAxIC4yNjMuMTExLjM2LjM2IDAgMCAxIC4xMTIuMjY0ek04LjAxOCAxNWEuMzYuMzYgMCAwIDEgLjExMS0uMjY0bDIuNjI1LTIuNjI1YS4zNi4zNiAwIDAgMSAuMjY0LS4xMTEuMzYuMzYgMCAwIDEgLjI2My4xMTFsMi42MjUgMi42MjVhLjM2LjM2IDAgMCAxIC4xMTIuMjY0LjM2LjM2IDAgMCAxLS4xMTIuMjY0LjM2LjM2IDAgMCAxLS4yNjMuMTExaC01LjI1YS4zNi4zNiAwIDAgMS0uMjY0LS4xMTEuMzYuMzYgMCAwIDEtLjExMS0uMjY0eiIvPjwvZz48L2c+PC9zdmc+Cg==);
background-repeat: no-repeat;
background-position: right;
}
.c0::-webkit-input-placeholder {
color: #919BAE;
}
.c0:focus {
border-color: #78caff;
}
.c0:disabled {
background-color: #FAFAFB;
cursor: not-allowed;
color: #9ea7b8;
opacity: 1;
}
<select
autocomplete="off"
class="c0"
id="comparator"
name="comparator"
tabindex="0"
>
<option
value="components.FilterOptions.FILTER_TYPES.="
>
components.FilterOptions.FILTER_TYPES.=
</option>
<option
value="components.FilterOptions.FILTER_TYPES._ne"
>
components.FilterOptions.FILTER_TYPES._ne
</option>
<option
value="components.FilterOptions.FILTER_TYPES._lt"
>
components.FilterOptions.FILTER_TYPES._lt
</option>
<option
value="components.FilterOptions.FILTER_TYPES._lte"
>
components.FilterOptions.FILTER_TYPES._lte
</option>
<option
value="components.FilterOptions.FILTER_TYPES._gt"
>
components.FilterOptions.FILTER_TYPES._gt
</option>
<option
value="components.FilterOptions.FILTER_TYPES._gte"
>
components.FilterOptions.FILTER_TYPES._gte
</option>
<option
value="components.FilterOptions.FILTER_TYPES._contains"
>
components.FilterOptions.FILTER_TYPES._contains
</option>
<option
value="components.FilterOptions.FILTER_TYPES._containss"
>
components.FilterOptions.FILTER_TYPES._containss
</option>
</select>
`);
});
it('changes the input component when selecting an attribute with a different type', () => {
const { container } = renderComponent();
fireEvent.change(container.querySelector('#ct-filter'), { target: { value: 'updated_at' } });
expect(container.querySelector('#date')).toMatchInlineSnapshot(`
.c0 {
width: 100%;
height: 3.4rem;
padding: 0 1rem;
font-weight: 400;
font-size: 1.3rem;
cursor: text;
outline: 0;
border: 1px solid #E3E9F3;
border-radius: 2px;
color: #333740;
background-color: transparent;
padding-left: calc(3.4rem + 1rem);
}
.c0::-webkit-input-placeholder {
color: #919BAE;
}
.c0:focus {
border-color: #78caff;
}
.c0:disabled {
background-color: #FAFAFB;
cursor: not-allowed;
color: #9ea7b8;
}
<input
autocomplete="off"
class="c0"
id="date"
name="start_date"
tabindex="0"
type="text"
value="June 29, 2021"
/>
`);
});
it('pushes the query in the URl when validating the filter form using the "equal comparator"', () => {
const { container } = renderComponent();
fireEvent.change(container.querySelector('#input'), { target: { value: 'hello world' } });
fireEvent.click(container.querySelector('[type="submit"]'));
expect(window.location.href).toBe(
'http://localhost:4000/admin?_where[0][categories.name]=hello%20world&page=1'
);
});
it('pushes the query in the URl when validating the filter form using the "not equal comparator"', () => {
const { container } = renderComponent();
fireEvent.change(container.querySelector('#comparator'), {
target: { value: 'components.FilterOptions.FILTER_TYPES._ne' },
});
fireEvent.change(container.querySelector('#input'), { target: { value: 'hello world' } });
fireEvent.click(container.querySelector('[type="submit"]'));
expect(window.location.href).toBe(
'http://localhost:4000/admin?_where[0][categories.name]=hello%20world&_where[1][categories.namecomponents.FilterOptions.FILTER_TYPES._ne]=hello%20world&page=1'
);
});
});