Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
Refs #101 - Cypress integration test block focusing
Browse files Browse the repository at this point in the history
  • Loading branch information
avoinea committed Jun 24, 2021
1 parent 04dd071 commit 98e7617
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
2 changes: 0 additions & 2 deletions cypress/integration/03-block-slate.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ describe('Block Tests', () => {
.type('{leftarrow}')
.type('{enter}');

// s1.lineBreakInSlate();

getSlateBlockValue(cy.get('.slate-editor').first()).then((val) => {
expect(val).to.deep.eq([
{
Expand Down
58 changes: 58 additions & 0 deletions cypress/integration/04-block-focus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { slateBeforeEach, slateAfterEach } from '../support';

describe('Block Tests', () => {
beforeEach(slateBeforeEach);
afterEach(slateAfterEach);

it('As editor I can add a link to a text block', function () {
// Complete chained commands
cy.get('.slate-editor [contenteditable=true]')
.focus()
.click()
.wait(1000)
.type('Colorless green ideas sleep furiously.');

cy.get('.slate-editor.selected [contenteditable=true]').setSelection(
'furiously',
);

// This also works
cy.get('.slate-editor [contenteditable=true]')
.focus()
.click()
.wait(1000)
.type('Colorless green ideas sleep furiously.')
.setSelection('furiously');

// As a function
const getSlateEditorAndType = (selector, type) => {
return cy.get(selector).focus().click().wait(1000).type(type);
};

getSlateEditorAndType(
'.slate-editor [contenteditable=true]',
'Colorless green ideas sleep furiously.',
).setSelection('furiously');

cy.get('.slate-inline-toolbar .button-wrapper a[title="Link"]').click();
cy.get('.sidebar-container a.item:nth-child(3)').click();
cy.get('input[name="external_link-0-external"]').click().type('https://google.com{enter}');
cy.get('.sidebar-container .form .header button:first-of-type').click();

cy.get('#toolbar-save').click();
cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page');
cy.waitForResourceToLoad('@navigation');
cy.waitForResourceToLoad('@breadcrumbs');
cy.waitForResourceToLoad('@actions');
cy.waitForResourceToLoad('@types');
cy.waitForResourceToLoad('my-page');

// then the page view should contain a link
cy.get('.ui.container p').contains(
'Colorless green ideas sleep furiously.',
);
cy.get('.ui.container p a')
.should('have.attr', 'href')
.and('include', 'https://google.com');
});
});

0 comments on commit 98e7617

Please sign in to comment.