Skip to content

Commit

Permalink
e2e test added for export options (#1028)
Browse files Browse the repository at this point in the history
* e2e test added for export options

* change export options to alphabetical order

* use of forEach to make e2e tests less verbose and added data-testid tag to visualization view cypher frame sidebar button

* add Plan view to the e2e tests for export options

* add PROFILE to Cypher command in order to get the Plan view
  • Loading branch information
Jas Kuner authored Jan 3, 2020
1 parent 0753439 commit 38d7a31
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 23 deletions.
57 changes: 44 additions & 13 deletions e2e_tests/integration/data-export.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,49 @@ describe('Data export', () => {
const password = Cypress.config('password')
cy.connect('neo4j', password)
})
it('shows export buttons on viz load', () => {
cy.executeCommand(':clear')
cy.executeCommand('CREATE (n:ExportTest) RETURN n')

cy.get('[data-testid="frame"]', { timeout: 10000 }).should('have.length', 1)
cy.get('[data-testid="frame-export-dropdown"]')
.first()
.trigger('mouseover')
cy.get('[data-testid="frame-export-dropdown"]')
.first()
.should('contain', 'Export PNG')

cy.executeCommand('MATCH (n:ExportTest) DETACH DELETE n')
context('export options', () => {
before(function() {
cy.executeCommand(':clear')
cy.executeCommand('PROFILE CREATE (n:ExportTest) RETURN n')
cy.get('[data-testid="frame"]', { timeout: 10000 }).should(
'have.length',
1
)
})
after(function() {
cy.executeCommand('MATCH (n:ExportTest) DETACH DELETE n')
})
const exportOptionsConfig = [
{
names: ['Plan', 'Visualization'],
order: ['CSV', 'JSON', 'PNG', 'SVG']
},
{
names: ['Table', 'Ascii', 'Code'],
order: ['CSV', 'JSON']
}
]
exportOptionsConfig.forEach(config => {
config.names.forEach(name => {
it(`shows the correct export buttons for ${name} view`, () => {
cy.get(`[data-testid="cypherFrameSidebar${name}"]`, {
timeout: 10000
}).click()
cy.get('[data-testid="frame-export-dropdown"]').trigger('mouseover')
cy.get('[data-testid="frame-export-dropdown"]', {
timeout: 10000
}).within(() => {
cy.get('a').then(exportButtonsList => {
expect(exportButtonsList).to.have.length(config.order.length)
config.order.forEach((exportType, index) => {
expect(exportButtonsList.eq(index)).to.contain(
`Export ${exportType}`
)
})
})
})
})
})
})
})
})
18 changes: 8 additions & 10 deletions src/browser/modules/Frame/FrameTitlebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,6 @@ class FrameTitlebar extends Component {
<DownloadIcon />
<DropdownList>
<DropdownContent>
<Render if={props.visElement}>
<span>
<DropdownItem onClick={() => this.exportPNG()}>
Export PNG
</DropdownItem>
<DropdownItem onClick={() => this.exportSVG()}>
Export SVG
</DropdownItem>
</span>
</Render>
<Render if={this.hasData() && frame.type === 'cypher'}>
<DropdownItem
onClick={() => this.exportCSV(props.getRecords())}
Expand All @@ -205,6 +195,14 @@ class FrameTitlebar extends Component {
Export JSON
</DropdownItem>
</Render>
<Render if={props.visElement}>
<DropdownItem onClick={() => this.exportPNG()}>
Export PNG
</DropdownItem>
<DropdownItem onClick={() => this.exportSVG()}>
Export SVG
</DropdownItem>
</Render>
<Render if={this.canExportTXT()}>
<DropdownItem onClick={this.exportTXT}>
Export TXT
Expand Down
3 changes: 3 additions & 0 deletions src/browser/modules/Stream/CypherFrame/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export class CypherFrame extends Component {
<FrameSidebar>
<Render if={resultHasNodes(this.props.request) && !this.state.errors}>
<CypherFrameButton
data-testid="cypherFrameSidebarVisualization"
selected={this.state.openView === viewTypes.VISUALIZATION}
onClick={() => {
this.changeView(viewTypes.VISUALIZATION)
Expand Down Expand Up @@ -177,6 +178,7 @@ export class CypherFrame extends Component {
</Render>
<Render if={resultHasPlan(this.props.request)}>
<CypherFrameButton
data-testid="cypherFrameSidebarPlan"
selected={this.state.openView === viewTypes.PLAN}
onClick={() => this.changeView(viewTypes.PLAN)}
>
Expand Down Expand Up @@ -205,6 +207,7 @@ export class CypherFrame extends Component {
</Render>
<Render if={!resultIsError(this.props.request)}>
<CypherFrameButton
data-testid="cypherFrameSidebarCode"
selected={this.state.openView === viewTypes.CODE}
onClick={() => {
this.changeView(viewTypes.CODE)
Expand Down

0 comments on commit 38d7a31

Please sign in to comment.