From ee75d4fb4637557e647b6be299b44e9d39b933f9 Mon Sep 17 00:00:00 2001 From: Julius Knorr Date: Tue, 31 Mar 2026 14:44:18 +0200 Subject: [PATCH 1/3] test: Add cypress test for file picker insert file flow (#5536) Co-Authored-By: Claude Opus 4.6 --- cypress/e2e/insert-file.spec.js | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 cypress/e2e/insert-file.spec.js diff --git a/cypress/e2e/insert-file.spec.js b/cypress/e2e/insert-file.spec.js new file mode 100644 index 0000000000..9273861b17 --- /dev/null +++ b/cypress/e2e/insert-file.spec.js @@ -0,0 +1,53 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +describe('Insert file (file picker)', function() { + let randUser + + before(function() { + cy.createRandomUser().then(user => { + randUser = user + cy.login(user) + cy.uploadFile(user, 'document.odt', 'application/vnd.oasis.opendocument.text', '/document.odt') + }) + }) + + beforeEach(function() { + cy.login(randUser) + cy.visit('/apps/files', { + onBeforeLoad(win) { + cy.spy(win, 'postMessage').as('postMessage') + }, + }) + cy.openFile('document.odt') + cy.waitForViewer() + cy.waitForCollabora() + }) + + it('Opens the file picker for inserting files without errors', function() { + cy.get('@loleafletframe').within(() => { + cy.get('.notebookbar-tabs-container', { timeout: 30_000 }) + .should('be.visible') + }) + + // Trigger UI_InsertFile by sending a postMessage to the Office component + // This simulates what Collabora does when "Document Compare" or similar actions are triggered + cy.window().then((win) => { + const iframe = win.document.querySelector('[data-cy="coolframe"]') + const message = JSON.stringify({ + MessageId: 'UI_InsertFile', + SendTime: Date.now(), + Values: { + mimeTypeFilter: [], + callback: 'Action_Paste', + }, + }) + win.postMessage(message, '*') + }) + + // The file picker should open without crashing + cy.get('.modal-container__content', { timeout: 10000 }).should('be.visible') + }) +}) From 7968bd9e3208fac0383c50540fc3229f7aca5244 Mon Sep 17 00:00:00 2001 From: Julius Knorr Date: Tue, 31 Mar 2026 14:45:21 +0200 Subject: [PATCH 2/3] fix: Handle missing share-attributes in file picker filter (#5536) Co-Authored-By: Claude Opus 4.6 --- src/view/FilesAppIntegration.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/view/FilesAppIntegration.js b/src/view/FilesAppIntegration.js index bc7bce5764..9ee1319d99 100644 --- a/src/view/FilesAppIntegration.js +++ b/src/view/FilesAppIntegration.js @@ -176,7 +176,8 @@ export default { getFilePickerBuilder(t('richdocuments', 'Insert file from {name}', { name: OC.theme.name })) .setMimeTypeFilter(mimeTypeFilter) .setFilter((node) => { - const downloadShareAttribute = JSON.parse(node.attributes['share-attributes']).find((shareAttribute) => shareAttribute.key === 'download') + const shareAttributes = node.attributes['share-attributes'] ? JSON.parse(node.attributes['share-attributes']) : [] + const downloadShareAttribute = shareAttributes.find((shareAttribute) => shareAttribute.key === 'download') const downloadPermissions = downloadShareAttribute !== undefined ? (downloadShareAttribute.enabled || downloadShareAttribute.value) : true return (node.permissions & OC.PERMISSION_READ) && downloadPermissions }) From 2f559d6dd492f4752a41f83b4c8ec9c4b9abe8f8 Mon Sep 17 00:00:00 2001 From: Julius Knorr Date: Tue, 31 Mar 2026 14:46:37 +0200 Subject: [PATCH 3/3] Revert "test: Add cypress test for file picker insert file flow (#5536)" This reverts commit ee75d4fb4637557e647b6be299b44e9d39b933f9. --- cypress/e2e/insert-file.spec.js | 53 --------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 cypress/e2e/insert-file.spec.js diff --git a/cypress/e2e/insert-file.spec.js b/cypress/e2e/insert-file.spec.js deleted file mode 100644 index 9273861b17..0000000000 --- a/cypress/e2e/insert-file.spec.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -describe('Insert file (file picker)', function() { - let randUser - - before(function() { - cy.createRandomUser().then(user => { - randUser = user - cy.login(user) - cy.uploadFile(user, 'document.odt', 'application/vnd.oasis.opendocument.text', '/document.odt') - }) - }) - - beforeEach(function() { - cy.login(randUser) - cy.visit('/apps/files', { - onBeforeLoad(win) { - cy.spy(win, 'postMessage').as('postMessage') - }, - }) - cy.openFile('document.odt') - cy.waitForViewer() - cy.waitForCollabora() - }) - - it('Opens the file picker for inserting files without errors', function() { - cy.get('@loleafletframe').within(() => { - cy.get('.notebookbar-tabs-container', { timeout: 30_000 }) - .should('be.visible') - }) - - // Trigger UI_InsertFile by sending a postMessage to the Office component - // This simulates what Collabora does when "Document Compare" or similar actions are triggered - cy.window().then((win) => { - const iframe = win.document.querySelector('[data-cy="coolframe"]') - const message = JSON.stringify({ - MessageId: 'UI_InsertFile', - SendTime: Date.now(), - Values: { - mimeTypeFilter: [], - callback: 'Action_Paste', - }, - }) - win.postMessage(message, '*') - }) - - // The file picker should open without crashing - cy.get('.modal-container__content', { timeout: 10000 }).should('be.visible') - }) -})