mirror of
https://github.com/nextcloud/richdocuments.git
synced 2025-12-18 05:20:43 +01:00
test(cypress-talk): Add e2e test talk shares opening viewer and for secure view in talk shares
Signed-off-by: Julius Knorr <jus@bitgrid.net>
This commit is contained in:
parent
2a83615567
commit
b41719c97b
4 changed files with 190 additions and 8 deletions
20
.github/workflows/cypress-e2e.yml
vendored
20
.github/workflows/cypress-e2e.yml
vendored
|
|
@ -58,6 +58,11 @@ jobs:
|
|||
git submodule sync --recursive
|
||||
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
|
||||
|
||||
- name: Register main git reference
|
||||
run: |
|
||||
main_app_ref="$(if [ "${{ matrix.server-versions }}" = "master" ]; then echo -n "main"; else echo -n "${{ matrix.server-versions }}"; fi)"
|
||||
echo "main_app_ref=$main_app_ref" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout viewer
|
||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
with:
|
||||
|
|
@ -65,6 +70,13 @@ jobs:
|
|||
ref: ${{ matrix.server-versions }}
|
||||
path: apps/viewer
|
||||
|
||||
- name: Checkout spreed
|
||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
with:
|
||||
repository: nextcloud/spreed
|
||||
ref: ${{ env.main_app_ref }}
|
||||
path: apps/spreed
|
||||
|
||||
- name: Checkout files_pdfviewer
|
||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
with:
|
||||
|
|
@ -106,6 +118,13 @@ jobs:
|
|||
run: |
|
||||
composer install
|
||||
|
||||
- name: Build talk
|
||||
working-directory: apps/spreed
|
||||
run: |
|
||||
composer install --no-dev
|
||||
npm ci
|
||||
npm run dev
|
||||
|
||||
- name: Set up Nextcloud
|
||||
env:
|
||||
DB_PORT: 4444
|
||||
|
|
@ -125,6 +144,7 @@ jobs:
|
|||
php occ app:enable --force viewer
|
||||
php occ app:enable --force files_pdfviewer
|
||||
php occ app:enable --force richdocuments
|
||||
php occ app:enable --force spreed
|
||||
php occ app:list
|
||||
php occ config:system:set trusted_domains 1 --value="172.17.0.1"
|
||||
|
||||
|
|
|
|||
|
|
@ -180,4 +180,4 @@ describe('Nextcloud integration', function() {
|
|||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
111
cypress/e2e/talk.spec.js
Normal file
111
cypress/e2e/talk.spec.js
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/**
|
||||
* SPDX-FileCopyrightText: 2023 Julius Härtl <jus@bitgrid.net>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
describe('Talk integraiton integration', function() {
|
||||
let randUser
|
||||
|
||||
const resetConfig = () => {
|
||||
cy.nextcloudTestingAppConfigSet('files', 'watermark_enabled', 'no')
|
||||
cy.nextcloudTestingAppConfigSet('files', 'watermark_text', '{userId}')
|
||||
cy.nextcloudTestingAppConfigSet('files', 'watermark_shareTalkPublic', 'no')
|
||||
cy.nextcloudTestingAppConfigSet('richdocuments', 'uiDefaults-UIMode', 'notebookbar')
|
||||
}
|
||||
|
||||
before(function() {
|
||||
resetConfig()
|
||||
cy.createRandomUser().then(user => {
|
||||
randUser = user
|
||||
cy.login(user)
|
||||
cy.uploadFile(user, 'document.odt', 'application/vnd.oasis.opendocument.text', '/document.odt')
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
resetConfig()
|
||||
})
|
||||
|
||||
const filename = 'document.odt'
|
||||
|
||||
beforeEach(function() {
|
||||
cy.login(randUser)
|
||||
})
|
||||
|
||||
it('Can share a file to a talk room and open it', function() {
|
||||
cy.createTalkRoom(randUser, {
|
||||
roomName: 'Test room',
|
||||
}).then(room => {
|
||||
cy.log(`Created talk room "${room.name}"`, room)
|
||||
cy.shareFileToTalkRoom(randUser, filename, room.token)
|
||||
cy.visit(`/call/${room.token}`)
|
||||
cy.get('.file-preview')
|
||||
.should('be.visible')
|
||||
.should('contain.text', filename)
|
||||
.click()
|
||||
|
||||
cy.waitForViewer()
|
||||
cy.waitForCollabora()
|
||||
})
|
||||
})
|
||||
|
||||
it('See that the file is shared without download', function() {
|
||||
cy.nextcloudTestingAppConfigSet('files', 'watermark_enabled', 'yes')
|
||||
cy.nextcloudTestingAppConfigSet('files', 'watermark_shareTalkPublic', 'yes')
|
||||
cy.nextcloudTestingAppConfigSet('files', 'watermark_text', 'TestingWatermark')
|
||||
|
||||
cy.createTalkRoom(randUser, {
|
||||
roomName: 'Secure room',
|
||||
}).then(room => {
|
||||
cy.log(`Created talk room "${room.name}"`, room)
|
||||
cy.shareFileToTalkRoom(randUser, filename, room.token, { permission: 1 })
|
||||
cy.makeTalkRoomPublic(randUser, room.token)
|
||||
|
||||
cy.logout()
|
||||
cy.clearAllLocalStorage()
|
||||
cy.visit(`/call/${room.token}`)
|
||||
cy.get('.username-form__input input[type="text"]')
|
||||
.should('be.visible')
|
||||
.type('Test user{enter}')
|
||||
|
||||
// Assert that the download button is hidden in talk
|
||||
cy.get('.messages:contains("document.odt")')
|
||||
.trigger('mouseover')
|
||||
|
||||
cy.get('.file-preview')
|
||||
.closest('.message')
|
||||
.find('button[aria-label="Actions"]')
|
||||
.should('be.visible')
|
||||
.click()
|
||||
|
||||
cy.get('.action:contains("Download")')
|
||||
.should('not.exist')
|
||||
|
||||
// Assert the file is still opening
|
||||
cy.get('.file-preview')
|
||||
.should('be.visible')
|
||||
.should('contain.text', filename)
|
||||
// We need to get the href to work around how cypress works with windows
|
||||
.invoke('attr', 'href')
|
||||
.then((href) => {
|
||||
cy.visit(href)
|
||||
|
||||
// FIXME: For some reason this shows up on main but not on stable31
|
||||
// cy.get('[data-cy="guestNameModal"]').should('be.visible')
|
||||
// cy.inputCollaboraGuestName('A guest')
|
||||
|
||||
cy.waitForCollabora()
|
||||
|
||||
cy.url().then(url => {
|
||||
const baseUrl = url.split('?')[0]
|
||||
cy.request({
|
||||
url: baseUrl + '/download',
|
||||
failOnStatusCode: false,
|
||||
}).then((response) => {
|
||||
expect(response.status).to.eq(403)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
@ -82,7 +82,7 @@ Cypress.Commands.add('uploadFile', (user, fixture, mimeType, target = `/${fixtur
|
|||
})
|
||||
|
||||
Cypress.Commands.add('ocsRequest', (user, options) => {
|
||||
const auth = { user: user.userId, password: user.password }
|
||||
const auth = user ? { user: user.userId, password: user.password } : null
|
||||
return cy.request({
|
||||
form: true,
|
||||
auth,
|
||||
|
|
@ -109,6 +109,22 @@ Cypress.Commands.add('shareFileToUser', (user, path, targetUser, shareData = {})
|
|||
})
|
||||
})
|
||||
|
||||
Cypress.Commands.add('shareFileToTalkRoom', (user, path, roomId, shareData = {}) => {
|
||||
cy.login(user)
|
||||
cy.ocsRequest(user, {
|
||||
method: 'POST',
|
||||
url: `${url}/ocs/v2.php/apps/files_sharing/api/v1/shares?format=json`,
|
||||
body: {
|
||||
path,
|
||||
shareType: 10,
|
||||
shareWith: roomId,
|
||||
...shareData,
|
||||
},
|
||||
}).then(response => {
|
||||
cy.log(`${user.userId} shared ${path} with talk room ${roomId}`, response.status)
|
||||
})
|
||||
})
|
||||
|
||||
Cypress.Commands.add('shareFileToRemoteUser', (user, path, targetUser, shareData = {}) => {
|
||||
cy.login(user)
|
||||
const federatedId = `${targetUser.userId}@${url}`
|
||||
|
|
@ -396,10 +412,45 @@ Cypress.Commands.add('verifyTemplateFields', (fields, fileId) => {
|
|||
})
|
||||
|
||||
Cypress.Commands.add('pickFile', (filename) => {
|
||||
cy.get('.office-target-picker')
|
||||
.find(`tr[data-filename="${filename}"]`)
|
||||
.click()
|
||||
cy.get('.office-target-picker')
|
||||
.find('button[aria-label="Select file"]')
|
||||
.click()
|
||||
cy.get('.office-target-picker')
|
||||
.find(`tr[data-filename="${filename}"]`)
|
||||
.click()
|
||||
cy.get('.office-target-picker')
|
||||
.find('button[aria-label="Select file"]')
|
||||
.click()
|
||||
})
|
||||
|
||||
Cypress.Commands.add('createTalkRoom', (user, options = {}) => {
|
||||
cy.login(user)
|
||||
return cy.ocsRequest(user, {
|
||||
method: 'POST',
|
||||
url: `${url}/ocs/v2.php/apps/spreed/api/v4/room?format=json`,
|
||||
body: {
|
||||
roomType: options.roomType || 3, // Default to group conversation
|
||||
roomName: options.roomName,
|
||||
invite: options.invite || '',
|
||||
source: options.source || '',
|
||||
objectType: options.objectType || '',
|
||||
objectId: options.objectId || '',
|
||||
password: options.password || '',
|
||||
}
|
||||
}).then(response => {
|
||||
cy.log(`Created talk room "${options.roomName}"`, response.status)
|
||||
return cy.wrap(response.body.ocs.data)
|
||||
})
|
||||
})
|
||||
|
||||
Cypress.Commands.add('makeTalkRoomPublic', (user, token, password = '') => {
|
||||
cy.login(user)
|
||||
return cy.ocsRequest(user, {
|
||||
method: 'POST',
|
||||
url: `${url}/ocs/v2.php/apps/spreed/api/v4/room/${token}/public?format=json`,
|
||||
body: {
|
||||
password: password,
|
||||
}
|
||||
}).then(response => {
|
||||
cy.log(`Made talk room public`, response.status)
|
||||
return cy.wrap(response.body.ocs.data)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue