Skip to content

Commit

Permalink
Merge pull request neo4j#735 from oskarhane/new-types-support
Browse files Browse the repository at this point in the history
Support new Neo4j types
  • Loading branch information
pe4cey authored Apr 23, 2018
2 parents 53bc1fe + bce2b72 commit 15b1172
Show file tree
Hide file tree
Showing 13 changed files with 478 additions and 148 deletions.
92 changes: 0 additions & 92 deletions __mocks__/neo4j.js

This file was deleted.

194 changes: 194 additions & 0 deletions e2e_tests/integration/types.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
/*
* Copyright (c) 2002-2018 "Neo4j, Inc"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* global Cypress, cy, test, expect */

describe('Types in Browser', () => {
it('can connect', () => {
cy.executeCommand(':server disconnect')
cy.executeCommand(':clear')
cy.executeCommand(':server connect')
const password = Cypress.env('BROWSER_NEW_PASSWORD') || 'newpassword'
cy.connect(password)
})
it('presents the point type correctly', () => {
cy.executeCommand(':clear')
const query =
"WITH point({{}crs: 'wgs-84', longitude: 12.78, latitude: 56.7}) as p1 RETURN p1"
cy.executeCommand(query)
cy.waitForCommandResult()

cy
.get('[data-test-id="frameContents"]', { timeout: 10000 })
.then(contents => {
// Check for point type support
if (contents.find('.table-row').length > 0) {
cy.resultContains('point({srid:4326, x:12.78, y:56.7})')

// Go to ascii view
cy
.get('[data-test-id="cypherFrameSidebarAscii"')
.first()
.click()
cy.resultContains('│point({srid:4326, x:12.78, y:56.7})')
} else {
cy.resultContains('ERROR')
}
})
})
it('presents datetime type correctly', () => {
cy.executeCommand(':clear')
const query =
'RETURN datetime({{}year:2015, month:7, day:20, hour:15, minute:11, second:42, timezone:"Europe/Stockholm"}) AS t1'
cy.executeCommand(query)
cy.waitForCommandResult()
cy
.get('[data-test-id="frameContents"]', { timeout: 10000 })
.then(contents => {
// Check for type support
if (contents.find('.table-row').length > 0) {
cy.resultContains('"2015-07-20T15:11:42.000000000[Europe/Stockholm]"')
// Go to ascii view
cy
.get('[data-test-id="cypherFrameSidebarAscii"')
.first()
.click()
cy.resultContains(
'│"2015-07-20T15:11:42.000000000[Europe/Stockholm]"'
)
} else {
cy.resultContains('ERROR')
}
})
})
it('presents local datetime type correctly', () => {
cy.executeCommand(':clear')
const query =
'RETURN localdatetime({{}year:2015, month:7, day:20, hour:15, minute:11, second:42}) AS t1'
cy.executeCommand(query)
cy.waitForCommandResult()
cy
.get('[data-test-id="frameContents"]', { timeout: 10000 })
.then(contents => {
// Check for type support
if (contents.find('.table-row').length > 0) {
cy.resultContains('"2015-07-20T15:11:42.000000000"')
// Go to ascii view
cy
.get('[data-test-id="cypherFrameSidebarAscii"')
.first()
.click()
cy.resultContains('│"2015-07-20T15:11:42.000000000"')
} else {
cy.resultContains('ERROR')
}
})
})
it('presents date type correctly', () => {
cy.executeCommand(':clear')
const query = 'RETURN date({{}year:2015, month:7, day:20}) AS t1'
cy.executeCommand(query)
cy.waitForCommandResult()
cy
.get('[data-test-id="frameContents"]', { timeout: 10000 })
.then(contents => {
// Check for type support
if (contents.find('.table-row').length > 0) {
cy.resultContains('"2015-07-20"')
// Go to ascii view
cy
.get('[data-test-id="cypherFrameSidebarAscii"')
.first()
.click()
cy.resultContains('│"2015-07-20"')
} else {
cy.resultContains('ERROR')
}
})
})
it('presents duration type correctly', () => {
cy.executeCommand(':clear')
const query =
'RETURN duration({{}months:14, days:3, seconds:14706, nanoseconds:0}) AS t1'
cy.executeCommand(query)
cy.waitForCommandResult()
cy
.get('[data-test-id="frameContents"]', { timeout: 10000 })
.then(contents => {
// Check for type support
if (contents.find('.table-row').length > 0) {
cy.resultContains('"P14M3DT14706.000000000S"')
// Go to ascii view
cy
.get('[data-test-id="cypherFrameSidebarAscii"')
.first()
.click()
cy.resultContains('│"P14M3DT14706.000000000S"')
} else {
cy.resultContains('ERROR')
}
})
})
it('presents time type correctly', () => {
cy.executeCommand(':clear')
const query =
'RETURN time({{}hour:14, minute:3, second:4, timezone: "Europe/Stockholm"}) AS t1'
cy.executeCommand(query)
cy.waitForCommandResult()
cy
.get('[data-test-id="frameContents"]', { timeout: 10000 })
.then(contents => {
// Check for type support
if (contents.find('.table-row').length > 0) {
cy.resultContains('"14:03:04.000000000+02:00"')
// Go to ascii view
cy
.get('[data-test-id="cypherFrameSidebarAscii"')
.first()
.click()
cy.resultContains('│"14:03:04.000000000+02:00"')
} else {
cy.resultContains('ERROR')
}
})
})
it('presents localtime type correctly', () => {
cy.executeCommand(':clear')
const query = 'RETURN localtime({{}hour:14, minute:3, second:4}) AS t1'
cy.executeCommand(query)
cy.waitForCommandResult()
cy
.get('[data-test-id="frameContents"]', { timeout: 10000 })
.then(contents => {
// Check for type support
if (contents.find('.table-row').length > 0) {
cy.resultContains('"14:03:04.000000000"')
// Go to ascii view
cy
.get('[data-test-id="cypherFrameSidebarAscii"')
.first()
.click()
cy.resultContains('│"14:03:04.000000000"')
} else {
cy.resultContains('ERROR')
}
})
})
})
7 changes: 6 additions & 1 deletion e2e_tests/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,16 @@ Cypress.Commands.add('disconnect', () => {
Cypress.Commands.add('executeCommand', query => {
cy.get(ClearEditorButton).click()
cy.get(Editor).type(query, { force: true })
cy.get(Editor).should('have.value', query)
cy.get(SubmitQueryButton).click()
})
Cypress.Commands.add('waitForCommandResult', () => {
cy
.get('[data-test-id="frame-loaded-contents"]', { timeout: 40000 })
.should('be.visible')
})
Cypress.Commands.add('resultContains', str => {
cy
.get('[data-test-id="frameContents"]', { timeout: 10000 })
.first()
.should('contain', str)
})
31 changes: 18 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
"apiVersion": "^1.2.0"
},
"scripts": {
"start":
"webpack-dashboard -t 'Neo4j Browser' -- webpack-dev-server --colors --no-info",
"starts":
"webpack-dashboard -t 'Neo4j Browser' -- webpack-dev-server --https --colors --no-info",
"start": "webpack-dashboard -t 'Neo4j Browser' -- webpack-dev-server --colors --no-info",
"starts": "webpack-dashboard -t 'Neo4j Browser' -- webpack-dev-server --https --colors --no-info",
"startnodash": "webpack-dev-server --colors --no-info",
"precommit": "lint-staged",
"format": "prettier-eslint 'src/**/!(*.min).js' 'src/**/*.jsx' --write",
Expand All @@ -31,23 +29,27 @@
"build": "rm -rf ./dist && NODE_ENV=\"production\" webpack",
"prepare-jar": "node ./scripts/prepare-mvn-package.js",
"jar": "yarn build && mvn package",
"version-pom":
"node ./scripts/set-pom-version.js -f ./pom.xml -v $npm_package_version",
"version-pom": "node ./scripts/set-pom-version.js -f ./pom.xml -v $npm_package_version",
"version": "npm run version-pom && git add ./pom.xml",
"update-licenses": "sh ./scripts/generate_licenses.sh"
},
"lint-staged": {
"linters": {
"*.{js,jsx}": ["prettier-eslint --write", "git add"]
"*.{js,jsx}": [
"prettier-eslint --write",
"git add"
]
}
},
"jest": {
"testPathIgnorePatterns": [".jsx$", "/e2e_tests/"],
"testPathIgnorePatterns": [
".jsx$",
"/e2e_tests/"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|html)$":
"<rootDir>/__mocks__/fileMock.js",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|html)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js",
"neo4j": "<rootDir>/__mocks__/neo4j.js",
"^neo4j-driver-alias$": "neo4j-driver",
"^react-dom/server$": "preact-render-to-string",
"^react-addons-test-utils$": "preact-test-utils",
"^react-addons-transition-group$": "preact-transition-group",
Expand All @@ -57,7 +59,10 @@
"^browser-components(.*)$": "<rootDir>/src/browser/components$1",
"worker-loader": "<rootDir>/__mocks__/workerLoaderMock.js"
},
"modulePaths": ["<rootDir>/src", "<rootDir>/src/shared"]
"modulePaths": [
"<rootDir>/src",
"<rootDir>/src/shared"
]
},
"devDependencies": {
"autoprefixer": "^7.1.4",
Expand Down Expand Up @@ -136,7 +141,7 @@
"isomorphic-fetch": "^2.2.1",
"jsonic": "^0.3.0",
"lodash.debounce": "^4.0.8",
"neo4j-driver": "^1.5.3",
"neo4j-driver": "1.6.0-rc1",
"node-noop": "^1.0.0",
"preact": "^8.2.5",
"preact-compat": "^3.17.0",
Expand Down
Loading

0 comments on commit 15b1172

Please sign in to comment.