-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more props to the codemirror editor to ease migration from older …
…version (#178) * support toggling line numbers * ensure min-height works as intended * add changeset * fix e2e test * fix test with overlapping panels * fix changeset typo
- Loading branch information
1 parent
df8f703
commit 6cc9022
Showing
6 changed files
with
211 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@neo4j-cypher/react-codemirror': patch | ||
--- | ||
|
||
Adds more props to the CypherEditor component |
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
97 changes: 97 additions & 0 deletions
97
packages/react-codemirror/src/e2e_tests/configuration.spec.tsx
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,97 @@ | ||
import { expect, test } from '@playwright/experimental-ct-react'; | ||
import { CypherEditor } from '../CypherEditor'; | ||
|
||
test.use({ viewport: { width: 500, height: 500 } }); | ||
|
||
test('prompt shows up', async ({ mount, page }) => { | ||
const component = await mount(<CypherEditor prompt="neo4j>" />); | ||
|
||
await expect(component).toContainText('neo4j>'); | ||
|
||
await component.update(<CypherEditor prompt="test>" />); | ||
await expect(component).toContainText('test>'); | ||
|
||
const textField = page.getByRole('textbox'); | ||
await textField.press('a'); | ||
|
||
await expect(textField).toHaveText('a'); | ||
}); | ||
|
||
test('line numbers can be turned on/off', async ({ mount }) => { | ||
const component = await mount(<CypherEditor lineNumbers />); | ||
|
||
await expect(component).toContainText('1'); | ||
|
||
await component.update(<CypherEditor lineNumbers={false} />); | ||
await expect(component).not.toContainText('1'); | ||
}); | ||
|
||
test('can configure readonly', async ({ mount, page }) => { | ||
const component = await mount(<CypherEditor readonly />); | ||
|
||
const textField = page.getByRole('textbox'); | ||
await textField.press('a'); | ||
await expect(textField).not.toHaveText('a'); | ||
|
||
await component.update(<CypherEditor readonly={false} />); | ||
await textField.press('b'); | ||
await expect(textField).toHaveText('b'); | ||
}); | ||
|
||
test('can set placeholder ', async ({ mount, page }) => { | ||
const component = await mount(<CypherEditor placeholder="bulbasaur" />); | ||
|
||
const textField = page.getByRole('textbox'); | ||
await expect(textField).toHaveText('bulbasaur'); | ||
|
||
await component.update(<CypherEditor placeholder="venusaur" />); | ||
await expect(textField).not.toHaveText('bulbasaur'); | ||
await expect(textField).toHaveText('venusaur'); | ||
|
||
await textField.fill('abc'); | ||
await expect(textField).not.toHaveText('venusaur'); | ||
await expect(textField).toHaveText('abc'); | ||
}); | ||
|
||
test('can set/unset onFocus/onBlur', async ({ mount, page }) => { | ||
const component = await mount(<CypherEditor />); | ||
|
||
let focusFireCount = 0; | ||
let blurFireCount = 0; | ||
|
||
const focus = () => { | ||
focusFireCount += 1; | ||
}; | ||
const blur = () => { | ||
blurFireCount += 1; | ||
}; | ||
|
||
await component.update(<CypherEditor domEventHandlers={{ blur, focus }} />); | ||
|
||
const textField = page.getByRole('textbox'); | ||
await textField.click(); | ||
await expect(textField).toBeFocused(); | ||
|
||
// this is to give the events time to fire | ||
await expect(() => { | ||
expect(focusFireCount).toBe(1); | ||
expect(blurFireCount).toBe(0); | ||
}).toPass(); | ||
|
||
await textField.blur(); | ||
|
||
await expect(() => { | ||
expect(focusFireCount).toBe(1); | ||
expect(blurFireCount).toBe(1); | ||
}).toPass(); | ||
|
||
await component.update(<CypherEditor />); | ||
await textField.click(); | ||
await expect(textField).toBeFocused(); | ||
await textField.blur(); | ||
|
||
await expect(() => { | ||
expect(focusFireCount).toBe(1); | ||
expect(blurFireCount).toBe(1); | ||
}).toPass(); | ||
}); |
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