Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions cypress/e2e/templates.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,12 @@ describe('User templates', function() {

it('Create a document from a template with fields', () => {
const fields = [
{ type: 'rich-text', alias: 'Name', content: 'Nextcloud' },
{ type: 'rich-text', alias: 'Favorite app', content: 'richdocuments' },
{ type: 'checkbox', alias: 'Uses Nextcloud at home', checked: true },
{ index: 'ContentControls.ByIndex.0', type: 'rich-text', alias: 'Name', content: 'Nextcloud' },
{ index: 'ContentControls.ByIndex.1', type: 'rich-text', alias: 'Favorite app', content: 'richdocuments' },
{ index: 'ContentControls.ByIndex.2', type: 'checkbox', alias: 'Uses Nextcloud at home', checked: true },

{ index: 'ContentControls.ByIndex.3', type: 'rich-text', alias: '', content: '' },
{ index: 'ContentControls.ByIndex.4', type: 'checkbox', alias: '', checked: false },
]

cy.visit('/apps/files')
Expand Down
Binary file modified cypress/fixtures/templates/document_template_with_fields.odt
Binary file not shown.
36 changes: 29 additions & 7 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,19 +319,35 @@ Cypress.Commands.add('submitTemplateFields', (fields) => {

for (const field of fields) {
switch (field.type) {

case 'rich-text':
cy.get('@templateFiller')
.find(`input[placeholder="${field.alias}"]`)
.type(field.content)
if (!field.alias) {
cy.get('@templateFiller')
.find(`label[for="text-field${field.index}"]`)
.should('not.exist')
} else {
cy.get('@templateFiller')
.find(`input[placeholder="${field.alias}"]`)
.type(field.content)
}

break

case 'checkbox':
cy.get('@templateFiller')
.find('span.checkbox-radio-switch__text').contains(field.alias)
.click()
if (!field.alias) {
cy.get('@templateFiller')
.find(`input[id="checkbox-field${field.index}`)
.should('not.exist')
} else {
cy.get('@templateFiller')
.find('span.checkbox-radio-switch__text').contains(field.alias)
.click()
}

break

default:
expect.fail('Using a field type not yet supported')
break
}
}

Expand All @@ -357,6 +373,12 @@ Cypress.Commands.add('verifyTemplateFields', (fields, fileId) => {
for (const index in body.ocs.data) {
const field = body.ocs.data[index]

// If a field has no name or alias, we don't need
// to check it because it is not shown in the template filler
if (!field.alias) {
continue;
}

switch (field.type) {
case 'rich-text':
expect(field.content).to.equal(fields[index].content)
Expand Down
Loading