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