Skip to content

Commit c91da01

Browse files
committed
Add better tests
1 parent 884e4a0 commit c91da01

File tree

4 files changed

+45
-11
lines changed

4 files changed

+45
-11
lines changed

e2e_tests/integration/0.index.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { isAura, isEnterpriseEdition } from '../support/utils'
2525
const Editor = '.ReactCodeMirror textarea'
2626
const Carousel = '[data-testid="carousel"]'
2727
const SubmitQueryButton = '[data-testid="editorPlay"]'
28-
const ClearEditorButton = '[data-testid="editorClear"]'
28+
const ClearEditorButton = '[data-testid="editor-discard"]'
2929

3030
describe('Neo4j Browser', () => {
3131
before(function() {

e2e_tests/integration/editor.spec.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
*/
2020

2121
/* global Cypress, cy, before */
22+
const fullscreenButton = '[data-testid="editor-fullscreen"]'
23+
const cardSizeButton = '[data-testid="editor-cardSize"]'
24+
const discardButton = '[data-testid="editor-discard"]'
2225

2326
describe('editor', () => {
2427
before(function() {
@@ -50,4 +53,29 @@ describe('editor', () => {
5053
cy.get('.CodeMirror-scroll').type(':history{control}{enter}')
5154
cy.get('.CodeMirror-linenumber').should('contain', '$')
5255
})
56+
57+
it('supports changing ui size from controls', () => {
58+
cy.get('.CodeMirror-linenumber').should('contain', '$')
59+
60+
// Toggle card view and back
61+
cy.get(cardSizeButton).click()
62+
cy.get('.CodeMirror-linenumber').should('contain', '1')
63+
cy.get(cardSizeButton).click()
64+
cy.get('.CodeMirror-linenumber').should('contain', '$')
65+
66+
// toggle full screen and nback
67+
cy.get(fullscreenButton).click()
68+
cy.get('.CodeMirror-linenumber').should('contain', '1')
69+
cy.get(fullscreenButton).click()
70+
cy.get('.CodeMirror-linenumber').should('contain', '$')
71+
72+
// discard resets size and clears editor
73+
cy.get(cardSizeButton).click()
74+
cy.get('.CodeMirror-linenumber').should('contain', '1')
75+
cy.get('body').type('/test')
76+
cy.get('.CodeMirror-line').contains('test')
77+
cy.get(discardButton).click()
78+
cy.get('.CodeMirror-linenumber').should('contain', '$')
79+
cy.get('.CodeMirror-line').should('not.contain.text', 'test')
80+
})
5381
})

e2e_tests/support/commands.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { executeCommand } from '../../src/shared/modules/commands/commandsDuck'
22

33
const SubmitQueryButton = '[data-testid="editorPlay"]'
4-
const ClearEditorButton = '[data-testid="editorClear"]'
4+
const ClearEditorButton = '[data-testid="editor-discard"]'
55
const Editor = '.ReactCodeMirror textarea'
66
const VisibleEditor = '[data-testid="editor-wrapper"]'
77

src/browser/modules/Editor/EditorFrame.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
UpIcon,
3838
DownIcon
3939
} from 'browser-components/icons/Icons'
40+
import { TransitionMotion } from 'react-motion'
4041

4142
type EditorSize = 'CARD' | 'LINE' | 'FULLSCREEN'
4243
type EditorFrameProps = { bus: Bus }
@@ -91,21 +92,21 @@ export function EditorFrame({ bus }: EditorFrameProps) {
9192
const buttons = [
9293
{
9394
onClick: toggleFullscreen,
94-
disabled: false,
9595
title: isFullscreen ? 'Close fullscreen' : 'Fullscreen',
96-
icon: isFullscreen ? <ContractIcon /> : <ExpandIcon />
96+
icon: isFullscreen ? <ContractIcon /> : <ExpandIcon />,
97+
testId: 'fullscreen'
9798
},
9899
{
99100
onClick: toggleCardView,
100-
disabled: false,
101-
title: isCardSize ? 'Collapse' : 'Cardview',
102-
icon: isCardSize ? <UpIcon /> : <DownIcon />
101+
title: isCardSize ? 'Collapse' : 'Expand',
102+
icon: isCardSize ? <UpIcon /> : <DownIcon />,
103+
testId: 'cardSize'
103104
},
104105
{
105106
onClick: discardEditor,
106-
disabled: false,
107107
title: 'Discard',
108-
icon: <CloseIcon />
108+
icon: <CloseIcon />,
109+
testId: 'discard'
109110
}
110111
]
111112

@@ -114,8 +115,13 @@ export function EditorFrame({ bus }: EditorFrameProps) {
114115
<FrameHeader>
115116
<FrameHeaderText> </FrameHeaderText>
116117
<UIControls>
117-
{buttons.map(({ onClick, icon, title }) => (
118-
<FrameButton key={`frame-${title}`} title={title} onClick={onClick}>
118+
{buttons.map(({ onClick, icon, title, testId }) => (
119+
<FrameButton
120+
key={`frame-${title}`}
121+
title={title}
122+
onClick={onClick}
123+
data-testid={`editor-${testId}`}
124+
>
119125
{icon}
120126
</FrameButton>
121127
))}

0 commit comments

Comments
 (0)