|
|
@@ -4,7 +4,7 @@ import gql from 'graphql-tag';
|
|
|
import path from 'path';
|
|
|
|
|
|
import { initialData } from '../../../e2e-common/e2e-initial-data';
|
|
|
-import { TEST_SETUP_TIMEOUT_MS, testConfig } from '../../../e2e-common/test-config';
|
|
|
+import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
|
|
|
|
|
|
import { ListQueryPlugin } from './fixtures/test-plugins/list-query-plugin';
|
|
|
import { fixPostgresTimezone } from './utils/fix-pg-timezone';
|
|
|
@@ -35,6 +35,141 @@ describe('ListQueryBuilder', () => {
|
|
|
return items.map((x: any) => x.label).sort();
|
|
|
}
|
|
|
|
|
|
+ describe('string filtering', () => {
|
|
|
+ it('eq', async () => {
|
|
|
+ const { testEntities } = await adminClient.query(GET_LIST, {
|
|
|
+ options: {
|
|
|
+ filter: {
|
|
|
+ label: {
|
|
|
+ eq: 'B',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(getItemLabels(testEntities.items)).toEqual(['B']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('contains', async () => {
|
|
|
+ const { testEntities } = await adminClient.query(GET_LIST, {
|
|
|
+ options: {
|
|
|
+ filter: {
|
|
|
+ description: {
|
|
|
+ contains: 'adip',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(getItemLabels(testEntities.items)).toEqual(['C']);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('boolean filtering', () => {
|
|
|
+ it('eq', async () => {
|
|
|
+ const { testEntities } = await adminClient.query(GET_LIST, {
|
|
|
+ options: {
|
|
|
+ filter: {
|
|
|
+ active: {
|
|
|
+ eq: false,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(getItemLabels(testEntities.items)).toEqual(['C', 'E']);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('number filtering', () => {
|
|
|
+ it('eq', async () => {
|
|
|
+ const { testEntities } = await adminClient.query(GET_LIST, {
|
|
|
+ options: {
|
|
|
+ filter: {
|
|
|
+ order: {
|
|
|
+ eq: 1,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(getItemLabels(testEntities.items)).toEqual(['B']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('lt', async () => {
|
|
|
+ const { testEntities } = await adminClient.query(GET_LIST, {
|
|
|
+ options: {
|
|
|
+ filter: {
|
|
|
+ order: {
|
|
|
+ lt: 1,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(getItemLabels(testEntities.items)).toEqual(['A']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('lte', async () => {
|
|
|
+ const { testEntities } = await adminClient.query(GET_LIST, {
|
|
|
+ options: {
|
|
|
+ filter: {
|
|
|
+ order: {
|
|
|
+ lte: 1,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(getItemLabels(testEntities.items)).toEqual(['A', 'B']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('gt', async () => {
|
|
|
+ const { testEntities } = await adminClient.query(GET_LIST, {
|
|
|
+ options: {
|
|
|
+ filter: {
|
|
|
+ order: {
|
|
|
+ gt: 1,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(getItemLabels(testEntities.items)).toEqual(['C', 'D', 'E']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('gte', async () => {
|
|
|
+ const { testEntities } = await adminClient.query(GET_LIST, {
|
|
|
+ options: {
|
|
|
+ filter: {
|
|
|
+ order: {
|
|
|
+ gte: 1,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(getItemLabels(testEntities.items)).toEqual(['B', 'C', 'D', 'E']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('between', async () => {
|
|
|
+ const { testEntities } = await adminClient.query(GET_LIST, {
|
|
|
+ options: {
|
|
|
+ filter: {
|
|
|
+ order: {
|
|
|
+ between: {
|
|
|
+ start: 2,
|
|
|
+ end: 4,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(getItemLabels(testEntities.items)).toEqual(['C', 'D', 'E']);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
describe('date filtering', () => {
|
|
|
it('before', async () => {
|
|
|
const { testEntities } = await adminClient.query(GET_LIST, {
|
|
|
@@ -75,7 +210,7 @@ describe('ListQueryBuilder', () => {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- expect(getItemLabels(testEntities.items)).toEqual(['C']);
|
|
|
+ expect(getItemLabels(testEntities.items)).toEqual(['C', 'D', 'E']);
|
|
|
});
|
|
|
|
|
|
it('after on same date', async () => {
|
|
|
@@ -89,7 +224,7 @@ describe('ListQueryBuilder', () => {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- expect(getItemLabels(testEntities.items)).toEqual(['C']);
|
|
|
+ expect(getItemLabels(testEntities.items)).toEqual(['C', 'D', 'E']);
|
|
|
});
|
|
|
|
|
|
it('between', async () => {
|