Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 8599-ModifyAndCreateInvoiceOutTests

This commit is contained in:
Jon Elias 2025-02-20 10:34:58 +01:00
commit e3bd8e59ca
17 changed files with 400 additions and 229 deletions

View File

@ -247,6 +247,7 @@ async function saveAndGo() {
}
function reset() {
formData.value = JSON.parse(JSON.stringify(originalData.value));
updateAndEmit('onFetch', { val: originalData.value });
if ($props.observeFormChanges) {
hasChanges.value = false;

View File

@ -1,6 +1,6 @@
<script setup>
import { markRaw, computed } from 'vue';
import { QIcon, QCheckbox, QToggle } from 'quasar';
import { QIcon, QToggle } from 'quasar';
import { dashIfEmpty } from 'src/filters';
import VnSelect from 'components/common/VnSelect.vue';

View File

@ -10,14 +10,15 @@ import {
render,
inject,
useAttrs,
nextTick,
} from 'vue';
import { useArrayData } from 'src/composables/useArrayData';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import { useQuasar } from 'quasar';
import { useQuasar, date } from 'quasar';
import { useStateStore } from 'stores/useStateStore';
import { useFilterParams } from 'src/composables/useFilterParams';
import { dashIfEmpty } from 'src/filters';
import { dashIfEmpty, toDate } from 'src/filters';
import CrudModel from 'src/components/CrudModel.vue';
import FormModelPopup from 'components/FormModelPopup.vue';
@ -344,7 +345,7 @@ const clickHandler = async (event) => {
if (isDateElement || isTimeElement || isQselectDropDown) return;
if (clickedElement === null) {
destroyInput(editingRow.value, editingField.value);
await destroyInput(editingRow.value, editingField.value);
return;
}
const rowIndex = clickedElement.getAttribute('data-row-index');
@ -354,7 +355,7 @@ const clickHandler = async (event) => {
if (editingRow.value !== null && editingField.value !== null) {
if (editingRow.value == rowIndex && editingField.value == colField) return;
destroyInput(editingRow.value, editingField.value);
await destroyInput(editingRow.value, editingField.value);
}
if (isEditableColumn(column)) {
@ -364,7 +365,7 @@ const clickHandler = async (event) => {
async function handleTabKey(event, rowIndex, colField) {
if (editingRow.value == rowIndex && editingField.value == colField)
destroyInput(editingRow.value, editingField.value);
await destroyInput(editingRow.value, editingField.value);
const direction = event.shiftKey ? -1 : 1;
const { nextRowIndex, nextColumnName } = await handleTabNavigation(
@ -424,7 +425,8 @@ async function renderInput(rowId, field, clickedElement) {
await column?.cellEvent?.['update:modelValue']?.(value, oldValue, row);
},
keyup: async (event) => {
if (event.key === 'Enter') handleBlur(rowId, field, clickedElement);
if (event.key === 'Enter')
await destroyInput(rowIndex, field, clickedElement);
},
keydown: async (event) => {
switch (event.key) {
@ -433,7 +435,7 @@ async function renderInput(rowId, field, clickedElement) {
event.stopPropagation();
break;
case 'Escape':
destroyInput(rowId, field, clickedElement);
await destroyInput(rowId, field, clickedElement);
break;
default:
break;
@ -455,12 +457,13 @@ async function renderInput(rowId, field, clickedElement) {
node.el?.querySelector('span > div > div').focus();
}
function destroyInput(rowIndex, field, clickedElement) {
async function destroyInput(rowIndex, field, clickedElement) {
if (!clickedElement)
clickedElement = document.querySelector(
`[data-row-index="${rowIndex}"][data-col-field="${field}"]`,
);
if (clickedElement) {
await nextTick();
render(null, clickedElement);
Array.from(clickedElement.childNodes).forEach((child) => {
child.style.visibility = 'visible';
@ -472,10 +475,6 @@ function destroyInput(rowIndex, field, clickedElement) {
editingField.value = null;
}
function handleBlur(rowIndex, field, clickedElement) {
destroyInput(rowIndex, field, clickedElement);
}
async function handleTabNavigation(rowIndex, colName, direction) {
const columns = $props.columns;
const totalColumns = columns.length;
@ -526,11 +525,36 @@ function formatColumnValue(col, row, dashIfEmpty) {
} else {
return col.format(row, dashIfEmpty);
}
}
if (col?.component === 'date') return dashIfEmpty(toDate(row[col?.name]));
if (col?.component === 'time')
return row[col?.name] >= 5
? dashIfEmpty(date.formatDate(new Date(row[col?.name]), 'HH:mm'))
: row[col?.name];
if (selectRegex.test(col?.component) && $props.isEditable) {
const { find, url } = col.attrs;
const urlRelation = url?.charAt(0)?.toLocaleLowerCase() + url?.slice(1, -1);
if (col?.attrs.options) {
const find = col?.attrs.options.find((option) => option.id === row[col.name]);
if (!col.attrs?.optionLabel || !find) return dashIfEmpty(row[col?.name]);
return dashIfEmpty(find[col.attrs?.optionLabel ?? 'name']);
}
if (typeof row[urlRelation] == 'object') {
if (typeof find == 'object')
return dashIfEmpty(row[urlRelation][find?.label ?? 'name']);
return dashIfEmpty(row[urlRelation][col?.attrs.optionLabel ?? 'name']);
}
if (typeof row[urlRelation] == 'string') return dashIfEmpty(row[urlRelation]);
} else {
return dashIfEmpty(row[col?.name]);
}
}
const checkbox = ref(null);
function cardClick(_, row) {
if ($props.redirect) router.push({ path: `/${$props.redirect}/${row.id}` });
}
@ -721,7 +745,11 @@ function cardClick(_, row) {
<span
v-else
:class="hasEditableFormat(col)"
:style="col?.style ? col.style(row) : null"
:style="
typeof col?.style == 'function'
? col.style(row)
: col?.style
"
style="bottom: 0"
>
{{ formatColumnValue(col, row, dashIfEmpty) }}

View File

@ -7,6 +7,7 @@ export function getColAlign(col) {
case 'number':
align = 'right';
break;
case 'time':
case 'date':
case 'checkbox':
align = 'center';

View File

@ -49,6 +49,7 @@ globals:
rowRemoved: Row removed
pleaseWait: Please wait...
noPinnedModules: You don't have any pinned modules
enterToConfirm: Press Enter to confirm
summary:
basicData: Basic data
daysOnward: Days onward

View File

@ -51,6 +51,7 @@ globals:
pleaseWait: Por favor espera...
noPinnedModules: No has fijado ningún módulo
split: Split
enterToConfirm: Pulsa Enter para confirmar
summary:
basicData: Datos básicos
daysOnward: Días adelante

View File

@ -21,6 +21,10 @@ const $props = defineProps({
type: String,
default: 'mana',
},
sale: {
type: Object,
default: null,
},
});
const emit = defineEmits(['save', 'cancel']);
@ -29,8 +33,8 @@ const { t } = useI18n();
const QPopupProxyRef = ref(null);
const manaCode = ref($props.manaCode);
const save = () => {
emit('save');
const save = (sale = $props.sale) => {
emit('save', sale);
QPopupProxyRef.value.hide();
};
@ -38,10 +42,11 @@ const cancel = () => {
emit('cancel');
QPopupProxyRef.value.hide();
};
defineExpose({ save });
</script>
<template>
<QPopupProxy ref="QPopupProxyRef">
<QPopupProxy ref="QPopupProxyRef" data-cy="ticketEditManaProxy">
<div class="container">
<QSpinner v-if="!mana" color="primary" size="md" />
<div v-else>

View File

@ -22,7 +22,6 @@ import { useVnConfirm } from 'composables/useVnConfirm';
import useNotify from 'src/composables/useNotify.js';
import axios from 'axios';
import VnTable from 'src/components/VnTable/VnTable.vue';
import VnUsesMana from 'src/components/ui/VnUsesMana.vue';
import VnConfirm from 'src/components/ui/VnConfirm.vue';
import TicketProblems from 'src/components/TicketProblems.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
@ -33,6 +32,7 @@ const { t } = useI18n();
const { notify } = useNotify();
const { openConfirmationModal } = useVnConfirm();
const editPriceProxyRef = ref(null);
const editManaProxyRef = ref(null);
const stateBtnDropdownRef = ref(null);
const quasar = useQuasar();
const arrayData = useArrayData('Ticket');
@ -53,7 +53,6 @@ const transfer = ref({
sales: [],
});
const tableRef = ref([]);
const canProceed = ref();
watch(
() => route.params.id,
@ -133,7 +132,6 @@ const columns = computed(() => [
align: 'left',
label: t('globals.amount'),
name: 'amount',
format: (row) => toCurrency(getSaleTotal(row)),
},
{
align: 'left',
@ -183,8 +181,6 @@ const resetChanges = async () => {
};
const rowToUpdate = ref(null);
const changeQuantity = async (sale) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
if (
!sale.itemFk ||
sale.quantity == null ||
@ -193,11 +189,21 @@ const changeQuantity = async (sale) => {
return;
if (!sale.id) return addSale(sale);
if (await isSalePrepared(sale)) {
await confirmUpdate(() => updateQuantity(sale));
} else await updateQuantity(sale);
};
const updateQuantity = async (sale) => {
try {
let { quantity, id } = sale;
if (!rowToUpdate.value) return;
rowToUpdate.value = null;
sale.isNew = false;
await updateQuantity(sale);
const params = { quantity: quantity };
await axios.post(`Sales/${id}/updateQuantity`, params);
notify('globals.dataSaved', 'positive');
tableRef.value.reload();
} catch (e) {
const { quantity } = tableRef.value.CrudModelRef.originalData.find(
(s) => s.id === sale.id,
@ -207,12 +213,6 @@ const changeQuantity = async (sale) => {
}
};
const updateQuantity = async ({ quantity, id }) => {
const params = { quantity: quantity };
await axios.post(`Sales/${id}/updateQuantity`, params);
notify('globals.dataSaved', 'positive');
};
const addSale = async (sale) => {
const params = {
barcode: sale.itemFk,
@ -237,13 +237,17 @@ const addSale = async (sale) => {
sale.isNew = false;
arrayData.fetch({});
};
const changeConcept = async (sale) => {
if (await isSalePrepared(sale)) {
await confirmUpdate(() => updateConcept(sale));
} else await updateConcept(sale);
};
const updateConcept = async (sale) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
const data = { newConcept: sale.concept };
await axios.post(`Sales/${sale.id}/updateConcept`, data);
notify('globals.dataSaved', 'positive');
tableRef.value.reload();
};
const DEFAULT_EDIT = {
@ -295,33 +299,43 @@ const onOpenEditDiscountPopover = async (sale) => {
};
}
};
const updatePrice = async (sale) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
const changePrice = async (sale) => {
const newPrice = edit.value.price;
if (newPrice != null && newPrice != sale.price) {
await axios.post(`Sales/${sale.id}/updatePrice`, { newPrice });
sale.price = newPrice;
edit.value = { ...DEFAULT_EDIT };
notify('globals.dataSaved', 'positive');
if (await isSalePrepared(sale)) {
await confirmUpdate(() => updatePrice(sale, newPrice));
} else updatePrice(sale, newPrice);
}
await getMana();
};
const updatePrice = async (sale, newPrice) => {
await axios.post(`Sales/${sale.id}/updatePrice`, { newPrice });
sale.price = newPrice;
edit.value = { ...DEFAULT_EDIT };
notify('globals.dataSaved', 'positive');
tableRef.value.reload();
};
const changeDiscount = async (sale) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
const newDiscount = edit.value.discount;
if (newDiscount != null && newDiscount != sale.discount) updateDiscount([sale]);
if (newDiscount != null && newDiscount != sale.discount) {
if (await isSalePrepared(sale))
await confirmUpdate(() => updateDiscount([sale], newDiscount));
else await updateDiscount([sale], newDiscount);
}
};
const updateDiscounts = async (sales, newDiscount = null) => {
const salesTracking = await fetchSalesTracking();
const someSaleIsPrepared = salesTracking.some((sale) =>
matchSale(salesTracking, sale),
);
if (someSaleIsPrepared) await confirmUpdate(() => updateDiscount(sales, newDiscount));
else updateDiscount(sales, newDiscount);
};
const updateDiscount = async (sales, newDiscount = null) => {
for (const sale of sales) {
const canProceed = await isSalePrepared(sale);
if (!canProceed) return;
}
const saleIds = sales.map((sale) => sale.id);
const _newDiscount = newDiscount || edit.value.discount;
const params = {
@ -424,9 +438,13 @@ onMounted(async () => {
const items = ref([]);
const newRow = ref({});
const changeItem = async (sale) => {
if (await isSalePrepared(sale)) {
await confirmUpdate(() => updateItem(sale));
} else await updateItem(sale);
};
const updateItem = async (row) => {
canProceed.value = await isSalePrepared(row);
if (!canProceed.value) return;
const selectedItem = items.value.find((item) => item.id === row.itemFk);
if (selectedItem) {
row.item = selectedItem;
@ -470,7 +488,18 @@ const endNewRow = (row) => {
}
};
async function isSalePrepared(item) {
async function confirmUpdate(cb) {
await quasar
.dialog({
component: VnConfirm,
componentProps: {
title: t('Item prepared'),
message: t('This item is already prepared. Do you want to continue?'),
},
})
.onOk(cb);
}
async function fetchSalesTracking() {
const filter = {
params: {
where: { ticketFk: route.params.id },
@ -482,48 +511,37 @@ async function isSalePrepared(item) {
filter: JSON.stringify(filter),
},
});
const matchingSale = data.find((sale) => sale.itemFk === item.itemFk);
if (!matchingSale) {
return true;
}
if (
matchingSale.hasSaleGroupDetail ||
matchingSale.isControled ||
matchingSale.isPrepared ||
matchingSale.isPrevious ||
matchingSale.isPreviousSelected
) {
try {
await new Promise((resolve, reject) => {
quasar
.dialog({
component: VnConfirm,
componentProps: {
title: t('Item prepared'),
message: t(
'This item is already prepared. Do you want to continue?',
),
data: item,
},
})
.onOk(() => resolve(true))
.onCancel(() => reject(new Error('cancelled')));
});
} catch (error) {
tableRef.value.reload();
return false;
}
}
return true;
return data;
}
async function isSalePrepared(sale) {
const data = await fetchSalesTracking();
return matchSale(data, sale);
}
function matchSale(data, sale) {
const matchingSale = data.find(({ itemFk }) => itemFk === sale.itemFk);
if (!matchingSale) {
return false;
}
return isPrepared(matchingSale);
}
function isPrepared(sale) {
const flagsToCheck = [
'hasSaleGroupDetail',
'isControled',
'isPrepared',
'isPrevious',
'isPreviousSelected',
];
return flagsToCheck.some((flag) => sale[flag] === 1);
}
watch(
() => newRow.value.itemFk,
(newItemFk) => {
if (newItemFk) {
updateItem(newRow.value);
changeItem(newRow.value);
}
},
);
@ -584,7 +602,7 @@ watch(
:mana="mana"
:ticket-config="ticketConfig"
@get-mana="getMana()"
@update-discounts="updateDiscount"
@update-discounts="updateDiscounts"
@refresh-table="resetChanges"
/>
<QBtn
@ -715,7 +733,7 @@ watch(
option-value="id"
v-model="row.itemFk"
:use-like="false"
@update:model-value="updateItem(row)"
@update:model-value="changeItem(row)"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
@ -741,16 +759,21 @@ watch(
</div>
<FetchedTags :item="row" :max-length="6" />
<QPopupProxy v-if="row.id && isTicketEditable">
<VnInput v-model="row.concept" @change="updateConcept(row)" />
<VnInput
v-model="row.concept"
@keyup.enter.stop="changeConcept(row)"
:hint="t('globals.enterToConfirm')"
/>
</QPopupProxy>
</template>
<template #column-quantity="{ row }">
<VnInput
data-cy="ticketSaleQuantityInput"
v-if="row.isNew || isTicketEditable"
type="number"
v-model.number="row.quantity"
@blur="changeQuantity(row)"
@keyup.enter="changeQuantity(row)"
@keyup.enter.stop="changeQuantity(row)"
@update:model-value="() => (rowToUpdate = row)"
@focus="edit.oldQuantity = row.quantity"
/>
@ -764,10 +787,12 @@ watch(
<TicketEditManaProxy
ref="editPriceProxyRef"
:mana="mana"
:sale="row"
:new-price="getNewPrice"
@save="updatePrice(row)"
@save="changePrice"
>
<VnInput
@keyup.enter.stop="() => editManaProxyRef.save(row)"
v-model.number="edit.price"
:label="t('basicData.price')"
type="number"
@ -781,31 +806,30 @@ watch(
<QBtn flat class="link" dense @click="onOpenEditDiscountPopover(row)">
{{ toPercentage(row.discount / 100) }}
</QBtn>
<TicketEditManaProxy
ref="editManaProxyRef"
:mana="mana"
:sale="row"
:new-price="getNewPrice"
:uses-mana="usesMana"
:mana-code="manaCode"
@save="changeDiscount(row)"
@save="changeDiscount"
>
<template #default="{ popup }">
<VnInput
autofocus
@keyup.enter="
() => {
changeDiscount(row);
popup.hide();
}
"
v-model.number="edit.discount"
:label="t('ticketSale.discount')"
type="number"
/>
</template>
<VnInput
autofocus
@keyup.enter.stop="() => editManaProxyRef.save(row)"
v-model.number="edit.discount"
:label="t('ticketSale.discount')"
type="number"
/>
</TicketEditManaProxy>
</template>
<span v-else>{{ toPercentage(row.discount / 100) }}</span>
</template>
<template #column-amount="{ row }">
{{ toCurrency(getSaleTotal(row)) }}
</template>
</VnTable>
<QPageSticky :offset="[20, 20]" style="z-index: 2">

View File

@ -209,7 +209,7 @@ const onThermographCreated = async (data) => {
}"
sort-by="thermographFk ASC"
option-label="thermographFk"
option-filter-value="id"
option-filter-value="thermographFk"
:disable="viewAction === 'edit'"
:tooltip="t('New thermograph')"
:roles-allowed-to-create="['logistic']"

View File

@ -119,7 +119,7 @@ const columns = computed(() => [
:url="`Workers/${entityId}/trainingCourse`"
:url-create="`Workers/${entityId}/trainingCourse`"
save-url="TrainingCourses/crud"
:filter="courseFilter"
:user-filter="courseFilter"
:create="{
urlCreate: 'trainingCourses',
title: t('Create training course'),

View File

@ -8,6 +8,17 @@ const { t } = useI18n();
const route = useRoute();
const entityId = computed(() => route.params.id);
const centerFilter = {
include: [
{
relation: 'center',
scope: {
fields: ['id', 'name'],
},
},
],
};
const columns = [
{
align: 'left',
@ -33,7 +44,7 @@ const columns = [
create: true,
component: 'select',
attrs: {
url: 'medicalCenters',
url: 'centers',
fields: ['id', 'name'],
},
},
@ -84,6 +95,7 @@ const columns = [
ref="tableRef"
data-key="WorkerMedical"
:url="`Workers/${entityId}/medicalReview`"
:user-filter="centerFilter"
save-url="MedicalReviews/crud"
:create="{
urlCreate: 'medicalReviews',

View File

@ -176,6 +176,7 @@ const deleteRelative = async (id) => {
:label="t('isDescendant')"
v-model="row.isDescendant"
class="q-gutter-xs q-mb-xs"
data-cy="Descendant/Ascendant"
/>
<VnSelect
:label="t('disabilityGrades')"

View File

@ -1,122 +1,208 @@
/// <reference types="cypress" />
describe('TicketSale', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/31/sale');
});
const firstRow = 'tbody > :nth-child(1)';
const selectFirstRow = () => {
cy.waitForElement(firstRow);
cy.get(firstRow).find('.q-checkbox__inner').click();
};
it('it should add item to basket', () => {
cy.window().then((win) => {
cy.stub(win, 'open').as('windowOpen');
describe('Free ticket #31', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/31/sale');
});
cy.dataCy('ticketSaleAddToBasketBtn').should('exist');
cy.dataCy('ticketSaleAddToBasketBtn').click();
cy.get('@windowOpen').should('be.calledWithMatch', /\/order\/\d+\/catalog/);
});
it('should send SMS', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="sendShortageSMSItem"]');
cy.dataCy('sendShortageSMSItem').should('exist');
cy.dataCy('sendShortageSMSItem').click();
cy.dataCy('vnSmsDialog').should('exist');
cy.dataCy('sendSmsBtn').click();
cy.checkNotification('SMS sent');
});
const firstRow = 'tbody > :nth-child(1)';
it('should recalculate price when "Recalculate price" is clicked', () => {
cy.intercept('POST', '**/recalculatePrice').as('recalculatePrice');
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="recalculatePriceItem"]');
cy.dataCy('recalculatePriceItem').should('exist');
cy.dataCy('recalculatePriceItem').click();
cy.wait('@recalculatePrice').its('response.statusCode').should('eq', 200);
cy.checkNotification('Data saved');
});
const selectFirstRow = () => {
cy.waitForElement(firstRow);
cy.get(firstRow).find('.q-checkbox__inner').click();
};
it('should update discount when "Update discount" is clicked', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="updateDiscountItem"]');
cy.dataCy('updateDiscountItem').should('exist');
cy.dataCy('updateDiscountItem').click();
cy.waitForElement('[data-cy="ticketSaleDiscountInput"]');
cy.dataCy('ticketSaleDiscountInput').find('input').focus();
cy.dataCy('ticketSaleDiscountInput').find('input').type('10');
cy.dataCy('saveManaBtn').click();
cy.waitForElement('.q-notification__message');
cy.checkNotification('Data saved');
});
it('it should add item to basket', () => {
cy.window().then((win) => {
cy.stub(win, 'open').as('windowOpen');
});
cy.dataCy('ticketSaleAddToBasketBtn').should('exist');
cy.dataCy('ticketSaleAddToBasketBtn').click();
cy.get('@windowOpen').should('be.calledWithMatch', /\/order\/\d+\/catalog/);
});
it('adds claim', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('createClaimItem').click();
cy.dataCy('VnConfirm_confirm').click();
cy.url().should('contain', 'claim/');
// Delete created claim to avoid cluttering the database
cy.dataCy('descriptor-more-opts').click();
cy.dataCy('deleteClaim').click();
cy.dataCy('VnConfirm_confirm').click();
cy.checkNotification('Data deleted');
});
it('should send SMS', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="sendShortageSMSItem"]');
cy.dataCy('sendShortageSMSItem').should('exist');
cy.dataCy('sendShortageSMSItem').click();
cy.dataCy('vnSmsDialog').should('exist');
cy.dataCy('sendSmsBtn').click();
cy.checkNotification('SMS sent');
});
it('marks row as reserved', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="markAsReservedItem"]');
cy.dataCy('markAsReservedItem').click();
cy.dataCy('ticketSaleReservedIcon').should('exist');
});
it('should recalculate price when "Recalculate price" is clicked', () => {
cy.intercept('POST', '**/recalculatePrice').as('recalculatePrice');
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="recalculatePriceItem"]');
cy.dataCy('recalculatePriceItem').should('exist');
cy.dataCy('recalculatePriceItem').click();
cy.wait('@recalculatePrice').its('response.statusCode').should('eq', 200);
cy.checkNotification('Data saved');
});
it('unmarks row as reserved', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="unmarkAsReservedItem"]');
cy.dataCy('unmarkAsReservedItem').click();
cy.dataCy('ticketSaleReservedIcon').should('not.exist');
});
it('should update discount when "Update discount" is clicked', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="updateDiscountItem"]');
cy.dataCy('updateDiscountItem').should('exist');
cy.dataCy('updateDiscountItem').click();
cy.waitForElement('[data-cy="ticketSaleDiscountInput"]');
cy.dataCy('ticketSaleDiscountInput').find('input').focus();
cy.dataCy('ticketSaleDiscountInput').find('input').type('10');
cy.dataCy('saveManaBtn').click();
cy.waitForElement('.q-notification__message');
cy.checkNotification('Data saved');
});
it('refunds row with warehouse', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('ticketSaleRefundItem').click();
cy.dataCy('ticketSaleRefundWithWarehouse').click();
cy.checkNotification('The following refund ticket have been created');
});
it('adds claim', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('createClaimItem').click();
cy.dataCy('VnConfirm_confirm').click();
cy.url().should('contain', 'claim/');
// Delete created claim to avoid cluttering the database
cy.dataCy('descriptor-more-opts').click();
cy.dataCy('deleteClaim').click();
cy.dataCy('VnConfirm_confirm').click();
cy.checkNotification('Data deleted');
});
it('refunds row without warehouse', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('ticketSaleRefundItem').click();
cy.dataCy('ticketSaleRefundWithoutWarehouse').click();
cy.checkNotification('The following refund ticket have been created');
});
it('marks row as reserved', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="markAsReservedItem"]');
cy.dataCy('markAsReservedItem').click();
cy.dataCy('ticketSaleReservedIcon').should('exist');
});
it('transfer sale to a new ticket', () => {
cy.visit('/#/ticket/32/sale');
cy.get('.q-item > .q-item__label').should('have.text', ' #32');
selectFirstRow();
cy.dataCy('ticketSaleTransferBtn').click();
cy.dataCy('ticketTransferPopup').should('exist');
cy.dataCy('ticketTransferNewTicketBtn').click();
//check the new ticket has been created succesfully
cy.get('.q-item > .q-item__label').should('not.have.text', ' #32');
});
it('unmarks row as reserved', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="unmarkAsReservedItem"]');
cy.dataCy('unmarkAsReservedItem').click();
cy.dataCy('ticketSaleReservedIcon').should('not.exist');
});
it('should redirect to ticket logs', () => {
cy.get(firstRow).find('.q-btn:last').click();
cy.url().should('match', /\/ticket\/31\/log/);
it('refunds row with warehouse', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('ticketSaleRefundItem').click();
cy.dataCy('ticketSaleRefundWithWarehouse').click();
cy.checkNotification('The following refund ticket have been created');
});
it('refunds row without warehouse', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('ticketSaleRefundItem').click();
cy.dataCy('ticketSaleRefundWithoutWarehouse').click();
cy.checkNotification('The following refund ticket have been created');
});
it('transfer sale to a new ticket', () => {
cy.visit('/#/ticket/32/sale');
cy.get('.q-item > .q-item__label').should('have.text', ' #32');
selectFirstRow();
cy.dataCy('ticketSaleTransferBtn').click();
cy.dataCy('ticketTransferPopup').should('exist');
cy.dataCy('ticketTransferNewTicketBtn').click();
//check the new ticket has been created succesfully
cy.get('.q-item > .q-item__label').should('not.have.text', ' #32');
});
it('should redirect to ticket logs', () => {
cy.get(firstRow).find('.q-btn:last').click();
cy.url().should('match', /\/ticket\/31\/log/);
});
});
describe('Ticket prepared #23', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/23/sale');
});
const firstRow = 'tbody > :nth-child(1)';
const selectFirstRow = () => {
cy.waitForElement(firstRow);
cy.get(firstRow).find('.q-checkbox__inner').click();
};
it('update price', () => {
const price = Number((Math.random() * 99 + 1).toFixed(2));
cy.waitForElement(firstRow);
cy.get(':nth-child(10) > .q-btn').click();
cy.waitForElement('[data-cy="ticketEditManaProxy"]');
cy.dataCy('ticketEditManaProxy').should('exist');
cy.waitForElement('[data-cy="Price_input"]');
cy.dataCy('Price_input').clear();
cy.dataCy('Price_input').type(price);
cy.dataCy('saveManaBtn').click();
handleVnConfirm();
cy.get(':nth-child(10) > .q-btn > .q-btn__content').should(
'have.text',
`${price}`,
);
});
it('update dicount', () => {
const discount = Math.floor(Math.random() * 100) + 1;
selectFirstRow();
cy.get(':nth-child(11) > .q-btn').click();
cy.waitForElement('[data-cy="ticketEditManaProxy"]');
cy.dataCy('ticketEditManaProxy').should('exist');
cy.waitForElement('[data-cy="Disc_input"]');
cy.dataCy('Disc_input').clear();
cy.dataCy('Disc_input').type(discount);
cy.dataCy('saveManaBtn').click();
handleVnConfirm();
cy.get(':nth-child(11) > .q-btn > .q-btn__content').should(
'have.text',
`${discount}.00%`,
);
});
it('change concept', () => {
const quantity = Math.floor(Math.random() * 100) + 1;
cy.waitForElement(firstRow);
cy.get(':nth-child(8) > .row').click();
cy.get(
'.q-menu > [data-v-ca3f07a4=""] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="undefined_input"]',
)
.type(quantity)
.type('{enter}');
handleVnConfirm();
cy.get(':nth-child(8) >.row').should('contain.text', `${quantity}`);
});
it('changequantity ', () => {
const quantity = Math.floor(Math.random() * 100) + 1;
cy.waitForElement(firstRow);
cy.dataCy('ticketSaleQuantityInput').clear();
cy.dataCy('ticketSaleQuantityInput').type(quantity).trigger('tab');
cy.get('.q-page > :nth-child(6)').click();
handleVnConfirm();
cy.get('[data-cy="ticketSaleQuantityInput"]')
.find('[data-cy="undefined_input"]')
.should('have.value', `${quantity}`);
});
});
});
function handleVnConfirm() {
cy.get('[data-cy="VnConfirm_confirm"] > .q-btn__content > .block').click();
cy.waitForElement('.q-notification__message');
cy.get('.q-notification__message').should('be.visible');
cy.checkNotification('Data saved');
}

View File

@ -8,7 +8,7 @@ describe('WagonTypeCreate', () => {
it('should create a new wagon type and then delete it', () => {
cy.get('.q-page-sticky > div > .q-btn').click();
cy.get('input').first().type('Example for testing');
cy.dataCy('Name_input').type('Example for testing');
cy.get('[data-cy="FormModelPopup_save"]').click();
cy.get('[title="Remove"] > .q-btn__content > .q-icon').first().click();
});

View File

@ -2,9 +2,24 @@ describe('WorkerCreate', () => {
const externalRadio = '.q-radio:nth-child(2)';
const developerBossId = 120;
const payMethodCross =
'.grid-create .full-width > :nth-child(9) .q-select .q-field__append:not(.q-anchor--skip)';
':nth-child(9) > .q-select > .q-field__inner > .q-field__control > :nth-child(2)';
const saveBtn = '.q-mt-lg > .q-btn--standard';
const internalWithOutPay = {
Fi: { val: '78457139E' },
'Web user': { val: 'manolo' },
Name: { val: 'Manolo' },
'Last name': { val: 'Hurtado' },
'Personal email': { val: 'manolo@mydomain.com' },
Company: { val: 'VNL', type: 'select' },
Street: { val: 'S/ DEFAULTWORKERSTREET' },
Location: { val: 1, type: 'select' },
Phone: { val: '123456789' },
'Worker code': { val: 'DWW' },
Boss: { val: developerBossId, type: 'select' },
Birth: { val: '11-12-2022', type: 'date' },
};
const internal = {
Fi: { val: '78457139E' },
'Web user': { val: 'manolo' },
@ -14,6 +29,7 @@ describe('WorkerCreate', () => {
Company: { val: 'VNL', type: 'select' },
Street: { val: 'S/ DEFAULTWORKERSTREET' },
Location: { val: 1, type: 'select' },
'Pay method': { val: 1, type: 'select' },
Phone: { val: '123456789' },
'Worker code': { val: 'DWW' },
Boss: { val: developerBossId, type: 'select' },
@ -37,17 +53,14 @@ describe('WorkerCreate', () => {
});
it('should throw an error if a pay method has not been selected', () => {
cy.fillInForm(internal);
cy.fillInForm(internalWithOutPay);
cy.get(payMethodCross).click();
cy.get(saveBtn).click();
cy.checkNotification('Payment method is required');
});
it('should create an internal', () => {
cy.fillInForm({
...internal,
'Pay method': { val: 'PayMethod one', type: 'select' },
});
cy.fillInForm(internal);
cy.get(saveBtn).click();
cy.checkNotification('Data created');
});

View File

@ -18,7 +18,7 @@ describe('WorkerNotificationsManager', () => {
cy.visit(`/#/worker/${salesPersonId}/notifications`);
cy.get(firstAvailableNotification).click();
cy.checkNotification(
'The notification subscription of this worker cant be modified'
'The notification subscription of this worker cant be modified',
);
});

View File

@ -8,7 +8,8 @@ describe('WorkerPit', () => {
const spousePensionInput = '[data-cy="Spouse Pension_input"]';
const spousePension = '120';
const addRelative = '[data-cy="addRelative"]';
const isDescendantSelect = '[data-cy="Descendant/Ascendant_select"]';
const isDescendantSelect = '[data-cy="Descendant/Ascendant"]';
const Descendant = 'Descendiente';
const birthedInput = '[data-cy="Birth Year_input"]';
const birthed = '2002';
const adoptionYearInput = '[data-cy="Adoption Year_input"]';
@ -28,11 +29,8 @@ describe('WorkerPit', () => {
cy.get(spouseNifInput).type(spouseNif);
cy.get(spousePensionInput).type(spousePension);
cy.get(savePIT).click();
});
it('complete relative', () => {
cy.get(addRelative).click();
cy.get(isDescendantSelect).type('{downArrow}{downArrow}{enter}');
cy.get(isDescendantSelect).type(Descendant);
cy.get(birthedInput).type(birthed);
cy.get(adoptionYearInput).type(adoptionYear);
cy.get(saveRelative).click();