1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-01-17 21:49:20 +01:00
Adrian e3a325f8a6
iframe example - use an onLoad callback instead of the ref (#4758)
* use an onLoad callback instead of the ref

* expect body to not be null on the iframe test

* remove onLoad prop
2022-01-10 16:21:20 -07:00

33 lines
718 B
TypeScript

// Taken from https://www.cypress.io/blog/2020/02/12/working-with-iframes-in-cypress/
const getIframeDocument = () => {
return cy
.get('iframe')
.its('0.contentDocument')
.should('exist')
}
const getIframeBody = () => {
return (
getIframeDocument()
.its('body')
// automatically retries until body is loaded
.should('not.be.undefined')
.should('not.be.null')
.then(cy.wrap)
)
}
describe('iframe editor', () => {
beforeEach(() => {
cy.visit('examples/iframe')
})
it('should be editable', () => {
getIframeBody()
.findByRole('textbox')
.type('{movetostart}')
.type('Hello World')
.should('contain.text', 'Hello World')
})
})