diff options
author | Julius Härtl <jus@bitgrid.net> | 2020-01-04 14:49:18 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2020-01-04 15:37:02 +0300 |
commit | 522efa4d9d383c98711fa78c497acc437873476b (patch) | |
tree | e79f03677f9caab8173a88319092c1c38e9bf47b /cypress | |
parent | 08386c96cf2b942c0d93f32aa0d39505ad6510ac (diff) |
Add public share page tests
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'cypress')
-rw-r--r-- | cypress/.env | 1 | ||||
-rw-r--r-- | cypress/docker-compose.yml | 4 | ||||
-rw-r--r-- | cypress/integration/share.spec.js | 126 | ||||
-rw-r--r-- | cypress/server.sh | 1 | ||||
-rw-r--r-- | cypress/support/commands.js | 6 |
5 files changed, 134 insertions, 4 deletions
diff --git a/cypress/.env b/cypress/.env new file mode 100644 index 000000000..1895b4a1f --- /dev/null +++ b/cypress/.env @@ -0,0 +1 @@ +APP_SOURCE=/home/runner/work/text/text diff --git a/cypress/docker-compose.yml b/cypress/docker-compose.yml index 048cafaa2..9e9eaddff 100644 --- a/cypress/docker-compose.yml +++ b/cypress/docker-compose.yml @@ -9,6 +9,6 @@ services: - 8081:80 environment: CYPRESS_baseUrl: - APP_SOURCE: /home/runner/work/text/text + APP_SOURCE: volumes: - - $APP_SOURCE:/var/www/html/apps/text + - ${APP_SOURCE}:/var/www/html/apps/text diff --git a/cypress/integration/share.spec.js b/cypress/integration/share.spec.js new file mode 100644 index 000000000..3e8fcde57 --- /dev/null +++ b/cypress/integration/share.spec.js @@ -0,0 +1,126 @@ + + +/* + * @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net> + * + * @author Julius Härtl <jus@bitgrid.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +import { randHash } from '../utils/' +const randUser = randHash() + +describe('Open test.md in viewer', function() { + before(function () { + // Init user + cy.nextcloudCreateUser(randUser, 'password') + cy.login(randUser, 'password') + + // Upload test files + cy.uploadFile('test.md', 'text/markdown') + cy.uploadFile('test.md', 'text/markdown', 'test2.md') + cy.visit('/apps/files') + cy.get('#fileList tr[data-file="test.md"]', {timeout: 10000}) + .should('contain', 'test.md') + + // FIXME: files app is thowing the following error for some reason + // Uncaught TypeError: Cannot read property 'protocol' of undefined + // Same for appswebroots setting in tests + cy.on('uncaught:exception', (err, runnable) => { + return false + }) + }) + after(function () { + cy.visit('/apps/files') + cy.logout() + }) + + it('Shares the file as a public read only link', function () { + cy.visit('/apps/files') + cy.get('#fileList tr[data-file="test.md"] a.action-share', {timeout: 10000}).trigger('click') + cy.get('#app-sidebar') + .should('be.visible') + cy.get('#app-sidebar a#sharing').trigger('click') + cy.get('#app-sidebar button.new-share-link').trigger('click') + cy.get('#app-sidebar a.sharing-entry__copy') + .should('have.attr', 'href').and('include', '/s/') + .then((href) => { + cy.visit(href) + cy.window().then(win => { + win.OC.appswebroots['files_texteditor'] = true + cy.wait(1000) + cy.get('#editor', { timeout: 4000 }).should('be.visible') + cy.get('#editor .ProseMirror').should('contain', 'Hello world') + cy.get('#editor .ProseMirror h2').should('contain', 'Hello world') + }) + }) + }) + + it('Shares the file as a public link with write permissions', function () { + cy.visit('/apps/files') + cy.get('#fileList tr[data-file="test2.md"] a.action-share', {timeout: 10000}).trigger('click') + cy.get('#app-sidebar') + .should('be.visible') + cy.get('#app-sidebar a#sharing').trigger('click') + cy.get('#app-sidebar button.new-share-link').trigger('click') + cy.get('#app-sidebar .sharing-link-list .action-item__menutoggle').trigger('click') + cy.get('#app-sidebar .sharing-link-list .action-item__menu input[type=checkbox]').first().check({ force: true }) + cy.get('#app-sidebar .sharing-link-list .action-item__menu input[type=checkbox]', { timeout: 4000 }).first().should('be.checked') + cy.get('#app-sidebar a.sharing-entry__copy') + .should('have.attr', 'href').and('include', '/s/') + .then((href) => { + cy.visit(href) + cy.window().then(win => { + win.OC.appswebroots['files_texteditor'] = true + cy.wait(1000) + cy.get('#editor', {timeout: 10000}).should('be.visible') + cy.get('#editor .ProseMirror').should('contain', 'Hello world') + cy.get('#editor .ProseMirror h2').should('contain', 'Hello world') + cy.get('#editor .menubar .menubar-icons .icon-undo').should('be.visible') + cy.get('#editor .menubar .menubar-icons .icon-redo').should('be.visible') + cy.get('#editor .menubar .menubar-icons .icon-bold').should('be.visible') + }) + }) + }) + + it('Opens the editor as guest', function () { + cy.visit('/apps/files') + cy.get('#fileList tr[data-file="test2.md"] a.action-share', {timeout: 10000}).trigger('click') + cy.get('#app-sidebar') + .should('be.visible') + cy.get('#app-sidebar a#sharing').trigger('click') + cy.get('#app-sidebar a.sharing-entry__copy') + .should('have.attr', 'href').and('include', '/s/') + .then((href) => { + cy.logout() + cy.visit(href) + cy.window().then(win => { + win.OC.appswebroots['files_texteditor'] = true + cy.wait(1000) + cy.get('#editor', {timeout: 10000}).should('be.visible') + cy.get('#editor .ProseMirror').should('contain', 'Hello world') + cy.get('#editor .ProseMirror h2').should('contain', 'Hello world') + cy.get('#editor .menubar .menubar-icons .icon-undo').should('be.visible') + cy.get('#editor .menubar .menubar-icons .icon-redo').should('be.visible') + cy.get('#editor .menubar .menubar-icons .icon-bold').should('be.visible') + }) + }) + }) + + +}) diff --git a/cypress/server.sh b/cypress/server.sh index a50a2c5f0..22f030470 100644 --- a/cypress/server.sh +++ b/cypress/server.sh @@ -1,6 +1,7 @@ #!/bin/bash git clone https://github.com/nextcloud/viewer /var/www/html/apps/viewer su www-data -c " +php occ config:system:set force_language --value en php /var/www/html/occ app:enable viewer php /var/www/html/occ app:enable text php /var/www/html/occ app:list diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 7a0e0be8c..a70605462 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -62,18 +62,20 @@ Cypress.Commands.add('nextcloudCreateUser', (user, password) => { headers: { 'OCS-ApiRequest': 'true', 'Content-Type': 'application/x-www-form-urlencoded', - Authorization: 'Basic YWRtaW46YWRtaW4=' } }).then(response => { cy.log(`Created user ${user}`, response.status) }) }) -Cypress.Commands.add('uploadFile', (fileName, mimeType) => { +Cypress.Commands.add('uploadFile', (fileName, mimeType, target) => { cy.fixture(fileName, 'base64') .then(Cypress.Blob.base64StringToBlob) .then(async blob => { const file = new File([blob], fileName, { type: mimeType }) + if (typeof target !== 'undefined') { + fileName = target + } await cy.window().then(async window => { await axios.put(`${Cypress.env('baseUrl')}/remote.php/webdav/${fileName}`, file, { headers: { |