Skip to content

Commit 6d695b6

Browse files
committed
fix(tests): add cypress tests for file picker
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
1 parent 3625986 commit 6d695b6

File tree

4 files changed

+55
-7
lines changed

4 files changed

+55
-7
lines changed

cypress/e2e/integration.spec.js

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,47 @@ describe('Nextcloud integration', function() {
121121
cy.get('.modal-container__content').should('be.visible')
122122
})
123123

124-
it('Smart picker', function() {
125-
cy.get('@loleafletframe').within(() => {
126-
cy.get('#Insert-tab-label').click()
127-
cy.get('#insert-insert-remote-link-button').click()
124+
describe('Smart picker', function() {
125+
describe('Link to office document section', function() {
126+
beforeEach(function() {
127+
// Proc the smart picker from Collabora
128+
cy.get('@loleafletframe').within(() => {
129+
cy.get('#Insert-tab-label').click()
130+
cy.get('#insert-insert-remote-link-button').click()
131+
})
132+
133+
// Wait for the reference picker to show
134+
cy.get('.reference-picker-modal--content')
135+
.should('be.visible')
136+
.as('referencePickerContent')
137+
138+
// Select "Link to office document section"
139+
cy.get('@referencePickerContent')
140+
.find('input[id="provider-select-input"]')
141+
.as('smartPickerDropdown')
142+
cy.get('@smartPickerDropdown').click()
143+
cy.get('@referencePickerContent')
144+
.contains('Link to office document section')
145+
.click()
146+
147+
// Pick the fixture document
148+
cy.pickFile('document.odt')
149+
})
150+
151+
it('Can link to heading', function() {
152+
cy.get('[data-cy-section-label="Headings"]').children().first().click()
153+
cy.get('[data-cy-link-to-section=""]').click()
154+
})
155+
156+
it('Can link to section', function() {
157+
cy.get('[data-cy-section-label="Sections"]').children().first().click()
158+
cy.get('[data-cy-link-to-section=""]').click()
159+
})
160+
161+
it('Can link to image', function() {
162+
cy.get('[data-cy-section-label="Images"]').children().first().click()
163+
cy.get('[data-cy-link-to-section=""]').click()
164+
})
128165
})
129-
cy.get('.reference-picker-modal--content').should('be.visible')
130166
})
131167
})

cypress/fixtures/document.odt

92.2 KB
Binary file not shown.

cypress/support/commands.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,12 @@ Cypress.Commands.add('verifyTemplateFields', (fields, fileId) => {
365365
})
366366
})
367367
})
368+
369+
Cypress.Commands.add('pickFile', (filename) => {
370+
cy.get('.office-target-picker')
371+
.find(`tr[data-filename="${filename}"]`)
372+
.click()
373+
cy.get('.office-target-picker')
374+
.find('button[aria-label="Select file"]')
375+
.click()
376+
})

src/view/DocumentTargetPicker.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<template v-else>
2525
<div v-for="section in sections" :key="section.label">
2626
<h3>{{ section.label }}</h3>
27-
<ul>
27+
<ul :data-cy-section-label="section.label">
2828
<NcListItem v-for="entry in section.entries"
2929
:key="entry.id"
3030
:name="entry.name"
@@ -38,7 +38,10 @@
3838
</div>
3939
</template>
4040
<div v-if="sections.length !== 0" class="office-target-picker__buttons">
41-
<NcButton type="primary" :disabled="!target" @click="submit()">
41+
<NcButton data-cy-link-to-section=""
42+
type="primary"
43+
:disabled="!target"
44+
@click="submit()">
4245
{{ t('richdocuments', 'Link to office document section') }}
4346
</NcButton>
4447
</div>

0 commit comments

Comments
 (0)