Merge branch 'dev' into vitest_ui
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javier Segarra 2025-04-08 12:57:32 +00:00
commit 87925d3fad
28 changed files with 417 additions and 172 deletions

View File

@ -78,7 +78,8 @@ export function useValidator() {
if (min >= 0)
if (Math.floor(value) < min) return t('inputMin', { value: min });
},
custom: (value) => validation.bindedFunction(value) || 'Invalid value',
custom: (value) =>
eval(`(${validation.bindedFunction})`)(value) || 'Invalid value',
};
};

View File

@ -88,13 +88,13 @@ const columns = [
auto-load
>
<template #column-itemFk="{ row }">
<span class="link">
<span class="link" @click.stop>
{{ row.itemFk }}
<ItemDescriptorProxy :id="row.itemFk" />
</span>
</template>
<template #column-ticketFk="{ row }">
<span class="link">
<span class="link" @click.stop>
{{ row.ticketFk }}
<TicketDescriptorProxy :id="row.ticketFk" />
</span>

View File

@ -22,7 +22,7 @@ const $props = defineProps({
});
</script>
<template>
<QPopupProxy style="max-width: 10px">
<QPopupProxy style="max-width: 10px" data-cy="ItemDescriptor">
<ItemDescriptor
v-if="$props.id"
:id="$props.id"

View File

@ -91,7 +91,7 @@ const totalPrice = computed(() => {
const totalNewPrice = computed(() => {
return rows.value.reduce(
(acc, item) => acc + item.component.newPrice * item.quantity,
0
0,
);
});
@ -210,18 +210,18 @@ onMounted(async () => {
flat
>
<template #body-cell-item="{ row }">
<QTd @click.stop class="link">
<QBtn flat>
<QTd align="center">
<span @click.stop class="link">
{{ row.itemFk }}
<ItemDescriptorProxy :id="row.itemFk" />
</QBtn>
</span>
</QTd>
</template>
<template #body-cell-description="{ row }">
<QTd style="min-width: 120px; max-width: 120px">
<div class="column q-pb-xs" style="min-width: 120px">
<span>{{ row.item.name }}</span>
<FetchedTags :item="row.item" class="full-width" />
<FetchedTags :item="row.item" class="full-width" :columns="6" />
</div>
</QTd>
</template>

View File

@ -1,59 +0,0 @@
<script setup>
import { ref } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import FormModelPopup from 'components/FormModelPopup.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import FetchData from 'components/FetchData.vue';
import { useState } from 'src/composables/useState';
import VnSelectWorker from 'src/components/common/VnSelectWorker.vue';
const emit = defineEmits(['onRequestCreated']);
const route = useRoute();
const { t } = useI18n();
const state = useState();
const user = state.getUser();
const stateFetchDataRef = ref(null);
const statesOptions = ref([]);
const onStateFkChange = (formData) => (formData.userFk = user.value.id);
</script>
<template>
<FetchData
ref="stateFetchDataRef"
url="States"
auto-load
@on-fetch="(data) => (statesOptions = data)"
/>
<FormModelPopup
:title="t('Create tracking')"
url-create="Tickets/state"
model="CreateTicketTracking"
:form-initial-data="{ ticketFk: route.params.id }"
@on-data-saved="() => emit('onRequestCreated')"
>
<template #form-inputs="{ data }">
<VnRow>
<VnSelect
v-model="data.stateFk"
:label="t('ticketList.state')"
:options="statesOptions"
@update:model-value="onStateFkChange(data)"
hide-selected
option-label="name"
option-value="id"
/>
<VnSelectWorker v-model="data.userFk" :fields="['id', 'name']" />
</VnRow>
</template>
</FormModelPopup>
</template>
<i18n>
es:
Create tracking: Crear estado
</i18n>

View File

@ -1,27 +1,23 @@
<script setup>
import { ref, computed, watch, reactive } from 'vue';
import { ref, reactive, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import TicketCreateTracking from './TicketCreateTracking.vue';
import VnPaginate from 'components/ui/VnPaginate.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnSelectWorker from 'src/components/common/VnSelectWorker.vue';
import { useState } from 'src/composables/useState';
import { toDateTimeFormat } from 'src/filters/date.js';
import VnTable from 'src/components/VnTable/VnTable.vue';
const state = useState();
const user = state.getUser();
const route = useRoute();
const { t } = useI18n();
const createTrackingDialogRef = ref(null);
const paginateRef = ref(null);
watch(
() => route.params.id,
async (val) => {
paginateFilter.where.ticketFk = val;
paginateRef.value.fetch();
},
);
const tableRef = ref(null);
const onStateFkChange = (formData) => (formData.userFk = user.value.id);
const paginateFilter = reactive({
include: [
{
@ -56,75 +52,68 @@ const columns = computed(() => [
name: 'state',
field: 'state',
align: 'left',
format: (val) => val.name,
format: (row) => row.state?.name,
},
{
label: t('expedition.worker'),
name: 'worker',
align: 'left',
field: 'user',
},
{
label: t('expedition.created'),
name: 'created',
field: 'created',
align: 'left',
format: (val) => toDateTimeFormat(val),
format: ({ created }) => toDateTimeFormat(created),
},
]);
const openCreateModal = () => createTrackingDialogRef.value.show();
</script>
<template>
<QPage class="column items-center q-pa-md">
<VnPaginate
ref="paginateRef"
data-key="TicketTracking"
:user-filter="paginateFilter"
search-url="table"
url="TicketTrackings"
auto-load
order="created DESC"
:limit="0"
>
<template #body="{ rows }">
<QTable
:rows="rows"
:columns="columns"
row-key="id"
:pagination="{ rowsPerPage: 0 }"
class="full-width q-mt-md"
:no-data-label="t('globals.noResults')"
>
<template #body-cell-worker="{ row }">
<QTd>
<QBtn flat class="link" @click.stop>
{{ row.user?.name }}
<WorkerDescriptorProxy :id="row.user?.worker?.id" />
</QBtn>
</QTd>
</template>
</QTable>
</template>
</VnPaginate>
<QDialog
ref="createTrackingDialogRef"
transition-show="scale"
transition-hide="scale"
>
<TicketCreateTracking @on-request-created="paginateRef.fetch()" />
</QDialog>
<QPageSticky :offset="[20, 20]">
<QBtn
@click="openCreateModal()"
color="primary"
fab
icon="add"
v-shortcut="'+'"
<VnTable
ref="tableRef"
:right-search="false"
:column-search="false"
:disable-option="{ card: true, table: true }"
:search-url="false"
:columns="columns"
data-key="TicketTracking"
:user-filter="paginateFilter"
url="TicketTrackings"
auto-load
order="created DESC"
:limit="0"
:without-header="true"
:create="{
urlCreate: 'Tickets/state',
title: t('Create tracking'),
onDataSaved: () => tableRef.reload(),
formInitialData: {
ticketFk: route.params.id,
},
}"
>
<template #more-create-dialog="{ data }">
<VnSelect
url="States"
v-model="data.stateFk"
:label="t('ticketList.state')"
auto-load
@update:model-value="onStateFkChange(data)"
hide-selected
/>
<QTooltip class="text-no-wrap">
{{ t('tracking.addState') }}
</QTooltip>
</QPageSticky>
</QPage>
<VnSelectWorker v-model="data.userFk" :fields="['id', 'name']" />
</template>
<template #column-worker="{ row }">
<span class="link" @click.stop>
{{ row.user.name }}
<WorkerDescriptorProxy :id="row.user?.worker?.id" />
</span>
</template>
</VnTable>
</template>
<i18n>
es:
Create tracking: Crear estado
</i18n>

View File

@ -134,7 +134,7 @@ onMounted(() => (stateStore.rightDrawer = true));
auto-load
>
<template #column-itemFk="{ row }">
<span class="link">
<span class="link" @click.stop>
{{ row.itemFk }}
<ItemDescriptorProxy :id="row.itemFk" />
</span>

View File

@ -11,7 +11,7 @@ const $props = defineProps({
</script>
<template>
<QPopupProxy>
<QPopupProxy data-cy="WorkerDescriptor">
<WorkerDescriptor
v-if="$props.id"
:id="$props.id"

View File

@ -11,7 +11,7 @@ const $props = defineProps({
</script>
<template>
<QPopupProxy>
<QPopupProxy data-cy="ZoneDescriptor">
<ZoneDescriptor v-if="$props.id" :id="$props.id" :summary="ZoneSummary" />
</QPopupProxy>
</template>

View File

@ -0,0 +1,46 @@
/// <reference types="cypress" />
describe('TicketBasicData', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/31/basic-data');
});
it('Should redirect to customer basic data', () => {
cy.get('.q-page').should('be.visible');
cy.get(':nth-child(2) > div > .text-primary').click();
cy.dataCy('Address_select').click();
cy.get('.q-btn-group ').find('.q-btn__content > .q-icon').click();
cy.get(
'[data-cy="CustomerBasicData-menu-item"] > .q-item__section--main',
).click();
cy.url().should('include', '/customer/1104/basic-data');
});
it.only('stepper', () => {
cy.get('.q-stepper__tab--active').should('have.class', 'q-stepper__tab--active');
cy.get('.q-stepper__nav > .q-btn--standard').click();
cy.get('.q-stepper__tab--done').should('have.class', 'q-stepper__tab--done');
cy.get('.q-stepper__tab--active').should('have.class', 'q-stepper__tab--active');
cy.get('tr:nth-child(1)>:nth-child(1)>span').should('have.class', 'link').click();
cy.dataCy('ItemDescriptor').should('exist');
cy.get('.q-drawer__content > :nth-child(1)').each(() => {
cy.get('span').should('contain.text', 'Price: €');
cy.get('span').should('contain.text', 'New price: €');
cy.get('span').should('contain.text', 'Difference: €');
});
cy.get(
':nth-child(3) > .q-radio > .q-radio__inner > .q-radio__bg > .q-radio__check',
).should('have.class', 'q-radio__check');
cy.get(
'.q-stepper__step-inner > .q-drawer-container > .q-drawer > .q-drawer__content',
).click();
cy.get(':nth-child(2) > :nth-child(1) > .text-weight-bold').click();
cy.get(':nth-child(3) > .q-radio > .q-radio__inner').should(
'have.class',
'q-radio__inner--truthy',
);
cy.get('.q-drawer__content > :nth-child(2)').click();
});
});

View File

@ -0,0 +1,30 @@
/// <reference types="cypress" />
describe('TicketComponents', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/1/components');
});
it('Should load layout', () => {
cy.get('.q-page').should('be.visible');
cy.validateScrollContent([
{ row: 2, col: 2, text: 'Base to commission: €799.20' },
{ row: 2, col: 3, text: 'Total without VAT: €807.20' },
{ row: 3, col: 2, text: 'valor de compra: €425.000' },
{ row: 3, col: 4, text: 'maná auto: €7.998' },
{ row: 4, col: 2, text: 'Price: €5.00' },
{ row: 4, col: 3, text: 'Bonus: €1.00' },
{ row: 4, col: 5, text: 'Packages: 6' },
{ row: 4, col: 4, text: 'Zone: Zone pickup A ' },
{ row: 5, col: 2, text: 'Total price: €16.00' },
]);
cy.get(':nth-child(4) > .link').click();
cy.dataCy('ZoneDescriptor').should('exist');
cy.getRowCol('total').should('have.text', '€250.000€247.000€4.970');
cy.getRowCol('import').should('have.text', '€50.000€49.400€0.994');
cy.getRowCol('components').should('have.text', 'valor de compramargenmaná auto');
cy.getRowCol('serie').should('have.text', 'costeempresacartera_comercial');
});
});

View File

@ -1,7 +1,5 @@
/// <reference types="cypress" />
describe('TicketList', () => {
const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)';
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
@ -11,7 +9,7 @@ describe('TicketList', () => {
const searchResults = (search) => {
if (search) cy.typeSearchbar().type(search);
cy.dataCy('vn-searchbar').find('input').type('{enter}');
cy.get(firstRow).should('exist');
cy.getRow().should('exist');
};
it('should search results', () => {
@ -24,13 +22,13 @@ describe('TicketList', () => {
cy.window().then((win) => {
cy.stub(win, 'open').as('windowOpen');
});
cy.get(firstRow).should('be.visible').find('.q-btn:first').click();
cy.getRow().should('be.visible').find('.q-btn:first').click();
cy.get('@windowOpen').should('be.calledWithMatch', /\/ticket\/\d+\/sale/);
});
it('should open ticket summary', () => {
searchResults();
cy.get(firstRow).find('.q-btn:last').click();
cy.getRow().find('.q-btn:last').click();
cy.get('.summaryHeader').should('exist');
cy.get('.summaryBody').should('exist');
});
@ -43,8 +41,9 @@ describe('TicketList', () => {
cy.dataCy('Customer ID_input').clear('1');
cy.dataCy('Customer ID_input').type('1101{enter}');
cy.get('[data-cy="vnTableCreateBtn"] > .q-btn__content > .q-icon').click();
cy.waitSpinner();
cy.intercept('GET', /\/api\/Clients\?filter/).as('clientFilter');
cy.vnTableCreateBtn();
cy.wait('@clientFilter');
cy.dataCy('Customer_select').should('have.value', 'Bruce Wayne');
cy.dataCy('Address_select').click();
@ -52,8 +51,7 @@ describe('TicketList', () => {
cy.dataCy('Address_select').should('have.value', 'Bruce Wayne');
});
it('Client list create new ticket', () => {
cy.dataCy('vnTableCreateBtn').should('exist');
cy.dataCy('vnTableCreateBtn').click();
cy.vnTableCreateBtn();
const data = {
Customer: { val: 1, type: 'select' },
Warehouse: { val: 'Warehouse One', type: 'select' },

View File

@ -19,7 +19,7 @@ describe('TicketNotes', () => {
cy.checkNotification('Data saved');
cy.dataCy('ticketNotesRemoveNoteBtn').should('exist');
cy.dataCy('ticketNotesRemoveNoteBtn').click();
cy.dataCy('VnConfirm_confirm').click();
cy.confirmVnConfirm();
cy.checkNotification('Data saved');
});
});

View File

@ -0,0 +1,21 @@
/// <reference types="cypress" />
describe('TicketPackages', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/31/package');
});
it('Should load layout', () => {
cy.get('.q-page').should('be.visible');
cy.get('.vn-row > .q-btn > .q-btn__content > .q-icon').click();
cy.dataCy('Package_select').click();
cy.get('.q-menu :nth-child(1) >.q-item__section').click();
cy.dataCy('Quantity_input').clear().type('5');
cy.saveCrudModel();
cy.checkNotification('Data saved');
cy.get('.q-mb-md > .text-primary').click();
cy.confirmVnConfirm();
cy.checkNotification('Data saved');
});
});

View File

@ -0,0 +1,18 @@
/// <reference types="cypress" />
describe('TicketPictures', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/31/picture');
});
it('Should load layout', () => {
cy.get(':nth-child(1) > .q-card > .content').should('be.visible');
cy.get('.content > .link').should('be.visible').click();
cy.dataCy('ItemDescriptor').should('exist');
cy.dataCy('vnLvColor:');
cy.dataCy('vnLvColor:');
cy.dataCy('vnLvTallos:');
cy.get('.q-mt-md').should('be.visible');
cy.get(':nth-child(1) > .q-card > .img-wrapper').should('be.visible');
});
});

View File

@ -7,8 +7,7 @@ describe('TicketRequest', () => {
});
it('Creates a new request', () => {
cy.dataCy('vnTableCreateBtn').should('exist');
cy.dataCy('vnTableCreateBtn').click();
cy.vnTableCreateBtn();
const data = {
Description: { val: 'Purchase description' },
Atender: { val: 'buyerNick', type: 'select' },

View File

@ -2,9 +2,9 @@
const firstRow = 'tbody > :nth-child(1)';
describe('TicketSale', () => {
describe('Ticket #23', () => {
describe('#23', () => {
beforeEach(() => {
cy.login('developer');
cy.login('salesBoss');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/23/sale');
});
@ -16,10 +16,12 @@ describe('TicketSale', () => {
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('Price_input').clear().type(price);
cy.intercept('POST', /\/api\/Sales\/\d+\/updatePrice/).as('updatePrice');
cy.dataCy('saveManaBtn').click();
handleVnConfirm();
cy.wait('@updatePrice').its('response.statusCode').should('eq', 200);
cy.get('[data-col-field="price"]')
.find('.q-btn > .q-btn__content')
@ -32,10 +34,14 @@ describe('TicketSale', () => {
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('Disc_input').clear().type(discount);
cy.intercept('POST', /\/api\/Tickets\/\d+\/updateDiscount/).as(
'updateDiscount',
);
cy.dataCy('saveManaBtn').click();
handleVnConfirm();
cy.wait('@updateDiscount').its('response.statusCode').should('eq', 204);
cy.get('[data-col-field="discount"]')
.find('.q-btn > .q-btn__content')
@ -46,6 +52,8 @@ describe('TicketSale', () => {
const concept = Math.floor(Math.random() * 100) + 1;
cy.waitForElement(firstRow);
cy.get('[data-col-field="item"]').click();
cy.intercept('POST', '**/api').as('postRequest');
cy.get('.q-menu')
.find('[data-cy="undefined_input"]')
.type(concept)
@ -58,6 +66,8 @@ describe('TicketSale', () => {
const quantity = Math.floor(Math.random() * 100) + 1;
cy.waitForElement(firstRow);
cy.dataCy('ticketSaleQuantityInput').find('input').clear();
cy.intercept('POST', '**/api').as('postRequest');
cy.dataCy('ticketSaleQuantityInput')
.find('input')
.type(quantity)
@ -71,7 +81,7 @@ describe('TicketSale', () => {
.should('have.value', `${quantity}`);
});
});
describe('Ticket to add claim #24', () => {
describe('#24 add claim', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
@ -82,15 +92,15 @@ describe('TicketSale', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('createClaimItem').click();
cy.dataCy('VnConfirm_confirm').click();
cy.confirmVnConfirm();
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.confirmVnConfirm();
});
});
describe('Free ticket #31', () => {
describe('#31 free ticket', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
@ -129,7 +139,9 @@ describe('TicketSale', () => {
cy.dataCy('ticketSaleMoreActionsDropdown').should('be.disabled');
});
it('should update discount when "Update discount" is clicked', () => {
it.only('should update discount when "Update discount" is clicked', () => {
const discount = Number((Math.random() * 99 + 1).toFixed(2));
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-cy="updateDiscountItem"]');
@ -137,9 +149,13 @@ describe('TicketSale', () => {
cy.dataCy('updateDiscountItem').click();
cy.waitForElement('[data-cy="ticketSaleDiscountInput"]');
cy.dataCy('ticketSaleDiscountInput').find('input').focus();
cy.dataCy('ticketSaleDiscountInput').find('input').type('10');
cy.intercept('POST', /\/api\/Tickets\/\d+\/updateDiscount/).as(
'updateDiscount',
);
cy.dataCy('ticketSaleDiscountInput').find('input').type(discount);
cy.dataCy('saveManaBtn').click();
cy.waitForElement('.q-notification__message');
cy.wait('@updateDiscount').its('response.statusCode').should('eq', 204);
cy.checkNotification('Data saved');
cy.dataCy('ticketSaleMoreActionsDropdown').should('be.disabled');
});
@ -148,7 +164,7 @@ describe('TicketSale', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('createClaimItem').click();
cy.dataCy('VnConfirm_confirm').click();
cy.confirmVnConfirm();
cy.checkNotification('Future ticket date not allowed');
});
@ -173,7 +189,7 @@ describe('TicketSale', () => {
cy.url().should('match', /\/ticket\/31\/log/);
});
});
describe('Ticket to transfer #32', () => {
describe('#32 transfer', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
@ -194,9 +210,7 @@ function selectFirstRow() {
cy.get(firstRow).find('.q-checkbox__inner').click();
}
function handleVnConfirm() {
cy.get('[data-cy="VnConfirm_confirm"]').click();
cy.waitForElement('.q-notification__message');
cy.confirmVnConfirm();
cy.get('.q-notification__message').should('be.visible');
cy.checkNotification('Data saved');
}

View File

@ -0,0 +1,53 @@
/// <reference types="cypress" />
function uncheckedSVG(className, state) {
cy.get(`${className} .q-checkbox__svg`).should(
state === 'checked' ? 'not.have.attr' : 'have.attr',
'fill',
'none',
);
}
function checkedSVG(className, state) {
cy.get(`${className} .q-checkbox__svg> .q-checkbox__truthy`).should(
state === 'checked' ? 'not.have.attr' : 'have.attr',
'fill',
'none',
);
}
function clickIconAndCloseDialog(n) {
cy.get(
`:nth-child(1) > :nth-child(6) > :nth-child(${n}) > .q-btn__content > .q-icon`,
).click();
}
describe('TicketSaleTracking', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/1/sale-tracking');
});
it('Should load layout', () => {
cy.get('.q-page').should('be.visible');
// Check checkbox states
uncheckedSVG('.pink', 'checked');
uncheckedSVG('.cyan', 'checked');
uncheckedSVG('.warning', 'checked');
uncheckedSVG('.info', 'checked');
checkedSVG('.yellow', 'unchecked');
cy.get('.q-page').click();
cy.get(
':nth-child(1) > :nth-child(6) > :nth-child(2) > .q-btn__content > .q-icon',
).click();
cy.get('body').type('{esc}');
cy.get(
':nth-child(1) > :nth-child(6) > :nth-child(1) > .q-btn__content > .q-icon',
).click();
cy.get(
'.q-dialog__inner > .q-table__container :nth-child(1) > :nth-child(2) .link.q-btn',
).click();
cy.dataCy('WorkerDescriptor').should('exist');
});
});

View File

@ -0,0 +1,23 @@
/// <reference types="cypress" />
describe('TicketService', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/31/service');
});
it('Add and remove service', () => {
cy.get('.q-page').should('be.visible');
cy.addBtnClick();
cy.dataCy('Description_icon').click();
cy.dataCy('Description_input').clear().type('test');
cy.saveFormModel();
cy.selectOption('[data-cy="Description_select"]', 'test');
cy.dataCy('Quantity_input').clear().type('1');
cy.dataCy('Price_input').clear().type('2');
cy.saveCrudModel();
cy.checkNotification('Data saved');
cy.get(':nth-child(5) > .q-icon').click();
});
});

View File

@ -0,0 +1,22 @@
/// <reference types="cypress" />
describe('TicketSms', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/32/sms');
});
it('Should load layout', () => {
cy.get('.q-page').should('be.visible');
cy.get('.q-infinite-scroll > :nth-child(1)').should(
'contain.text',
'0004 444444444Lorem ipsum dolor sit amet, consectetur adipiscing elit.2001-01-01 00:00:00OK',
);
cy.get(
':nth-child(1) > .q-item > .q-item__section--top > .column > .q-avatar',
).should('be.visible');
cy.get(
':nth-child(1) > .q-item > .q-item__section--side.justify-center > .center > .q-chip > .q-chip__content',
).should('have.class', 'q-chip__content');
});
});

View File

@ -0,0 +1,25 @@
/// <reference types="cypress" />
describe('Ticket tracking', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/31/tracking');
});
it('Add new tracking', () => {
cy.get('.q-page').should('be.visible');
cy.getRowCol('worker').find('span').should('have.class', 'link').click();
cy.dataCy('WorkerDescriptor').should('exist');
cy.vnTableCreateBtn();
cy.selectOption('.q-field--float [data-cy="State_select"]', 'OK').click();
cy.saveFormModel();
cy.get(
':last-child > [data-col-field="state"] > [data-cy="vnTableCell_state"]',
).should('have.text', 'OK');
cy.get(':last-child > [data-col-field="worker"]').should(
'have.text',
'developer ',
);
});
});

View File

@ -0,0 +1,27 @@
/// <reference types="cypress" />
function checkRightLabel(index, value, tag = 'Volume: ') {
cy.get(`.q-scrollarea__content > :nth-child(${index}) > :nth-child(2) > span`)
.should('be.visible')
.should('have.text', `${tag}${value}`);
}
describe('TicketVolume', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/1/volume');
});
it('Check right panel info', () => {
cy.get('.q-page').should('be.visible');
checkRightLabel(2, '0.028');
checkRightLabel(3, '0.014');
checkRightLabel(4, '1.526');
});
it('Descriptors', () => {
cy.get(':nth-child(1) > [data-col-field="itemFk"]')
.find('span')
.should('have.class', 'link')
.click();
cy.dataCy('ItemDescriptor').should('exist');
});
});

View File

@ -0,0 +1,3 @@
Cypress.Commands.add('saveCrudModel', () =>
cy.dataCy('crudModelDefaultSaveBtn').should('exist').click(),
);

View File

@ -0,0 +1,3 @@
Cypress.Commands.add('saveFormModel', () =>
cy.dataCy('FormModelPopup_save').should('exist').click(),
);

View File

@ -0,0 +1,3 @@
Cypress.Commands.add('confirmVnConfirm', () =>
cy.dataCy('VnConfirm_confirm').should('exist').click(),
);

View File

@ -0,0 +1,3 @@
Cypress.Commands.add('clickOption', (index = 1) =>
cy.get(`.q-menu :nth-child(${index}) >.q-item__section`).click(),
);

View File

@ -0,0 +1,16 @@
Cypress.Commands.add('getRow', (index = 1) =>
cy.get(`.vnTable .q-virtual-scroll__content tr:nth-child(${index})`),
);
Cypress.Commands.add('getRowCol', (field, index = 1) =>
cy.get(
`.vnTable .q-virtual-scroll__content > :nth-child(${index}) > [data-col-field="${field}"]`,
),
);
Cypress.Commands.add('vnTableCreateBtn', () =>
cy.dataCy('vnTableCreateBtn').should('exist').click(),
);
Cypress.Commands.add('waitTableScrollLoad', () =>
cy.waitForElement('[data-q-vs-anchor]'),
);

View File

@ -29,7 +29,12 @@
// import { registerCommands } from '@quasar/quasar-app-extension-testing-e2e-cypress';
import moment from 'moment';
import waitUntil from './waitUntil';
// Importar dinámicamente todos los archivos con el sufijo .commands.js dentro de la carpeta src/test/cypress/integration
const requireCommands = require.context('../integration', true, /\.commands\.js$/);
// Iterar sobre cada archivo y requerirlo
requireCommands.keys().forEach(requireCommands);
// Common comma
Cypress.Commands.add('waitUntil', { prevSubject: 'optional' }, waitUntil);
Cypress.Commands.add('resetDB', () => {
@ -606,6 +611,11 @@ Cypress.Commands.add('checkQueryParams', (expectedParams = {}) => {
});
});
Cypress.Commands.add('waitTableScrollLoad', () =>
cy.waitForElement('[data-q-vs-anchor]'),
);
Cypress.Commands.add('validateScrollContent', (validations) => {
validations.forEach(({ row, col, text }) => {
cy.get(`.q-scrollarea__content > :nth-child(${row}) > :nth-child(${col})`).should(
'have.text',
text,
);
});
});