fix: refs #8349 fixed ItemFixedPrice test failing intermittently

This commit is contained in:
PAU ROVIRA ROSALENY 2025-02-03 08:37:40 +01:00
parent eba9c4240d
commit 30aa36684c
2 changed files with 22 additions and 27 deletions

View File

@ -35,6 +35,7 @@ const editTableCellDialogRef = ref(null);
const user = state.getUser(); const user = state.getUser();
const fixedPrices = ref([]); const fixedPrices = ref([]);
const warehousesOptions = ref([]); const warehousesOptions = ref([]);
const hasSelectedRows = computed(() => rowsSelected.value.length > 0);
const rowsSelected = ref([]); const rowsSelected = ref([]);
const itemFixedPriceFilterRef = ref(); const itemFixedPriceFilterRef = ref();
@ -53,7 +54,6 @@ const columns = computed(() => [
name: 'itemFk', name: 'itemFk',
...defaultColumnAttrs, ...defaultColumnAttrs,
isId: true, isId: true,
cardVisible: true,
columnField: { columnField: {
component: 'input', component: 'input',
type: 'number', type: 'number',
@ -65,14 +65,12 @@ const columns = computed(() => [
name: 'name', name: 'name',
...defaultColumnAttrs, ...defaultColumnAttrs,
create: true, create: true,
cardVisible: true,
}, },
{ {
label: t('item.fixedPrice.groupingPrice'), label: t('item.fixedPrice.groupingPrice'),
field: 'rate2', field: 'rate2',
name: 'rate2', name: 'rate2',
...defaultColumnAttrs, ...defaultColumnAttrs,
cardVisible: true,
component: 'input', component: 'input',
type: 'number', type: 'number',
}, },
@ -81,7 +79,6 @@ const columns = computed(() => [
field: 'rate3', field: 'rate3',
name: 'rate3', name: 'rate3',
...defaultColumnAttrs, ...defaultColumnAttrs,
cardVisible: true,
component: 'input', component: 'input',
type: 'number', type: 'number',
}, },
@ -91,7 +88,6 @@ const columns = computed(() => [
field: 'minPrice', field: 'minPrice',
name: 'minPrice', name: 'minPrice',
...defaultColumnAttrs, ...defaultColumnAttrs,
cardVisible: true,
component: 'input', component: 'input',
type: 'number', type: 'number',
}, },
@ -100,7 +96,6 @@ const columns = computed(() => [
field: 'started', field: 'started',
name: 'started', name: 'started',
format: ({ started }) => toDate(started), format: ({ started }) => toDate(started),
cardVisible: true,
...defaultColumnAttrs, ...defaultColumnAttrs,
columnField: { columnField: {
component: 'date', component: 'date',
@ -116,7 +111,6 @@ const columns = computed(() => [
field: 'ended', field: 'ended',
name: 'ended', name: 'ended',
...defaultColumnAttrs, ...defaultColumnAttrs,
cardVisible: true,
columnField: { columnField: {
component: 'date', component: 'date',
class: 'shrink', class: 'shrink',
@ -235,7 +229,7 @@ const validations = ({ row }) => {
'warehouseFk', 'warehouseFk',
]; ];
const isValid = requiredFields.every( const isValid = requiredFields.every(
(field) => row[field] !== null && row[field] !== undefined (field) => row[field] !== null && row[field] !== undefined,
); );
return isValid; return isValid;
}; };
@ -251,11 +245,14 @@ const upsertPrice = async (props, resetMinPrice = false) => {
} }
if (!changes.updates && !changes.creates) return; if (!changes.updates && !changes.creates) return;
const data = await upsertFixedPrice(row); const data = await upsertFixedPrice(row);
tableRef.value.CrudModelRef.formData[props.rowIndex] = data; Object.assign(tableRef.value.CrudModelRef.formData[props.rowIndex], data);
notify(t('globals.dataSaved'), 'positive');
tableRef.value.reload();
}; };
async function upsertFixedPrice(row) { async function upsertFixedPrice(row) {
const { data } = await axios.patch('FixedPrices/upsertFixedPrice', row); const { data } = await axios.patch('FixedPrices/upsertFixedPrice', row);
data.hasMinPrice = data.hasMinPrice ? 1 : 0;
return data; return data;
} }
@ -372,9 +369,9 @@ function handleOnDataSave({ CrudModelRef }) {
</template> </template>
</RightMenu> </RightMenu>
<VnSubToolbar> <VnSubToolbar>
<template #st-data> <template #st-actions>
<QBtn <QBtn
v-if="rowsSelected.length" :disable="!hasSelectedRows"
@click="openEditTableCellDialog()" @click="openEditTableCellDialog()"
color="primary" color="primary"
icon="edit" icon="edit"
@ -384,23 +381,17 @@ function handleOnDataSave({ CrudModelRef }) {
</QTooltip> </QTooltip>
</QBtn> </QBtn>
<QBtn <QBtn
:disable="!hasSelectedRows"
:label="tMobile('globals.remove')" :label="tMobile('globals.remove')"
color="primary" color="primary"
icon="delete" icon="delete"
flat flat
@click="(row) => confirmRemove(row, true)" @click="(row) => confirmRemove(row, true)"
:title="t('globals.remove')" :title="t('globals.remove')"
v-if="rowsSelected.length"
/> />
</template> </template>
</VnSubToolbar> </VnSubToolbar>
<VnTable <VnTable
@on-fetch="
(data) =>
data.forEach((item) => {
item.hasMinPrice = `${item.hasMinPrice !== 0}`;
})
"
:default-remove="false" :default-remove="false"
:default-reset="false" :default-reset="false"
:default-save="false" :default-save="false"
@ -424,6 +415,9 @@ function handleOnDataSave({ CrudModelRef }) {
'row-key': 'id', 'row-key': 'id',
selection: 'multiple', selection: 'multiple',
}" }"
:crud-model="{
disableInfiniteScroll: true,
}"
:use-model="true" :use-model="true"
v-model:selected="rowsSelected" v-model:selected="rowsSelected"
:create-as-dialog="false" :create-as-dialog="false"
@ -467,7 +461,7 @@ function handleOnDataSave({ CrudModelRef }) {
</span> </span>
<span class="subName">{{ row.subName }}</span> <span class="subName">{{ row.subName }}</span>
<ItemDescriptorProxy :id="row.itemFk" /> <ItemDescriptorProxy :id="row.itemFk" />
<FetchedTags :item="row" /> <FetchedTags :item="row" :columns="3" />
</template> </template>
<template #column-rate2="props"> <template #column-rate2="props">
<QTd class="col"> <QTd class="col">
@ -499,14 +493,15 @@ function handleOnDataSave({ CrudModelRef }) {
<QCheckbox <QCheckbox
:model-value="props.row.hasMinPrice" :model-value="props.row.hasMinPrice"
@update:model-value="updateMinPrice($event, props)" @update:model-value="updateMinPrice($event, props)"
:false-value="'false'" :false-value="0"
:true-value="'true'" :true-value="1"
:toggle-indeterminate="false"
/> />
<VnInput <VnInput
class="col" class="col"
type="currency" type="currency"
mask="###.##" mask="###.##"
:disable="props.row.hasMinPrice === 1" :disable="props.row.hasMinPrice === 0"
v-model.number="props.row.minPrice" v-model.number="props.row.minPrice"
v-on="getRowUpdateInputEvents(props)" v-on="getRowUpdateInputEvents(props)"
> >
@ -556,7 +551,7 @@ function handleOnDataSave({ CrudModelRef }) {
openConfirmationModal( openConfirmationModal(
t('globals.rowWillBeRemoved'), t('globals.rowWillBeRemoved'),
t('Do you want to clone this item?'), t('Do you want to clone this item?'),
() => removePrice(row.id, rowIndex) () => removePrice(row.id, rowIndex),
) )
" "
> >

View File

@ -25,11 +25,11 @@ describe('Handle Items FixedPrice', () => {
it('Create and delete ', function () { it('Create and delete ', function () {
cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content').click(); cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content').click();
cy.get('.bottomButton > .q-btn > .q-btn__content > .q-icon').click(); cy.dataCy('vnTableCreateBtn').click();
cy.get(`${secondRow} > :nth-child(5) > .q-td`).type("2{enter}");
cy.get(`${secondRow} > :nth-child(2)`).type('11'); cy.get(`${secondRow} > :nth-child(2)`).type('11');
cy.get('.q-menu .q-item').contains('#11').click(); cy.get('.q-menu .q-item').contains('#11').click();
cy.get(`${secondRow} > :nth-child(4)`).find('input').type(1); cy.get(`${secondRow} > :nth-child(4) > .q-td`).type("1{enter}");
cy.get(`${secondRow} > :nth-child(5)`).find('input').type(2);
cy.get(`${secondRow} > :nth-child(9)`).type('Warehouse One'); cy.get(`${secondRow} > :nth-child(9)`).type('Warehouse One');
cy.get('.q-menu .q-item').contains('Warehouse One').click(); cy.get('.q-menu .q-item').contains('Warehouse One').click();
cy.get('.q-notification__message').should('have.text', 'Data saved'); cy.get('.q-notification__message').should('have.text', 'Data saved');
@ -38,13 +38,13 @@ describe('Handle Items FixedPrice', () => {
}); });
it.skip('Massive edit', function () { it.skip('Massive edit', function () {
//Falla debido a que hay una petición doble
cy.get(' .bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner ').click(); cy.get(' .bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner ').click();
cy.get('#subToolbar > .q-btn--standard').click(); cy.get('#subToolbar > .q-btn--standard').click();
cy.selectOption("[data-cy='field-to-edit']", 'Min price'); cy.selectOption("[data-cy='field-to-edit']", 'Min price');
cy.dataCy('value-to-edit').find('input').type('1'); cy.dataCy('value-to-edit').find('input').type('1');
cy.get('.countLines').invoke('text').then(parseFloat).should('be.gte', 1); cy.get('.countLines').invoke('text').then(parseFloat).should('be.gte', 1);
cy.get('.q-mt-lg > .q-btn--standard').click(); cy.get('.q-mt-lg > .q-btn--standard').click();
//Falla debido a que hay una petición doble
cy.get('.q-notification__message').should('have.text', 'Data saved'); cy.get('.q-notification__message').should('have.text', 'Data saved');
}); });
it('Massive remove', function () { it('Massive remove', function () {