2021-11-19 12:04:04 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
declare namespace Cypress {
|
|
|
|
interface Chainable {
|
2021-12-25 10:44:24 -05:00
|
|
|
getByCypressId(id: string): Chainable<Element>
|
|
|
|
|
|
|
|
findByCypressId(id: string): Chainable<Element>
|
2021-11-19 12:04:04 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const CYPRESS_ATTR = 'data-cypress-id'
|
|
|
|
|
2021-12-25 10:44:24 -05:00
|
|
|
Cypress.Commands.add('getByCypressId', (id: string) => {
|
2021-11-19 12:04:04 -05:00
|
|
|
return cy.get(`[${CYPRESS_ATTR}="${id}"]`)
|
|
|
|
})
|
|
|
|
|
|
|
|
Cypress.Commands.add(
|
2021-12-25 10:44:24 -05:00
|
|
|
'findByCypressId',
|
2021-11-19 12:04:04 -05:00
|
|
|
{
|
|
|
|
prevSubject: 'element'
|
|
|
|
},
|
|
|
|
(parent: JQuery<HTMLElement>, id: string) => {
|
|
|
|
return cy.wrap(parent).find(`[${CYPRESS_ATTR}="${id}"]`)
|
|
|
|
}
|
|
|
|
)
|