-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #722 from oskarhane/multi-statements
Add support for multi-statement execution
- Loading branch information
Showing
42 changed files
with
1,671 additions
and
385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* 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('Multi statements', () => { | ||
it('can connect', () => { | ||
const password = Cypress.env('browser-password') || 'newpassword' | ||
cy.connect( | ||
'neo4j', | ||
password | ||
) | ||
}) | ||
it('can run multiple statements (non open by default)', () => { | ||
cy.executeCommand(':clear') | ||
const query = 'RETURN 1; :config; RETURN 2;' | ||
cy.executeCommand(query) | ||
cy.get('[data-test-id="frame"]', { timeout: 10000 }).should( | ||
'have.length', | ||
1 | ||
) | ||
const frame = cy.get('[data-test-id="frame"]', { timeout: 10000 }).first() | ||
frame.get('[data-test-id="multi-statement-list"]').should('have.length', 1) | ||
frame | ||
.get('[data-test-id="multi-statement-list-title"]') | ||
.should('have.length', 3) | ||
frame | ||
.get('[data-test-id="multi-statement-list-content"]') | ||
.should('have.length', 0) | ||
}) | ||
it('can run multiple statements with error open', () => { | ||
cy.executeCommand(':clear') | ||
const query = 'RETURN 1; RETURN $nonsetparam; RETURN 2;' | ||
cy.executeCommand(query) | ||
cy.get('[data-test-id="frame"]', { timeout: 10000 }).should( | ||
'have.length', | ||
1 | ||
) | ||
const frame = cy.get('[data-test-id="frame"]', { timeout: 10000 }).first() | ||
frame.find('[data-test-id="multi-statement-list"]').should('have.length', 1) | ||
frame | ||
.get('[data-test-id="multi-statement-list-title"]') | ||
.should('have.length', 3) | ||
frame | ||
.get('[data-test-id="multi-statement-list-content"]', { timeout: 10000 }) | ||
.should('have.length', 1) | ||
frame | ||
.get('[data-test-id="multi-statement-list-content"]', { timeout: 10000 }) | ||
.first() | ||
.should('contain', 'ERROR') | ||
}) | ||
it('Takes any statements (not just valid cypher and client commands)', () => { | ||
cy.executeCommand(':clear') | ||
const query = 'RETURN 1; hello1; RETURN 2; hello2;' | ||
cy.executeCommand(query) | ||
cy.get('[data-test-id="frame"]', { timeout: 10000 }).should( | ||
'have.length', | ||
1 | ||
) | ||
const frame = cy.get('[data-test-id="frame"]', { timeout: 10000 }).first() | ||
frame.find('[data-test-id="multi-statement-list"]').should('have.length', 1) | ||
frame | ||
.get('[data-test-id="multi-statement-list-title"]') | ||
.should('have.length', 4) | ||
frame | ||
.get('[data-test-id="multi-statement-list-content"]', { timeout: 10000 }) | ||
.should('have.length', 1) | ||
frame | ||
.get('[data-test-id="multi-statement-list-content"]', { timeout: 10000 }) | ||
.first() | ||
.should('contain', 'ERROR') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* 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/>. | ||
*/ | ||
|
||
import React, { Component } from 'react' | ||
import { BorderedWrapper, TitleBar, ContentArea } from './styled' | ||
|
||
class Accordion extends Component { | ||
state = { | ||
activeIndex: -1, | ||
initialLoad: true | ||
} | ||
titleClick = index => { | ||
const newIndex = this.state.activeIndex === index ? -1 : index | ||
this.setState({ activeIndex: newIndex, initialLoad: false }) | ||
} | ||
getChildProps = ({ index, defaultActive = false, forceActive = false }) => { | ||
const props = { | ||
titleProps: { | ||
onClick: () => this.titleClick(index) | ||
}, | ||
contentProps: {} | ||
} | ||
if (forceActive) { | ||
props.titleProps.onClick = () => {} | ||
} | ||
if (defaultActive && this.state.initialLoad) { | ||
props.titleProps.onClick = () => this.titleClick(-1) | ||
} | ||
if ( | ||
index === this.state.activeIndex || | ||
(this.state.initialLoad && defaultActive) || | ||
forceActive | ||
) { | ||
props.titleProps.active = true | ||
props.contentProps.active = true | ||
return props | ||
} | ||
props.titleProps.active = false | ||
props.contentProps.active = false | ||
return props | ||
} | ||
render () { | ||
const { getChildProps } = this | ||
const { render: renderProp, ...rest } = this.props | ||
return ( | ||
<BorderedWrapper {...rest}> | ||
{renderProp({ getChildProps })} | ||
</BorderedWrapper> | ||
) | ||
} | ||
} | ||
|
||
const Title = ({ children, ...rest }) => { | ||
return <TitleBar {...rest}>{children}</TitleBar> | ||
} | ||
Accordion.Title = Title | ||
|
||
const Content = ({ children, active, ...rest }) => { | ||
if (!active) return null | ||
return <ContentArea {...rest}>{children}</ContentArea> | ||
} | ||
Accordion.Content = Content | ||
|
||
export default Accordion |
Oops, something went wrong.