From 5fdcfcba9b04594b6ae4d8d2768610bed2c22299 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 5 Mar 2025 13:20:13 +0100 Subject: [PATCH] refactor: use constant for account input selector in VnAccountNumber tests --- .../vnComponent/VnAccountNumber.spec.js | 45 +++++++------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/test/cypress/integration/vnComponent/VnAccountNumber.spec.js b/test/cypress/integration/vnComponent/VnAccountNumber.spec.js index 0dc12205b..053902f35 100644 --- a/test/cypress/integration/vnComponent/VnAccountNumber.spec.js +++ b/test/cypress/integration/vnComponent/VnAccountNumber.spec.js @@ -1,4 +1,5 @@ describe('VnAccountNumber', () => { + const accountInput = 'input[data-cy="supplierFiscalDataAccount_input"]'; beforeEach(() => { cy.login('developer'); cy.viewport(1920, 1080); @@ -7,44 +8,30 @@ describe('VnAccountNumber', () => { describe('VnInput handleInsertMode()', () => { it('should replace character at cursor position in insert mode', () => { - cy.get('input[data-cy="supplierFiscalDataAccount"]').type( - '{selectall}4100000001', - ); - cy.get('input[data-cy="supplierFiscalDataAccount"]').type('{movetostart}'); - cy.get('input[data-cy="supplierFiscalDataAccount"]').type('999'); - cy.get('input[data-cy="supplierFiscalDataAccount"]').should( - 'have.value', - '9990000001', - ); + cy.get(accountInput).type('{selectall}4100000001'); + cy.get(accountInput).type('{movetostart}'); + cy.get(accountInput).type('999'); + cy.get(accountInput).should('have.value', '9990000001'); }); it('should replace character at cursor position in insert mode', () => { - cy.get('input[data-cy="supplierFiscalDataAccount"]').clear(); - cy.get('input[data-cy="supplierFiscalDataAccount"]').type('4100000001'); - cy.get('input[data-cy="supplierFiscalDataAccount"]').type('{movetostart}'); - cy.get('input[data-cy="supplierFiscalDataAccount"]').type('999'); - cy.get('input[data-cy="supplierFiscalDataAccount"]').should( - 'have.value', - '9990000001', - ); + cy.get(accountInput).clear(); + cy.get(accountInput).type('4100000001'); + cy.get(accountInput).type('{movetostart}'); + cy.get(accountInput).type('999'); + cy.get(accountInput).should('have.value', '9990000001'); }); it('should respect maxlength prop', () => { - cy.get('input[data-cy="supplierFiscalDataAccount"]').clear(); - cy.get('input[data-cy="supplierFiscalDataAccount"]').type('123456789012345'); - cy.get('input[data-cy="supplierFiscalDataAccount"]').should( - 'have.value', - '1234567890', - ); + cy.get(accountInput).clear(); + cy.get(accountInput).type('123456789012345'); + cy.get(accountInput).should('have.value', '1234567890'); }); }); it('should convert short account number to standard format', () => { - cy.get('input[data-cy="supplierFiscalDataAccount"]').clear(); - cy.get('input[data-cy="supplierFiscalDataAccount"]').type('123.'); - cy.get('input[data-cy="supplierFiscalDataAccount"]').should( - 'have.value', - '1230000000', - ); + cy.get(accountInput).clear(); + cy.get(accountInput).type('123.'); + cy.get(accountInput).should('have.value', '1230000000'); }); });