|
| 1 | +/// <reference types="Cypress" /> |
| 2 | + |
| 3 | +const selectors = { |
| 4 | + nameInput: 'input[name=sw-field--productFeatureSet-name]', |
| 5 | + saveButton: '.smart-bar__actions > button.sw-button--primary', |
| 6 | + emptyFieldsCard: '.sw-settings-product-feature-set-card__empty-state', |
| 7 | + addFieldButton: `.sw-settings-product-feature-set-card__empty-state > button.sw-button--ghost`, |
| 8 | + fieldsModal: '.sw-settings-product-feature-sets-modal__options', |
| 9 | + fieldsModalFooter: '.sw-modal__footer', |
| 10 | + radioGroup: '.sw-field__radio-group', |
| 11 | + button: 'button.sw-button', |
| 12 | + valueTable: 'table.sw-data-grid__table tbody', |
| 13 | + valueTableRow: '.sw-data-grid__row', |
| 14 | + checkbox: 'input[type=checkbox]' |
| 15 | +} |
| 16 | + |
| 17 | +describe('Essential characteristics: Test create operation', () => { |
| 18 | + beforeEach(() => { |
| 19 | + cy.setToInitialState() |
| 20 | + .then(() => { |
| 21 | + cy.loginViaApi() |
| 22 | + .then(() => { |
| 23 | + cy.openInitialPage(`${Cypress.env('admin')}#/sw/settings/product/feature/sets/create`); |
| 24 | + }); |
| 25 | + }); |
| 26 | + }) |
| 27 | + |
| 28 | + it('@base @settings: create a feature set', () => { |
| 29 | + // Request we want to wait for later |
| 30 | + cy.server(); |
| 31 | + cy.route({ |
| 32 | + url: '/api/v*/product-feature-set', |
| 33 | + method: 'post' |
| 34 | + }).as('saveData'); |
| 35 | + cy.route({ |
| 36 | + url: '/api/v*/product-feature-set/*', |
| 37 | + method: 'patch' |
| 38 | + }).as('addField'); |
| 39 | + |
| 40 | + // Create country |
| 41 | + cy.get(selectors.nameInput).typeAndCheck('Lorem ipsum'); |
| 42 | + |
| 43 | + cy.get(selectors.saveButton).click(); |
| 44 | + |
| 45 | + // Verify creation |
| 46 | + cy.wait('@saveData').then((xhr) => { |
| 47 | + expect(xhr).to.have.property('status', 204); |
| 48 | + }); |
| 49 | + |
| 50 | + cy.get(selectors.addFieldButton).click(); |
| 51 | + |
| 52 | + cy.get(selectors.fieldsModal).within(() => { |
| 53 | + cy.get(selectors.radioGroup) |
| 54 | + .contains('Product information') |
| 55 | + .click(); |
| 56 | + }) |
| 57 | + |
| 58 | + cy.get(selectors.fieldsModalFooter).within(() => { |
| 59 | + cy.get(selectors.button) |
| 60 | + .contains('Next') |
| 61 | + .click(); |
| 62 | + }) |
| 63 | + |
| 64 | + cy.get(selectors.valueTable).within(() => { |
| 65 | + cy.get(selectors.valueTableRow).first().within(() => { |
| 66 | + cy.get(selectors.checkbox).click(); |
| 67 | + }); |
| 68 | + }) |
| 69 | + |
| 70 | + cy.get(selectors.fieldsModalFooter).within(() => { |
| 71 | + cy.get(selectors.button) |
| 72 | + .contains('Add') |
| 73 | + .click(); |
| 74 | + }) |
| 75 | + |
| 76 | + // Verify creation |
| 77 | + cy.wait('@addField').then((xhr) => { |
| 78 | + expect(xhr).to.have.property('status', 204); |
| 79 | + }); |
| 80 | + }); |
| 81 | +}); |
0 commit comments