diff options
author | Vinicius Reis <vinicius.reis@nextcloud.com> | 2022-04-20 00:59:57 +0300 |
---|---|---|
committer | Vinicius Reis <vinicius.reis@nextcloud.com> | 2022-04-20 00:59:57 +0300 |
commit | a555ff058025380032cc96338def8f2bb05b3a1b (patch) | |
tree | 55bb90e91ba0e01a4d470086541c2c83eaf9e703 /cypress | |
parent | ed315459132834fc74863653d692d9d0bc597f76 (diff) |
✅ (#2097): add link integration tests
Signed-off-by: Vinicius Reis <vinicius.reis@nextcloud.com>
Diffstat (limited to 'cypress')
-rw-r--r-- | cypress/fixtures/empty.md | 0 | ||||
-rw-r--r-- | cypress/integration/links.spec.js | 71 | ||||
-rw-r--r-- | cypress/support/commands.js | 4 |
3 files changed, 75 insertions, 0 deletions
diff --git a/cypress/fixtures/empty.md b/cypress/fixtures/empty.md new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/cypress/fixtures/empty.md diff --git a/cypress/integration/links.spec.js b/cypress/integration/links.spec.js new file mode 100644 index 000000000..98df8fbe0 --- /dev/null +++ b/cypress/integration/links.spec.js @@ -0,0 +1,71 @@ +import { randHash } from '../utils/' + +const randUser = randHash() +const fileName = 'empty.md' + +const getEditor = () => cy.get('#viewer #editor .ProseMirror') + +const clearContent = () => getEditor() + .type('{selectall}') + .type('{enter}') + +describe('test link marks', function() { + before(function() { + // Init user + cy.nextcloudCreateUser(randUser, 'password') + cy.login(randUser, 'password') + + // Upload test files + cy.uploadFile('test.md', 'text/markdown') + cy.uploadFile(fileName, 'text/markdown') + }) + + beforeEach(function() { + cy.login(randUser, 'password') + + cy.visit('/apps/files', { + onBeforeLoad(win) { + cy.stub(win, 'open') + .as('winOpen') + + }, + }).as('page') + + cy.openFile(fileName) + }) + + describe('autolink', function() { + beforeEach(clearContent) + it('with protocol', () => { + cy.getFile('test.md') + .then($el => { + const id = $el.data('id') + + const link = `${Cypress.env('baseUrl')}/file-name?fileId=${id}` + getEditor() + .type(link) + + getEditor() + .get(`a[href*="${Cypress.env('baseUrl')}`) + .click({ force: true }) + + cy.get('@winOpen') + .should('have.been.calledOnce') + .should('have.been.calledWith', `/index.php/f/${id}`) + }) + }) + + it('whithout protocol', () => { + getEditor() + .type('google.com') + + getEditor() + .get('a[href*="google.com"]') + .click({ force: true }) + + cy.get('@winOpen') + .should('have.been.calledOnce') + .should('have.been.calledWith', 'http://google.com/') + }) + }) +}) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index b04170534..f9289a486 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -166,6 +166,10 @@ Cypress.Commands.add('openFile', fileName => { cy.wait(250) }) +Cypress.Commands.add('getFile', fileName => { + return cy.get(`#fileList tr[data-file="${fileName}"]`) +}) + Cypress.Commands.add('deleteFile', fileName => { cy.get(`#fileList tr[data-file="${fileName}"] a.name .action-menu`).click() cy.get(`#fileList tr[data-file="${fileName}"] a.name + .popovermenu .action-delete`).click() |