diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml new file mode 100644 index 00000000..8201686a --- /dev/null +++ b/.github/workflows/cypress.yml @@ -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 diff --git a/test/cypress/tests/copy-paste.spec.ts b/test/cypress/tests/copy-paste.spec.ts index 97f6a0ec..beae0177 100644 --- a/test/cypress/tests/copy-paste.spec.ts +++ b/test/cypress/tests/copy-paste.spec.ts @@ -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('
First block
Second block
'); + expect(clipboardData['text/html']).to.match(/First block(
)?<\/p>
Second block(
)?<\/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(
)?/);
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(
)?/);
});
});
});
@@ -214,7 +216,7 @@ describe('Copy pasting from Editor', () => {
})
.cut()
.then(clipboardData => {
- expect(clipboardData['text/html']).to.eq('
First block
Second block
'); + expect(clipboardData['text/html']).to.match(/First block(
)?<\/p>
Second block(
)?<\/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(
)?/);
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(
)?/);
});
});
diff --git a/test/cypress/tests/sanitisation.spec.ts b/test/cypress/tests/sanitisation.spec.ts
index 00808964..2c40206f 100644
--- a/test/cypress/tests/sanitisation.spec.ts
+++ b/test/cypress/tests/sanitisation.spec.ts
@@ -44,7 +44,7 @@ describe('Output sanitisation', () => {
const text = output.blocks[0].data.text;
- expect(text).to.eq('This text should be bold.');
+ expect(text).to.match(/This text should be bold\.(
)?<\/b>/);
});
});
diff --git a/test/cypress/tests/tools/BlockTool.spec.ts b/test/cypress/tests/tools/BlockTool.spec.ts
index da0b33bf..e6306a18 100644
--- a/test/cypress/tests/tools/BlockTool.spec.ts
+++ b/test/cypress/tests/tools/BlockTool.spec.ts
@@ -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
*/