mirror of
https://github.com/nextcloud/richdocuments.git
synced 2025-12-18 05:20:43 +01:00
test(cypress): Add simple federated editing tests
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
c8f29a32cd
commit
78b21775a4
3 changed files with 104 additions and 4 deletions
|
|
@ -11,7 +11,7 @@ const createDirectEditingLink = (user, fileId) => {
|
|||
body: {
|
||||
fileId,
|
||||
},
|
||||
auth: { user: user.userId, pass: user.password },
|
||||
// auth: { user: user.userId, pass: user.password },
|
||||
headers: {
|
||||
'OCS-ApiRequest': 'true',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
|
|
@ -88,4 +88,19 @@ describe('Direct editing (legacy)', function() {
|
|||
})
|
||||
})
|
||||
|
||||
it('Open a remotely shared file', () => {
|
||||
cy.createRandomUser().then(shareRecipient => {
|
||||
cy.login(randUser)
|
||||
cy.shareFileToRemoteUser(randUser, '/document.odt', shareRecipient)
|
||||
.then(incomingFileId => {
|
||||
createDirectEditingLink(shareRecipient, incomingFileId)
|
||||
.then((token) => {
|
||||
cy.logout()
|
||||
cy.visit(token)
|
||||
cy.waitForCollabora(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
|
|
|||
40
cypress/e2e/share-federated.spec.js
Normal file
40
cypress/e2e/share-federated.spec.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
* SPDX-FileCopyrightText: 2023 Julius Härtl <jus@bitgrid.net>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
import { User } from '@nextcloud/cypress'
|
||||
import { randHash } from '../utils/index.js'
|
||||
const shareOwner = new User(randHash(), randHash())
|
||||
const shareRecipient = new User(randHash(), randHash())
|
||||
|
||||
describe('Federated sharing of office documents', function() {
|
||||
|
||||
before(function() {
|
||||
cy.nextcloudEnableApp('testing')
|
||||
cy.nextcloudTestingAppConfigSet('richdocuments', 'uiDefaults-UIMode', 'notebookbar')
|
||||
cy.createUser(shareRecipient)
|
||||
cy.createUser(shareOwner)
|
||||
|
||||
cy.uploadFile(shareOwner, 'document.odt', 'application/vnd.oasis.opendocument.text', '/document.odt')
|
||||
})
|
||||
|
||||
it('Open a remotely shared file', function() {
|
||||
const filename = 'document.odt'
|
||||
|
||||
cy.login(shareOwner)
|
||||
cy.shareFileToRemoteUser(shareOwner, '/document.odt', shareRecipient)
|
||||
cy.login(shareRecipient)
|
||||
|
||||
cy.visit('/apps/files', {
|
||||
onBeforeLoad(win) {
|
||||
cy.spy(win, 'postMessage').as('postMessage')
|
||||
},
|
||||
})
|
||||
cy.openFile(filename)
|
||||
cy.waitForViewer()
|
||||
cy.waitForCollabora(true, true).within(() => {
|
||||
cy.get('#closebutton').click()
|
||||
cy.get('#viewer', { timeout: 5000 }).should('not.exist')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
@ -109,6 +109,44 @@ Cypress.Commands.add('shareFileToUser', (user, path, targetUser, shareData = {})
|
|||
})
|
||||
})
|
||||
|
||||
Cypress.Commands.add('shareFileToRemoteUser', (user, path, targetUser, shareData = {}) => {
|
||||
cy.login(user)
|
||||
const federatedId = `${targetUser.userId}@${url}`
|
||||
return cy.ocsRequest(user, {
|
||||
method: 'POST',
|
||||
url: `${url}/ocs/v2.php/apps/files_sharing/api/v1/shares?format=json`,
|
||||
body: {
|
||||
path,
|
||||
shareType: 6,
|
||||
shareWith: federatedId,
|
||||
...shareData,
|
||||
},
|
||||
}).then(response => {
|
||||
cy.log(`${user.userId} shared ${path} with ${federatedId}`, response.status)
|
||||
cy.login(targetUser)
|
||||
return cy.ocsRequest(targetUser, {
|
||||
method: 'GET',
|
||||
url: `${url}/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending?format=json`,
|
||||
})
|
||||
}).then(({ body }) => {
|
||||
for (const index in body.ocs.data) {
|
||||
cy.ocsRequest(targetUser, {
|
||||
method: 'POST',
|
||||
url: `${url}/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/${body.ocs.data[index].id}`,
|
||||
})
|
||||
return cy.wrap(body.ocs.data[index].id)
|
||||
}
|
||||
}).then((shareId) => {
|
||||
cy.ocsRequest(targetUser, {
|
||||
method: 'GET',
|
||||
url: `${url}/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/${shareId}?format=json`,
|
||||
}).then((response) => {
|
||||
cy.login(user)
|
||||
return cy.wrap(response.body.ocs.data['file_id'])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Cypress.Commands.add('shareLink', (user, path, shareData = {}) => {
|
||||
cy.login(user)
|
||||
cy.ocsRequest(user, {
|
||||
|
|
@ -190,9 +228,10 @@ Cypress.Commands.add('waitForViewer', () => {
|
|||
.and('not.have.class', 'icon-loading')
|
||||
})
|
||||
|
||||
Cypress.Commands.add('waitForCollabora', (wrapped = false) => {
|
||||
Cypress.Commands.add('waitForCollabora', (wrapped = false, federated = false) => {
|
||||
const wrappedFrameIdentifier = federated ? 'coolframe' : 'documentframe'
|
||||
if (wrapped) {
|
||||
cy.get('[data-cy="documentframe"]', { timeout: 30000 })
|
||||
cy.get(`[data-cy="${wrappedFrameIdentifier}"]`, { timeout: 30000 })
|
||||
.its('0.contentDocument')
|
||||
.its('body').should('not.be.empty')
|
||||
.should('be.visible').should('not.be.empty')
|
||||
|
|
@ -207,7 +246,13 @@ Cypress.Commands.add('waitForCollabora', (wrapped = false) => {
|
|||
.its('0.contentDocument')
|
||||
.its('body').should('not.be.empty')
|
||||
.as('loleafletframe')
|
||||
cy.get('@loleafletframe').find('#main-document-content').should('be.visible')
|
||||
|
||||
cy.get('@loleafletframe')
|
||||
.within(() => {
|
||||
cy.get('#main-document-content').should('be.visible')
|
||||
})
|
||||
|
||||
return cy.get('@loleafletframe')
|
||||
})
|
||||
|
||||
Cypress.Commands.add('waitForPostMessage', (messageId, values = undefined) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue