hedgedoc/cypress/support/getMarkdownRenderer.ts
Tilman Vatteroth 1fef30bebc Add new data property to iframe that indicates if the content is ready.
Some tests fail because the iframe hasn't loaded the inner hedgedoc renderer yet
but cypress tries to travel through the dom and verify the render results.

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
2021-06-19 16:41:43 +02:00

28 lines
678 B
TypeScript

/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
declare namespace Cypress {
interface Chainable {
getMarkdownRenderer(): Chainable<Element>
getMarkdownBody(): Chainable<Element>
}
}
Cypress.Commands.add('getMarkdownRenderer', () => {
return cy
.get(`iframe[data-cy="documentIframe"][data-content-ready="true"]`)
.should('be.visible')
.its('0.contentDocument')
.should('exist')
.its('body')
.should('not.be.undefined')
.then(cy.wrap.bind(cy))
})
Cypress.Commands.add('getMarkdownBody', () => {
return cy.getMarkdownRenderer().find('.markdown-body')
})