Add cypress workflow (#1638)

* Add cypress workflow

* Setup different browsers

* Pull tools

* Update ff image

* Fix test

* Adopt tests

* Fix eslint
This commit is contained in:
George Berezhnoy 2021-04-08 23:15:42 +03:00 committed by GitHub
parent 3b20c4a139
commit 2c77edb457
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 8 deletions

33
.github/workflows/cypress.yml vendored Normal file
View file

@ -0,0 +1,33 @@
name: Tests
on: [pull_request]
jobs:
firefox:
runs-on: ubuntu-latest
container:
image: cypress/browsers:node14.16.0-chrome89-ff86
options: --user 1001
steps:
- uses: actions/checkout@v2
- run: yarn pull_tools
- uses: cypress-io/github-action@v2
with:
browser: firefox
build: yarn build
chrome:
runs-on: ubuntu-16.04
steps:
- uses: actions/checkout@v2
- run: yarn pull_tools
- uses: cypress-io/github-action@v2
with:
browser: chrome
build: yarn build
edge:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- run: yarn pull_tools
- uses: cypress-io/github-action@v2
with:
browser: edge
build: yarn build

View file

@ -18,12 +18,14 @@ describe('Copy pasting from Editor', () => {
context('pasting', () => {
it('should paste plain text', () => {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.get('[data-cy=editorjs]')
.get('div.ce-block')
.click()
.paste({
'text/plain': 'Some plain text',
})
.wait(0)
.should('contain', 'Some plain text');
});
@ -161,7 +163,7 @@ describe('Copy pasting from Editor', () => {
})
.copy()
.then(clipboardData => {
expect(clipboardData['text/html']).to.eq('<p>First block</p><p>Second block</p>');
expect(clipboardData['text/html']).to.match(/<p>First block(<br>)?<\/p><p>Second block(<br>)?<\/p>/);
expect(clipboardData['text/plain']).to.eq(`First block\n\nSecond block`);
/**
@ -174,9 +176,9 @@ describe('Copy pasting from Editor', () => {
const data = JSON.parse(clipboardData['application/x-editor-js']);
expect(data[0].tool).to.eq('paragraph');
expect(data[0].data).to.deep.eq({ text: 'First block' });
expect(data[0].data.text).to.match(/First block(<br>)?/);
expect(data[1].tool).to.eq('paragraph');
expect(data[1].data).to.deep.eq({ text: 'Second block' });
expect(data[1].data.text).to.match(/Second block(<br>)?/);
});
});
});
@ -214,7 +216,7 @@ describe('Copy pasting from Editor', () => {
})
.cut()
.then(clipboardData => {
expect(clipboardData['text/html']).to.eq('<p>First block</p><p>Second block</p>');
expect(clipboardData['text/html']).to.match(/<p>First block(<br>)?<\/p><p>Second block(<br>)?<\/p>/);
expect(clipboardData['text/plain']).to.eq(`First block\n\nSecond block`);
/**
@ -227,9 +229,9 @@ describe('Copy pasting from Editor', () => {
const data = JSON.parse(clipboardData['application/x-editor-js']);
expect(data[0].tool).to.eq('paragraph');
expect(data[0].data).to.deep.eq({ text: 'First block' });
expect(data[0].data.text).to.match(/First block(<br>)?/);
expect(data[1].tool).to.eq('paragraph');
expect(data[1].data).to.deep.eq({ text: 'Second block' });
expect(data[1].data.text).to.match(/Second block(<br>)?/);
});
});

View file

@ -44,7 +44,7 @@ describe('Output sanitisation', () => {
const text = output.blocks[0].data.text;
expect(text).to.eq('<b>This text should be bold.</b>');
expect(text).to.match(/<b>This text should be bold\.(<br>)?<\/b>/);
});
});

View file

@ -5,7 +5,7 @@ import BlockTool from '../../../../src/components/tools/block';
import InlineTool from '../../../../src/components/tools/inline';
import ToolsCollection from '../../../../src/components/tools/collection';
describe.only('BlockTool', () => {
describe('BlockTool', () => {
/**
* Mock for BlockTool constructor options
*/