2021-02-22 21:27:59 +00:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
describe('Link gets replaced with embedding: ', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.visitTestEditor()
|
|
|
|
})
|
|
|
|
|
|
|
|
// TODO Add general testing of one-click-embedding component. The tests below just test a specific use of the component.
|
|
|
|
|
|
|
|
it('GitHub Gist', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('https://gist.github.com/schacon/1')
|
2021-11-19 17:04:04 +00:00
|
|
|
cy.getMarkdownBody().findById('click-shield-gist').find('.preview-background').parent().click()
|
|
|
|
cy.getMarkdownBody().findById('gh-gist').should('be.visible')
|
2021-02-22 21:27:59 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('YouTube', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('https://www.youtube.com/watch?v=YE7VzlLtp-4')
|
2021-02-22 21:27:59 +00:00
|
|
|
cy.getMarkdownBody()
|
2021-11-19 17:04:04 +00:00
|
|
|
.findById('click-shield-youtube')
|
|
|
|
.find('.preview-background')
|
2021-02-22 21:27:59 +00:00
|
|
|
.should('have.attr', 'src', 'https://i.ytimg.com/vi/YE7VzlLtp-4/maxresdefault.jpg')
|
|
|
|
.parent()
|
|
|
|
.click()
|
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('iframe')
|
|
|
|
.should('have.attr', 'src', 'https://www.youtube-nocookie.com/embed/YE7VzlLtp-4?autoplay=1')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Vimeo', () => {
|
2021-11-19 17:04:04 +00:00
|
|
|
cy.intercept(
|
|
|
|
{
|
|
|
|
method: 'GET',
|
|
|
|
url: 'https://vimeo.com/api/v2/video/23237102.json'
|
2021-02-22 21:27:59 +00:00
|
|
|
},
|
2021-11-19 17:04:04 +00:00
|
|
|
{
|
|
|
|
statusCode: 200,
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json'
|
|
|
|
},
|
|
|
|
body: '[{"thumbnail_large": "https://i.vimeocdn.com/video/503631401_640.jpg"}]'
|
|
|
|
}
|
|
|
|
)
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('https://vimeo.com/23237102')
|
2021-02-22 21:27:59 +00:00
|
|
|
cy.getMarkdownBody()
|
2021-11-19 17:04:04 +00:00
|
|
|
.findById('click-shield-vimeo')
|
|
|
|
.find('.preview-background')
|
2021-02-22 21:27:59 +00:00
|
|
|
.should('have.attr', 'src', 'https://i.vimeocdn.com/video/503631401_640.jpg')
|
|
|
|
.parent()
|
|
|
|
.click()
|
2021-11-19 17:04:04 +00:00
|
|
|
cy.getMarkdownBody().find('iframe').should('have.attr', 'src', 'https://player.vimeo.com/video/23237102?autoplay=1')
|
2021-02-22 21:27:59 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Asciinema', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('https://asciinema.org/a/117928')
|
2021-02-22 21:27:59 +00:00
|
|
|
cy.getMarkdownBody()
|
2021-11-19 17:04:04 +00:00
|
|
|
.findById('click-shield-asciinema')
|
|
|
|
.find('.preview-background')
|
2021-02-22 21:27:59 +00:00
|
|
|
.should('have.attr', 'src', 'https://asciinema.org/a/117928.png')
|
|
|
|
.parent()
|
|
|
|
.click()
|
2021-11-19 17:04:04 +00:00
|
|
|
cy.getMarkdownBody().find('iframe').should('have.attr', 'src', 'https://asciinema.org/a/117928/embed?autoplay=1')
|
2021-02-22 21:27:59 +00:00
|
|
|
})
|
|
|
|
})
|