Merge branch 'dev' into 8648-addTestCasesInRoadmapListTest
gitea/salix-front/pipeline/pr-dev This commit is unstable Details

This commit is contained in:
Javier Segarra 2025-03-03 21:57:36 +00:00
commit 68cc1ad016
51 changed files with 726 additions and 224 deletions

3
Jenkinsfile vendored
View File

@ -94,7 +94,7 @@ pipeline {
parallel {
stage('Unit') {
steps {
sh 'pnpm run test:unit:ci'
sh 'pnpm run test:front:ci'
}
post {
always {
@ -113,6 +113,7 @@ pipeline {
}
steps {
script {
sh 'rm junit/e2e-*.xml || true'
env.COMPOSE_TAG = PROTECTED_BRANCH.contains(env.CHANGE_TARGET) ? env.CHANGE_TARGET : 'dev'
def image = docker.build('lilium-dev', '-f docs/Dockerfile.dev docs')
sh "docker-compose ${env.COMPOSE_PARAMS} up -d"

View File

@ -23,7 +23,7 @@ quasar dev
### Run unit tests
```bash
pnpm run test:unit
pnpm run test:front
```
### Run e2e tests

View File

@ -14,8 +14,8 @@
"test:e2e": "cypress open",
"test:e2e:ci": "npm run resetDatabase && cd ../salix-front && cypress run",
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
"test:unit": "vitest",
"test:unit:ci": "vitest run",
"test:front": "vitest",
"test:front:ci": "vitest run",
"commitlint": "commitlint --edit",
"prepare": "npx husky install",
"addReferenceTag": "node .husky/addReferenceTag.js",

View File

@ -184,8 +184,11 @@ async function saveChanges(data) {
if ($props.beforeSaveFn) {
changes = await $props.beforeSaveFn(changes, getChanges);
}
try {
if (changes?.creates?.length === 0 && changes?.updates?.length === 0) {
return;
}
await axios.post($props.saveUrl || $props.url + '/crud', changes);
} finally {
isLoading.value = false;

View File

@ -681,6 +681,7 @@ const rowCtrlClickFunction = computed(() => {
@update:selected="emit('update:selected', $event)"
@selection="(details) => handleSelection(details, rows)"
:hide-selected-banner="true"
:data-cy="$props.dataCy ?? 'vnTable'"
>
<template #top-left v-if="!$props.withoutHeader">
<slot name="top-left"> </slot>

View File

@ -30,8 +30,8 @@ describe('CrudModel', () => {
saveFn: '',
},
});
wrapper=wrapper.wrapper;
vm=wrapper.vm;
wrapper = wrapper.wrapper;
vm = wrapper.vm;
});
beforeEach(() => {
@ -143,14 +143,14 @@ describe('CrudModel', () => {
});
it('should return true if object is empty', async () => {
dummyObj ={};
result = vm.isEmpty(dummyObj);
dummyObj = {};
result = vm.isEmpty(dummyObj);
expect(result).toBe(true);
});
it('should return false if object is not empty', async () => {
dummyObj = {a:1, b:2, c:3};
dummyObj = { a: 1, b: 2, c: 3 };
result = vm.isEmpty(dummyObj);
expect(result).toBe(false);
@ -158,29 +158,31 @@ describe('CrudModel', () => {
it('should return true if array is empty', async () => {
dummyArray = [];
result = vm.isEmpty(dummyArray);
result = vm.isEmpty(dummyArray);
expect(result).toBe(true);
});
it('should return false if array is not empty', async () => {
dummyArray = [1,2,3];
dummyArray = [1, 2, 3];
result = vm.isEmpty(dummyArray);
expect(result).toBe(false);
})
});
});
describe('resetData()', () => {
it('should add $index to elements in data[] and sets originalData and formData with data', async () => {
data = [{
name: 'Tony',
lastName: 'Stark',
age: 42,
}];
data = [
{
name: 'Tony',
lastName: 'Stark',
age: 42,
},
];
vm.resetData(data);
expect(vm.originalData).toEqual(data);
expect(vm.originalData[0].$index).toEqual(0);
expect(vm.formData).toEqual(data);
@ -200,7 +202,7 @@ describe('CrudModel', () => {
lastName: 'Stark',
age: 42,
};
vm.resetData(data);
expect(vm.originalData).toEqual(data);
@ -210,17 +212,19 @@ describe('CrudModel', () => {
});
describe('saveChanges()', () => {
data = [{
name: 'Tony',
lastName: 'Stark',
age: 42,
}];
data = [
{
name: 'Tony',
lastName: 'Stark',
age: 42,
},
];
it('should call saveFn if exists', async () => {
await wrapper.setProps({ saveFn: vi.fn() });
vm.saveChanges(data);
expect(vm.saveFn).toHaveBeenCalledOnce();
expect(vm.isLoading).toBe(false);
expect(vm.hasChanges).toBe(false);
@ -229,13 +233,15 @@ describe('CrudModel', () => {
});
it("should use default url if there's not saveFn", async () => {
const postMock =vi.spyOn(axios, 'post');
vm.formData = [{
name: 'Bruce',
lastName: 'Wayne',
age: 45,
}]
const postMock = vi.spyOn(axios, 'post');
vm.formData = [
{
name: 'Bruce',
lastName: 'Wayne',
age: 45,
},
];
await vm.saveChanges(data);

View File

@ -1,10 +1,9 @@
<script setup>
import { onBeforeMount } from 'vue';
import { useRouter, onBeforeRouteUpdate } from 'vue-router';
import { useRouter, onBeforeRouteUpdate, onBeforeRouteLeave } from 'vue-router';
import { useArrayData } from 'src/composables/useArrayData';
import { useStateStore } from 'stores/useStateStore';
import useCardSize from 'src/composables/useCardSize';
import LeftMenu from 'components/LeftMenu.vue';
import VnSubToolbar from '../ui/VnSubToolbar.vue';
const props = defineProps({
@ -27,7 +26,13 @@ const arrayData = useArrayData(props.dataKey, {
oneRecord: true,
});
onBeforeRouteLeave(() => {
stateStore.cardDescriptorChangeValue(null);
});
onBeforeMount(async () => {
stateStore.cardDescriptorChangeValue(props.descriptor);
const route = router.currentRoute.value;
try {
await fetch(route.params.id);
@ -62,11 +67,6 @@ function hasRouteParam(params, valueToCheck = ':addressId') {
}
</script>
<template>
<Teleport to="#left-panel" v-if="stateStore.isHeaderMounted()">
<component :is="descriptor" />
<QSeparator />
<LeftMenu source="card" />
</Teleport>
<VnSubToolbar />
<div :class="[useCardSize(), $attrs.class]">
<RouterView :key="$route.path" />

View File

@ -641,15 +641,7 @@ watch(
>
{{ prop.nameI18n }}:
</span>
<VnJsonValue :value="prop.val.val" />
<span
v-if="prop.val.id"
class="id-value"
>
#{{ prop.val.id }}
</span>
<span v-if="log.action == 'update'">
<VnJsonValue
:value="prop.old.val"
/>
@ -659,6 +651,26 @@ watch(
>
#{{ prop.old.id }}
</span>
<VnJsonValue
:value="prop.val.val"
/>
<span
v-if="prop.val.id"
class="id-value"
>
#{{ prop.val.id }}
</span>
</span>
<span v-else="prop.old.val">
<VnJsonValue
:value="prop.val.val"
/>
<span
v-if="prop.old.id"
class="id-value"
>#{{ prop.old.id }}</span
>
</span>
</div>
</span>

View File

@ -12,7 +12,7 @@ const $props = defineProps({
},
});
onMounted(
() => (stateStore.leftDrawer = useQuasar().screen.gt.xs ? $props.leftDrawer : false)
() => (stateStore.leftDrawer = useQuasar().screen.gt.xs ? $props.leftDrawer : false),
);
const teleportRef = ref({});
@ -35,8 +35,14 @@ onMounted(() => {
<template>
<QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256">
<QScrollArea class="fit text-grey-8">
<div id="left-panel" ref="teleportRef"></div>
<LeftMenu v-if="!hasContent" />
<div id="left-panel" ref="teleportRef">
<template v-if="stateStore.cardDescriptor">
<component :is="stateStore.cardDescriptor" />
<QSeparator />
<LeftMenu source="card" />
</template>
<template v-else> <LeftMenu /></template>
</div>
</QScrollArea>
</QDrawer>
<QPageContainer>

View File

@ -694,8 +694,10 @@ worker:
machine: Machine
business:
tableVisibleColumns:
id: ID
started: Start Date
ended: End Date
hourlyLabor: Time sheet
company: Company
reasonEnd: Reason for Termination
department: Department
@ -703,6 +705,7 @@ worker:
calendarType: Work Calendar
workCenter: Work Center
payrollCategories: Contract Category
workerBusinessAgreementName: Agreement
occupationCode: Contribution Code
rate: Rate
businessType: Contract Type

View File

@ -770,8 +770,10 @@ worker:
concept: Concepto
business:
tableVisibleColumns:
id: Id
started: Fecha inicio
ended: Fecha fin
hourlyLabor: Ficha
company: Empresa
reasonEnd: Motivo finalización
department: Departamento
@ -782,6 +784,7 @@ worker:
occupationCode: Cotización
rate: Tarifa
businessType: Contrato
workerBusinessAgreementName: Convenio
amount: Salario
basicSalary: Salario transportistas
notes: Notas

View File

@ -325,7 +325,7 @@ const sumRisk = ({ clientRisks }) => {
</QCard>
<QCard class="vn-max">
<VnTitle :text="t('Latest tickets')" />
<CustomerSummaryTable />
<CustomerSummaryTable :id="entityId" />
</QCard>
</template>
</CardSummary>

View File

@ -20,7 +20,12 @@ const { t } = useI18n();
const route = useRoute();
const router = useRouter();
const { viewSummary } = useSummaryDialog();
const $props = defineProps({
id: {
type: Number,
default: null,
},
});
const filter = {
include: [
{
@ -43,7 +48,7 @@ const filter = {
},
},
],
where: { clientFk: route.params.id },
where: { clientFk: $props.id ?? route.params.id },
order: ['shipped DESC', 'id'],
limit: 30,
};

View File

@ -17,9 +17,9 @@ describe('getAddresses', () => {
expect(axios.get).toHaveBeenCalledWith(`Clients/${clientId}/addresses`, {
params: {
filter: JSON.stringify({
fields: ['nickname', 'street', 'city', 'id'],
fields: ['nickname', 'street', 'city', 'id', 'isActive'],
where: { isActive: true },
order: 'nickname ASC',
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
}),
},
});
@ -30,4 +30,4 @@ describe('getAddresses', () => {
expect(axios.get).not.toHaveBeenCalled();
});
});
});

View File

@ -1,15 +1,15 @@
import axios from 'axios';
export async function getAddresses(clientId, _filter = {}) {
export async function getAddresses(clientId, _filter = {}) {
if (!clientId) return;
const filter = {
..._filter,
fields: ['nickname', 'street', 'city', 'id'],
fields: ['nickname', 'street', 'city', 'id', 'isActive'],
where: { isActive: true },
order: 'nickname ASC',
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
};
const params = { filter: JSON.stringify(filter) };
return await axios.get(`Clients/${clientId}/addresses`, {
params,
});
};
}

View File

@ -62,9 +62,10 @@ const columns = [
name: 'workerFk',
component: 'select',
attrs: {
url: 'Workers/search',
url: 'TicketRequests/getItemTypeWorker',
fields: ['id', 'nickname'],
optionLabel: 'nickname',
sortBy: 'nickname ASC',
optionValue: 'id',
},
visible: false,
@ -655,7 +656,6 @@ onMounted(() => {
:without-header="!editableMode"
:with-filters="editableMode"
:right-search="editableMode"
:right-search-icon="true"
:row-click="false"
:columns="columns"
:beforeSaveFn="beforeSave"

View File

@ -248,7 +248,7 @@ const entryFilterPanel = ref();
<i18n>
en:
params:
isExcludedFromAvailable: Inventory
isExcludedFromAvailable: Is excluded
isOrdered: Ordered
isReceived: Received
isConfirmed: Confirmed

View File

@ -19,6 +19,7 @@ const { t } = useI18n();
const quasar = useQuasar();
const state = useState();
const user = state.getUser();
const footer = ref({ bought: 0, reserve: 0 });
const columns = computed(() => [
{
align: 'left',
@ -38,16 +39,14 @@ const columns = computed(() => [
cardVisible: true,
create: true,
attrs: {
url: 'Workers/activeWithInheritedRole',
fields: ['id', 'name', 'nickname'],
where: { role: 'buyer' },
optionFilter: 'firstName',
url: 'TicketRequests/getItemTypeWorker',
fields: ['id', 'nickname'],
optionLabel: 'nickname',
sortBy: 'nickname ASC',
optionValue: 'id',
useLike: false,
},
columnFilter: false,
width: '70px',
width: '50px',
},
{
align: 'center',
@ -58,6 +57,7 @@ const columns = computed(() => [
component: 'number',
summation: true,
width: '50px',
format: ({ reserve }, dashIfEmpty) => dashIfEmpty(round(reserve)),
},
{
align: 'center',
@ -65,6 +65,7 @@ const columns = computed(() => [
name: 'bought',
summation: true,
cardVisible: true,
style: ({ reserve, bought }) => boughtStyle(bought, reserve),
columnFilter: false,
},
{
@ -95,7 +96,6 @@ const columns = computed(() => [
},
},
],
dataCy: 'table-actions',
},
]);
@ -137,20 +137,20 @@ function openDialog() {
}
function setFooter(data) {
const footer = {
bought: 0,
reserve: 0,
};
footer.value = { bought: 0, reserve: 0 };
data.forEach((row) => {
footer.bought += row?.bought;
footer.reserve += row?.reserve;
footer.value.bought += row?.bought;
footer.value.reserve += row?.reserve;
});
tableRef.value.footer = footer;
}
function round(value) {
return Math.round(value * 100) / 100;
}
function boughtStyle(bought, reserve) {
return reserve < bought ? { color: 'var(--q-negative)' } : '';
}
</script>
<template>
<VnSubToolbar>
@ -253,24 +253,14 @@ function round(value) {
<WorkerDescriptorProxy :id="row?.workerFk" />
</span>
</template>
<template #column-bought="{ row }">
<span :class="{ 'text-negative': row.reserve < row.bought }">
{{ row?.bought }}
</span>
</template>
<template #column-footer-reserve>
<span>
{{ round(tableRef.footer.reserve) }}
{{ round(footer.reserve) }}
</span>
</template>
<template #column-footer-bought>
<span
:class="{
'text-negative':
tableRef.footer.reserve < tableRef.footer.bought,
}"
>
{{ round(tableRef.footer.bought) }}
<span :style="boughtStyle(footer?.bought, footer?.reserve)">
{{ round(footer.bought) }}
</span>
</template>
</VnTable>
@ -286,7 +276,7 @@ function round(value) {
justify-content: center;
}
.column {
min-width: 40%;
min-width: 35%;
margin-top: 5%;
display: flex;
flex-direction: column;

View File

@ -14,7 +14,7 @@ const $props = defineProps({
required: true,
},
dated: {
type: Date,
type: [Date, String],
required: true,
},
});

View File

@ -185,6 +185,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
data-key="InvoiceInSummary"
:url="`InvoiceIns/${entityId}/summary`"
@on-fetch="(data) => init(data)"
module-name="InvoiceIn"
>
<template #header="{ entity }">
<div>{{ entity.id }} - {{ entity.supplier?.name }}</div>

View File

@ -12,7 +12,7 @@ import FetchData from 'components/FetchData.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import { toDateFormat } from 'src/filters/date.js';
import { toDateTimeFormat } from 'src/filters/date.js';
import { dashIfEmpty } from 'src/filters';
import { date } from 'quasar';
import { useState } from 'src/composables/useState';
@ -143,7 +143,12 @@ onMounted(async () => {
const fetchItemBalances = async () => await arrayDataItemBalances.fetch({});
const getBadgeAttrs = (_date) => {
const isSameDate = date.isSameDate(today, _date);
let today = Date.vnNew();
today.setHours(0, 0, 0, 0);
let timeTicket = new Date(_date);
timeTicket.setHours(0, 0, 0, 0);
const isSameDate = date.isSameDate(today, timeTicket);
const attrs = {
'text-color': isSameDate ? 'black' : 'white',
color: isSameDate ? 'warning' : 'transparent',
@ -153,15 +158,10 @@ const getBadgeAttrs = (_date) => {
const scrollToToday = async () => {
await nextTick();
const todayCell = document.querySelector(`td[data-date="${today.toISOString()}"]`);
if (todayCell) {
todayCell.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
};
const formatDateForAttribute = (dateValue) => {
if (dateValue instanceof Date) return date.formatDate(dateValue, 'YYYY-MM-DD');
return dateValue;
const todayCell = document.querySelector(
`td[data-date="${date.formatDate(today, 'YYYY-MM-DD')}"]`,
);
if (todayCell) todayCell.scrollIntoView({ behavior: 'smooth', block: 'center' });
};
async function updateWarehouse(warehouseFk) {
@ -237,14 +237,14 @@ async function updateWarehouse(warehouseFk) {
</QTd>
</template>
<template #body-cell-date="{ row }">
<QTd @click.stop :data-date="formatDateForAttribute(row.shipped)">
<QTd @click.stop :data-date="row?.shipped.substring(0, 10)">
<QBadge
v-bind="getBadgeAttrs(row.shipped)"
class="q-ma-none"
dense
style="font-size: 14px"
>
{{ toDateFormat(row.shipped) }}
{{ toDateTimeFormat(row.shipped) }}
</QBadge>
</QTd>
</template>

View File

@ -11,7 +11,6 @@ import { toCurrency } from 'filters/index';
import { useArrayData } from 'composables/useArrayData';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue';
const { t } = useI18n();
const route = useRoute();
const from = ref();
@ -41,7 +40,7 @@ const itemLastEntries = ref([]);
const columns = computed(() => [
{
label: 'Nv',
label: 'NV',
name: 'ig',
align: 'center',
},
@ -70,6 +69,7 @@ const columns = computed(() => [
field: 'reference',
align: 'center',
format: (_, row) => toCurrency(row.price2) + ' / ' + toCurrency(row.price3),
style: (row) => highlightedRow(row),
},
{
label: t('lastEntries.printedStickers'),
@ -84,6 +84,7 @@ const columns = computed(() => [
field: 'stickers',
align: 'center',
format: (val) => dashIfEmpty(val),
style: (row) => highlightedRow(row),
},
{
label: 'Packing',
@ -102,12 +103,14 @@ const columns = computed(() => [
name: 'stems',
field: 'stems',
align: 'center',
style: (row) => highlightedRow(row),
},
{
label: t('lastEntries.quantity'),
name: 'quantity',
field: 'quantity',
align: 'center',
style: (row) => highlightedRow(row),
},
{
label: t('lastEntries.cost'),
@ -120,12 +123,14 @@ const columns = computed(() => [
name: 'weight',
field: 'weight',
align: 'center',
style: (row) => highlightedRow(row),
},
{
label: t('lastEntries.cube'),
name: 'cube',
field: 'packagingFk',
align: 'center',
style: (row) => highlightedRow(row),
},
{
label: t('lastEntries.supplier'),
@ -208,6 +213,14 @@ onMounted(async () => {
function getBadgeClass(groupingMode, expectedGrouping) {
return groupingMode === expectedGrouping ? 'accent-badge' : 'simple-badge';
}
function highlightedRow(row) {
return row?.isInventorySupplier
? {
'background-color': 'var(--vn-section-hover-color)',
}
: '';
}
</script>
<template>
<VnSubToolbar>
@ -236,7 +249,7 @@ function getBadgeClass(groupingMode, expectedGrouping) {
:no-data-label="t('globals.noResults')"
>
<template #body-cell-ig="{ row }">
<QTd class="text-center">
<QTd class="text-center" :style="highlightedRow(row)">
<QIcon
:name="row.isIgnored ? 'check_box' : 'check_box_outline_blank'"
style="color: var(--vn-label-color)"
@ -245,38 +258,38 @@ function getBadgeClass(groupingMode, expectedGrouping) {
</QTd>
</template>
<template #body-cell-warehouse="{ row }">
<QTd>
<QTd :style="highlightedRow(row)">
<span>{{ row.warehouse }}</span>
</QTd>
</template>
<template #body-cell-date="{ row }">
<QTd class="text-center">
<QTd class="text-center" :style="highlightedRow(row)">
<VnDateBadge :date="row.landed" />
</QTd>
</template>
<template #body-cell-entry="{ row }">
<QTd @click.stop>
<QTd @click.stop :style="highlightedRow(row)">
<div class="full-width flex justify-center">
<EntryDescriptorProxy :id="row.entryFk" class="q-ma-none" dense />
<span class="link">{{ row.entryFk }}</span>
</div>
</QTd>
</template>
<template #body-cell-pvp="{ value }">
<QTd @click.stop class="text-center">
<template #body-cell-pvp="{ row, value }">
<QTd @click.stop class="text-center" :style="highlightedRow(row)">
<span> {{ value }}</span>
<QTooltip> {{ t('lastEntries.grouping') }}/Packing </QTooltip></QTd
>
<QTooltip> {{ t('lastEntries.grouping') }}/Packing </QTooltip>
</QTd>
</template>
<template #body-cell-printedStickers="{ row }">
<QTd @click.stop class="text-center">
<QTd @click.stop class="text-center" :style="highlightedRow(row)">
<span style="color: var(--vn-label-color)">
{{ row.printedStickers }}</span
>
</QTd>
</template>
<template #body-cell-packing="{ row }">
<QTd @click.stop>
<QTd @click.stop :style="highlightedRow(row)">
<QBadge
class="center-content"
:class="getBadgeClass(row.groupingMode, 'packing')"
@ -288,7 +301,7 @@ function getBadgeClass(groupingMode, expectedGrouping) {
</QTd>
</template>
<template #body-cell-grouping="{ row }">
<QTd @click.stop>
<QTd @click.stop :style="highlightedRow(row)">
<QBadge
class="center-content"
:class="getBadgeClass(row.groupingMode, 'grouping')"
@ -300,7 +313,7 @@ function getBadgeClass(groupingMode, expectedGrouping) {
</QTd>
</template>
<template #body-cell-cost="{ row }">
<QTd @click.stop class="text-center">
<QTd @click.stop class="text-center" :style="highlightedRow(row)">
<span>
{{ toCurrency(row.cost, 'EUR', 3) }}
<QTooltip>
@ -319,7 +332,7 @@ function getBadgeClass(groupingMode, expectedGrouping) {
</QTd>
</template>
<template #body-cell-supplier="{ row }">
<QTd @click.stop>
<QTd @click.stop :style="highlightedRow(row)">
<div class="full-width flex justify-left">
<QBadge
:class="
@ -354,7 +367,6 @@ function getBadgeClass(groupingMode, expectedGrouping) {
.th :first-child {
.td {
text-align: center;
background-color: red;
}
}
.accent-badge {

View File

@ -10,6 +10,7 @@ import OrderCatalogFilter from 'src/pages/Order/Card/OrderCatalogFilter.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import { useArrayData } from 'src/composables/useArrayData';
import RightMenu from 'src/components/common/RightMenu.vue';
import { onUnmounted } from 'vue';
const route = useRoute();
const router = useRouter();
@ -23,16 +24,40 @@ const catalogParams = {
const arrayData = useArrayData(dataKey, {
url: 'Orders/CatalogFilter',
userParams: catalogParams,
exprBuilder,
searchUrl: 'table',
});
const store = arrayData.store;
const tags = ref([]);
const itemRefs = ref({});
onMounted(() => {
onMounted(async () => {
stateStore.rightDrawer = true;
checkOrderConfirmation();
if (
arrayData.store.userParams &&
Object.keys(arrayData.store.userParams).some((key) => !key.startsWith('order'))
) {
await arrayData.fetch({});
}
});
onUnmounted(() => {
arrayData.destroy();
});
function exprBuilder(param, value) {
switch (param) {
case 'categoryFk':
case 'typeFk':
return { [param]: value };
case 'search':
if (/^\d+$/.test(value)) return { 'i.id': value };
else return { 'i.name': { like: `%${value}%` } };
}
}
async function checkOrderConfirmation() {
const response = await axios.get(`Orders/${route.params.id}`);
if (response.data.isConfirmed === 1) {
@ -96,6 +121,7 @@ watch(
:tag-value="tagValue"
:tags="tags"
:initial-catalog-params="catalogParams"
:arrayData
/>
</template>
</RightMenu>

View File

@ -24,6 +24,10 @@ const props = defineProps({
type: Array,
required: true,
},
arrayData: {
type: Object,
required: true,
},
});
const { t } = useI18n();
@ -74,17 +78,6 @@ const loadTypes = async (id) => {
typeList.value = data;
};
function exprBuilder(param, value) {
switch (param) {
case 'categoryFk':
case 'typeFk':
return { [param]: value };
case 'search':
if (/^\d+$/.test(value)) return { 'i.id': value };
else return { 'i.name': { like: `%${value}%` } };
}
}
const applyTags = (tagInfo, params, search) => {
if (!tagInfo || !tagInfo.values.length) {
params.tagGroups = null;
@ -152,9 +145,8 @@ function addOrder(value, field, params) {
:data-key="props.dataKey"
:hidden-tags="['filter', 'orderFk', 'orderBy']"
:unremovable-params="['orderFk', 'orderBy']"
:expr-builder="exprBuilder"
:custom-tags="['tagGroups', 'categoryFk']"
:redirect="false"
:arrayData
>
<template #tags="{ tag, formatFn }">
<strong v-if="tag.label === 'typeFk' && typeList">

View File

@ -155,11 +155,23 @@ onMounted(() => {
});
async function fetchClientAddress(id, formData = {}) {
const { data } = await axios.get(
`Clients/${id}/addresses?filter[order]=isActive DESC`
);
const { data } = await axios.get(`Clients/${id}/addresses`, {
params: {
filter: JSON.stringify({
include: [
{
relation: 'client',
scope: {
fields: ['defaultAddressFk'],
},
},
],
order: ['isActive DESC'],
}),
},
});
addressOptions.value = data;
formData.addressId = data.defaultAddressFk;
formData.addressId = data[0].client.defaultAddressFk;
fetchAgencies(formData);
}
@ -167,7 +179,13 @@ async function fetchAgencies({ landed, addressId }) {
if (!landed || !addressId) return (agencyList.value = []);
const { data } = await axios.get('Agencies/landsThatDay', {
params: { addressFk: addressId, landed },
params: {
filter: JSON.stringify({
order: ['agencyMode DESC', 'agencyModeFk ASC'],
}),
addressFk: addressId,
landed,
},
});
agencyList.value = data;
}
@ -258,6 +276,7 @@ const getDateColor = (date) => {
</template>
</VnSelect>
<VnSelect
:disable="!data.clientFk"
v-model="data.addressId"
:options="addressOptions"
:label="t('module.address')"
@ -284,6 +303,9 @@ const getDateColor = (date) => {
{{ scope.opt?.street }},
{{ scope.opt?.city }}
</QItemLabel>
<QItemLabel caption>
{{ `#${scope.opt?.id}` }}
</QItemLabel>
</QItemSection>
</QItem>
</template>

View File

@ -27,14 +27,17 @@ describe('getAgencies', () => {
landed: 'true',
};
const filter = {
fields: ['nickname', 'street', 'city', 'id'],
fields: ['name', 'street', 'city', 'id'],
where: { isActive: true },
order: 'nickname ASC',
order: ['name ASC'],
};
await getAgencies(formData, null, filter);
expect(axios.get).toHaveBeenCalledWith('Agencies/getAgenciesWithWarehouse', generateParams(formData, filter));
expect(axios.get).toHaveBeenCalledWith(
'Agencies/getAgenciesWithWarehouse',
generateParams(formData, filter),
);
});
it('should not call API when formData is missing required landed field', async () => {
@ -64,19 +67,19 @@ describe('getAgencies', () => {
it('should return options and agency when default agency is found', async () => {
const formData = { warehouseId: '123', addressId: '456', landed: 'true' };
const client = { defaultAddress: { agencyModeFk: 'Agency1' } };
const { options, agency } = await getAgencies(formData, client);
expect(options).toEqual(response.data);
expect(agency).toEqual(response.data[0]);
});
});
it('should return options and agency when client is not provided', async () => {
it('should return options and agency when client is not provided', async () => {
const formData = { warehouseId: '123', addressId: '456', landed: 'true' };
const { options, agency } = await getAgencies(formData);
expect(options).toEqual(response.data);
expect(agency).toBeNull();
});
});
});

View File

@ -1,14 +1,14 @@
import axios from 'axios';
import agency from 'src/router/modules/agency';
export async function getAgencies(formData, client, _filter = {}) {
if (!formData.warehouseId || !formData.addressId || !formData.landed) return;
const filter = {
..._filter
..._filter,
order: ['name ASC'],
};
let defaultAgency = null;
let agency = null;
let params = {
filter: JSON.stringify(filter),
warehouseFk: formData.warehouseId,
@ -16,11 +16,15 @@ export async function getAgencies(formData, client, _filter = {}) {
landed: formData.landed,
};
const { data } = await axios.get('Agencies/getAgenciesWithWarehouse', { params });
const { data: options } = await axios.get('Agencies/getAgenciesWithWarehouse', {
params,
});
if(data && client) {
defaultAgency = data.find((agency) => agency.agencyModeFk === client.defaultAddress.agencyModeFk );
};
return {options: data, agency: defaultAgency}
if (options && client) {
agency = options.find(
({ agencyModeFk }) => agencyModeFk === client.defaultAddress.agencyModeFk,
);
}
return { options, agency };
}

View File

@ -180,6 +180,7 @@ const onDmsSaved = async (dms, response) => {
rows: dmsDialog.value.rowsToCreateInvoiceIn,
dms: response.data,
});
notify(t('Data saved'), 'positive');
}
dmsDialog.value.show = false;
dmsDialog.value.initialForm = null;
@ -243,7 +244,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</template>
<template #column-invoiceInFk="{ row }">
<span class="link" @click.stop>
{{ row.invoiceInFk }}
{{ row.supplierRef }}
<InvoiceInDescriptorProxy v-if="row.invoiceInFk" :id="row.invoiceInFk" />
</span>
</template>

View File

@ -1,5 +1,5 @@
<script setup>
import { computed, ref } from 'vue';
import { computed, ref, markRaw } from 'vue';
import { useI18n } from 'vue-i18n';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import { toHour } from 'src/filters';
@ -8,6 +8,7 @@ import RouteFilter from 'pages/Route/Card/RouteFilter.vue';
import VnTable from 'components/VnTable/VnTable.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import VnSection from 'src/components/common/VnSection.vue';
import VnSelectWorker from 'src/components/common/VnSelectWorker.vue';
const { t } = useI18n();
const { viewSummary } = useSummaryDialog();
@ -38,17 +39,7 @@ const columns = computed(() => [
align: 'left',
name: 'workerFk',
label: t('route.Worker'),
component: 'select',
attrs: {
url: 'Workers/activeWithInheritedRole',
fields: ['id', 'name'],
useLike: false,
optionFilter: 'firstName',
find: {
value: 'workerFk',
label: 'workerUserName',
},
},
component: markRaw(VnSelectWorker),
create: true,
cardVisible: true,
format: (row, dashIfEmpty) => dashIfEmpty(row.travelRef),
@ -59,6 +50,10 @@ const columns = computed(() => [
name: 'agencyName',
label: t('route.Agency'),
cardVisible: true,
},
{
label: t('route.Agency'),
name: 'agencyModeFk',
component: 'select',
attrs: {
url: 'agencyModes',
@ -69,14 +64,19 @@ const columns = computed(() => [
},
},
create: true,
columnClass: 'expand',
columnFilter: false,
visible: false,
},
{
align: 'left',
name: 'vehiclePlateNumber',
label: t('route.Vehicle'),
cardVisible: true,
},
{
name: 'vehicleFk',
label: t('route.Vehicle'),
cardVisible: true,
component: 'select',
attrs: {
url: 'vehicles',
@ -90,6 +90,7 @@ const columns = computed(() => [
},
create: true,
columnFilter: false,
visible: false,
},
{
align: 'left',
@ -156,6 +157,7 @@ const columns = computed(() => [
<VnTable
:data-key
:columns="columns"
ref="tableRef"
:right-search="false"
redirect="route"
:create="{

View File

@ -22,7 +22,12 @@ const links = {
};
</script>
<template>
<CardSummary data-key="Vehicle" :url="`Vehicles/${entityId}`" :filter="VehicleFilter">
<CardSummary
data-key="Vehicle"
:url="`Vehicles/${entityId}`"
module-name="Vehicle"
:filter="VehicleFilter"
>
<template #header="{ entity }">
<div>{{ entity.id }} - {{ entity.numberPlate }}</div>
</template>

View File

@ -105,6 +105,9 @@ const columns = computed(() => [
name: 'created',
align: 'left',
cardVisible: true,
columnFilter: {
component: 'date',
},
format: (row) => toDateTimeFormat(row.created),
},
{
@ -201,7 +204,7 @@ const getExpeditionState = async (expedition) => {
const openGrafana = (expeditionFk) => {
useOpenURL(
`https://grafana.verdnatura.es/d/de1njb6p5answd/control-de-expediciones?orgId=1&var-expeditionFk=${expeditionFk}`
`https://grafana.verdnatura.es/d/de1njb6p5answd/control-de-expediciones?orgId=1&var-expeditionFk=${expeditionFk}`,
);
};
@ -287,7 +290,7 @@ onMounted(async () => {
openConfirmationModal(
'',
t('expedition.removeExpeditionSubtitle'),
deleteExpedition
deleteExpedition,
)
"
>
@ -302,7 +305,6 @@ onMounted(async () => {
url="Expeditions/filter"
search-url="expeditions"
:columns="columns"
:filter="expeditionsFilter"
v-model:selected="selectedRows"
:table="{
'row-key': 'id',
@ -316,6 +318,8 @@ onMounted(async () => {
return { id: value };
case 'packageItemName':
return { packagingItemFk: value };
case 'created':
return { 'e.created': { gte: value } };
}
}
"

View File

@ -121,6 +121,50 @@ async function handleSave() {
isSaving.value = false;
}
}
function validateFields(item) {
// Only validate fields that are being updated
const shouldExist = (field) => !isUpdate || field in item;
if (!shouldExist('ticketServiceTypeFk') && !item.ticketServiceTypeFk) {
notify('Description is required', 'negative');
return false;
}
if (!shouldExist('quantity') && (!item.quantity || item.quantity <= 0)) {
notify('Quantity must be greater than 0', 'negative');
return false;
}
if (!shouldExist('price') && (!item.price || item.price < 0)) {
notify('Price must be valid', 'negative');
return false;
}
return true;
}
function beforeSave(data) {
const { creates = [], updates = [] } = data;
const validData = { creates: [], updates: [] };
// Validate creates
if (creates.length) {
for (const create of creates) {
create.ticketFk = route.params.id;
if (validateFields(create)) {
validData.creates.push(create);
}
}
}
// Validate updates
if (updates.length) {
for (const update of updates) {
validData.updates.push(update);
}
}
return validData;
}
</script>
<template>
@ -141,6 +185,7 @@ async function handleSave() {
v-model:selected="selected"
:order="['description ASC']"
:default-remove="false"
:beforeSaveFn="beforeSave"
>
<template #moreBeforeActions>
<QBtn
@ -170,6 +215,7 @@ async function handleSave() {
option-value="id"
hide-selected
sort-by="name ASC"
:required="true"
>
<template #form>
<TicketCreateServiceType
@ -185,6 +231,7 @@ async function handleSave() {
:label="col.label"
v-model.number="row.quantity"
type="number"
:required="true"
min="0"
:info="t('service.quantityInfo')"
/>
@ -196,6 +243,7 @@ async function handleSave() {
:label="col.label"
v-model.number="row.price"
type="number"
:required="true"
min="0"
@keyup.enter="handleSave"
/>

View File

@ -42,7 +42,7 @@ const transferRef = ref(null);
/>
</div>
<div v-else>
<div style="display: flex; flex-direction: row" v-else>
<TicketTransfer
ref="transferRef"
:ticket="$props.ticket"

View File

@ -142,7 +142,7 @@ onMounted(() => (stateStore.rightDrawer = true));
<template #column-concept="{ row }">
<span>{{ row.item.name }}</span>
<span class="color-vn-label q-pl-md">{{ row.item.subName }}</span>
<FetchedTags :item="row.item" />
<FetchedTags :item="row.item" :columns="6" />
</template>
<template #column-volume="{ rowIndex }">
<span>{{ packingTypeVolume?.[rowIndex]?.volume }}</span>

View File

@ -456,6 +456,7 @@ watch(
:pagination="{ rowsPerPage: 0 }"
:no-data-label="t('globals.noResults')"
:right-search="false"
:order="['futureTotalWithVat ASC']"
auto-load
:disable-option="{ card: true }"
>

View File

@ -46,7 +46,12 @@ const getGroupedStates = (data) => {
"
auto-load
/>
<FetchData url="AgencyModes" @on-fetch="(data) => (agencies = data)" auto-load />
<FetchData
url="AgencyModes"
:sort-by="['name ASC']"
@on-fetch="(data) => (agencies = data)"
auto-load
/>
<FetchData url="Warehouses" @on-fetch="(data) => (warehouses = data)" auto-load />
<VnFilterPanel :data-key="props.dataKey" :search-button="true">
<template #tags="{ tag, formatFn }">
@ -74,10 +79,20 @@ const getGroupedStates = (data) => {
</QItem>
<QItem>
<QItemSection>
<VnInputDate v-model="params.from" :label="t('From')" is-outlined />
<VnInputDate
v-model="params.from"
:label="t('From')"
is-outlined
data-cy="From_date"
/>
</QItemSection>
<QItemSection>
<VnInputDate v-model="params.to" :label="t('To')" is-outlined />
<VnInputDate
v-model="params.to"
:label="t('To')"
is-outlined
data-cy="To_date"
/>
</QItemSection>
</QItem>
<QItem>

View File

@ -1,6 +1,6 @@
<script setup>
import axios from 'axios';
import { computed, ref, onBeforeMount } from 'vue';
import { computed, ref, onBeforeMount, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useStateStore } from 'stores/useStateStore';
import { useI18n } from 'vue-i18n';
@ -69,6 +69,8 @@ const companiesOptions = ref([]);
const accountingOptions = ref([]);
const amountToReturn = ref();
const dataKey = 'TicketList';
const filterPanelRef = ref(null);
const formInitialData = ref({});
const columns = computed(() => [
{
@ -119,12 +121,16 @@ const columns = computed(() => [
{
align: 'left',
name: 'shipped',
component: 'time',
columnFilter: false,
label: t('ticketList.hour'),
format: (row) => toTimeFormat(row.shipped),
},
{
align: 'left',
name: 'zoneLanding',
component: 'time',
columnFilter: false,
label: t('ticketList.closure'),
format: (row, dashIfEmpty) => dashIfEmpty(toTimeFormat(row.zoneLanding)),
},
@ -144,9 +150,16 @@ const columns = computed(() => [
},
{
align: 'left',
name: 'province',
name: 'provinceFk',
label: t('ticketList.province'),
columnClass: 'expand',
component: 'select',
attrs: {
url: 'Provinces',
},
columnField: {
component: null,
},
format: (row, dashIfEmpty) => dashIfEmpty(row.province),
},
{
align: 'left',
@ -180,9 +193,19 @@ const columns = computed(() => [
},
{
align: 'left',
name: 'warehouse',
label: t('ticketList.warehouse'),
columnClass: 'expand',
name: 'warehouseFk',
label: t('globals.warehouse'),
component: 'select',
attrs: {
url: 'warehouses',
fields: ['id', 'name'],
},
format: (row) => row.warehouse,
columnField: {
component: null,
},
cardVisible: false,
create: false,
},
{
align: 'left',
@ -422,6 +445,22 @@ function setReference(data) {
dialogData.value.value.description = newDescription;
}
watch(
() => route.query.table,
(newValue) => {
if (newValue) {
const clientId = +JSON.parse(newValue)?.clientFk;
if (!clientId) return;
formInitialData.value = {
clientId,
};
if (tableRef.value) tableRef.value.create.formInitialData = { clientId };
onClientSelected({ clientId });
}
},
{ immediate: true },
);
</script>
<template>
@ -456,7 +495,7 @@ function setReference(data) {
urlCreate: 'Tickets/new',
title: t('ticketList.createTicket'),
onDataSaved: ({ id }) => tableRef.redirect(id),
formInitialData: { clientId: null },
formInitialData,
}"
default-mode="table"
:columns="columns"
@ -538,11 +577,9 @@ function setReference(data) {
:label="t('ticketList.client')"
v-model="data.clientId"
:options="clientsOptions"
option-value="id"
option-label="name"
hide-selected
required
@update:model-value="(client) => onClientSelected(data)"
@update:model-value="() => onClientSelected(data)"
:sort-by="'id ASC'"
>
<template #option="scope">
@ -564,7 +601,6 @@ function setReference(data) {
:label="t('basicData.address')"
v-model="data.addressId"
:options="addressesOptions"
option-value="id"
option-label="nickname"
hide-selected
map-options
@ -610,6 +646,9 @@ function setReference(data) {
{{ scope.opt?.city }}
</span>
</QItemLabel>
<QItemLabel caption>
{{ `#${scope.opt?.id}` }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
@ -633,8 +672,6 @@ function setReference(data) {
:label="t('globals.warehouse')"
v-model="data.warehouseId"
:options="warehousesOptions"
option-value="id"
option-label="name"
hide-selected
required
@update:model-value="() => fetchAvailableAgencies(data)"
@ -694,7 +731,6 @@ function setReference(data) {
:label="t('ticketList.company')"
v-model="dialogData.companyFk"
:options="companiesOptions"
option-value="id"
option-label="code"
hide-selected
>
@ -705,7 +741,6 @@ function setReference(data) {
:label="t('ticketList.bank')"
v-model="dialogData.bankFk"
:options="accountingOptions"
option-value="id"
option-label="bank"
hide-selected
@update:model-value="setReference"

View File

@ -1,5 +1,5 @@
<script setup>
import { ref } from 'vue';
import { ref, nextTick } from 'vue';
import { useI18n } from 'vue-i18n';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import FetchData from 'components/FetchData.vue';

View File

@ -35,6 +35,22 @@ async function reactivateWorker() {
}
}
const columns = computed(() => [
{
name: 'id',
label: t('Id'),
align: 'left',
isId: true,
cardVisible: true,
width: '40px',
},
{
name: 'isHourlyLabor',
label: t('worker.business.tableVisibleColumns.hourlyLabor'),
align: 'left',
component: 'checkbox',
cardVisible: true,
width: '60px',
},
{
name: 'started',
label: t('worker.business.tableVisibleColumns.started'),
@ -194,6 +210,20 @@ const columns = computed(() => [
format: ({ workerBusinessTypeName }, dashIfEmpty) =>
dashIfEmpty(workerBusinessTypeName),
},
{
align: 'left',
name: 'workerBusinessAgreementFk',
label: t('worker.business.tableVisibleColumns.workerBusinessAgreementName'),
component: 'select',
attrs: {
url: 'WorkerBusinessAgreements',
fields: ['id', 'name'],
},
cardVisible: true,
create: true,
format: ({ workerBusinessAgreementName }, dashIfEmpty) =>
dashIfEmpty(workerBusinessAgreementName),
},
{
align: 'left',
label: t('worker.business.tableVisibleColumns.amount'),
@ -230,7 +260,7 @@ const columns = computed(() => [
save-url="/Businesses/crud"
:create="{
urlCreate: `Workers/${entityId}/Business`,
title: 'Create business',
title: t('Create business'),
onDataSaved: () => tableRef.reload(),
formInitialData: {},
}"
@ -248,4 +278,5 @@ const columns = computed(() => [
<i18n>
es:
Do you want to reactivate the user?: desea reactivar el usuario?
Create business: Crear contrato
</i18n>

View File

@ -79,7 +79,7 @@ const editEvent = async (event) => {
};
const { data } = await axios.patch(
`Workers/${route.params.id}/updateAbsence`,
params
params,
);
if (data) emit('refresh');
@ -108,14 +108,14 @@ const handleDateSelected = (date) => {
if (!event) createEvent(_date);
};
const handleEventSelected = (event, { year, month, day }) => {
const handleEventSelected = async (event, { year, month, day }) => {
if (!props.absenceType) {
notify(t('Choose an absence type from the right menu'), 'warning');
return;
}
const date = new Date(year, month - 1, day);
if (!event?.absenceId) createEvent(date);
if (!event?.absenceId) await createEvent(date);
else if (event.type == props.absenceType.code) deleteEvent(event, date);
else editEvent(event);
};

View File

@ -7,7 +7,11 @@ export const useStateStore = defineStore('stateStore', () => {
const rightDrawer = ref(false);
const rightAdvancedDrawer = ref(false);
const subToolbar = ref(false);
const cardDescriptor = ref(null);
function cardDescriptorChangeValue(descriptor) {
cardDescriptor.value = descriptor;
}
function toggleLeftDrawer() {
leftDrawer.value = !leftDrawer.value;
}
@ -49,6 +53,8 @@ export const useStateStore = defineStore('stateStore', () => {
}
return {
cardDescriptor,
cardDescriptorChangeValue,
leftDrawer,
rightDrawer,
rightAdvancedDrawer,

View File

@ -1,4 +1,4 @@
describe('ClaimNotes', () => {
describe.skip('ClaimNotes', () => {
const saveBtn = '.q-field__append > .q-btn > .q-btn__content > .q-icon';
const firstNote = '.q-infinite-scroll :nth-child(1) > .q-card__section--vert';
beforeEach(() => {

View File

@ -17,7 +17,7 @@ describe('Client consignee', () => {
const addressName = 'test';
cy.dataCy('Consignee_input').type(addressName);
cy.dataCy('Location_select').click();
cy.get('[role="listbox"] .q-item:nth-child(1)').click();
cy.getOption();
cy.dataCy('Street address_input').type('TEST ADDRESS');
cy.get('.q-btn-group > .q-btn--standard').click();
cy.location('href').should('contain', '#/customer/1107/address');

View File

@ -16,9 +16,9 @@ describe('EntryStockBought', () => {
cy.get('input[aria-label="Reserve"]').type('1');
cy.get('input[aria-label="Date"]').eq(1).clear();
cy.get('input[aria-label="Date"]').eq(1).type('01-01');
cy.get('input[aria-label="Buyer"]').type('buyerBossNick');
cy.get('input[aria-label="Buyer"]').type('itNick');
cy.get('div[role="listbox"] > div > div[role="option"]')
.eq(0)
.eq(1)
.should('be.visible')
.click();

View File

@ -0,0 +1,121 @@
describe('RouteAutonomous', () => {
const getLinkSelector = (colField) =>
`tr:first-child > [data-col-field="${colField}"] > .no-padding > .link`;
const selectors = {
reference: 'Reference_input',
date: 'tr:first-child > [data-col-field="dated"]',
total: '.value > .text-h6',
received: getLinkSelector('invoiceInFk'),
autonomous: getLinkSelector('supplierName'),
firstRowCheckbox: '.q-virtual-scroll__content tr:first-child .q-checkbox__bg',
secondRowCheckbox: '.q-virtual-scroll__content tr:nth-child(2) .q-checkbox__bg',
createInvoiceBtn: '.q-card > .q-btn',
saveFormBtn: 'FormModelPopup_save',
summaryIcon: 'tableAction-0',
summaryPopupBtn: '.header > :nth-child(2) > .q-btn__content > .q-icon',
summaryHeader: '.summaryHeader > :nth-child(2)',
descriptorHeader: '.summaryHeader > div',
descriptorTitle: '.q-item__label--header > .title > span',
summaryGoToSummaryBtn: '.header > .q-icon',
descriptorGoToSummaryBtn: '.descriptor > .header > a[href] > .q-btn',
};
const data = {
reference: 'Test invoice',
total: '€206.40',
supplier: 'PLANTS SL',
route: 'first route',
};
const summaryUrl = '/summary';
const dataSaved = 'Data saved';
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/route/agency-term`);
cy.typeSearchbar('{enter}');
});
it('Should list autonomous routes', () => {
cy.get('.q-table')
.children()
.should('be.visible')
.should('have.length.greaterThan', 0);
});
it('Should create invoice in to selected route', () => {
cy.get(selectors.firstRowCheckbox).click();
cy.get(selectors.createInvoiceBtn).click();
cy.dataCy(selectors.reference).type(data.reference);
cy.get('.q-file').selectFile('test/cypress/fixtures/image.jpg', {
force: true,
});
cy.dataCy(selectors.saveFormBtn).click();
cy.checkNotification(dataSaved);
cy.typeSearchbar('{enter}');
});
it('Should display the total price of the selected rows', () => {
cy.get(selectors.firstRowCheckbox).click();
cy.get(selectors.secondRowCheckbox).click();
cy.validateContent(selectors.total, data.total);
});
it('Should redirect to the summary when clicking a route', () => {
cy.get(selectors.date).click();
cy.get(selectors.summaryHeader).should('contain', data.route);
cy.url().should('include', summaryUrl);
});
describe('Received pop-ups', () => {
it('Should redirect to invoice in summary from the received descriptor pop-up', () => {
cy.get(selectors.received).click();
cy.validateContent(selectors.descriptorTitle, data.reference);
cy.get(selectors.descriptorGoToSummaryBtn).click();
cy.get(selectors.descriptorHeader).should('contain', data.supplier);
cy.url().should('include', summaryUrl);
});
it('Should redirect to the invoiceIn summary from summary pop-up from the received descriptor pop-up', () => {
cy.get(selectors.received).click();
cy.validateContent(selectors.descriptorTitle, data.reference);
cy.get(selectors.summaryPopupBtn).click();
cy.get(selectors.descriptorHeader).should('contain', data.supplier);
cy.get(selectors.summaryGoToSummaryBtn).click();
cy.get(selectors.descriptorHeader).should('contain', data.supplier);
cy.url().should('include', summaryUrl);
});
});
describe('Autonomous pop-ups', () => {
it('Should redirect to the supplier summary from the received descriptor pop-up', () => {
cy.get(selectors.autonomous).click();
cy.validateContent(selectors.descriptorTitle, data.supplier);
cy.get(selectors.descriptorGoToSummaryBtn).click();
cy.get(selectors.summaryHeader).should('contain', data.supplier);
cy.url().should('include', summaryUrl);
});
it('Should redirect to the supplier summary from summary pop-up from the autonomous descriptor pop-up', () => {
cy.get(selectors.autonomous).click();
cy.get(selectors.descriptorTitle).should('contain', data.supplier);
cy.get(selectors.summaryPopupBtn).click();
cy.get(selectors.summaryHeader).should('contain', data.supplier);
cy.get(selectors.summaryGoToSummaryBtn).click();
cy.get(selectors.summaryHeader).should('contain', data.supplier);
cy.url().should('include', summaryUrl);
});
});
describe('Route pop-ups', () => {
it('Should redirect to the summary from the route summary pop-up', () => {
cy.dataCy(selectors.summaryIcon).first().click();
cy.get(selectors.summaryHeader).should('contain', data.route);
cy.get(selectors.summaryGoToSummaryBtn).click();
cy.get(selectors.summaryHeader).should('contain', data.route);
cy.url().should('include', summaryUrl);
});
});
});

View File

@ -0,0 +1,59 @@
describe('Vehicle list', () => {
const selectors = {
saveFormBtn: 'FormModelPopup_save',
summaryPopupBtn: 'tr:last-child > .q-table--col-auto-width > .q-btn',
summaryGoToSummaryBtn: '.header > .q-icon',
summaryHeader: '.summaryHeader > div',
numberPlate: 'tr:last-child > [data-col-field="numberPlate"] > .no-padding',
};
const data = {
'Nº Plate': { val: '9465-LPA' },
'Trade Mark': { val: 'WAYNE INDUSTRIES' },
Model: { val: 'BATREMOLQUE' },
Type: { val: 'remolque', type: 'select' },
Warehouse: { val: 'Warehouse One', type: 'select' },
Country: { val: 'Portugal', type: 'select' },
Description: { val: 'Exclusive for batpod transport' },
};
const expected = data['Nº Plate'].val;
const summaryUrl = '/summary';
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/route/vehicle/list`);
cy.typeSearchbar('{enter}');
});
it('should list vehicles', () => {
cy.get('.q-table')
.children()
.should('be.visible')
.should('have.length.greaterThan', 0);
});
it('Should add new vehicle', () => {
cy.addBtnClick();
cy.fillInForm(data);
cy.dataCy(selectors.saveFormBtn).should('be.visible').click();
cy.checkNotification('Data created');
cy.get(selectors.summaryHeader).should('contain', expected);
cy.url().should('include', summaryUrl);
});
it('should open summary by clicking a vehicle', () => {
cy.get(selectors.numberPlate).click();
cy.get(selectors.summaryHeader).should('contain', expected);
cy.url().should('include', summaryUrl);
});
it('should redirect to vehicle summary when click summary icon on summary pop-up', () => {
cy.get(selectors.summaryPopupBtn).click();
cy.get(selectors.summaryHeader).should('contain', expected);
cy.get(selectors.summaryGoToSummaryBtn).click();
cy.url().should('include', summaryUrl);
});
});

View File

@ -0,0 +1,50 @@
/// <reference types="cypress" />
describe('TicketFilter', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/list');
});
it('use search button', function () {
cy.waitForElement('.q-page');
cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketFilter');
cy.searchBtnFilterPanel();
cy.waitRequest('@ticketFilter', ({ request }) => {
const { query } = request;
expect(query).to.have.property('from');
expect(query).to.have.property('to');
});
cy.on('uncaught:exception', () => {
return false;
});
cy.get('.q-field__control-container > [data-cy="From_date"]')
.type(`${today()} `)
.type('{enter}');
cy.get('.q-notification').should(
'contain',
`The date range must have both 'from' and 'to'`,
);
cy.get('.q-field__control-container > [data-cy="To_date"]').type(
`${today()}{enter}`,
);
cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketFilter');
cy.searchBtnFilterPanel();
cy.wait('@ticketFilter').then(({ request }) => {
const { query } = request;
expect(query).to.have.property('from');
expect(query).to.have.property('to');
});
cy.location('href').should('contain', '#/ticket/999999');
});
});
function today(date) {
// return new Date().toISOString().split('T')[0];
return new Intl.DateTimeFormat('es-ES', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}).format(date ?? new Date());
}

View File

@ -1,6 +1,6 @@
/// <reference types="cypress" />
describe('TicketList', () => {
const firstRow = 'tbody > :nth-child(1)';
const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)';
beforeEach(() => {
cy.login('developer');
@ -9,8 +9,7 @@ describe('TicketList', () => {
});
const searchResults = (search) => {
cy.dataCy('vn-searchbar').find('input').focus();
if (search) cy.dataCy('vn-searchbar').find('input').type(search);
if (search) cy.typeSearchbar().type(search);
cy.dataCy('vn-searchbar').find('input').type('{enter}');
cy.dataCy('ticketListTable').should('exist');
cy.get(firstRow).should('exist');
@ -27,7 +26,7 @@ describe('TicketList', () => {
cy.window().then((win) => {
cy.stub(win, 'open').as('windowOpen');
});
cy.get(firstRow).find('.q-btn:first').click();
cy.get(firstRow).should('be.visible').find('.q-btn:first').click();
cy.get('@windowOpen').should('be.calledWithMatch', /\/ticket\/\d+\/sale/);
});
@ -38,6 +37,31 @@ describe('TicketList', () => {
cy.get('.summaryBody').should('exist');
});
it('filter client and create ticket', () => {
cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketSearchbar');
searchResults();
cy.wait('@ticketSearchbar').then(({ request }) => {
const { query } = request;
expect(query).to.have.property('from');
expect(query).to.have.property('to');
expect(query).to.not.have.property('clientFk');
});
cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketFilter');
cy.dataCy('Customer ID_input').clear('1');
cy.dataCy('Customer ID_input').type('1101{enter}');
cy.wait('@ticketFilter').then(({ request }) => {
const { query } = request;
expect(query).to.not.have.property('from');
expect(query).to.not.have.property('to');
expect(query).to.have.property('clientFk');
});
cy.get('[data-cy="vnTableCreateBtn"] > .q-btn__content > .q-icon').click();
cy.dataCy('Customer_select').should('have.value', 'Bruce Wayne');
cy.dataCy('Address_select').click();
cy.getOption().click();
cy.dataCy('Address_select').should('have.value', 'Bruce Wayne');
});
it('Client list create new client', () => {
cy.dataCy('vnTableCreateBtn').should('exist');
cy.dataCy('vnTableCreateBtn').click();

View File

@ -18,7 +18,7 @@ describe('UserPanel', () => {
cy.get(userWarehouse).should('have.value', 'VNL').click();
// Actualizo la opción
getOption(3);
cy.getOption(3);
//Compruebo la notificación
cy.get('.q-notification').should('be.visible');
@ -26,7 +26,7 @@ describe('UserPanel', () => {
//Restauro el valor
cy.get(userWarehouse).click();
getOption(2);
cy.getOption(2);
});
it('should notify when update user company', () => {
const userCompany =
@ -39,7 +39,7 @@ describe('UserPanel', () => {
cy.get(userCompany).should('have.value', 'Warehouse One').click();
//Actualizo la opción
getOption(2);
cy.getOption(2);
//Compruebo la notificación
cy.get('.q-notification').should('be.visible');
@ -47,12 +47,6 @@ describe('UserPanel', () => {
//Restauro el valor
cy.get(userCompany).click();
getOption(1);
cy.getOption(1);
});
});
function getOption(index) {
cy.waitForElement('[role="listbox"]');
const option = `[role="listbox"] .q-item:nth-child(${index})`;
cy.get(option).click();
}

View File

@ -88,7 +88,7 @@ describe('VnLocation', () => {
cy.get(
firstOption.concat(' > .q-item__section > .q-item__label--caption'),
).should('have.text', postCodeLabel);
cy.get(firstOption).click();
cy.getOption();
cy.get('.q-btn-group > .q-btn--standard > .q-btn__content > .q-icon').click();
cy.reload();
cy.waitForElement('.q-form');

View File

@ -393,6 +393,22 @@ Cypress.Commands.add('clickButtonWithIcon', (iconClass) => {
cy.wrap($btn).click();
});
});
Cypress.Commands.add('clickButtonWithText', (buttonText) => {
cy.get('.q-btn').contains(buttonText).click();
});
Cypress.Commands.add('getOption', (index = 1) => {
cy.waitForElement('[role="listbox"]');
cy.get(`[role="listbox"] .q-item:nth-child(${index})`).click();
});
Cypress.Commands.add('searchBtnFilterPanel', () => {
cy.get(
'.q-scrollarea__content > .q-btn--standard > .q-btn__content > .q-icon',
).click();
});
Cypress.Commands.add('waitRequest', (alias, cb) => {
cy.wait(alias).then(cb);
});