-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Resolve cursor position & toolbar flicker bugs (#134)
- Loading branch information
1 parent
fb68977
commit b75bc63
Showing
8 changed files
with
234 additions
and
211 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,30 @@ | ||
import { | ||
formatCode, | ||
typeCode, | ||
assertFirstFrameContains, | ||
assertCodePaneContains, | ||
assertCodePaneLineCount | ||
} from '../support/utils'; | ||
|
||
describe('Editor', () => { | ||
it('renders to frame', () => { | ||
typeCode('<Foo />'); | ||
assertFirstFrameContains('Foo'); | ||
|
||
typeCode('<Bar />'); | ||
assertFirstFrameContains('Foo\nBar'); | ||
}); | ||
|
||
it('autocompletes', () => { | ||
typeCode('<F{enter} c{enter}={downarrow}{enter} />'); | ||
assertFirstFrameContains('Foo'); | ||
assertCodePaneContains('<Foo color="blue" />'); | ||
}); | ||
|
||
it('formats', () => { | ||
typeCode('<Foo><Foo><Bar/>'); | ||
assertCodePaneLineCount(1); | ||
formatCode(); | ||
assertCodePaneLineCount(6); | ||
}); | ||
}); |
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,7 @@ | ||
import { getFirstFrame } from '../support/utils'; | ||
|
||
describe('Smoke', () => { | ||
it('frames are interactive', () => { | ||
getFirstFrame().click('center'); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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,112 @@ | ||
import dedent from 'dedent'; | ||
import { | ||
typeCode, | ||
assertFirstFrameContains, | ||
assertCodePaneContains, | ||
assertCodePaneLineCount, | ||
selectSnippetByIndex, | ||
filterSnippets, | ||
toggleSnippets, | ||
assertSnippetCount, | ||
assertSnippetsListIsVisible, | ||
mouseOverSnippet | ||
} from '../support/utils'; | ||
|
||
describe('Snippets', () => { | ||
beforeEach(() => typeCode('<div>Initial <span>code')); | ||
|
||
it('driven with mouse', () => { | ||
// Open and format for insertion point | ||
toggleSnippets(); | ||
assertSnippetsListIsVisible(); | ||
assertCodePaneLineCount(8); | ||
|
||
// Browse snippetlist | ||
assertSnippetCount(4); | ||
mouseOverSnippet(0); | ||
assertFirstFrameContains('Initial code\nFoo\nFoo'); | ||
mouseOverSnippet(1); | ||
assertFirstFrameContains('Initial code\nFoo\nRed Foo'); | ||
mouseOverSnippet(2); | ||
assertFirstFrameContains('Initial code\nBar\nBar'); | ||
|
||
// Close without persisting | ||
toggleSnippets(); | ||
assertCodePaneContains('<div>Initial <span>code</span></div>'); | ||
assertCodePaneLineCount(1); | ||
|
||
// Re-open and persist | ||
toggleSnippets(); | ||
mouseOverSnippet(3); | ||
assertFirstFrameContains('Initial code\nBar\nBlue Bar'); | ||
selectSnippetByIndex(3).click(); | ||
assertFirstFrameContains('Initial code\nBar\nBlue Bar'); | ||
assertCodePaneLineCount(7); | ||
assertCodePaneContains(dedent` | ||
<div> | ||
Initial{" "} | ||
<span> | ||
code<Bar color="blue">Blue Bar</Bar> | ||
</span> | ||
</div>\n | ||
`); | ||
typeCode('cursor position'); | ||
assertCodePaneContains(dedent` | ||
<div> | ||
Initial{" "} | ||
<span> | ||
code<Bar color="blue">Blue Bar</Bar>cursor position | ||
</span> | ||
</div>\n | ||
`); | ||
}); | ||
|
||
it('driven with keyboard', () => { | ||
// Open and format for insertion point | ||
typeCode(`${navigator.platform.match('Mac') ? '{cmd}' : '{ctrl}'}k`); | ||
assertSnippetsListIsVisible(); | ||
assertCodePaneLineCount(8); | ||
filterSnippets('{esc}'); | ||
assertCodePaneLineCount(1); | ||
typeCode(`${navigator.platform.match('Mac') ? '{cmd}' : '{ctrl}'}k`); | ||
assertSnippetsListIsVisible(); | ||
assertCodePaneLineCount(8); | ||
|
||
// Browse snippetlist | ||
assertSnippetCount(4); | ||
filterSnippets('{downarrow}'); | ||
assertFirstFrameContains('Initial code\nFoo\nFoo'); | ||
filterSnippets('{downarrow}'); | ||
assertFirstFrameContains('Initial code\nFoo\nRed Foo'); | ||
filterSnippets('{downarrow}'); | ||
assertFirstFrameContains('Initial code\nBar\nBar'); | ||
|
||
// Close without persisting | ||
filterSnippets('{esc}'); | ||
assertCodePaneContains('<div>Initial <span>code</span></div>'); | ||
assertCodePaneLineCount(1); | ||
|
||
// Re-open and persist | ||
typeCode(`${navigator.platform.match('Mac') ? '{cmd}' : '{ctrl}'}k`); | ||
filterSnippets('{downarrow}{downarrow}{downarrow}{downarrow}{enter}'); | ||
assertFirstFrameContains('Initial code\nBar\nBlue Bar'); | ||
assertCodePaneLineCount(7); | ||
assertCodePaneContains(dedent` | ||
<div> | ||
Initial{" "} | ||
<span> | ||
code<Bar color="blue">Blue Bar</Bar> | ||
</span> | ||
</div>\n | ||
`); | ||
typeCode('cursor position'); | ||
assertCodePaneContains(dedent` | ||
<div> | ||
Initial{" "} | ||
<span> | ||
code<Bar color="blue">Blue Bar</Bar>cursor position | ||
</span> | ||
</div>\n | ||
`); | ||
}); | ||
}); |
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,37 @@ | ||
import { | ||
assertFramesMatch, | ||
selectWidthPreferenceByIndex, | ||
visit | ||
} from '../support/utils'; | ||
|
||
describe('Toolbar', () => { | ||
it('filter widths', () => { | ||
const frames = ['320px', '375px', '768px', '1024px']; | ||
const widthIndexToSelect = 1; | ||
|
||
assertFramesMatch(frames); | ||
selectWidthPreferenceByIndex(widthIndexToSelect); | ||
assertFramesMatch([frames[widthIndexToSelect]]); | ||
}); | ||
|
||
it('copy to clipboard', () => { | ||
const copySpy = cy.spy(); | ||
|
||
visit( | ||
'http://localhost:9000/#?code=N4Igxg9gJgpiBcIA8AxCEB8r1YEIEMAnAei2LUyXJxAF8g' | ||
); | ||
|
||
cy.document() | ||
.then(doc => { | ||
cy.stub(doc, 'execCommand', args => { | ||
if (args === 'copy') { | ||
copySpy(); | ||
return true; | ||
} | ||
}); | ||
}) | ||
.get('[data-testid="copyToClipboard"]') | ||
.click() | ||
.then(() => expect(copySpy).to.have.been.called); | ||
}); | ||
}); |
Oops, something went wrong.