From 0ddc8f225c9defbf7cffb968c3631b6122d238ad Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 2 Dec 2024 23:02:35 +0100 Subject: [PATCH] test: #7260 add dataCy --- src/components/EditTableCellValueForm.vue | 2 ++ src/components/ui/VnNotes.vue | 2 -- src/pages/Item/ItemFixedPrice.vue | 34 +++++++------------ .../integration/item/ItemFixedPrice.spec.js | 4 +-- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/components/EditTableCellValueForm.vue b/src/components/EditTableCellValueForm.vue index 7755df9ab..172866191 100644 --- a/src/components/EditTableCellValueForm.vue +++ b/src/components/EditTableCellValueForm.vue @@ -85,12 +85,14 @@ const closeForm = () => { hide-selected option-label="label" v-model="selectedField" + data-cy="field-to-edit" /> diff --git a/src/components/ui/VnNotes.vue b/src/components/ui/VnNotes.vue index bb8ac3dba..e308ea9bb 100644 --- a/src/components/ui/VnNotes.vue +++ b/src/components/ui/VnNotes.vue @@ -6,7 +6,6 @@ import { useI18n } from 'vue-i18n'; import { useQuasar } from 'quasar'; import { toDateHourMin } from 'src/filters'; -import { useState } from 'src/composables/useState'; import VnPaginate from 'components/ui/VnPaginate.vue'; import VnUserLink from 'components/ui/VnUserLink.vue'; @@ -26,7 +25,6 @@ const $props = defineProps({ }); const { t } = useI18n(); -const state = useState(); const quasar = useQuasar(); const newNote = reactive({ text: null, observationTypeFk: null }); const observationTypes = ref([]); diff --git a/src/pages/Item/ItemFixedPrice.vue b/src/pages/Item/ItemFixedPrice.vue index fb8009b2e..09fccfd6d 100644 --- a/src/pages/Item/ItemFixedPrice.vue +++ b/src/pages/Item/ItemFixedPrice.vue @@ -240,31 +240,23 @@ const validations = ({ row }) => { return isValid; }; const upsertPrice = async (props, resetMinPrice = false) => { - try { - const isValid = validations({ ...props }); - if (!isValid) { - return; - } - const { row } = props; - const changes = tableRef.value.CrudModelRef.getChanges(); - if (changes?.updates?.length > 0) { - if (resetMinPrice) row.hasMinPrice = 0; - } - if (!changes.updates && !changes.creates) return; - const data = await upsertFixedPrice(row); - tableRef.value.CrudModelRef.formData[props.rowIndex] = data; - } catch (err) { - console.error('Error editing price', err); + const isValid = validations({ ...props }); + if (!isValid) { + return; } + const { row } = props; + const changes = tableRef.value.CrudModelRef.getChanges(); + if (changes?.updates?.length > 0) { + if (resetMinPrice) row.hasMinPrice = 0; + } + if (!changes.updates && !changes.creates) return; + const data = await upsertFixedPrice(row); + tableRef.value.CrudModelRef.formData[props.rowIndex] = data; }; async function upsertFixedPrice(row) { - try { - const { data } = await axios.patch('FixedPrices/upsertFixedPrice', row); - return data; - } catch (err) { - console.error('Error editing price', err); - } + const { data } = await axios.patch('FixedPrices/upsertFixedPrice', row); + return data; } function checkLastVisibleRow() { diff --git a/test/cypress/integration/item/ItemFixedPrice.spec.js b/test/cypress/integration/item/ItemFixedPrice.spec.js index 2ffdb93d7..824ecf7a0 100644 --- a/test/cypress/integration/item/ItemFixedPrice.spec.js +++ b/test/cypress/integration/item/ItemFixedPrice.spec.js @@ -46,8 +46,8 @@ describe('Handle Items FixedPrice', () => { it('Massive edit', function () { cy.get(' .bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner ').click(); cy.get('#subToolbar > .q-btn--standard').click(); - cy.selectOption('.vn-row > :nth-child(2)', 'Min price'); - cy.get('.vn-row > :nth-child(3)').type('1'); + cy.selectOption("[data-cy='field-to-edit']", 'Min price'); + cy.dataCy('value-to-edit').find('input').type('1'); cy.get('.countLines').should('have.text', ' 1 '); cy.get('.q-mt-lg > .q-btn--standard').click(); cy.get('.q-notification__message').should('have.text', 'Data saved');