diff --git a/cypress/e2e/templates.spec.js b/cypress/e2e/templates.spec.js index 10669c8fb9..5d237b5926 100644 --- a/cypress/e2e/templates.spec.js +++ b/cypress/e2e/templates.spec.js @@ -108,7 +108,7 @@ describe('Create templates with fields', () => { cy.login(randUser) cy.visit('/apps/files') - + // Create a templates folder cy.get('.files-list__header div[menu-title="New"] button') .should('be.visible') @@ -126,8 +126,9 @@ describe('Create templates with fields', () => { it('Create a document from a template with fields', () => { const fields = [ - { alias: 'Name', content: 'Nextcloud' }, - { alias: 'Favorite app', content: 'richdocuments' } + { type: 'rich-text', alias: 'Name', content: 'Nextcloud' }, + { type: 'rich-text', alias: 'Favorite app', content: 'richdocuments' }, + { type: 'checkbox', alias: 'Uses Nextcloud at home', checked: true }, ] 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 fb56a3adaa..5083b1b649 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 7f8c31f41e..e9bd78f305 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -311,9 +311,21 @@ Cypress.Commands.add('submitTemplateFields', (fields) => { cy.get('.template-field-modal__buttons').as('templateFillerButtons') for (const field of fields) { - cy.get('@templateFiller') - .find(`input[placeholder="${field.alias}"]`) - .type(field.content) + switch (field.type) { + case 'rich-text': + cy.get('@templateFiller') + .find(`input[placeholder="${field.alias}"]`) + .type(field.content) + break + case 'checkbox': + cy.get('@templateFiller') + .find('label').contains(field.alias) + .click() + break + default: + expect.fail('Using a field type not yet supported') + break + } } // Submit the template fields @@ -332,11 +344,23 @@ Cypress.Commands.add('verifyTemplateFields', (fields, fileId) => { method: 'GET', url: Cypress.env('baseUrl') + apiEndpoint + fileId + '?format=json', headers: { - requesttoken + requesttoken, }, }).then(({ body }) => { for (const index in body.ocs.data) { - expect(body.ocs.data[index].content).to.equal(fields[index].content) + const field = body.ocs.data[index] + + switch (field.type) { + case 'rich-text': + expect(field.content).to.equal(fields[index].content) + break + case 'checkbox': + expect(field.checked).to.equal(fields[index].checked) + break + default: + expect.fail('Using a field type not yet supported') + break + } } }) })