diff --git a/cypress/e2e/templates.spec.js b/cypress/e2e/templates.spec.js index f4c54d1ec8..860168354e 100644 --- a/cypress/e2e/templates.spec.js +++ b/cypress/e2e/templates.spec.js @@ -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') diff --git a/cypress/fixtures/templates/document_template_with_fields.odt b/cypress/fixtures/templates/document_template_with_fields.odt index 5083b1b649..1606fab51f 100644 Binary files a/cypress/fixtures/templates/document_template_with_fields.odt and b/cypress/fixtures/templates/document_template_with_fields.odt differ diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 7d621c8e8e..dc064b77d6 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -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 } } @@ -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)