Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Resolve cursor position & toolbar flicker bugs #134

Merged
merged 6 commits into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions cypress/integration/editor.js
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);
});
});
7 changes: 7 additions & 0 deletions cypress/integration/smoke.js
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');
});
});
204 changes: 0 additions & 204 deletions cypress/integration/smokeTest.js

This file was deleted.

112 changes: 112 additions & 0 deletions cypress/integration/snippets.js
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
`);
});
});
37 changes: 37 additions & 0 deletions cypress/integration/toolbar.js
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);
});
});
Loading