Skip to content
Snippets Groups Projects
Unverified Commit 37f9c8ed authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

[SQL filters coverage] Extract and apply SQL field filter data (#16893)

* Extract and apply SQL field filter data objects

* Refactor object key `term` -> `value`
parent f41e4eb6
Branches
Tags
No related merge requests found
export const STRING_FILTER_SUBTYPES = {
String: {
value: "Synergistic Granite Chair",
representativeResult: "Synergistic Granite Chair",
},
"String is not": {
value: "Synergistic Granite Chair",
representativeResult: "Rustic Paper Wallet",
},
"String contains": {
value: "Bronze",
representativeResult: "Incredible Bronze Pants",
},
"String does not contain": {
value: "Bronze",
representativeResult: "Rustic Paper Wallet",
},
"String starts with": {
value: "Rustic",
representativeResult: "Rustic Paper Wallet",
},
"String ends with": {
value: "Hat",
representativeResult: "Small Marble Hat",
},
};
export const NUMBER_FILTER_SUBTYPES = {
"Equal to": {
value: "4.3",
representativeResult: "Aerodynamic Linen Coat",
},
"Not equal to": {
value: "4.3",
representativeResult: "Rustic Paper Wallet",
},
Between: {
value: ["4.3", "5"],
representativeResult: "Rustic Paper Wallet",
},
"Greater than or equal to": {
value: "4.3",
representativeResult: "Rustic Paper Wallet",
},
"Less than or equal to": {
value: "4.3",
representativeResult: "Small Marble Shoes",
},
};
export const DATE_FILTER_SUBTYPES = {
"Month and Year": {
value: {
month: "September",
year: "2017",
},
representativeResult: "Durable Steel Toucan",
},
"Quarter and Year": {
value: {
quarter: "Q2",
year: "2017",
},
representativeResult: "Aerodynamic Linen Coat",
},
"Single Date": {
value: "15",
representativeResult: "No results!",
},
"Date Range": {
value: {
startDate: "13",
endDate: "15",
},
representativeResult: "No results!",
},
"Relative Date": {
value: "Past 7 days",
representativeResult: "No results!",
},
"Date Filter": {
value: {
timeBucket: "Years",
},
representativeResult: "Small Marble Shoes",
},
};
......@@ -4,48 +4,12 @@ import {
openNativeEditor,
} from "__support__/e2e/cypress";
import { DATE_FILTER_SUBTYPES } from "./helpers/e2e-field-filter-data-objects";
import * as SQLFilter from "./helpers/e2e-sql-filter-helpers";
import * as FieldFilter from "./helpers/e2e-field-filter-helpers";
import * as DateFilter from "./helpers/e2e-date-filter-helpers";
const DATE_FILTER_SUBTYPES = {
"Month and Year": {
value: {
month: "September",
year: "2017",
},
representativeResult: "Durable Steel Toucan",
},
"Quarter and Year": {
value: {
quarter: "Q2",
year: "2017",
},
representativeResult: "Aerodynamic Linen Coat",
},
"Single Date": {
value: "15",
representativeResult: "No results!",
},
"Date Range": {
value: {
startDate: "13",
endDate: "15",
},
representativeResult: "No results!",
},
"Relative Date": {
value: "Past 7 days",
representativeResult: "No results!",
},
"Date Filter": {
value: {
timeBucket: "Years",
},
representativeResult: "Small Marble Shoes",
},
};
describe("scenarios > filters > sql filters > field filter > Date", () => {
beforeEach(() => {
restore();
......
......@@ -4,32 +4,11 @@ import {
openNativeEditor,
} from "__support__/e2e/cypress";
import { NUMBER_FILTER_SUBTYPES } from "./helpers/e2e-field-filter-data-objects";
import * as SQLFilter from "./helpers/e2e-sql-filter-helpers";
import * as FieldFilter from "./helpers/e2e-field-filter-helpers";
const NUMBER_FILTER_SUBTYPES = {
"Equal to": {
term: "4.3",
representativeResult: "Aerodynamic Linen Coat",
},
"Not equal to": {
term: "4.3",
representativeResult: "Rustic Paper Wallet",
},
Between: {
term: ["4.3", "5"],
representativeResult: "Rustic Paper Wallet",
},
"Greater than or equal to": {
term: "4.3",
representativeResult: "Rustic Paper Wallet",
},
"Less than or equal to": {
term: "4.3",
representativeResult: "Small Marble Shoes",
},
};
describe("scenarios > filters > sql filters > field filter > Number", () => {
beforeEach(() => {
restore();
......@@ -54,13 +33,13 @@ describe("scenarios > filters > sql filters > field filter > Number", () => {
});
Object.entries(NUMBER_FILTER_SUBTYPES).forEach(
([subType, { term, representativeResult }]) => {
([subType, { value, representativeResult }]) => {
describe(`should work for ${subType}`, () => {
it("when set through the filter widget", () => {
FieldFilter.setWidgetType(subType);
FieldFilter.openEntryForm();
FieldFilter.addWidgetNumberFilter(term);
FieldFilter.addWidgetNumberFilter(value);
SQLFilter.runQuery();
......@@ -75,7 +54,7 @@ describe("scenarios > filters > sql filters > field filter > Number", () => {
SQLFilter.toggleRequired();
FieldFilter.openEntryForm({ isFilterRequired: true });
FieldFilter.addDefaultNumberFilter(term);
FieldFilter.addDefaultNumberFilter(value);
SQLFilter.runQuery();
......
......@@ -4,36 +4,11 @@ import {
openNativeEditor,
} from "__support__/e2e/cypress";
import { STRING_FILTER_SUBTYPES } from "./helpers/e2e-field-filter-data-objects";
import * as SQLFilter from "./helpers/e2e-sql-filter-helpers";
import * as FieldFilter from "./helpers/e2e-field-filter-helpers";
const STRING_FILTER_SUBTYPES = {
String: {
term: "Synergistic Granite Chair",
representativeResult: "Synergistic Granite Chair",
},
"String is not": {
term: "Synergistic Granite Chair",
representativeResult: "Rustic Paper Wallet",
},
"String contains": {
term: "Bronze",
representativeResult: "Incredible Bronze Pants",
},
"String does not contain": {
term: "Bronze",
representativeResult: "Rustic Paper Wallet",
},
"String starts with": {
term: "Rustic",
representativeResult: "Rustic Paper Wallet",
},
"String ends with": {
term: "Hat",
representativeResult: "Small Marble Hat",
},
};
describe("scenarios > filters > sql filters > field filter > String", () => {
beforeEach(() => {
restore();
......@@ -58,13 +33,13 @@ describe("scenarios > filters > sql filters > field filter > String", () => {
});
Object.entries(STRING_FILTER_SUBTYPES).forEach(
([subType, { term, representativeResult }]) => {
([subType, { value, representativeResult }]) => {
describe(`should work for ${subType}`, () => {
it("when set through the filter widget", () => {
FieldFilter.setWidgetType(subType);
FieldFilter.openEntryForm();
FieldFilter.addWidgetStringFilter(term);
FieldFilter.addWidgetStringFilter(value);
SQLFilter.runQuery();
......@@ -79,7 +54,7 @@ describe("scenarios > filters > sql filters > field filter > String", () => {
SQLFilter.toggleRequired();
FieldFilter.openEntryForm({ isFilterRequired: true });
FieldFilter.addDefaultStringFilter(term);
FieldFilter.addDefaultStringFilter(value);
SQLFilter.runQuery();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment