2021-01-06 12:09:33 +00:00
|
|
|
/*
|
2022-06-19 18:02:51 +00:00
|
|
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
2021-01-06 12:09:33 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
2022-02-13 11:14:01 +00:00
|
|
|
import 'cypress-fill-command'
|
2021-01-06 12:09:33 +00:00
|
|
|
|
|
|
|
declare namespace Cypress {
|
|
|
|
interface Chainable {
|
2021-10-04 10:50:39 +00:00
|
|
|
setCodemirrorContent(value: string): Chainable<Element>
|
2021-01-06 12:09:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-04 10:50:39 +00:00
|
|
|
Cypress.Commands.add('setCodemirrorContent', (content: string) => {
|
2021-11-19 17:04:04 +00:00
|
|
|
const line = content.split('\n').find((value) => value !== '')
|
2022-06-19 18:02:51 +00:00
|
|
|
cy.getByCypressId('editor-pane')
|
|
|
|
.should('have.attr', 'data-cypress-editor-ready', 'true')
|
|
|
|
.get('.cm-editor')
|
|
|
|
.click()
|
|
|
|
.get('.cm-content')
|
|
|
|
.fill(content)
|
2021-02-03 21:13:04 +00:00
|
|
|
if (line) {
|
2022-06-19 18:02:51 +00:00
|
|
|
cy.getByCypressId('editor-pane')
|
|
|
|
.should('have.attr', 'data-cypress-editor-ready', 'true')
|
|
|
|
.get('.cm-editor')
|
|
|
|
.find('.cm-line')
|
|
|
|
.should('contain.text', line)
|
2021-01-15 21:54:43 +00:00
|
|
|
}
|
2021-01-06 12:09:33 +00:00
|
|
|
})
|