Skip to content

Commit

Permalink
test(cypress): Fix link tests with link bubble
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- committed Jan 23, 2024
1 parent 2153566 commit ac2c647
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions cypress/e2e/nodes/Links.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,20 @@ describe('test link marks', function() {
cy.openFile(fileName, { force: true })
})

describe('link preview', function() {
it('shows a link preview', () => {
describe('link bubble', function() {
it('shows a link preview in the bubble', () => {
cy.getContent().type('https://nextcloud.com')
cy.getContent().type('{enter}')

cy.getContent()
.find('a[href*="https://nextcloud.com"]')
.click()

cy.get('.link-view-bubble')
.find('.widgets--list', { timeout: 10000 })
.find('.widget-default--name')
.contains('Nextcloud')
})

it('does not show a link preview for links within a paragraph', () => {
cy.getContent().type('Please visit https://nextcloud.com')
cy.getContent().type('{enter}')

cy.getContent()
.find('.widgets--list', { timeout: 10000 })
.should('not.exist')
})
})

describe('autolink', function() {
Expand All @@ -56,6 +51,11 @@ describe('test link marks', function() {
.find(`a[href*="${Cypress.env('baseUrl')}"]`)
.click({ force: true })

cy.get('.link-view-bubble')
.find('.widget--list', { timeout: 10000 })
.find('.widget-file--details')
.click()

cy.get('@winOpen')
.should('have.been.calledOnce')
.should('have.been.calledWithMatch', new RegExp(`/f/${id}$`))
Expand All @@ -76,6 +76,11 @@ describe('test link marks', function() {
.find(`a[href*="${Cypress.env('baseUrl')}"]`)
.click({ force: true })

cy.get('.link-view-bubble')
.find('.widget--list', { timeout: 10000 })
.find('.widget-file--details')
.click()

cy.get('@winOpen')
.should('have.been.calledOnce')
.should('have.been.calledWithMatch', new RegExp(`${Cypress.env('baseUrl')}/file-name\\?fileId=${id}$`))
Expand Down Expand Up @@ -116,6 +121,11 @@ describe('test link marks', function() {
.should('have.text', text) // ensure correct text used
.click({ force: true })

cy.get('.link-view-bubble')
.find('.widget--list', { timeout: 10000 })
.find('.widget-default--name')
.click()

cy.get('@winOpen')
.should('have.been.calledOnce')
.should('have.been.calledWith', url)
Expand Down Expand Up @@ -148,10 +158,15 @@ describe('test link marks', function() {
cy.contains('button', isFolder ? 'Choose' : `Choose ${filename}`).click()
})

return cy.getContent()
cy.getContent()
.find(`a[href*="${encodeURIComponent(filename)}"]`)
.should('have.text', text === undefined ? filename : text)
.click({ force: true })

return cy.get('.link-view-bubble')
.find('.widget--list', { timeout: 10000 })
.find('.widget-file--details')
.click()
}

beforeEach(() => cy.clearContent())
Expand Down

0 comments on commit ac2c647

Please sign in to comment.