Skip to content

Commit

Permalink
fix(tests): add cypress tests for file picker
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <[email protected]>
  • Loading branch information
elzody committed Sep 12, 2024
1 parent 3625986 commit 6d695b6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 7 deletions.
46 changes: 41 additions & 5 deletions cypress/e2e/integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,47 @@ 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')
.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')
})
})
Binary file modified cypress/fixtures/document.odt
Binary file not shown.
9 changes: 9 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,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()
})
7 changes: 5 additions & 2 deletions src/view/DocumentTargetPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<template v-else>
<div v-for="section in sections" :key="section.label">
<h3>{{ section.label }}</h3>
<ul>
<ul :data-cy-section-label="section.label">
<NcListItem v-for="entry in section.entries"
:key="entry.id"
:name="entry.name"
Expand All @@ -38,7 +38,10 @@
</div>
</template>
<div v-if="sections.length !== 0" class="office-target-picker__buttons">
<NcButton type="primary" :disabled="!target" @click="submit()">
<NcButton data-cy-link-to-section=""
type="primary"
:disabled="!target"
@click="submit()">
{{ t('richdocuments', 'Link to office document section') }}
</NcButton>
</div>
Expand Down

0 comments on commit 6d695b6

Please sign in to comment.