Skip to content

Commit 274a08b

Browse files
Add Cypress and a first test (#115)
* Initialize cypress test framework & initial testing structure Co-authored-by: Marius Conjeaud <[email protected]>
1 parent a52096f commit 274a08b

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed

cypress.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"baseUrl": "http://localhost:3000"
3+
}

cypress/fixtures/cypher_queries.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const defaultCypherQuery = "MATCH (n) RETURN n LIMIT 25";
2+
export const tableCypherQuery = "MATCH (n:Movie) RETURN n.title AS title, n.released AS released LIMIT 8";
3+
export const barChartCypherQuery = "MATCH (n:Movie) RETURN n.released AS released, count(n.title) AS count ORDER BY released";
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import {defaultCypherQuery, tableCypherQuery} from "../fixtures/cypher_queries"
2+
3+
describe('The Dashboard Page', () => {
4+
beforeEach(() => {
5+
// Navigate to index
6+
cy.visit('/')
7+
cy.get('#form-dialog-title').should('contain', 'NeoDash - Neo4j Dashboard Builder')
8+
9+
// Create new dashboard
10+
cy.contains('New Dashboard').click()
11+
cy.wait(300)
12+
cy.get('#form-dialog-title').should('contain', 'Connect to Neo4j')
13+
14+
// Connect to Neo4j database
15+
cy.get('#protocol').click()
16+
cy.contains('neo4j+s').click()
17+
cy.get('#url').clear().type('demo.neo4jlabs.com')
18+
cy.get('#database').type('movies')
19+
cy.get('#dbusername').clear().type('movies')
20+
cy.get('#dbpassword').type('movies')
21+
cy.get('button').contains('Connect').click()
22+
})
23+
24+
it('initializes the dashboard', () => {
25+
// Check the starter cards
26+
cy.get('main .MuiGrid-item:eq(0)').should('contain', "This is your first dashboard!")
27+
cy.get('main .MuiGrid-item:eq(1) .force-graph-container canvas').should('be.visible')
28+
cy.get('main .MuiGrid-item:eq(2) button').should('have.attr', 'aria-label', 'add')
29+
})
30+
31+
it('creates a new card', () => {
32+
cy.get('main .MuiGrid-item:eq(2) button').click()
33+
cy.get('main .MuiGrid-item:eq(2)').should('contain', 'No query specified.')
34+
})
35+
36+
// Test each type of card
37+
it('creates a table report', () => {
38+
cy.get('main .MuiGrid-item:eq(2) button').click()
39+
cy.get('main .MuiGrid-item:eq(2) button[aria-label="settings"]').click()
40+
cy.get('main .MuiGrid-item:eq(2) .MuiInputLabel-root').contains("Type").next().should('contain', 'Table')
41+
cy.get('main .MuiGrid-item:eq(2) .ReactCodeMirror').type(tableCypherQuery)
42+
cy.get('main .MuiGrid-item:eq(2) button[aria-label="save"]').click()
43+
cy.get('main .MuiGrid-item:eq(2) .MuiDataGrid-columnHeaders').should('contain', 'title').and('contain', 'released')
44+
cy.get('main .MuiGrid-item:eq(2) .MuiDataGrid-virtualScroller .MuiDataGrid-row').should('have.length', 5)
45+
cy.get('main .MuiGrid-item:eq(2) .MuiDataGrid-footerContainer').should('contain', '1–5 of 8')
46+
cy.get('main .MuiGrid-item:eq(2) .MuiDataGrid-footerContainer button[aria-label="Go to next page"]').click()
47+
cy.get('main .MuiGrid-item:eq(2) .MuiDataGrid-virtualScroller .MuiDataGrid-row').should('have.length', 3)
48+
cy.get('main .MuiGrid-item:eq(2) .MuiDataGrid-footerContainer').should('contain', '6–8 of 8')
49+
})
50+
51+
// Test card deletion
52+
53+
// Test create/delete new page
54+
55+
// Test load dashboard from file
56+
// Niels to provide file test case
57+
58+
// Test opening existing dashboard ?
59+
})

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
"@emotion/styled": "^11.6.0",
7878
"babel-loader": "^8.2.3",
7979
"css-loader": "^3.6.0",
80+
"cypress": "^9.5.3",
8081
"file-loader": "^6.2.0",
8182
"react-hot-loader": "^4.13.0",
8283
"source-map-loader": "^1.1.3",

0 commit comments

Comments
 (0)