mirror of
https://github.com/nextcloud/richdocuments.git
synced 2025-12-18 05:20:43 +01:00
feat(test): add tests for template fields with empty labels
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
This commit is contained in:
parent
20e836c670
commit
18d01d574b
3 changed files with 35 additions and 10 deletions
|
|
@ -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')
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue