From 16d550085fbbe4b03eddf95aaa4f46a835f922a9 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 5 Mar 2025 14:49:34 +0100 Subject: [PATCH] test: better itemBarcode test --- src/pages/Item/Card/ItemBarcode.vue | 1 + .../integration/item/itemBarcodes.spec.js | 19 +++++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/pages/Item/Card/ItemBarcode.vue b/src/pages/Item/Card/ItemBarcode.vue index 590b524cd..53b4514b7 100644 --- a/src/pages/Item/Card/ItemBarcode.vue +++ b/src/pages/Item/Card/ItemBarcode.vue @@ -94,6 +94,7 @@ const submit = async (rows) => { icon="add_circle" v-shortcut="'+'" flat + data-cy="addBarcode_input" > {{ t('Add barcode') }} diff --git a/test/cypress/integration/item/itemBarcodes.spec.js b/test/cypress/integration/item/itemBarcodes.spec.js index 844768d9e..1f6698f9c 100644 --- a/test/cypress/integration/item/itemBarcodes.spec.js +++ b/test/cypress/integration/item/itemBarcodes.spec.js @@ -3,23 +3,22 @@ describe('ItemBarcodes', () => { beforeEach(() => { cy.viewport(1920, 1080); cy.login('developer'); - cy.visit(`/#/item/list`); - cy.typeSearchbar('1{enter}'); + cy.visit(`/#/item/1/barcode`); }); it('should throw an error if the barcode exists', () => { - cy.get('[href="#/item/1/barcode"]').click(); - cy.get('.q-card > .q-btn > .q-btn__content > .q-icon').click(); - cy.dataCy('Code_input').eq(3).type('1111111111'); - cy.dataCy('crudModelDefaultSaveBtn').click(); + newBarcode('1111111111'); cy.checkNotification('Codes can not be repeated'); }); it('should create a new barcode', () => { - cy.get('[href="#/item/1/barcode"]').click(); - cy.get('.q-card > .q-btn > .q-btn__content > .q-icon').click(); - cy.dataCy('Code_input').eq(3).type('1231231231'); - cy.dataCy('crudModelDefaultSaveBtn').click(); + newBarcode('1231231231'); cy.checkNotification('Data saved'); }); + + function newBarcode(text) { + cy.dataCy('addBarcode_input').click(); + cy.dataCy('Code_input').eq(3).should('exist').type(text); + cy.dataCy('crudModelDefaultSaveBtn').click(); + } });