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 325cbba
Showing 1 changed file with 24 additions and 36 deletions.
60 changes: 24 additions & 36 deletions cypress/e2e/nodes/Links.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,28 @@ 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('.widgets--list', { timeout: 10000 })
.find('a[href*="https://nextcloud.com"]')
.click()

cy.get('.link-view-bubble .widget-default', { 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() {
it('with protocol to files app and fileId', () => {
it.only('with protocol to files app and fileId', () => {
cy.getFile(fileName)
.then($el => {
const id = $el.data('id')
const id = $el.data('cyFilesListRowFileid')

const link = `${Cypress.env('baseUrl')}/apps/files/file-name?fileId=${id}`
const link = `${Cypress.env('baseUrl')}/apps/files/?dir=/&openfile=${id}#relPath=/${fileName}`
cy.clearContent()
cy.getContent()
.type(`${link}{enter}`)
Expand All @@ -56,29 +50,15 @@ describe('test link marks', function() {
.find(`a[href*="${Cypress.env('baseUrl')}"]`)
.click({ force: true })

cy.get('@winOpen')
.should('have.been.calledOnce')
.should('have.been.calledWithMatch', new RegExp(`/f/${id}$`))
})
})

it('with protocol and fileId', () => {
cy.getFile(fileName)
.then($el => {
const id = $el.data('id')

const link = `${Cypress.env('baseUrl')}/file-name?fileId=${id}`
cy.clearContent()
cy.getContent()
.type(`${link}{enter}`)

cy.getContent()
.find(`a[href*="${Cypress.env('baseUrl')}"]`)
.click({ force: true })
cy.get('.link-view-bubble .widget-file', { timeout: 10000 })
.find('.widget-file--details')
.click()

/** Clicking on the file widget opens it in viewer, but same file is already opened
cy.get('@winOpen')
.should('have.been.calledOnce')
.should('have.been.calledWithMatch', new RegExp(`${Cypress.env('baseUrl')}/file-name\\?fileId=${id}$`))
.should('have.been.calledWithMatch', new RegExp(`/f/${id}$`))
*/
})
})

Expand Down Expand Up @@ -116,6 +96,10 @@ describe('test link marks', function() {
.should('have.text', text) // ensure correct text used
.click({ force: true })

cy.get('.link-view-bubble .widget-default', { 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 +132,14 @@ 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 .widget-file', { timeout: 10000 })
.find('.widget-file--details')
.click()
}

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

0 comments on commit 325cbba

Please sign in to comment.