From 8c499e3fc3a4d4616ff47a47125a08dc66c08e05 Mon Sep 17 00:00:00 2001
From: Jon <jon@verdnatura.es>
Date: Mon, 10 Feb 2025 10:20:40 +0100
Subject: [PATCH 1/3] fix: fixed basic data e2e

---
 .../invoiceIn/invoiceInBasicData.spec.js      | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js
index 2016fca6df0..c214380931d 100644
--- a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js
+++ b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js
@@ -1,23 +1,20 @@
 /// <reference types="cypress" />
 describe('InvoiceInBasicData', () => {
-    const formInputs = '.q-form > .q-card input';
     const firstFormSelect = '.q-card > .vn-row:nth-child(1) > .q-select';
-    const documentBtns = '[data-cy="dms-buttons"] button';
+    const documentBtns = '[data-cy="dms-buttons"]';
     const dialogInputs = '.q-dialog input';
 
     beforeEach(() => {
         cy.login('developer');
-        cy.visit(`/#/invoice-in/1/basic-data`);
+        cy.visit(`/#/invoice-in/2/basic-data`);
     });
 
     it('should edit the provideer and supplier ref', () => {
-        cy.selectOption(firstFormSelect, 'Bros');
+        cy.selectOption('[data-cy="Undeductible VAT_select"]', '4751000000')
         cy.get('[title="Reset"]').click();
-        cy.get(formInputs).eq(1).type('{selectall}4739');
+        cy.selectOption(firstFormSelect, 'Bros');
         cy.saveCard();
-
-        cy.get(`${firstFormSelect} input`).invoke('val').should('eq', 'Plants nick');
-        cy.get(formInputs).eq(1).invoke('val').should('eq', '4739');
+        cy.get(`${firstFormSelect} input`).invoke('val').should('eq', 'Bros nick');
     });
 
     it('should edit, remove and create the dms data', () => {
@@ -25,18 +22,18 @@ describe('InvoiceInBasicData', () => {
         const secondInput = "I don't know what posting here!";
 
         //edit
-        cy.get(documentBtns).eq(1).click();
+        cy.get(`${documentBtns} > :nth-child(2)`).click();
         cy.get(dialogInputs).eq(0).type(`{selectall}${firtsInput}`);
         cy.get('textarea').type(`{selectall}${secondInput}`);
         cy.get('[data-cy="FormModelPopup_save"]').click();
-        cy.get(documentBtns).eq(1).click();
+        cy.get(`${documentBtns} > :nth-child(2)`).click();
         cy.get(dialogInputs).eq(0).invoke('val').should('eq', firtsInput);
         cy.get('textarea').invoke('val').should('eq', secondInput);
         cy.get('[data-cy="FormModelPopup_save"]').click();
         cy.checkNotification('Data saved');
 
         //remove
-        cy.get(documentBtns).eq(2).click();
+        cy.get(`${documentBtns} > :nth-child(3)`).click();
         cy.get('[data-cy="VnConfirm_confirm"]').click();
         cy.checkNotification('Data saved');
 

From aa6c6f0e690a3c86c51924a38aebe8ea08872aef Mon Sep 17 00:00:00 2001
From: Jon <jon@verdnatura.es>
Date: Mon, 10 Feb 2025 12:44:35 +0100
Subject: [PATCH 2/3] refactor: requested changes

---
 .../InvoiceIn/Card/InvoiceInBasicData.vue     |  2 ++
 .../invoiceIn/invoiceInBasicData.spec.js      | 19 +++++++++++--------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue b/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue
index 0cc9ac2c9a4..0ea5dd0ed6d 100644
--- a/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue
+++ b/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue
@@ -121,6 +121,7 @@ function deleteFile(dmsFk) {
                     hide-selected
                     :is-clearable="false"
                     :required="true"
+                    data-cy="vnSupplierSelect"
                 />
                 <VnInput
                     clearable
@@ -149,6 +150,7 @@ function deleteFile(dmsFk) {
                     option-value="id"
                     option-label="id"
                     :filter-options="['id', 'name']"
+                    data-cy="UnDeductibleVatSelect"
                 >
                     <template #option="scope">
                         <QItem v-bind="scope.itemProps">
diff --git a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js
index c214380931d..7a9c2b4a04b 100644
--- a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js
+++ b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js
@@ -1,18 +1,21 @@
 /// <reference types="cypress" />
 describe('InvoiceInBasicData', () => {
     const firstFormSelect = '.q-card > .vn-row:nth-child(1) > .q-select';
-    const documentBtns = '[data-cy="dms-buttons"]';
     const dialogInputs = '.q-dialog input';
+    const resetBtn = '.q-btn-group--push > .q-btn--flat';
+    const getDocumentBtns = (opt) => `[data-cy="dms-buttons"]  > :nth-child(${opt})`;
 
     beforeEach(() => {
         cy.login('developer');
-        cy.visit(`/#/invoice-in/2/basic-data`);
+        cy.visit(`/#/invoice-in/1/basic-data`);
     });
 
     it('should edit the provideer and supplier ref', () => {
-        cy.selectOption('[data-cy="Undeductible VAT_select"]', '4751000000')
-        cy.get('[title="Reset"]').click();
-        cy.selectOption(firstFormSelect, 'Bros');
+        cy.dataCy('UnDeductibleVatSelect').type('4751000000');
+        cy.get('.q-menu .q-item').contains('4751000000').click();
+        cy.get(resetBtn).click();
+        cy.dataCy('vnSupplierSelect').type('Bros nick');
+        cy.get('.q-menu .q-item').contains('Bros nick').click();
         cy.saveCard();
         cy.get(`${firstFormSelect} input`).invoke('val').should('eq', 'Bros nick');
     });
@@ -22,18 +25,18 @@ describe('InvoiceInBasicData', () => {
         const secondInput = "I don't know what posting here!";
 
         //edit
-        cy.get(`${documentBtns} > :nth-child(2)`).click();
+        cy.get(getDocumentBtns(2)).click();
         cy.get(dialogInputs).eq(0).type(`{selectall}${firtsInput}`);
         cy.get('textarea').type(`{selectall}${secondInput}`);
         cy.get('[data-cy="FormModelPopup_save"]').click();
-        cy.get(`${documentBtns} > :nth-child(2)`).click();
+        cy.get(getDocumentBtns(2)).click();
         cy.get(dialogInputs).eq(0).invoke('val').should('eq', firtsInput);
         cy.get('textarea').invoke('val').should('eq', secondInput);
         cy.get('[data-cy="FormModelPopup_save"]').click();
         cy.checkNotification('Data saved');
 
         //remove
-        cy.get(`${documentBtns} > :nth-child(3)`).click();
+        cy.get(getDocumentBtns(3)).click();
         cy.get('[data-cy="VnConfirm_confirm"]').click();
         cy.checkNotification('Data saved');
 

From 73f02cf8bd8a49607651062a59b35954ac1cdfba Mon Sep 17 00:00:00 2001
From: Jon <jon@verdnatura.es>
Date: Mon, 10 Feb 2025 13:18:59 +0100
Subject: [PATCH 3/3] refactor: use data-cy in VnSelectSupplier component and
 refactored e2e

---
 src/components/common/VnSelectSupplier.vue                   | 1 +
 src/pages/InvoiceIn/Card/InvoiceInBasicData.vue              | 1 -
 .../cypress/integration/invoiceIn/invoiceInBasicData.spec.js | 5 ++++-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/components/common/VnSelectSupplier.vue b/src/components/common/VnSelectSupplier.vue
index 5a821456efe..5b52ae75b24 100644
--- a/src/components/common/VnSelectSupplier.vue
+++ b/src/components/common/VnSelectSupplier.vue
@@ -15,6 +15,7 @@ const model = defineModel({ type: [String, Number, Object] });
         :fields="['id', 'name', 'nickname', 'nif']"
         :filter-options="['id', 'name', 'nickname', 'nif']"
         sort-by="name ASC"
+        data-cy="vnSupplierSelect"
     >
         <template #option="scope">
             <QItem v-bind="scope.itemProps">
diff --git a/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue b/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue
index 0ea5dd0ed6d..905ddebb2b0 100644
--- a/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue
+++ b/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue
@@ -121,7 +121,6 @@ function deleteFile(dmsFk) {
                     hide-selected
                     :is-clearable="false"
                     :required="true"
-                    data-cy="vnSupplierSelect"
                 />
                 <VnInput
                     clearable
diff --git a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js
index 7a9c2b4a04b..c6bcc37c191 100644
--- a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js
+++ b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js
@@ -14,7 +14,10 @@ describe('InvoiceInBasicData', () => {
         cy.dataCy('UnDeductibleVatSelect').type('4751000000');
         cy.get('.q-menu .q-item').contains('4751000000').click();
         cy.get(resetBtn).click();
-        cy.dataCy('vnSupplierSelect').type('Bros nick');
+
+        cy.waitForElement('#formModel').within(() => {
+            cy.dataCy('vnSupplierSelect').type('Bros nick');
+        })
         cy.get('.q-menu .q-item').contains('Bros nick').click();
         cy.saveCard();
         cy.get(`${firstFormSelect} input`).invoke('val').should('eq', 'Bros nick');