Skip to content

Commit 102d924

Browse files
Added tests for change all dbs
- Testing changing the dbs for all cards - Testinf menu population - Test no popover Related to #1048
1 parent f32de0b commit 102d924

File tree

7 files changed

+339
-97
lines changed

7 files changed

+339
-97
lines changed

cypress/Page.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ export class Page {
8080
return this;
8181
}
8282

83+
selectReportDatabase(database) {
84+
cy.get('main .react-grid-item')
85+
.contains('Query returned no data.')
86+
.parentsUntil('.react-grid-item')
87+
.find('button[aria-label="settings"]', { timeout: 2000 })
88+
.should('be.visible')
89+
.click();
90+
cy.get('[data-test="database-dropdown"]').should('be.visible').click();
91+
cy.contains(database)
92+
return this;
93+
}
94+
8395
createReportOfType(type, query, fast = false, run = true) {
8496
this.selectReportOfType(type);
8597
if (fast) {
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { createDB2 } from '../../fixtures/cypher_queries';
2+
import { Page } from '../../Page';
3+
4+
const CARD_SELECTOR = 'main .react-grid-item:eq(2)';
5+
const page = new Page(CARD_SELECTOR);
6+
7+
// Ignore warnings that may appear when using the Cypress dev server
8+
Cypress.on('uncaught:exception', (err, runnable) => {
9+
console.log(err, runnable);
10+
return false;
11+
});
12+
13+
describe('Tests for change all db button', () => {
14+
beforeEach('open neodash', () => {
15+
page.init().createNewDashboard().connectToNeo4j();
16+
cy.wait(100);
17+
});
18+
19+
it('Testing menu population', () => {
20+
//Create a second db
21+
page.createReportOfType('Table', createDB2, true, true);
22+
23+
//Check menus are populated
24+
page.selectReportDatabase('db2')
25+
cy.get('[style="padding-bottom: 6px; width: 440px; height: 430px; position: absolute; transform: translate(460px, 10px);"] > .n-bg-neutral-bg-weak > .MuiCollapse-entered > .MuiCollapse-wrapper > .MuiCollapse-wrapperInner > .MuiPaper-root > .card-view > .MuiCardHeader-root > .MuiCardHeader-action > .ndl-icon-btn')
26+
.should('be.visible')
27+
.click()
28+
cy.get('.ndl-btn').should('be.visible').click()
29+
cy.contains('db2')
30+
});
31+
32+
it('Testing changing the dbs for all cards', () => {
33+
//Create a second db
34+
page.createReportOfType('Table', createDB2, true, true);
35+
36+
//Change all db button
37+
cy.get('.ndl-btn').should('be.visible').click()
38+
cy.contains('db2').should('be.visible').click()
39+
cy.contains('Continue').should('be.visible').click()
40+
cy.get('[style="border-width: 1px; border-style: solid; color: rgb(var(--palette-primary-bg-strong)); border-color: rgb(var(--palette-primary-bg-strong)); border-radius: 8px;"] > .n-flex-row > .n-flex > .ndl-menu-item-title')
41+
.should('contain', 'db2')
42+
43+
//Check reports
44+
cy.get('[data-testid="popover-backdrop"]').click()
45+
46+
//Report 1
47+
cy.get('[style="padding-bottom: 6px; transform: translate(909px, 10px); width: 440px; height: 430px; position: absolute;"] > .n-bg-neutral-bg-weak > .MuiCollapse-entered > .MuiCollapse-wrapper > .MuiCollapse-wrapperInner > .MuiPaper-root > .card-view > .MuiCardHeader-root > .MuiCardHeader-action > .ndl-icon-btn')
48+
.should('be.visible')
49+
.click()
50+
cy.get('[data-test="database-dropdown"] > .css-b62m3t-container > .css-19x0je5-control > .css-1fdsijx-ValueContainer > .css-4zo8aq-Input')
51+
.should('be.visible')
52+
.click()
53+
cy.get('#react-select-11-option-0').should('be.visible').should('contain', 'db2')
54+
cy.get('[style="padding-bottom: 6px; transform: translate(909px, 10px); width: 440px; height: 430px; position: absolute;"] > .n-bg-neutral-bg-weak > .MuiCollapse-entered > .MuiCollapse-wrapper > .MuiCollapse-wrapperInner > .MuiPaper-root > .card-view > .MuiCardHeader-root > .MuiCardHeader-action > .ndl-icon-btn')
55+
.should('be.visible')
56+
.click()
57+
58+
//Report 2
59+
cy.get('[style="padding-bottom: 6px; width: 440px; height: 430px; position: absolute; transform: translate(460px, 10px);"] > .n-bg-neutral-bg-weak > .MuiCollapse-entered > .MuiCollapse-wrapper > .MuiCollapse-wrapperInner > .MuiPaper-root > .card-view > .MuiCardHeader-root > .MuiCardHeader-action > .ndl-icon-btn')
60+
.should('be.visible')
61+
.click()
62+
cy.get('[style="padding-bottom: 6px; width: 440px; height: 430px; position: absolute; transform: translate(460px, 10px);"] > .n-bg-neutral-bg-weak > .MuiCollapse-entered > .MuiCollapse-wrapper > .MuiCollapse-wrapperInner > .MuiPaper-root > .card-view > .sc-bcXHqe > .MuiCardContent-root > [data-test="database-dropdown"] > .css-b62m3t-container > .css-19x0je5-control > .css-1fdsijx-ValueContainer > .css-4zo8aq-Input')
63+
.should('be.visible')
64+
.click()
65+
cy.get('#react-select-15-option-0').should('be.visible').should('contain', 'db2')
66+
});
67+
68+
it('Test no popover', () => {
69+
//Create a second db
70+
page.createReportOfType('Table', createDB2, true, true);
71+
72+
//Check menus are populated
73+
cy.get('.ndl-btn').should('be.visible').click()
74+
cy.contains('db2').should('be.visible').click()
75+
cy.get('.ndl-form-item-label > input').should('be.visible').click()
76+
cy.contains('Continue').should('be.visible').click()
77+
cy.get('[data-testid="popover-backdrop"]').click()
78+
79+
//Click without popover
80+
cy.get('.ndl-btn').should('be.visible').click()
81+
cy.get('[style=""] > .n-flex-row > .n-flex > .ndl-menu-item-title').contains('neo4j').should('be.visible').click()
82+
83+
});
84+
});

cypress/fixtures/cypher_queries.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
"babel-plugin-istanbul": "^6.1.1",
125125
"circular-dependency-plugin": "^5.2.2",
126126
"css-loader": "^3.6.0",
127-
"cypress": "^12.17.4",
127+
"cypress": "^14.3.0",
128128
"eslint": "^8.26.0",
129129
"eslint-config-prettier": "^8.5.0",
130130
"eslint-plugin-import": "^2.26.0",

src/card/settings/CardSettingsContent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ const NeoCardSettingsContent = ({
128128

129129
{report?.disableDatabaseSelector == undefined ? (
130130
<Dropdown
131+
data-test='database-dropdown'
131132
id='databaseSelector'
132133
label='Database'
133134
placeholder='neo4j'

src/dashboard/header/DashboardHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export const NeoDashboardHeader = ({
122122
</Tooltip>
123123
<Tooltip title='Database' aria-label='database' disableInteractive>
124124
<Button
125-
aria-label={'settings'}
125+
aria-label='database'
126126
fill='text'
127127
size='large'
128128
color='neutral'

0 commit comments

Comments
 (0)