feat(test): add tests for template fields with empty labels

Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
This commit is contained in:
Elizabeth Danzberger 2025-02-07 14:32:00 -05:00
parent 20e836c670
commit 18d01d574b
No known key found for this signature in database
GPG key ID: D64CE07FD0188C79
3 changed files with 35 additions and 10 deletions

View file

@ -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')

View file

@ -321,19 +321,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
}
}
@ -359,6 +375,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)