From 5f3071bd7c13e27f0d3e1796086f0da930f7ff8c Mon Sep 17 00:00:00 2001 From: Matteo Guarnaccia Date: Wed, 1 Nov 2023 15:05:56 +0000 Subject: [PATCH] added more e2e tests #73 --- cypress/e2e/manufacturer/manufacturer.cy.ts | 49 +++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/cypress/e2e/manufacturer/manufacturer.cy.ts b/cypress/e2e/manufacturer/manufacturer.cy.ts index 8f68c2e56..704b454e6 100644 --- a/cypress/e2e/manufacturer/manufacturer.cy.ts +++ b/cypress/e2e/manufacturer/manufacturer.cy.ts @@ -236,4 +236,53 @@ describe('Manufacturer', () => { cy.contains('Please enter a valid URL'); }); }); + + it('Not changing any fields shows error', () => { + cy.findByRole('button', { + name: 'Edit Manufacturer A manufacturer', + }).click(); + + cy.findByRole('button', { name: 'Save' }).click(); + + cy.findByRole('dialog') + .should('be.visible') + .within(() => { + cy.contains( + "There have been no changes made. Please change a field's value or press Cancel to exit" + ); + }); + }); + + it('Required fields that are cleared are not allowed and show error message', () => { + cy.findByRole('button', { + name: 'Edit Manufacturer A manufacturer', + }).click(); + + cy.findByLabelText('Name').clear(); + cy.findByLabelText('Building number').clear(); + cy.findByLabelText('Street name').clear(); + cy.findByLabelText('Post/Zip code').clear(); + + cy.findByRole('button', { name: 'Save' }).click(); + cy.findByRole('dialog') + .should('be.visible') + .within(() => { + cy.contains('Please enter a name.'); + }); + cy.findByRole('dialog') + .should('be.visible') + .within(() => { + cy.contains('Please enter a building number.'); + }); + cy.findByRole('dialog') + .should('be.visible') + .within(() => { + cy.contains('Please enter a street name.'); + }); + cy.findByRole('dialog') + .should('be.visible') + .within(() => { + cy.contains('Please enter a post code or zip code.'); + }); + }); });