This repository has been archived by the owner on Oct 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #101 - Cypress integration test block focusing
- Loading branch information
Showing
2 changed files
with
58 additions
and
2 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
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,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'); | ||
}); | ||
}); |