Skip to content

Commit

Permalink
Work on e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarDamkjaer committed Feb 19, 2021
1 parent 3d86dda commit ffab3fd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
2 changes: 0 additions & 2 deletions e2e_tests/integration/0.index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ describe('Neo4j Browser', () => {
cy.get(Editor).type(`RETURN 1{enter}`, { force: true })

cy.get('[data-testid="frame-Favorite"]').click()
cy.get('[data-testid="saveScript"]').click()

cy.get('[data-testid="savedScriptListItem"]')
.first()
.contains('RETURN 1')
Expand Down
25 changes: 6 additions & 19 deletions e2e_tests/integration/saved-scripts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,19 @@ describe('Saved Scripts', () => {
.title()
.should('include', 'Neo4j Browser')
//cy.wait(3000)
// TODO REMOVE THIS
cy.connect('neo4j', Cypress.config('password'))
})

it('can save a result as favorite', () => {
cy.executeCommand('RETURN 1')
cy.get('[data-testid=frame-Favorite]').click()
cy.get('[data-testid=scriptName]')
.clear()
.type('script name')
cy.get('[data-testid=saveScript]').click()

// saved in the list and can populate editor
cy.get('[data-testid="navicon-script name"').click({ force: true })
cy.get('[data-testid="navicon-RETURN 1"').click({ force: true })
cy.get('[data-testid="contextMenuEdit"').click()

cy.get('[data-testid="currentlyEditing"]').contains('script name')
cy.get('[data-testid="currentlyEditing"]').contains('RETURN 1')
// Editing script updates name and content
cy.get('[data-testid="activeEditor"] textarea')
.type(
Expand All @@ -67,17 +64,9 @@ describe('Saved Scripts', () => {
cy.executeCommand(':clear')
cy.executeCommand(':help cypher')
cy.get('[data-testid=frame-Favorite]').click()
cy.get('[data-testid=scriptName]')
.invoke('val')
.should('equal', ':help cypher')

cy.get('[data-testid=saveScript]').click()

cy.get('[data-testid="savedScriptsButton-New folder"]').click()
cy.get('[data-testid="savedScriptsButton-Edit"]').click({ force: true })
cy.get('[data-testid="editSavedScriptFolderName"]')
.clear()
.type('fldr{enter}')
cy.get('[data-testid=editSavedScriptFolderName]').type('fldr{enter}')

cy.get('[data-testid="scriptTitle-:help cypher"]').trigger('dragstart')

Expand All @@ -95,10 +84,8 @@ describe('Saved Scripts', () => {
cy.get('[data-testid="scriptTitle-:help cypher"]').should('exist')

// cleanup and delete the folder as well
cy.get('[data-testid="savedScriptsButton-Edit"]')
.first()
.click({ force: true })
cy.get('[data-testid="savedScriptsButton-Remove"]').click()
cy.get('[data-testid=navicon-fldr]').click({ force: true })
cy.get('[data-testid=contextMenuRename]').click()
cy.get('[data-testid=expandFolder-fldr]').should('not.exist')
cy.get('[data-testid=drawerFavorites]').click()
})
Expand Down
1 change: 1 addition & 0 deletions src/browser/components/SavedScripts/SavedScriptsFolder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function SavedScriptsFolder({
<ContextMenuHoverParent
ref={drop}
data-testid={`savedScriptsFolder-${folder.name}`}
stayVisible={showOverlay}
>
<SavedScriptsFolderMain>
<SavedScriptsFolderHeader title={folder.name} ref={blurRef}>
Expand Down
1 change: 1 addition & 0 deletions src/browser/modules/Frame/FrameTitlebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ const mapDispatchToProps = (
return {
newFavorite: (cmd: string) => {
dispatch(addFavorite(cmd))
dispatch(sidebar.open('favorites'))
},
newProjectFile: (cmd: string) => {
dispatch(sidebar.setDraftScript(cmd, 'project files'))
Expand Down
14 changes: 13 additions & 1 deletion src/shared/modules/sidebar/sidebarDuck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { GlobalState } from 'shared/globalState'
export const NAME = 'sidebar'

export const TOGGLE = 'sidebar/TOGGLE'
export const OPEN = 'sidebar/OPEN'
export const SET_DRAFT_SCRIPT = 'sidebar/SET_DRAFT_SCRIPT'

export function getOpenDrawer(state: GlobalState): string | null {
Expand Down Expand Up @@ -67,13 +68,18 @@ function toggleDrawer(state: SidebarState, drawer: DrawerId): SidebarState {
return { draftScript: null, drawer, scriptId: null }
}

type SidebarAction = ToggleAction | SetDraftScriptAction
type SidebarAction = ToggleAction | SetDraftScriptAction | OpenAction

interface ToggleAction {
type: typeof TOGGLE
drawerId: DrawerId
}

interface OpenAction {
type: typeof OPEN
drawerId: DrawerId
}

interface SetDraftScriptAction {
type: typeof SET_DRAFT_SCRIPT
cmd: string | null
Expand All @@ -88,6 +94,8 @@ export default function reducer(
switch (action.type) {
case TOGGLE:
return toggleDrawer(state, action.drawerId)
case OPEN:
return { ...state, drawer: action.drawerId }
case SET_DRAFT_SCRIPT:
return {
drawer: action.drawerId,
Expand All @@ -102,6 +110,10 @@ export function toggle(drawerId: DrawerId): ToggleAction {
return { type: TOGGLE, drawerId }
}

export function open(drawerId: DrawerId): OpenAction {
return { type: OPEN, drawerId }
}

export function setDraftScript(
cmd: string | null,
drawerId: DrawerId,
Expand Down

0 comments on commit ffab3fd

Please sign in to comment.