Loading tests/example-app/cypress/e2e/app.cy.ts +51 −0 Original line number Diff line number Diff line Loading @@ -60,4 +60,55 @@ describe('Elements have unique IDs', () => { }); }); describe('Form has elements', () => { it('Form has table and labels', () => { cy.get('h1').should('have.text', 'Default Test Form'); cy.get('input[id="multivalue_textfield_in_table_row_2[0]"]').should( 'exist', ); cy.get('textarea[id="table_01_textarea_in_table_row_1"]').should('exist'); cy.get('input[id="table_01_textfield_in_table_row_1"]').should('exist'); cy.get('textarea[id="required_textarea_in_table_row_2"]').should('exist'); cy.get('label[for="table_01_textarea_in_table_row_1"]').should( 'have.text', 'Textarea in table row 1', ); cy.get('label[for="table_01_textfield_in_table_row_1"]').should( 'have.text', 'Textfield in table row 1', ); cy.get('label[for="required_textarea_in_table_row_2"]').should( 'have.text', 'Required textarea in table row 2', ); cy.get('label[data-cy-selector="multifield-label-table-child"]') .not('.visually-hidden') .should('have.text', 'Multivalue textfield in table row 2'); }); it('Form has radio buttons with predefined options', () => { const employmentOptions = [ 'Full Time', 'Part Time', 'Military', 'Unemployed', 'Retired', ]; employmentOptions.forEach((item) => { cy.get(`input[id="radios_other_predefined_options-${item}"]`).should( 'have.value', item, ); cy.get(`label[for="radios_other_predefined_options-${item}"]`).should( 'have.text', item, ); }); // Check "other" option cy.get(`label[for="radios_other_predefined_options-other"]`).should( 'have.text', 'Other...', ); }); }); export {}; tests/example-app/cypress/e2e/conditions.cy.ts 0 → 100644 +61 −0 Original line number Diff line number Diff line describe('Conditions', () => { it( '"conditional_textarea" should be disabled and required when "conditional_helper_checkbox" is checked and ' + '"conditional_helper_textfield has a value of "req"', () => { cy.get('textarea[id="conditional_textarea"]').should('not.be.disabled'); cy.get('textarea[id="conditional_textarea"]').should( 'not.have.attr', 'required', ); cy.get('input[id=conditional_helper_checkbox').check(); cy.get('textarea[id="conditional_textarea"]').should('be.disabled'); cy.get('textarea[id="conditional_textarea"]').should( 'not.have.attr', 'required', ); cy.get('input[id=conditional_helper_textfield').type('req'); cy.get('textarea[id="conditional_textarea"]').should( 'have.attr', 'required', ); cy.get('textarea[id="conditional_textarea"]').should('be.disabled'); cy.get('input[id=conditional_helper_checkbox').uncheck(); cy.get('textarea[id="conditional_textarea"]').should('not.be.disabled'); cy.get('textarea[id="conditional_textarea"]').should( 'have.attr', 'required', ); cy.get('input[id=conditional_helper_textfield').type('foo'); cy.get('textarea[id="conditional_textarea"]').should( 'not.have.attr', 'required', ); }, ); it('text_field_with_a_default_value_inside_container" should disable when "custom_option_autocomplete-input" has value of "Corona"', () => { cy.get( 'input[id="text_field_with_a_default_value_inside_container"]', ).should('not.be.disabled'); cy.get('input[id=custom_option_autocomplete-input').type('Corona'); cy.get( 'input[id="text_field_with_a_default_value_inside_container"]', ).should('be.disabled'); cy.get('input[id=custom_option_autocomplete-input').type('foo'); cy.get( 'input[id="text_field_with_a_default_value_inside_container"]', ).should('not.be.disabled'); }); it('table_01_textfield_in_table_row_1 should hide when table_01_textarea_in_table_row_1 is filled', () => { cy.get('input[id="table_01_textfield_in_table_row_1"]').should( 'not.be.hidden', ); cy.get('textarea[id="table_01_textarea_in_table_row_1"]').type('anything'); cy.get('input[id="table_01_textfield_in_table_row_1"]').should('be.hidden'); cy.get('textarea[id="table_01_textarea_in_table_row_1"]').clear(); cy.get('input[id="table_01_textfield_in_table_row_1"]').should( 'not.be.hidden', ); }); }); tests/example-app/cypress/e2e/multifield.cy.ts +56 −0 Original line number Diff line number Diff line Loading @@ -15,4 +15,60 @@ describe('Multifield', () => { ) .should('not.have.attr', 'webform-remove-for-attribute'); }); it('should add and remove an element', () => { const firstInputSelector = 'input[id="multivalue_unlimited_predefined_options_autocomplete[0]-input"]'; const secondInputSelector = 'input[id="multivalue_unlimited_predefined_options_autocomplete[1]-input"]'; const addBtnSelector = 'button[id="multivalue_unlimited_predefined_options_autocomplete-add-btn"]'; const removeBtnSelector = 'button[id="multivalue_unlimited_predefined_options_autocomplete-remove-btn-1"]'; cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('not.exist'); cy.get(addBtnSelector).click(); cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('exist'); cy.get(removeBtnSelector).click(); cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('not.exist'); }); it('should add and remove an element in a table', () => { const firstInputSelector = 'input[id="multivalue_textfield_in_table_row_2[0]"]'; const secondInputSelector = 'input[id="multivalue_textfield_in_table_row_2[1]"]'; const addBtnSelector = 'button[id="multivalue_textfield_in_table_row_2-add-btn"]'; const removeBtnSelector = 'button[id="multivalue_textfield_in_table_row_2-remove-btn-1"]'; cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('not.exist'); cy.get(addBtnSelector).click(); cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('exist'); cy.get(removeBtnSelector).click(); cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('not.exist'); }); it('should add and remove a composite element inside of a container', () => { const firstInputSelector = 'input[name="multivalue_basic_address_inside_of_a_container[0]"]'; const secondInputSelector = 'input[name="multivalue_basic_address_inside_of_a_container[1]"]'; const addBtnSelector = 'button[id="multivalue_basic_address_inside_of_a_container-add-btn"]'; const removeBtnSelector = 'button[id="multivalue_basic_address_inside_of_a_container-remove-btn-1"]'; cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('not.exist'); cy.get(addBtnSelector).click(); cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('exist'); cy.get(removeBtnSelector).click(); cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('not.exist'); }); }); tests/example-app/cypress/e2e/theming.cy.ts +6 −4 Original line number Diff line number Diff line describe('CSS classes and styles based on Webform configuration', () => { it('"multivalue_unlimited_predefined_options_autocomplete" label has class', () => { cy.get('.test-multifield-label-class').should( cy.get('label[data-cy-selector="multifield-label"]') .should('have.class', 'test-multifield-label-class') .should( 'have.text', 'Multivalue unlimited predefined options autocomplete', ); Loading tests/example-app/json/webform-rest-elements.json +3 −1 Original line number Diff line number Diff line Loading @@ -11764,7 +11764,9 @@ } }, "#label_attributes": { "webform-remove-for-attribute": true "class": "test-multifield-label-class", "webform-remove-for-attribute": true, "data-cy-selector": "multifield-label-table-child" }, "#cardinality": 3, "#header_label": "", Loading Loading
tests/example-app/cypress/e2e/app.cy.ts +51 −0 Original line number Diff line number Diff line Loading @@ -60,4 +60,55 @@ describe('Elements have unique IDs', () => { }); }); describe('Form has elements', () => { it('Form has table and labels', () => { cy.get('h1').should('have.text', 'Default Test Form'); cy.get('input[id="multivalue_textfield_in_table_row_2[0]"]').should( 'exist', ); cy.get('textarea[id="table_01_textarea_in_table_row_1"]').should('exist'); cy.get('input[id="table_01_textfield_in_table_row_1"]').should('exist'); cy.get('textarea[id="required_textarea_in_table_row_2"]').should('exist'); cy.get('label[for="table_01_textarea_in_table_row_1"]').should( 'have.text', 'Textarea in table row 1', ); cy.get('label[for="table_01_textfield_in_table_row_1"]').should( 'have.text', 'Textfield in table row 1', ); cy.get('label[for="required_textarea_in_table_row_2"]').should( 'have.text', 'Required textarea in table row 2', ); cy.get('label[data-cy-selector="multifield-label-table-child"]') .not('.visually-hidden') .should('have.text', 'Multivalue textfield in table row 2'); }); it('Form has radio buttons with predefined options', () => { const employmentOptions = [ 'Full Time', 'Part Time', 'Military', 'Unemployed', 'Retired', ]; employmentOptions.forEach((item) => { cy.get(`input[id="radios_other_predefined_options-${item}"]`).should( 'have.value', item, ); cy.get(`label[for="radios_other_predefined_options-${item}"]`).should( 'have.text', item, ); }); // Check "other" option cy.get(`label[for="radios_other_predefined_options-other"]`).should( 'have.text', 'Other...', ); }); }); export {};
tests/example-app/cypress/e2e/conditions.cy.ts 0 → 100644 +61 −0 Original line number Diff line number Diff line describe('Conditions', () => { it( '"conditional_textarea" should be disabled and required when "conditional_helper_checkbox" is checked and ' + '"conditional_helper_textfield has a value of "req"', () => { cy.get('textarea[id="conditional_textarea"]').should('not.be.disabled'); cy.get('textarea[id="conditional_textarea"]').should( 'not.have.attr', 'required', ); cy.get('input[id=conditional_helper_checkbox').check(); cy.get('textarea[id="conditional_textarea"]').should('be.disabled'); cy.get('textarea[id="conditional_textarea"]').should( 'not.have.attr', 'required', ); cy.get('input[id=conditional_helper_textfield').type('req'); cy.get('textarea[id="conditional_textarea"]').should( 'have.attr', 'required', ); cy.get('textarea[id="conditional_textarea"]').should('be.disabled'); cy.get('input[id=conditional_helper_checkbox').uncheck(); cy.get('textarea[id="conditional_textarea"]').should('not.be.disabled'); cy.get('textarea[id="conditional_textarea"]').should( 'have.attr', 'required', ); cy.get('input[id=conditional_helper_textfield').type('foo'); cy.get('textarea[id="conditional_textarea"]').should( 'not.have.attr', 'required', ); }, ); it('text_field_with_a_default_value_inside_container" should disable when "custom_option_autocomplete-input" has value of "Corona"', () => { cy.get( 'input[id="text_field_with_a_default_value_inside_container"]', ).should('not.be.disabled'); cy.get('input[id=custom_option_autocomplete-input').type('Corona'); cy.get( 'input[id="text_field_with_a_default_value_inside_container"]', ).should('be.disabled'); cy.get('input[id=custom_option_autocomplete-input').type('foo'); cy.get( 'input[id="text_field_with_a_default_value_inside_container"]', ).should('not.be.disabled'); }); it('table_01_textfield_in_table_row_1 should hide when table_01_textarea_in_table_row_1 is filled', () => { cy.get('input[id="table_01_textfield_in_table_row_1"]').should( 'not.be.hidden', ); cy.get('textarea[id="table_01_textarea_in_table_row_1"]').type('anything'); cy.get('input[id="table_01_textfield_in_table_row_1"]').should('be.hidden'); cy.get('textarea[id="table_01_textarea_in_table_row_1"]').clear(); cy.get('input[id="table_01_textfield_in_table_row_1"]').should( 'not.be.hidden', ); }); });
tests/example-app/cypress/e2e/multifield.cy.ts +56 −0 Original line number Diff line number Diff line Loading @@ -15,4 +15,60 @@ describe('Multifield', () => { ) .should('not.have.attr', 'webform-remove-for-attribute'); }); it('should add and remove an element', () => { const firstInputSelector = 'input[id="multivalue_unlimited_predefined_options_autocomplete[0]-input"]'; const secondInputSelector = 'input[id="multivalue_unlimited_predefined_options_autocomplete[1]-input"]'; const addBtnSelector = 'button[id="multivalue_unlimited_predefined_options_autocomplete-add-btn"]'; const removeBtnSelector = 'button[id="multivalue_unlimited_predefined_options_autocomplete-remove-btn-1"]'; cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('not.exist'); cy.get(addBtnSelector).click(); cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('exist'); cy.get(removeBtnSelector).click(); cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('not.exist'); }); it('should add and remove an element in a table', () => { const firstInputSelector = 'input[id="multivalue_textfield_in_table_row_2[0]"]'; const secondInputSelector = 'input[id="multivalue_textfield_in_table_row_2[1]"]'; const addBtnSelector = 'button[id="multivalue_textfield_in_table_row_2-add-btn"]'; const removeBtnSelector = 'button[id="multivalue_textfield_in_table_row_2-remove-btn-1"]'; cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('not.exist'); cy.get(addBtnSelector).click(); cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('exist'); cy.get(removeBtnSelector).click(); cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('not.exist'); }); it('should add and remove a composite element inside of a container', () => { const firstInputSelector = 'input[name="multivalue_basic_address_inside_of_a_container[0]"]'; const secondInputSelector = 'input[name="multivalue_basic_address_inside_of_a_container[1]"]'; const addBtnSelector = 'button[id="multivalue_basic_address_inside_of_a_container-add-btn"]'; const removeBtnSelector = 'button[id="multivalue_basic_address_inside_of_a_container-remove-btn-1"]'; cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('not.exist'); cy.get(addBtnSelector).click(); cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('exist'); cy.get(removeBtnSelector).click(); cy.get(firstInputSelector).should('exist'); cy.get(secondInputSelector).should('not.exist'); }); });
tests/example-app/cypress/e2e/theming.cy.ts +6 −4 Original line number Diff line number Diff line describe('CSS classes and styles based on Webform configuration', () => { it('"multivalue_unlimited_predefined_options_autocomplete" label has class', () => { cy.get('.test-multifield-label-class').should( cy.get('label[data-cy-selector="multifield-label"]') .should('have.class', 'test-multifield-label-class') .should( 'have.text', 'Multivalue unlimited predefined options autocomplete', ); Loading
tests/example-app/json/webform-rest-elements.json +3 −1 Original line number Diff line number Diff line Loading @@ -11764,7 +11764,9 @@ } }, "#label_attributes": { "webform-remove-for-attribute": true "class": "test-multifield-label-class", "webform-remove-for-attribute": true, "data-cy-selector": "multifield-label-table-child" }, "#cardinality": 3, "#header_label": "", Loading