0
0
Fork 0

ref #5835 tests basicData and list

This commit is contained in:
Jorge Penadés 2023-11-06 16:03:36 +01:00
parent 112e057cfa
commit a9241b17f5
4 changed files with 337 additions and 283 deletions

View File

@ -85,10 +85,10 @@ async function setCreateDms() {
async function edit() { async function edit() {
try { try {
if (!dms.value.companyId) throw new Error(t(`The company can't be empty`)); if (!dms.value.companyId) throw Error(t(`The company can't be empty`));
if (!dms.value.warehouseId) throw new Error(t(`The warehouse can't be empty`)); if (!dms.value.warehouseId) throw Error(t(`The warehouse can't be empty`));
if (!dms.value.dmsTypeId) throw new Error(t(`The DMS Type can't be empty`)); if (!dms.value.dmsTypeId) throw Error(t(`The DMS Type can't be empty`));
if (!dms.value.description) throw new Error(t(`The description can't be empty`)); if (!dms.value.description) throw Error(t(`The description can't be empty`));
const formData = new FormData(); const formData = new FormData();
@ -111,7 +111,7 @@ async function edit() {
}); });
} catch (error) { } catch (error) {
quasar.notify({ quasar.notify({
message: t(`${error}`), message: t(`${error.message}`),
type: 'negative', type: 'negative',
}); });
} }
@ -119,11 +119,11 @@ async function edit() {
async function create() { async function create() {
try { try {
if (!dms.value.companyId) throw new Error(t(`The company can't be empty`)); if (!dms.value.companyId) throw Error(t(`The company can't be empty`));
if (!dms.value.warehouseId) throw new Error(t(`The warehouse can't be empty`)); if (!dms.value.warehouseId) throw Error(t(`The warehouse can't be empty`));
if (!dms.value.dmsTypeId) throw new Error(t(`The DMS Type can't be empty`)); if (!dms.value.dmsTypeId) throw Error(t(`The DMS Type can't be empty`));
if (!dms.value.description) throw new Error(t(`The description can't be empty`)); if (!dms.value.description) throw Error(t(`The description can't be empty`));
if (!dms.value.files) throw new Error(t(`The files can't be empty`)); if (!dms.value.files) throw Error(t(`The files can't be empty`));
const formData = new FormData(); const formData = new FormData();
@ -144,8 +144,9 @@ async function create() {
type: 'positive', type: 'positive',
}); });
} catch (error) { } catch (error) {
console.log(error);
quasar.notify({ quasar.notify({
message: t(`${error}`), message: t(`${error.message}`),
type: 'negative', type: 'negative',
}); });
} }
@ -197,13 +198,7 @@ async function create() {
@on-fetch="(data) => (userConfig = data)" @on-fetch="(data) => (userConfig = data)"
auto-load auto-load
/> />
<div class="column items-center"> <FormModel v-if="invoiceIn" :url="`InvoiceIns/${route.params.id}`" model="invoiceIn">
<QCard>
<FormModel
v-if="invoiceIn"
:url="`InvoiceIns/${route.params.id}`"
model="invoiceIn"
>
<template #form="{ data }"> <template #form="{ data }">
<div class="row q-gutter-md q-mb-md"> <div class="row q-gutter-md q-mb-md">
<div class="col"> <div class="col">
@ -214,6 +209,7 @@ async function create() {
:options="suppliers" :options="suppliers"
option-value="id" option-value="id"
option-label="nickname" option-label="nickname"
:input-debounce="100"
@input-value="suppliersRef.fetch()" @input-value="suppliersRef.fetch()"
> >
<template #option="scope"> <template #option="scope">
@ -238,14 +234,13 @@ async function create() {
</div> </div>
<div class="row q-gutter-md q-mb-md"> <div class="row q-gutter-md q-mb-md">
<div class="col"> <div class="col">
<QInput :label="t('Expedition date')" v-model="data.issued"> <QInput
<template #append> :label="t('Expedition date')"
<QIcon v-model="data.issued"
name="event"
class="cursor-pointer"
mask="####-##-##" mask="####-##-##"
fill-mask="_"
> >
<template #append>
<QIcon name="event" class="cursor-pointer" fill-mask="_">
<QPopupProxy <QPopupProxy
cover cover
transition-show="scale" transition-show="scale"
@ -281,10 +276,7 @@ async function create() {
transition-show="scale" transition-show="scale"
transition-hide="scale" transition-hide="scale"
> >
<QDate <QDate v-model="data.operated" mask="YYYY-MM-DD">
v-model="data.operated"
mask="YYYY-MM-DD"
>
<div class="row items-center justify-end"> <div class="row items-center justify-end">
<QBtn <QBtn
v-close-popup v-close-popup
@ -375,10 +367,7 @@ async function create() {
transition-show="scale" transition-show="scale"
transition-hide="scale" transition-hide="scale"
> >
<QDate <QDate v-model="data.bookEntried" mask="YYYY-MM-DD">
v-model="data.bookEntried"
mask="YYYY-MM-DD"
>
<div class="row items-center justify-end"> <div class="row items-center justify-end">
<QBtn <QBtn
v-close-popup v-close-popup
@ -409,10 +398,7 @@ async function create() {
transition-show="scale" transition-show="scale"
transition-hide="scale" transition-hide="scale"
> >
<QDate <QDate v-model="data.booked" mask="YYYY-MM-DD">
v-model="data.booked"
mask="YYYY-MM-DD"
>
<div class="row items-center justify-end"> <div class="row items-center justify-end">
<QBtn <QBtn
v-close-popup v-close-popup
@ -463,8 +449,6 @@ async function create() {
</div> </div>
</template> </template>
</FormModel> </FormModel>
</QCard>
</div>
<QDialog ref="editDmsRef"> <QDialog ref="editDmsRef">
<QCard> <QCard>
<QCardSection class="q-pb-none"> <QCardSection class="q-pb-none">
@ -691,13 +675,12 @@ async function create() {
</QDialog> </QDialog>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.column {
.q-card {
width: 100%;
max-width: 60em;
}
}
@media (max-width: $breakpoint-xs) { @media (max-width: $breakpoint-xs) {
.column {
.row:not(:last-child) {
flex-direction: column;
}
}
.q-dialog { .q-dialog {
.q-card { .q-card {
&__section:not(:first-child) { &__section:not(:first-child) {
@ -714,7 +697,7 @@ async function create() {
supplierFk: Supplier supplierFk: Supplier
es: es:
supplierFk: Proveedor supplierFk: Proveedor
Supplier Ref: Ref. proveedor Supplier ref: Ref. proveedor
Expedition date: Fecha expedición Expedition date: Fecha expedición
Operation date: Fecha operación Operation date: Fecha operación
Undeductible VAT: Iva no deducible Undeductible VAT: Iva no deducible

View File

@ -0,0 +1,24 @@
/// <reference types="cypress" />
describe('InvoiceInBasicData', () => {
const selects = '.q-form .q-select';
const appendBtns = 'label button';
const saveBtn = '.q-btn-group > .q-btn--standard > .q-btn__content > .q-icon';
beforeEach(() => {
cy.login('developer');
cy.visit(`/#/invoice-in/1/basic-data`);
});
it('should edit the provideer and supplier ref', () => {
cy.get(selects).eq(0).click();
cy.get(selects).eq(0).type('Bros');
cy.get(selects).eq(0).type('{enter}');
cy.get(appendBtns).eq(0).click();
cy.get('input').eq(2).type(4739);
cy.get(saveBtn).click();
cy.get(`${selects} input`).eq(0).invoke('val').should('eq', 'Bros nick');
cy.get('input').eq(2).invoke('val').should('eq', 4739);
});
});

View File

@ -23,5 +23,6 @@ describe('InvoiceInList', () => {
it('should open the details', () => { it('should open the details', () => {
cy.get(firstDetailBtn).click(); cy.get(firstDetailBtn).click();
cy.get(summaryHeaders).eq(1).contains('Basic Data'); cy.get(summaryHeaders).eq(1).contains('Basic Data');
cy.get(summaryHeaders).eq(5).contains('Vat');
}); });
}); });

View File

@ -0,0 +1,46 @@
import { vi, describe, expect, it, beforeAll } from 'vitest';
import { createWrapper, axios } from 'app/test/vitest/helper';
import InvoiceInBasicData from 'src/pages/InvoiceIn/Card/InvoiceInBasicData.vue';
describe('InvoiceInBasicData', () => {
let vm;
beforeAll(() => {
vm = createWrapper(InvoiceInBasicData, {
global: {
stubs: [],
mocks: {
fetch: vi.fn(),
},
},
}).vm;
});
it('should throw an error when data is empty', async () => {
vi.spyOn(axios, 'post').mockResolvedValue({ data: [] });
vi.spyOn(vm.quasar, 'notify');
await vm.edit();
expect(vm.quasar.notify).toHaveBeenCalledWith(
expect.objectContaining({
message: `The company can't be empty`,
type: 'negative',
})
);
});
it('should throw an error when data is empty', async () => {
vi.spyOn(axios, 'post').mockResolvedValue({ data: [] });
vi.spyOn(vm.quasar, 'notify');
await vm.create();
expect(vm.quasar.notify).toHaveBeenCalledWith(
expect.objectContaining({
message: `The company can't be empty`,
type: 'negative',
})
);
});
});