diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 616074a31de..b353b5ff3af 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -139,7 +139,7 @@ jobs: cypress: name: Cypress E2E Tests - needs: [check, php-cs-fixer] + needs: [check] if: | needs.check.outputs.cypress > 0 || needs.check.outputs.php > 0 || diff --git a/cypress/e2e/openmage/backend/catalog/categories.cy.js b/cypress/e2e/openmage/backend/catalog/categories.cy.js index 6f3c92d9f33..ea55f3629f2 100644 --- a/cypress/e2e/openmage/backend/catalog/categories.cy.js +++ b/cypress/e2e/openmage/backend/catalog/categories.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.catalog.categories +const route = cy.testRoutes.backend.catalog.categories; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/catalog/products.cy.js b/cypress/e2e/openmage/backend/catalog/products.cy.js index 1838a23940f..da6b3152778 100644 --- a/cypress/e2e/openmage/backend/catalog/products.cy.js +++ b/cypress/e2e/openmage/backend/catalog/products.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.catalog.products +const route = cy.testRoutes.backend.catalog.products; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/catalog/search.cy.js b/cypress/e2e/openmage/backend/catalog/search.cy.js index d6b0da867da..b0714d2dd5d 100644 --- a/cypress/e2e/openmage/backend/catalog/search.cy.js +++ b/cypress/e2e/openmage/backend/catalog/search.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.catalog.search +const route = cy.testRoutes.backend.catalog.search; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/catalog/sitemap.cy.js b/cypress/e2e/openmage/backend/catalog/sitemap.cy.js index 46f12db4aa2..f1117f4ff01 100644 --- a/cypress/e2e/openmage/backend/catalog/sitemap.cy.js +++ b/cypress/e2e/openmage/backend/catalog/sitemap.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.catalog.sitemap +const route = cy.testRoutes.backend.catalog.sitemap; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/catalog/urlrewrites.cy.js b/cypress/e2e/openmage/backend/catalog/urlrewrites.cy.js index a135f521176..aa75e93b615 100644 --- a/cypress/e2e/openmage/backend/catalog/urlrewrites.cy.js +++ b/cypress/e2e/openmage/backend/catalog/urlrewrites.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.catalog.urlrewrite +const route = cy.testRoutes.backend.catalog.urlrewrite; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/cms/block.cy.js b/cypress/e2e/openmage/backend/cms/block.cy.js index 0113e0c356c..4d957ad176a 100644 --- a/cypress/e2e/openmage/backend/cms/block.cy.js +++ b/cypress/e2e/openmage/backend/cms/block.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.cms.block +const route = cy.testRoutes.backend.cms.block; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/cms/page.cy.js b/cypress/e2e/openmage/backend/cms/page.cy.js index 3bbb55a8332..c0f43f81f0f 100644 --- a/cypress/e2e/openmage/backend/cms/page.cy.js +++ b/cypress/e2e/openmage/backend/cms/page.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.cms.page +const route = cy.testRoutes.backend.cms.page; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/cms/widget.cy.js b/cypress/e2e/openmage/backend/cms/widget.cy.js index 5af1b2a16b5..57328d77c5f 100644 --- a/cypress/e2e/openmage/backend/cms/widget.cy.js +++ b/cypress/e2e/openmage/backend/cms/widget.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.cms.widget +const route = cy.testRoutes.backend.cms.widget; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/customer/group.cy.js b/cypress/e2e/openmage/backend/customer/group.cy.js index 7930239cf29..4e86668e508 100644 --- a/cypress/e2e/openmage/backend/customer/group.cy.js +++ b/cypress/e2e/openmage/backend/customer/group.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.customers.groups +const route = cy.testRoutes.backend.customers.groups; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/customer/manage.cy.js b/cypress/e2e/openmage/backend/customer/manage.cy.js index 09ca251bda7..c3a235895a8 100644 --- a/cypress/e2e/openmage/backend/customer/manage.cy.js +++ b/cypress/e2e/openmage/backend/customer/manage.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.customers.manage +const route = cy.testRoutes.backend.customers.manage; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/customer/online.cy.js b/cypress/e2e/openmage/backend/customer/online.cy.js index 1f06c02c267..f7de43c12b0 100644 --- a/cypress/e2e/openmage/backend/customer/online.cy.js +++ b/cypress/e2e/openmage/backend/customer/online.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.customers.online +const route = cy.testRoutes.backend.customers.online; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/login.cy.js b/cypress/e2e/openmage/backend/login.cy.js index 800bcd73f51..c88a020807d 100644 --- a/cypress/e2e/openmage/backend/login.cy.js +++ b/cypress/e2e/openmage/backend/login.cy.js @@ -3,7 +3,7 @@ describe('Check admin login', () => { cy.visit('/admin'); }); - const login = cy.openmage.login.admin + const login = cy.openmage.login.admin; it('tests valid login', () => { const username = login.username.value; @@ -13,6 +13,7 @@ describe('Check admin login', () => { cy.get(login.username._id).clear().type(username).should('have.value', username); cy.get(login.password._id).clear().type(password).should('have.value', password); cy.get(login._submit.__selector).click(); + cy.url().should('include', '/dashboard/index'); }) it('tests invalid login', () => { @@ -23,11 +24,14 @@ describe('Check admin login', () => { cy.get(login.username._id).clear().type(username).should('have.value', username); cy.get(login.password._id).clear().type(password).should('have.value', password); cy.get(login._submit.__selector).click(); + cy.url().should('include', '/index/index'); }) it('tests empty login', () => { cy.get(login.username._id).clear().should('have.value', ''); cy.get(login.password._id).clear().should('have.value', ''); cy.get(login._submit.__selector).click(); + cy.url().should('not.include', '/index/index'); + cy.url().should('not.include', '/index/dashboard'); }) }) diff --git a/cypress/e2e/openmage/backend/newsletter/queue.cy.js b/cypress/e2e/openmage/backend/newsletter/queue.cy.js index 1434292f41f..51b1158261c 100644 --- a/cypress/e2e/openmage/backend/newsletter/queue.cy.js +++ b/cypress/e2e/openmage/backend/newsletter/queue.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.newsletter.queue +const route = cy.testRoutes.backend.newsletter.queue; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/newsletter/report.cy.js b/cypress/e2e/openmage/backend/newsletter/report.cy.js index 90dc70b8a19..6b5f6db4fe3 100644 --- a/cypress/e2e/openmage/backend/newsletter/report.cy.js +++ b/cypress/e2e/openmage/backend/newsletter/report.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.newsletter.report +const route = cy.testRoutes.backend.newsletter.report; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/newsletter/subscriber.cy.js b/cypress/e2e/openmage/backend/newsletter/subscriber.cy.js index 7e3209402a0..cf915f44e02 100644 --- a/cypress/e2e/openmage/backend/newsletter/subscriber.cy.js +++ b/cypress/e2e/openmage/backend/newsletter/subscriber.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.newsletter.subscriber +const route = cy.testRoutes.backend.newsletter.subscriber; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/newsletter/templates.cy.js b/cypress/e2e/openmage/backend/newsletter/templates.cy.js index 2db232dd533..90c81014432 100644 --- a/cypress/e2e/openmage/backend/newsletter/templates.cy.js +++ b/cypress/e2e/openmage/backend/newsletter/templates.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.newsletter.templates +const route = cy.testRoutes.backend.newsletter.templates; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/promo/cart.cy.js b/cypress/e2e/openmage/backend/promo/cart.cy.js index 1b1d5913ff9..770a92dd59b 100644 --- a/cypress/e2e/openmage/backend/promo/cart.cy.js +++ b/cypress/e2e/openmage/backend/promo/cart.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.promo.cart +const route = cy.testRoutes.backend.promo.cart; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/promo/catalog.cy.js b/cypress/e2e/openmage/backend/promo/catalog.cy.js index 1dd20a3eb18..c5c9e498fb3 100644 --- a/cypress/e2e/openmage/backend/promo/catalog.cy.js +++ b/cypress/e2e/openmage/backend/promo/catalog.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.promo.catalog +const route = cy.testRoutes.backend.promo.catalog; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/sales/creditmemo.cy.js b/cypress/e2e/openmage/backend/sales/creditmemo.cy.js index 2385273a696..ac5f9608cc1 100644 --- a/cypress/e2e/openmage/backend/sales/creditmemo.cy.js +++ b/cypress/e2e/openmage/backend/sales/creditmemo.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.sales.creditmemo +const route = cy.testRoutes.backend.sales.creditmemo; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/sales/invoice.cy.js b/cypress/e2e/openmage/backend/sales/invoice.cy.js index 5ddc96f33a7..bb12260d139 100644 --- a/cypress/e2e/openmage/backend/sales/invoice.cy.js +++ b/cypress/e2e/openmage/backend/sales/invoice.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.sales.invoice +const route = cy.testRoutes.backend.sales.invoice; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/sales/order.cy.js b/cypress/e2e/openmage/backend/sales/order.cy.js index 4f92080c63b..e0d9b46050b 100644 --- a/cypress/e2e/openmage/backend/sales/order.cy.js +++ b/cypress/e2e/openmage/backend/sales/order.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.sales.order +const route = cy.testRoutes.backend.sales.order; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/sales/shipment.cy.js b/cypress/e2e/openmage/backend/sales/shipment.cy.js index 3dd105bf94c..09ab46db2fb 100644 --- a/cypress/e2e/openmage/backend/sales/shipment.cy.js +++ b/cypress/e2e/openmage/backend/sales/shipment.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.sales.shipment +const route = cy.testRoutes.backend.sales.shipment; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/sales/transactions.cy.js b/cypress/e2e/openmage/backend/sales/transactions.cy.js index e73ae6a7135..88cc54d3bc2 100644 --- a/cypress/e2e/openmage/backend/sales/transactions.cy.js +++ b/cypress/e2e/openmage/backend/sales/transactions.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.sales.transactions +const route = cy.testRoutes.backend.sales.transactions; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/backend/system/config/catalog/configswatches.cy.js b/cypress/e2e/openmage/backend/system/config/catalog/configswatches.cy.js index ed5bd0e1220..cbe6ad2644e 100644 --- a/cypress/e2e/openmage/backend/system/config/catalog/configswatches.cy.js +++ b/cypress/e2e/openmage/backend/system/config/catalog/configswatches.cy.js @@ -25,7 +25,7 @@ describe(`Checks admin system "${route.h3}" settings`, () => { }); it(`tests non-digit dimensions`, () => { - const value = cy.openmage.validation.assert.float; + const value = cy.openmage.validation.test.float; Object.keys(validate.dimension._input).forEach(section => { const group = validate.dimension._input[section]; diff --git a/cypress/e2e/openmage/backend/system/config/catalog/sitemap.cy.js b/cypress/e2e/openmage/backend/system/config/catalog/sitemap.cy.js index 3e54917da7f..c43ceefe257 100644 --- a/cypress/e2e/openmage/backend/system/config/catalog/sitemap.cy.js +++ b/cypress/e2e/openmage/backend/system/config/catalog/sitemap.cy.js @@ -1,5 +1,5 @@ const route = cy.testRoutes.backend.system.config.catalog.sitemap; -const saveButton = cy.testRoutes.backend.system.config._buttonSave +const saveButton = cy.testRoutes.backend.system.config._buttonSave; const validation = cy.openmage.validation; describe(`Checks admin system "${route.h3}" settings`, () => { @@ -8,21 +8,31 @@ describe(`Checks admin system "${route.h3}" settings`, () => { cy.adminGetConfiguration(route); }); + const priority = route.__validation.priority._input; + it(`tests invalid string priority`, () => { - validation.fillFields(route.__validation.priority._input, validation.number, validation.assert.string); + validation.fillFields(priority, validation.number, validation.test.string); validation.saveAction(saveButton); - validation.validateFields(route.__validation.priority._input, validation.number); + validation.validateFields(priority, validation.number); }); it(`tests invalid number priority`, () => { - validation.fillFields(route.__validation.priority._input, validation.numberRange, validation.assert.numberGreater1); + validation.fillFields(priority, validation.numberRange, validation.test.numberGreater1); validation.saveAction(saveButton); - validation.validateFields(route.__validation.priority._input, validation.numberRange); + validation.validateFields(priority, validation.numberRange); }); it(`tests empty priority`, () => { - validation.fillFields(route.__validation.priority._input, validation.requiredEntry); + validation.fillFields(priority, validation.requiredEntry); + validation.saveAction(saveButton); + validation.validateFields(priority, validation.requiredEntry); + }); + + it(`tests empty priority, no js`, () => { + const error = 'An error occurred while saving this configuration: The priority must be between 0 and 1.'; + validation.fillFields(priority, validation.requiredEntry); + validation.removeClasses(priority); validation.saveAction(saveButton); - validation.validateFields(route.__validation.priority._input, validation.requiredEntry); + cy.get(cy.openmage.validation._errorMessage).should('include.text', error); }); }); \ No newline at end of file diff --git a/cypress/e2e/openmage/backend/system/config/customers/promo.cy.js b/cypress/e2e/openmage/backend/system/config/customers/promo.cy.js index 7595c6b7e0e..eaa11dfb4a4 100644 --- a/cypress/e2e/openmage/backend/system/config/customers/promo.cy.js +++ b/cypress/e2e/openmage/backend/system/config/customers/promo.cy.js @@ -1,5 +1,5 @@ const route = cy.testRoutes.backend.system.config.customers.promo; -const saveButton = cy.testRoutes.backend.system.config._buttonSave +const saveButton = cy.testRoutes.backend.system.config._buttonSave; const validation = cy.openmage.validation; describe(`Checks admin system "${route.h3}" settings`, () => { @@ -18,7 +18,7 @@ describe(`Checks admin system "${route.h3}" settings`, () => { const fields = fieldset._input; const validate = validation.digits; - validation.fillFields(fields, validate, validation.assert.string); + validation.fillFields(fields, validate, validation.test.string); validation.saveAction(saveButton); validation.validateFields(fields, validate); }); diff --git a/cypress/e2e/openmage/backend/system/manage-currency.cy.js b/cypress/e2e/openmage/backend/system/manage-currency.cy.js index a19817a5f43..8f57d0c6c27 100644 --- a/cypress/e2e/openmage/backend/system/manage-currency.cy.js +++ b/cypress/e2e/openmage/backend/system/manage-currency.cy.js @@ -1,4 +1,5 @@ -const route = cy.testRoutes.backend.system.manage_curreny +const route = cy.testRoutes.backend.system.manage_curreny; +const validation = cy.openmage.validation; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { @@ -17,9 +18,9 @@ describe(`Checks admin system "${route.h3}"`, () => { cy.get('body').then($body => { if ($body.find(route.__validation._input.from).length > 0) { cy.get(route.__validation._input.from).clear(); - cy.openmage.validation.saveAction(route._buttonSave); - cy.get('.warning-msg').should('include.text', warning); - cy.get('.success-msg').should('include.text', success); + validation.saveAction(route._buttonSave); + cy.get(validation._warningMessage).should('include.text', warning); + cy.get(validation._successMessage).should('include.text', success); } }); }); @@ -28,9 +29,9 @@ describe(`Checks admin system "${route.h3}"`, () => { cy.get('body').then($body => { if ($body.find(route.__validation._input.from).length > 0) { cy.get(route.__validation._input.from).clear().type('abc'); - cy.openmage.validation.saveAction(route._buttonSave); - cy.get('.warning-msg').should('include.text', warning); - cy.get('.success-msg').should('include.text', success); + validation.saveAction(route._buttonSave); + cy.get(validation._warningMessage).should('include.text', warning); + cy.get(validation._successMessage).should('include.text', success); } }); }); diff --git a/cypress/e2e/openmage/backend/system/myacount.cy.js b/cypress/e2e/openmage/backend/system/myacount.cy.js index 95a1afd9981..00488494fdf 100644 --- a/cypress/e2e/openmage/backend/system/myacount.cy.js +++ b/cypress/e2e/openmage/backend/system/myacount.cy.js @@ -1,4 +1,5 @@ -const route = cy.testRoutes.backend.system.myaccount +const route = cy.testRoutes.backend.system.myaccount; +const validation = cy.openmage.validation; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { @@ -10,10 +11,10 @@ describe(`Checks admin system "${route.h3}"`, () => { cy.adminTestRoute(route); }); - it(`tests empty priority`, () => { + it(`tests empty input`, () => { const validate = cy.openmage.validation.requiredEntry; - cy.openmage.validation.fillFields(route.__validation._input, validate); - cy.openmage.validation.saveAction(route._buttonSave); - cy.openmage.validation.validateFields(route.__validation._input, validate); + validation.fillFields(route.__validation._input, validate); + validation.saveAction(route._buttonSave); + validation.validateFields(route.__validation._input, validate); }); }); \ No newline at end of file diff --git a/cypress/e2e/openmage/backend/system/notifications.cy.js b/cypress/e2e/openmage/backend/system/notifications.cy.js index 710cd984f4d..75c15ec7e7f 100644 --- a/cypress/e2e/openmage/backend/system/notifications.cy.js +++ b/cypress/e2e/openmage/backend/system/notifications.cy.js @@ -1,4 +1,4 @@ -const route = cy.testRoutes.backend.system.notification +const route = cy.testRoutes.backend.system.notification; describe(`Checks admin system "${route.h3}"`, () => { beforeEach('Log in the user', () => { diff --git a/cypress/e2e/openmage/frontend/customer/account/create.cy.js b/cypress/e2e/openmage/frontend/customer/account/create.cy.js index 97bd3a909c2..e438f7ddb07 100644 --- a/cypress/e2e/openmage/frontend/customer/account/create.cy.js +++ b/cypress/e2e/openmage/frontend/customer/account/create.cy.js @@ -1,38 +1,54 @@ +const route = cy.testRoutes.frontend.customer.account.create; +const fields = route.__validation._input; +const validation = cy.openmage.validation; + describe('Checks customer account create', () => { - beforeEach('Log in the user', () => { - cy.visit('/customer/account/create'); + beforeEach('Go to page', () => { + cy.visit(route.url); }); it('Checks the Create Account page title', () => { - cy.get('h1').should('include.text', 'Create an Account'); + cy.get(route._h1).should('include.text', route.h1); }); it('Submits empty form', () => { - const error = 'This is a required field.'; - cy.get('#form-validate button[type="submit"]').click(); - cy.get('#advice-required-entry-firstname').should('include.text', error); - cy.get('#advice-required-entry-lastname').should('include.text', error); - cy.get('#advice-required-entry-email_address').should('include.text', error); - cy.get('#advice-required-entry-password').should('include.text', error); - cy.get('#advice-required-entry-confirmation').should('include.text', error); + validation.fillFields(fields, validation.requiredEntry); + validation.saveAction(route._buttonSubmit); + validation.validateFields(fields, validation.requiredEntry); + }); + + it('Submits empty form, no js', () => { + validation.fillFields(fields, validation.requiredEntry); + validation.removeClasses(fields); + validation.saveAction(route._buttonSubmit); + cy.get(validation._errorMessage) + .should('include.text', '"First Name" is a required value.') + .should('include.text', '"First Name" length must be equal or greater than 1 characters.') + .should('include.text', '"Last Name" is a required value.') + .should('include.text', '"Last Name" length must be equal or greater than 1 characters.') + .should('include.text', '"Email" is a required value.'); }); it('Submits form with short password and wrong confirmation', () => { - cy.get('#password').type('123').should('have.value', '123'); - cy.get('#confirmation').type('abc').should('have.value', 'abc'); - cy.get('#form-validate button[type="submit"]').click(); + cy.get(fields.password).type('123').should('have.value', '123'); + cy.get(fields.confirmation).type('abc').should('have.value', 'abc'); + cy.get(route._buttonSubmit).click(); cy.get('#advice-validate-password-password').should('include.text', 'Please enter more characters or clean leading or trailing spaces.'); cy.get('#advice-validate-cpassword-confirmation').should('include.text', 'Please make sure your passwords match.'); }); it('Submits valid form with random email', () => { const email = cy.openmage.tools.generateRandomEmail(); - cy.get('#firstname').type('John').should('have.value', 'John'); - cy.get('#lastname').type('Doe').should('have.value', 'Doe'); - cy.get('#email_address').type(email).should('have.value', email); - cy.get('#password').type('12345678').should('have.value', '12345678'); - cy.get('#confirmation').type('12345678').should('have.value', '12345678'); - cy.get('#form-validate button[type="submit"]').click(); - cy.get('.success-msg').should('include.text', 'Thank you for registering with Madison Island.'); + const firstname = 'John'; + const lastname = 'Doe'; + const password = '12345678'; + const successMsg = 'Thank you for registering with Madison Island.'; + cy.get(fields.firstname).type(firstname).should('have.value', firstname); + cy.get(fields.lastname).type(lastname).should('have.value', lastname); + cy.get(fields.email_address).type(email).should('have.value', email); + cy.get(fields.password).type(password).should('have.value', password); + cy.get(fields.confirmation).type(password).should('have.value', password); + cy.get(route._buttonSubmit).click(); + cy.get(validation._successMessage).should('include.text', successMsg); }); }); diff --git a/cypress/e2e/openmage/frontend/newsletter-subscribe.cy.js b/cypress/e2e/openmage/frontend/newsletter-subscribe.cy.js index f85a1fe6932..2aefb3b99c1 100644 --- a/cypress/e2e/openmage/frontend/newsletter-subscribe.cy.js +++ b/cypress/e2e/openmage/frontend/newsletter-subscribe.cy.js @@ -1,20 +1,27 @@ +const route = cy.testRoutes.frontend.homepage; + describe('Check newsletter subribe', () => { - it('Test empty input', () => { - cy.visit('/') - cy.get('#newsletter').should('have.value', ''); - cy.get('#newsletter-validate-detail button[type="submit"]').click(); - cy.get('#advice-required-entry-newsletter').should('include.text', 'This is a required field.'); + beforeEach('Go to page', () => { + cy.visit(route.url); + }); + + it('tests empty input', () => { + const error = cy.openmage.validation.requiredEntry.error; + cy.get(route.newsletter._id).should('have.value', ''); + cy.get(route.newsletter._buttonSubmit).click(); + cy.get('#advice-required-entry-newsletter').should('include.text', error); }) it('Test valid input twice', () => { const email = cy.openmage.tools.generateRandomEmail(); - cy.visit('/') - cy.get('#newsletter').type(email).should('have.value', email); - cy.get('#newsletter-validate-detail button[type="submit"]').click(); - cy.get('.success-msg').should('include.text', 'Thank you for your subscription.'); + cy.log('Test first valid input'); + cy.get(route.newsletter._id).type(email).should('have.value', email); + cy.get(route.newsletter._buttonSubmit).click(); + cy.get(cy.openmage.validation._successMessage).should('include.text', 'Thank you for your subscription.'); - cy.get('#newsletter').type(email).should('have.value', email); - cy.get('#newsletter-validate-detail button[type="submit"]').click(); - cy.get('.error-msg').should('include.text', 'There was a problem with the subscription: This email address is already registered.'); + cy.log('Test second valid input'); + cy.get(route.newsletter._id).type(email).should('have.value', email); + cy.get(route.newsletter._buttonSubmit).click(); + cy.get(cy.openmage.validation._errorMessage).should('include.text', 'There was a problem with the subscription: This email address is already registered.'); }) }) diff --git a/cypress/e2e/security/formkeys.cy.js b/cypress/e2e/openmage/security/formkeys.cy.js similarity index 100% rename from cypress/e2e/security/formkeys.cy.js rename to cypress/e2e/openmage/security/formkeys.cy.js diff --git a/cypress/support/openmage.js b/cypress/support/openmage.js index 21b6e53621f..e4c67926cc9 100644 --- a/cypress/support/openmage.js +++ b/cypress/support/openmage.js @@ -25,7 +25,7 @@ cy.openmage = { } }, validation: { - assert: { + test: { float: '1.1', number: '1', numberGreater1: '666', @@ -51,6 +51,9 @@ cy.openmage = { error: 'The value is not within the specified range.', _error: '#advice-validate-number-range-', }, + _errorMessage: '.error-msg', + _successMessage: '.success-msg', + _warningMessage: '.warning-msg', fillFields: (fields, validation, value = '') =>{ cy.log('Filling fields with invalid values'); Object.keys(fields).forEach(field => { @@ -68,6 +71,15 @@ cy.openmage = { } }); }, + removeClasses: (fields) =>{ + cy.log('Removing classes from fields'); + Object.keys(fields).forEach(field => { + const selector = fields[field]; + cy + .get(selector) + .invoke('removeClass'); + }); + }, saveAction: (selector) => { cy.log('Clicking on Save button'); cy.get(selector).click({force: true, multiple: true}); diff --git a/cypress/support/openmage/config/paths.js b/cypress/support/openmage/config/paths.js index ec15e370485..2470f01ecf2 100644 --- a/cypress/support/openmage/config/paths.js +++ b/cypress/support/openmage/config/paths.js @@ -13,7 +13,15 @@ const adminPage = { } cy.testRoutes = { + api: {}, + backendLogin: {}, backend: { + dashboard: { + _id: '#nav-admin-dashboard', + url: 'dashboard/index', + h3: 'Dashboard', + _h3: adminPage._h3, + }, catalog: { products: { _id_parent: adminNav.catalog, @@ -306,5 +314,33 @@ cy.testRoutes = { }, } } + }, + frontend: { + homepage: { + url: '/', + newsletter: { + _buttonSubmit: '#newsletter-validate-detail button[type="submit"]', + _id: '#newsletter' + } + }, + customer: { + account: { + create: { + url: '/customer/account/create', + _buttonSubmit: '#form-validate button[type="submit"]', + _h1: 'h1', + h1: 'Create an Account', + __validation: { + _input: { + firstname: '#firstname', + lastname: '#lastname', + email_address: '#email_address', + password: '#password', + confirmation: '#confirmation', + } + } + } + } + } } }