Skip to content

Commit 97e343e

Browse files
Merge pull request #301 from terminusdb/leafletFix
diff bug and more tests
2 parents e47a933 + 3cab78d commit 97e343e

File tree

27 files changed

+906
-31
lines changed

27 files changed

+906
-31
lines changed
Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
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+
})
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import './branch_management.cy'
2+
import './cr_inactive.cy'
3+
import './document_ui.cy'

packages/tdb-dashboard/cypress/e2e/dashboard/branch_management.cy.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ describe(`Test to check Branch Management workflow`, () => {
119119
cy.wait('@addDocument').then((interception) => {
120120
assert.isNotNull(interception.response.body, 'intercepting Add Document API')
121121
//console.log("interception.response.body", interception.response.body)
122-
documentID = interception.response.body.branchName
122+
let fullId = interception.response.body[0]
123+
documentID = btoa(fullId)
123124
})
124-
125+
cy.get(2000)
125126
})
126127

127128
// Submit CR for Review

packages/tdb-dashboard/cypress/e2e/dashboard/document_ui.cy.js

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe(`Test document explorer UI (Edit/delete/create)`, () => {
2929
})
3030

3131
// select Terminusdb_demo team
32-
/*it('Select Team', () => {
32+
it('Select Team', () => {
3333
cy.selectTeam(teamName)
3434
})
3535

@@ -38,11 +38,11 @@ describe(`Test document explorer UI (Edit/delete/create)`, () => {
3838
cy.intercept(`/${teamName}/${dataProduct}`).as('cloaning')
3939
cy.get(`button[data-cy=${CONST.CLONE_BUTTON}_${dataProduct}]`).should('exist').click();
4040
cy.wait('@cloaning')
41-
})*/
41+
})
4242

4343
// set CR Inactive
4444
it("Set Change Request Inactive", () => {
45-
cy.visit(`/CYPRESS_TEST_TEAM/nuclear`)
45+
//cy.visit(`/CYPRESS_TEST_TEAM/nuclear`)
4646
cy.get(`label[data-cy=${CONST.CHANGE_REQUEST_MODE_INACTIVE}]`).should('exist').click();
4747
})
4848

@@ -145,10 +145,10 @@ describe(`Test document explorer UI (Edit/delete/create)`, () => {
145145

146146
cy.wait('@addDocument').then((interception) => {
147147
assert.isNotNull(interception.response.body, 'intercepting Add Document API')
148-
console.log("interception.response.body", interception.response.body)
148+
//console.log("interception.response.body", interception.response.body)
149149
let fullId = interception.response.body[0]
150150
documentID = btoa(fullId)
151-
console.log("encoded", documentID)
151+
//console.log("encoded", documentID)
152152
//`https://dashboard.terminusdb.com/${orgName}/${dbName}/documents/${type}/${fullIdEncode}`
153153
})
154154
cy.get(2000)
@@ -179,12 +179,53 @@ describe(`Test document explorer UI (Edit/delete/create)`, () => {
179179
// test document traversing
180180
it("Click linked Country to test Document traversing", () => {
181181
// check if frame viewer loaded
182-
cy.get(`div[data-cy=${`Country/${nuclearPowerPlantData.country}`}]`).should('exist').click();
182+
cy.get(`div[data-cy="${`${nuclearPowerPlantData.country}`}"]`).should('exist').click();
183183
cy.wait(1000)
184184
cy.get('.modal-dialog').should('exist')
185185
cy.get(`div[id="traverse__document__links"]`).should('exist')
186-
186+
// close traverse modal
187+
cy.get(`button[data-cy="close__traverse__document__links"]`).should('exist').click()
188+
})
189+
190+
// Edit Document
191+
it("Edit NuclearPowerPlant", () => {
192+
cy.get(`button[data-cy="edit__document"]`).should('exist').click()
193+
})
194+
195+
// Unlink Country and add another Country instead
196+
it("Unlink Country and create a new Country and link instead", () => {
197+
// after linking a document, change link button for the field should appear in dom
198+
cy.get(`button[data-cy="delete__country"]`).contains('Unlink').should('exist').click();
199+
cy.wait(1000)
200+
// add country
201+
cy.get(`input[data-cy="Create New Document__country"]`).should('exist').click();
202+
cy.get(`textarea[data-cy="root_country_name_1"]`).focus().type("test__country")
203+
204+
// click on submit button to create document
205+
cy.get('.btn').contains('Submit').should('exist').click();
206+
cy.wait(1000)
187207
})
188208

209+
// delete document
210+
it("Delete document", () => {
211+
cy.get(`button[data-cy="Delete Document"]`).should('exist').click();
212+
cy.wait(1000)
213+
cy.get('.modal-dialog').should('exist')
214+
cy.get(`button[data-cy="Delete"]`).should('exist').click();
215+
cy.wait(1000)
216+
217+
})
218+
219+
// delete dataProduct
220+
it('Delete dataProduct', ()=>{
221+
cy.visit(`/${teamName}/${dataProduct}`)
222+
cy.deleteDataProduct(dataProduct)
223+
})
224+
225+
it('Logout', () => {
226+
cy.logout()
227+
})
228+
229+
189230

190231
})

0 commit comments

Comments
 (0)