-
Notifications
You must be signed in to change notification settings - Fork 1
/
TaxonomyFilter.test.js
112 lines (103 loc) · 3.42 KB
/
TaxonomyFilter.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* global cy, describe, it, expect */
describe("TaxonomyFilter", function() {
it("Correctly filters rows", function() {
const route = "metabolite";
const entity = "dTDP-D-Glucose";
const organism = "Escherichia coli";
const url = "/" + route + "/" + entity + "/" + organism;
const dataContainerId = "concentration";
//use fixture with taxon_distance always = 1
cy.server();
cy.fixture("metabolite-concentrations-" + entity).then(json => {
cy.route({
method: "GET",
url: "/metabolites/concentration/?metabolite=" + entity + "&*",
status: 200,
response: json
});
});
cy.visit(url);
// open all colums including the taxonomic distance column
cy.get("#" + dataContainerId + " .biochemical-entity-data-table-tool-panel")
.eq(0)
.click();
cy.get(
"#" +
dataContainerId +
" .biochemical-entity-scene-columns-tool-panel input"
).each($input => {
cy.wrap($input).check({ force: true });
});
// open filters tool panel and open all filters, including the taxonomy distance filter
cy.get("#" + dataContainerId + " .biochemical-entity-data-table-tool-panel")
.eq(1)
.click();
cy.get(
"#" + dataContainerId + " .biochemical-entity-scene-filter-container"
).each($filter => {
cy.wrap($filter).click();
});
// change the value of the filter to the maximum
cy.get(
"#" +
dataContainerId +
" .biochemical-entity-scene-taxonomy-slider-filter input"
).should("not.have.attr", "value", "0");
cy.get(
"#" +
dataContainerId +
" .biochemical-entity-scene-taxonomy-slider-filter .MuiSlider-thumb"
)
.trigger("mousedown", { which: 1 })
.trigger("mousemove", { clientX: 0, clientY: 1e6 })
.trigger("mouseup", { force: true });
cy.get(
"#" +
dataContainerId +
" .biochemical-entity-scene-taxonomy-slider-filter input"
).should("have.attr", "value", "0");
// check that rows were filtered
cy.get("#" + dataContainerId + " .ag-center-cols-container")
.children()
.should("have.length", 0);
cy.get("#" + dataContainerId + " .ag-root-wrapper").then($grid => {
expect(
$grid[0].__agComponent.gridApi.getFilterModel().taxonomicProximity
.selectedMarkValue
).to.equal(0);
});
// programmatically reset filter so all rows are displayed
cy.get("#" + dataContainerId + " .ag-root-wrapper").then($grid => {
$grid[0].__agComponent.gridApi.setFilterModel({
taxonomicProximity: null
});
});
cy.get("#" + dataContainerId + " .ag-center-cols-container")
.children()
.should("not.have.length", 0);
// programmatically set filter so no rows are displayed
cy.get("#" + dataContainerId + " .ag-root-wrapper").then($grid => {
$grid[0].__agComponent.gridApi.setFilterModel({
taxonomicProximity: {
selectedMarkValue: 0,
markValueToDistance: Array(7)
.fill()
.map((x, i) => i),
rankNameToDistance: {
species: 0,
genus: 1,
family: 2,
order: 3,
class: 4,
phylum: 5,
superkingdom: 6,
"cellular life": 7
}
}
});
});
cy.get("#" + dataContainerId + " .ag-center-cols-container")
.children()
.should("have.length", 0);
});
});