diff --git a/cypress/e2e/integration.spec.js b/cypress/e2e/integration.spec.js index 4d98c1fd82..4214f90f6f 100644 --- a/cypress/e2e/integration.spec.js +++ b/cypress/e2e/integration.spec.js @@ -121,11 +121,49 @@ describe('Nextcloud integration', function() { cy.get('.modal-container__content').should('be.visible') }) - it('Smart picker', function() { - cy.get('@loleafletframe').within(() => { - cy.get('#Insert-tab-label').click() - cy.get('#insert-insert-remote-link-button').click() + describe('Smart picker', function() { + describe('Link to office document section', function() { + beforeEach(function() { + // Proc the smart picker from Collabora + cy.get('@loleafletframe').within(() => { + cy.get('#Insert-tab-label').click() + cy.get('#insert-insert-remote-link-button').click() + }) + + // Wait for the reference picker to show + cy.get('.reference-picker-modal--content') + .should('be.visible') + .as('referencePickerContent') + + // Select "Link to office document section" + cy.get('@referencePickerContent') + .find('input[id="provider-select-input"]') + .as('smartPickerDropdown') + cy.get('@smartPickerDropdown').click() + cy.get('@referencePickerContent') + .find('ul[aria-label="Options"]') + .should('be.visible') + .contains('Link to office document section') + .click() + + // Pick the fixture document + cy.pickFile('document.odt') + }) + + it('Can link to heading', function() { + cy.get('[data-cy-section-label="Headings"]').children().first().click() + cy.get('[data-cy-link-to-section=""]').click() + }) + + it('Can link to section', function() { + cy.get('[data-cy-section-label="Sections"]').children().first().click() + cy.get('[data-cy-link-to-section=""]').click() + }) + + it('Can link to image', function() { + cy.get('[data-cy-section-label="Images"]').children().first().click() + cy.get('[data-cy-link-to-section=""]').click() + }) }) - cy.get('.reference-picker-modal--content').should('be.visible') }) }) diff --git a/cypress/fixtures/document.odt b/cypress/fixtures/document.odt index d2a8dc274c..8a0305e175 100644 Binary files a/cypress/fixtures/document.odt and b/cypress/fixtures/document.odt differ diff --git a/cypress/support/commands.js b/cypress/support/commands.js index bf9fa9544a..fe613859a5 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -374,3 +374,12 @@ 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() +}) diff --git a/lib/Listener/LoadViewerListener.php b/lib/Listener/LoadViewerListener.php index aec47c6fde..0a76ecdae4 100644 --- a/lib/Listener/LoadViewerListener.php +++ b/lib/Listener/LoadViewerListener.php @@ -14,7 +14,9 @@ use OCA\Richdocuments\PermissionManager; use OCA\Richdocuments\Service\InitialStateService; use OCA\Viewer\Event\LoadViewer; +use OCP\Collaboration\Reference\RenderReferenceEvent; use OCP\EventDispatcher\Event; +use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventListener; use OCP\Util; @@ -23,6 +25,7 @@ class LoadViewerListener implements IEventListener { public function __construct( private PermissionManager $permissionManager, private InitialStateService $initialStateService, + private IEventDispatcher $eventDispatcher, private ?string $userId, ) { } @@ -34,6 +37,7 @@ public function handle(Event $event): void { if ($this->permissionManager->isEnabledForUser() && $this->userId !== null) { $this->initialStateService->provideCapabilities(); Util::addScript('richdocuments', 'richdocuments-viewer', 'viewer'); + $this->eventDispatcher->dispatchTyped(new RenderReferenceEvent()); } } } diff --git a/src/view/DocumentTargetPicker.vue b/src/view/DocumentTargetPicker.vue index 92286f7fa4..758ccedd01 100644 --- a/src/view/DocumentTargetPicker.vue +++ b/src/view/DocumentTargetPicker.vue @@ -5,7 +5,12 @@