2021-01-24 14:50:51 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
2021-11-21 06:48:30 -05:00
|
|
|
import { RendererType } from '../../src/components/render-page/window-post-message-communicator/rendering-message'
|
|
|
|
|
2021-01-24 14:50:51 -05:00
|
|
|
declare namespace Cypress {
|
2022-10-06 15:56:52 -04:00
|
|
|
interface Chainable<Subject = unknown> {
|
2021-11-21 06:48:30 -05:00
|
|
|
getIframeBody(rendererType?: RendererType): Chainable<Element>
|
|
|
|
|
2021-10-04 06:50:39 -04:00
|
|
|
getReveal(): Chainable<Element>
|
2021-11-21 06:48:30 -05:00
|
|
|
|
2021-02-03 16:13:04 -05:00
|
|
|
getMarkdownBody(): Chainable<Element>
|
2022-10-06 15:56:52 -04:00
|
|
|
|
2023-03-16 03:20:16 -04:00
|
|
|
getSimpleRendererBody(): Chainable<Element>
|
2021-01-24 14:50:51 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-21 06:48:30 -05:00
|
|
|
Cypress.Commands.add('getIframeBody', (rendererType?: RendererType) => {
|
|
|
|
const renderTypeAttribute = rendererType ? `[data-cypress-renderer-type="${rendererType}"]` : ''
|
2021-06-18 17:26:36 -04:00
|
|
|
return cy
|
2021-11-21 06:48:30 -05:00
|
|
|
.get(`iframe[data-cypress-id="documentIframe"][data-cypress-renderer-ready="true"]${renderTypeAttribute}`)
|
2021-06-18 17:26:36 -04:00
|
|
|
.should('be.visible')
|
|
|
|
.its('0.contentDocument')
|
|
|
|
.should('exist')
|
|
|
|
.its('body')
|
|
|
|
.should('not.be.undefined')
|
|
|
|
.then(cy.wrap.bind(cy))
|
2021-01-24 14:50:51 -05:00
|
|
|
})
|
|
|
|
|
2021-10-04 06:50:39 -04:00
|
|
|
Cypress.Commands.add('getReveal', () => {
|
2021-11-21 06:48:30 -05:00
|
|
|
return cy.getIframeBody(RendererType.SLIDESHOW).find('.reveal')
|
2021-10-04 06:50:39 -04:00
|
|
|
})
|
|
|
|
|
2021-01-24 14:50:51 -05:00
|
|
|
Cypress.Commands.add('getMarkdownBody', () => {
|
2021-12-25 10:44:24 -05:00
|
|
|
return cy.getIframeBody(RendererType.DOCUMENT).findByCypressId('markdown-body')
|
2021-11-21 06:48:30 -05:00
|
|
|
})
|
|
|
|
|
2023-03-16 03:20:16 -04:00
|
|
|
Cypress.Commands.add('getSimpleRendererBody', () => {
|
|
|
|
return cy.getIframeBody(RendererType.SIMPLE).findByCypressId('markdown-body')
|
2022-10-06 15:56:52 -04:00
|
|
|
})
|