1+ import * as CONST from "../../../src/cypress.constants"
2+ import { IconBarConfig } from "../../../src/components/constants"
3+ import { EXAMPLES_PRODUCTS } from "../../../src/routing/constants"
4+ const teamName = Cypress . env ( 'TEAM_NAME' )
5+ const dataProduct = "star_wars"
6+
7+ describe ( `Test Advanced Filters in document explorer` , ( ) => {
8+ const dashboard = Cypress . config ( ) . baseUrl
9+
10+ /** add this statement to stop cypress form complaining
11+ * about react-leaflet being used in terminusdb-document-ui */
12+ Cypress . on ( 'uncaught:exception' , ( err , runnable ) => {
13+ return false ;
14+ } ) ;
15+
16+ // visit dashboard-dev at the start
17+ before ( function ( ) {
18+ cy . visit ( dashboard )
19+ } ) ;
20+
21+ // login to terminusdb
22+ it ( 'Check to see that you can login with an exists user' , ( ) => {
23+ cy . userLogin ( )
24+ } )
25+
26+ // select Terminusdb_demo team
27+ it ( 'Select Team' , ( ) => {
28+ cy . selectTeam ( teamName )
29+ } )
30+
31+ //Clone Starwars team
32+ it ( 'Clone Starwars team' , ( ) => {
33+ cy . intercept ( `/${ teamName } /${ dataProduct } ` ) . as ( 'cloaning' )
34+ cy . get ( `button[data-cy=${ CONST . CLONE_BUTTON } _${ dataProduct } ]` ) . should ( 'exist' ) . click ( ) ;
35+ cy . wait ( '@cloaning' )
36+ } )
37+
38+ // Go to Document Explorer
39+ it ( "Go to Document Explorer" , ( ) => {
40+ cy . visit ( `/CYPRESS_TEST_TEAM/star_wars` )
41+ cy . get ( `a[data-cy=${ IconBarConfig . documentExplorer . key } ]` ) . should ( 'exist' ) . click ( ) ;
42+ } )
43+
44+ // Click on People to view documents of type People
45+ // Go to Document Explorer
46+ it ( "Go to Document Explorer and Click on People to view documents of type People" , ( ) => {
47+ cy . get ( `button[id="People"]` ) . should ( 'exist' ) . click ( ) ;
48+ cy . wait ( 1000 )
49+ } )
50+
51+ // Click on Advanced filter and add rule
52+ it ( "Click on Advanced filter and add rule" , ( ) => {
53+ cy . get ( `h2[data-cy="Advanced filter"]` ) . should ( 'exist' ) . click ( ) ;
54+ cy . get ( "button" ) . contains ( "Add rule" ) . should ( 'exist' ) . click ( ) ;
55+ } )
56+
57+ // Advanced filter - contains
58+ it ( "Test Advanced filter - contains Skywalker & should filter out three results" , ( ) => {
59+ cy . get ( `.rule--field select` ) . should ( 'exist' ) . select ( 'label' )
60+ cy . get ( `.rule--operator select` ) . should ( 'exist' ) . select ( 'Contains' )
61+ cy . get ( `.widget--widget input` ) . should ( 'exist' ) . type ( 'Skywalker' )
62+ cy . get ( "button" ) . contains ( "Filter Data" ) . should ( 'exist' ) . click ( ) ;
63+ cy . get ( `span[data-cy="Luke Skywalker"]` ) . contains ( "Luke Skywalker" ) . should ( 'exist' )
64+ cy . get ( `span[data-cy="Anakin Skywalker"]` ) . contains ( "Anakin Skywalker" ) . should ( 'exist' )
65+ cy . get ( `span[data-cy="Shmi Skywalker"]` ) . contains ( "Shmi Skywalker" ) . should ( 'exist' )
66+ cy . get ( "table tbody" ) . find ( "tr" ) . then ( ( row ) => {
67+ expect ( row . length ) . eq ( 3 )
68+ } ) ;
69+ } )
70+
71+ // Advanced filter - Equals
72+ it ( "Test Advanced filter - Equals to Luke Skywalker & should filter one result" , ( ) => {
73+ cy . get ( `.rule--field select` ) . should ( 'exist' ) . select ( 'label' )
74+ cy . get ( `.rule--operator select` ) . should ( 'exist' ) . select ( '==' )
75+ cy . get ( `.widget--widget input` ) . should ( 'exist' ) . clear ( )
76+ cy . get ( `.widget--widget input` ) . type ( 'Luke Skywalker' )
77+ cy . get ( "button" ) . contains ( "Filter Data" ) . should ( 'exist' ) . click ( ) ;
78+ cy . get ( `span[data-cy="Luke Skywalker"]` ) . contains ( "Luke Skywalker" ) . should ( 'exist' )
79+ cy . get ( "table tbody" ) . find ( "tr" ) . then ( ( row ) => {
80+ expect ( row . length ) . eq ( 1 )
81+ } ) ;
82+ } )
83+
84+ // Group filter - mixed parameters
85+ it ( "Test Group filter - mixed parameters Name contains Skywalker | eye_color is blue" , ( ) => {
86+ cy . get ( `.rule--field select` ) . should ( 'exist' ) . select ( 'label' )
87+ cy . get ( `.rule--operator select` ) . should ( 'exist' ) . select ( 'Contains' )
88+ cy . get ( `.widget--widget input` ) . should ( 'exist' ) . clear ( )
89+ cy . get ( `.widget--widget input` ) . type ( 'Skywalker' )
90+ cy . get ( "button" ) . contains ( "Filter Data" ) . should ( 'exist' ) . click ( ) ;
91+ cy . get ( "table tbody" ) . find ( "tr" ) . then ( ( row ) => {
92+ expect ( row . length ) . eq ( 3 )
93+ } ) ;
94+ // add a group
95+ cy . get ( "button" ) . contains ( "Add group" ) . should ( 'exist' ) . click ( ) ;
96+ cy . get ( '.one--child .rule--field select' ) . should ( 'exist' ) . select ( 'eye_color' )
97+ cy . get ( `.one--child .widget--widget input` ) . type ( 'blue' )
98+ cy . get ( "button" ) . contains ( "Filter Data" ) . should ( 'exist' ) . click ( ) ;
99+ // Shmi Skywalker does not have blue eye
100+ cy . get ( `span` ) . contains ( "Shmi Skywalker" ) . should ( 'not.exist' )
101+ cy . get ( "table tbody" ) . find ( "tr" ) . then ( ( row ) => {
102+ expect ( row . length ) . eq ( 2 )
103+ } ) ;
104+ } )
105+
106+ // Go to Document Explorer
107+ it ( "Go to Document Explorer" , ( ) => {
108+ cy . get ( `a[data-cy=${ IconBarConfig . documentExplorer . key } ]` ) . should ( 'exist' ) . click ( ) ;
109+ } )
110+
111+ // Click on People to view documents of type People
112+ // Go to Document Explorer
113+ it ( "Go to Document Explorer and Click on People to view documents of type People" , ( ) => {
114+ cy . get ( `button[id="People"]` ) . should ( 'exist' ) . click ( ) ;
115+ cy . wait ( 1000 )
116+ } )
117+
118+ // Click on Advanced filter and add rule
119+ it ( "Click on Advanced filter and add rule" , ( ) => {
120+ cy . get ( `h2[data-cy="Advanced filter"]` ) . should ( 'exist' ) . click ( ) ;
121+ cy . get ( "button" ) . contains ( "Add rule" ) . should ( 'exist' ) . click ( ) ;
122+ } )
123+
124+ // And Filter
125+ it ( "And filter - Name contains Skywalker AND gender is female" , ( ) => {
126+
127+ cy . get ( `.rule--field select` ) . should ( 'exist' ) . select ( 'label' )
128+ cy . get ( `.rule--operator select` ) . should ( 'exist' ) . select ( 'Contains' )
129+ cy . get ( `.widget--widget input` ) . should ( 'exist' ) . clear ( )
130+ cy . get ( `.widget--widget input` ) . type ( 'Skywalker' )
131+ cy . get ( "button" ) . contains ( "Filter Data" ) . should ( 'exist' ) . click ( ) ;
132+ cy . get ( "table tbody" ) . find ( "tr" ) . then ( ( row ) => {
133+ expect ( row . length ) . eq ( 3 )
134+ } ) ;
135+ // add a group
136+ cy . get ( "button" ) . contains ( "Add rule" ) . should ( 'exist' ) . click ( ) ;
137+ cy . get ( '.rule--field select' ) . last ( ) . should ( 'exist' ) . select ( 'gender' )
138+ cy . get ( `.widget--widget input` ) . last ( ) . type ( 'female' )
139+ cy . get ( "button" ) . contains ( "Filter Data" ) . should ( 'exist' ) . click ( ) ;
140+ // Shmi Skywalker should be the only female
141+ cy . get ( `span[data-cy="Shmi Skywalker"]` ) . contains ( "Shmi Skywalker" ) . should ( 'exist' )
142+ cy . get ( "table tbody" ) . find ( "tr" ) . then ( ( row ) => {
143+ expect ( row . length ) . eq ( 1 )
144+ } ) ;
145+ } )
146+
147+ // Or Filter
148+ it ( "Or filter - Name contains Skywalker OR gender is female" , ( ) => {
149+ cy . get ( `input[value="OR"]` ) . should ( 'exist' ) . click ( ) ;
150+ cy . get ( "button" ) . contains ( "Filter Data" ) . should ( 'exist' ) . click ( ) ;
151+ cy . wait ( 1000 )
152+ cy . get ( "table tbody" ) . find ( "tr" ) . then ( ( row ) => {
153+ expect ( row . length ) . not . eq ( 3 )
154+ } ) ;
155+ } )
156+
157+ // Go to Document Explorer
158+ it ( "Go to Document Explorer" , ( ) => {
159+ cy . get ( `a[data-cy=${ IconBarConfig . documentExplorer . key } ]` ) . should ( 'exist' ) . click ( ) ;
160+ } )
161+
162+ // Click on People to view documents of type People
163+ // Go to Document Explorer
164+ it ( "Go to Document Explorer and Click on People to view documents of type People" , ( ) => {
165+ cy . get ( `button[id="People"]` ) . should ( 'exist' ) . click ( ) ;
166+ } )
167+
168+ // Click on Advanced filter and add rule
169+ it ( "Click on Advanced filter and add rule" , ( ) => {
170+ cy . get ( `h2[data-cy="Advanced filter"]` ) . should ( 'exist' ) . click ( ) ;
171+ cy . get ( "button" ) . contains ( "Add rule" ) . should ( 'exist' ) . click ( ) ;
172+ } )
173+
174+
175+ // Not Filter
176+ it ( "Not filter - eye color is NOT blue" , ( ) => {
177+
178+
179+ cy . get ( `.rule--field select` ) . should ( 'exist' ) . select ( 'eye_color' )
180+ cy . get ( `.rule--operator select` ) . should ( 'exist' ) . select ( '==' )
181+ cy . get ( `.widget--widget input` ) . should ( 'exist' ) . clear ( )
182+ cy . get ( `.widget--widget input` ) . type ( 'blue' )
183+ cy . get ( `input[type="checkbox"]` ) . should ( 'exist' ) . click ( ) ;
184+ cy . get ( "button" ) . contains ( "Filter Data" ) . should ( 'exist' ) . click ( ) ;
185+ cy . get ( `span` ) . contains ( "brown" ) . should ( 'not.exist' )
186+ } )
187+
188+
189+
190+ // Go to Document Explorer
191+ it ( "Go to Document Explorer" , ( ) => {
192+ cy . get ( `a[data-cy=${ IconBarConfig . documentExplorer . key } ]` ) . should ( 'exist' ) . click ( ) ;
193+ } )
194+
195+ // Click on People to view documents of type Film
196+ // Go to Document Explorer
197+ it ( "Go to Document Explorer and Click on Film to view documents of type Films" , ( ) => {
198+ cy . get ( `button[id="Film"]` ) . should ( 'exist' ) . click ( ) ;
199+ cy . wait ( 1000 )
200+ } )
201+
202+ // Click on Advanced filter and add rule
203+ it ( "Click on Advanced filter and add rule" , ( ) => {
204+ cy . get ( `h2[data-cy="Advanced filter"]` ) . should ( 'exist' ) . click ( ) ;
205+ cy . get ( "button" ) . contains ( "Add rule" ) . should ( 'exist' ) . click ( ) ;
206+ } )
207+
208+ // Advanced filter - Does Not Equal Attack of the Clones
209+ it ( "Test Advanced filter - Does Not Equal to Attack of the Clones & should filter 6 results" , ( ) => {
210+ cy . get ( `.rule--field select` ) . should ( 'exist' ) . select ( 'label' )
211+ cy . get ( `.rule--operator select` ) . should ( 'exist' ) . select ( '!=' )
212+ cy . get ( `.widget--widget input` ) . should ( 'exist' ) . type ( 'Attack of the Clones' )
213+ cy . get ( "button" ) . contains ( "Filter Data" ) . should ( 'exist' ) . click ( ) ;
214+ cy . get ( `span` ) . contains ( "Attack of the Clones" ) . should ( 'not.exist' )
215+ cy . get ( "table tbody" ) . find ( "tr" ) . then ( ( row ) => {
216+ expect ( row . length ) . eq ( 6 )
217+ } ) ;
218+ } )
219+
220+ // Go to Document Explorer
221+ it ( "Go to Document Explorer" , ( ) => {
222+ cy . get ( `a[data-cy=${ IconBarConfig . documentExplorer . key } ]` ) . should ( 'exist' ) . click ( ) ;
223+ } )
224+
225+ // Click on People to view documents of type People
226+ // Go to Document Explorer
227+ it ( "Go to Document Explorer and Click on People to view documents of type People" , ( ) => {
228+ cy . get ( `button[id="People"]` ) . should ( 'exist' ) . click ( ) ;
229+ } )
230+
231+ // Regex filter from table
232+ it ( "Test Advanced filter - Regex filter from table - search for Sky in label & height 188" , ( ) => {
233+ /*cy.get(`input[data-cy="label"]`).focus().type('sky{enter}')
234+ cy.wait(2000)
235+ cy.get(`span[data-cy="Luke Skywalker"]`).contains("Luke Skywalker").should('exist')
236+ cy.get(`span[data-cy="Anakin Skywalker"]`).contains("Anakin Skywalker").should('exist')
237+ //cy.get(`span[data-cy="Shmi Skywalker"]`).contains("Shmi Skywalker").should('exist')
238+ /*cy.get("table tbody").find("tr").then((row) => {
239+ expect(row.length).eq()
240+ });*/
241+ cy . get ( `input[data-cy="mass"]` ) . then ( function ( $input ) {
242+ $input [ 0 ] . setAttribute ( 'value' , `77` )
243+ } )
244+ . should ( 'have.attr' , 'value' , `77` )
245+ //cy.wait(1000)
246+ /*cy.get(`span[data-cy="Anakin Skywalker"]`).contains("Shmi Skywalker").should('exist')
247+ cy.get("table tbody").find("tr").then((row) => {
248+ expect(row.length).eq(1)
249+ });*/
250+ } )
251+
252+
253+ } )
0 commit comments