|
| 1 | +/** |
| 2 | + * SPDX-FileCopyrightText: 2023 Julius Härtl <jus@bitgrid.net> |
| 3 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | + */ |
| 5 | + |
| 6 | +describe('Talk integraiton integration', function() { |
| 7 | + let randUser |
| 8 | + |
| 9 | + const resetConfig = () => { |
| 10 | + cy.nextcloudTestingAppConfigSet('files', 'watermark_enabled', 'no') |
| 11 | + cy.nextcloudTestingAppConfigSet('files', 'watermark_text', '{userId}') |
| 12 | + cy.nextcloudTestingAppConfigSet('files', 'watermark_shareTalkPublic', 'no') |
| 13 | + cy.nextcloudTestingAppConfigSet('richdocuments', 'uiDefaults-UIMode', 'notebookbar') |
| 14 | + } |
| 15 | + |
| 16 | + before(function() { |
| 17 | + resetConfig() |
| 18 | + cy.createRandomUser().then(user => { |
| 19 | + randUser = user |
| 20 | + cy.login(user) |
| 21 | + cy.uploadFile(user, 'document.odt', 'application/vnd.oasis.opendocument.text', '/document.odt') |
| 22 | + }) |
| 23 | + }) |
| 24 | + |
| 25 | + afterEach(() => { |
| 26 | + resetConfig() |
| 27 | + }) |
| 28 | + |
| 29 | + const filename = 'document.odt' |
| 30 | + |
| 31 | + beforeEach(function() { |
| 32 | + cy.login(randUser) |
| 33 | + }) |
| 34 | + |
| 35 | + it('Can share a file to a talk room and open it', function() { |
| 36 | + cy.createTalkRoom(randUser, { |
| 37 | + roomName: 'Test room', |
| 38 | + }).then(room => { |
| 39 | + cy.log(`Created talk room "${room.name}"`, room) |
| 40 | + cy.shareFileToTalkRoom(randUser, filename, room.token) |
| 41 | + cy.visit(`/call/${room.token}`) |
| 42 | + cy.get('.file-preview') |
| 43 | + .should('be.visible') |
| 44 | + .should('contain.text', filename) |
| 45 | + .click() |
| 46 | + |
| 47 | + cy.waitForViewer() |
| 48 | + cy.waitForCollabora() |
| 49 | + }) |
| 50 | + }) |
| 51 | + |
| 52 | + it('See that the file is shared without download', function() { |
| 53 | + cy.nextcloudTestingAppConfigSet('files', 'watermark_enabled', 'yes') |
| 54 | + cy.nextcloudTestingAppConfigSet('files', 'watermark_shareTalkPublic', 'yes') |
| 55 | + cy.nextcloudTestingAppConfigSet('files', 'watermark_text', 'TestingWatermark') |
| 56 | + |
| 57 | + cy.createTalkRoom(randUser, { |
| 58 | + roomName: 'Secure room', |
| 59 | + }).then(room => { |
| 60 | + cy.log(`Created talk room "${room.name}"`, room) |
| 61 | + cy.shareFileToTalkRoom(randUser, filename, room.token, { permission: 1 }) |
| 62 | + cy.makeTalkRoomPublic(randUser, room.token) |
| 63 | + |
| 64 | + cy.logout() |
| 65 | + cy.clearAllLocalStorage() |
| 66 | + cy.visit(`/call/${room.token}`) |
| 67 | + cy.get('.username-form__input input[type="text"]') |
| 68 | + .should('be.visible') |
| 69 | + .type('Test user{enter}') |
| 70 | + |
| 71 | + // Assert that the download button is hidden in talk |
| 72 | + cy.get('.messages:contains("document.odt")') |
| 73 | + .trigger('mouseover') |
| 74 | + |
| 75 | + cy.get('.file-preview') |
| 76 | + .closest('.message') |
| 77 | + .find('button[aria-label="Actions"]') |
| 78 | + .should('be.visible') |
| 79 | + .click() |
| 80 | + |
| 81 | + cy.get('.action:contains("Download")') |
| 82 | + .should('not.exist') |
| 83 | + |
| 84 | + // Assert the file is still opening |
| 85 | + cy.get('.file-preview') |
| 86 | + .should('be.visible') |
| 87 | + .should('contain.text', filename) |
| 88 | + // We need to get the href to work around how cypress works with windows |
| 89 | + .invoke('attr', 'href') |
| 90 | + .then((href) => { |
| 91 | + cy.visit(href) |
| 92 | + |
| 93 | + cy.get('[data-cy="guestNameModal"]').should('be.visible') |
| 94 | + cy.inputCollaboraGuestName('A guest') |
| 95 | + |
| 96 | + cy.waitForCollabora() |
| 97 | + |
| 98 | + cy.url().then(url => { |
| 99 | + const baseUrl = url.split('?')[0] |
| 100 | + cy.request({ |
| 101 | + url: baseUrl + '/download', |
| 102 | + failOnStatusCode: false, |
| 103 | + }).then((response) => { |
| 104 | + expect(response.status).to.eq(403) |
| 105 | + }) |
| 106 | + }) |
| 107 | + }) |
| 108 | + }) |
| 109 | + }) |
| 110 | +}) |
0 commit comments