fix: refs #7527 create and edit functionality for thermographs, update tests
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
37773f2ce0
commit
d5960617f4
|
@ -23,6 +23,7 @@ const { notify } = useNotify();
|
||||||
|
|
||||||
const travel = computed(() => useArrayData('Travel').store.data);
|
const travel = computed(() => useArrayData('Travel').store.data);
|
||||||
const thermographPaginateRef = ref();
|
const thermographPaginateRef = ref();
|
||||||
|
const saveType= ref('create');
|
||||||
const warehouses = ref([]);
|
const warehouses = ref([]);
|
||||||
const showForm = ref(false);
|
const showForm = ref(false);
|
||||||
const formData = ref({});
|
const formData = ref({});
|
||||||
|
@ -49,6 +50,12 @@ const thermographFilter = {
|
||||||
|
|
||||||
const TableColumns = computed(() => {
|
const TableColumns = computed(() => {
|
||||||
return [
|
return [
|
||||||
|
{
|
||||||
|
label: t('globals.id'),
|
||||||
|
field: 'id',
|
||||||
|
name: 'id',
|
||||||
|
visible: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: t('globals.code'),
|
label: t('globals.code'),
|
||||||
field: 'thermographFk',
|
field: 'thermographFk',
|
||||||
|
@ -175,6 +182,7 @@ const removeThermograph = async (id) => {
|
||||||
() => {
|
() => {
|
||||||
formData = row;
|
formData = row;
|
||||||
showForm = !showForm;
|
showForm = !showForm;
|
||||||
|
saveType = 'update';
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
@ -201,6 +209,7 @@ const removeThermograph = async (id) => {
|
||||||
@click="
|
@click="
|
||||||
() => {
|
() => {
|
||||||
formData = { dms: {} };
|
formData = { dms: {} };
|
||||||
|
saveType = 'create';
|
||||||
showForm = !showForm;
|
showForm = !showForm;
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
@ -214,6 +223,7 @@ const removeThermograph = async (id) => {
|
||||||
<TravelThermographsForm
|
<TravelThermographsForm
|
||||||
:form-initial-data="formData"
|
:form-initial-data="formData"
|
||||||
:agencyModeFk="travel?.agencyModeFk"
|
:agencyModeFk="travel?.agencyModeFk"
|
||||||
|
:save-type="saveType"
|
||||||
/>
|
/>
|
||||||
</QDialog>
|
</QDialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -37,6 +37,10 @@ const $props = defineProps({
|
||||||
type: Number,
|
type: Number,
|
||||||
default: undefined,
|
default: undefined,
|
||||||
},
|
},
|
||||||
|
saveType: {
|
||||||
|
type: String,
|
||||||
|
default: 'create',
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
|
@ -72,8 +76,7 @@ async function setCreateDefaultParams() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onSubmit(data) {
|
async function onSubmit(data) {
|
||||||
const dataParsed = {
|
const basicData = {
|
||||||
travelThermographFk: data.thermographFk,
|
|
||||||
state: data.result,
|
state: data.result,
|
||||||
reference: data.dms.reference,
|
reference: data.dms.reference,
|
||||||
warehouseId: +data.warehouseFk,
|
warehouseId: +data.warehouseFk,
|
||||||
|
@ -87,6 +90,19 @@ async function onSubmit(data) {
|
||||||
agencyModeFk: +data.agencyModeFk,
|
agencyModeFk: +data.agencyModeFk,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateData = {
|
||||||
|
travelThermographFk: data.id,
|
||||||
|
thermographFk: data.thermographFk,
|
||||||
|
}
|
||||||
|
|
||||||
|
const createData = {
|
||||||
|
travelThermographFk: data.thermographFk
|
||||||
|
}
|
||||||
|
|
||||||
|
const aditionalData = $props.saveType === 'create' ? createData : updateData
|
||||||
|
|
||||||
|
const dataParsed = {...basicData, ...aditionalData };
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
if (Array.isArray(data.files)) {
|
if (Array.isArray(data.files)) {
|
||||||
dataParsed.hasFileAttached = true;
|
dataParsed.hasFileAttached = true;
|
||||||
|
@ -107,7 +123,6 @@ async function onSubmit(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onThermographCreated(newThermograph, data) {
|
async function onThermographCreated(newThermograph, data) {
|
||||||
await fetchTravelThermographsRef.value.fetch();
|
|
||||||
data = {
|
data = {
|
||||||
...data,
|
...data,
|
||||||
...newThermograph,
|
...newThermograph,
|
||||||
|
@ -177,8 +192,9 @@ async function onThermographCreated(newThermograph, data) {
|
||||||
<template #form>
|
<template #form>
|
||||||
<CreateThermographForm
|
<CreateThermographForm
|
||||||
@on-data-saved="
|
@on-data-saved="
|
||||||
(newThermograph) =>
|
(newThermograph) =>{
|
||||||
onThermographCreated(newThermograph, data)
|
onThermographCreated(newThermograph, data);
|
||||||
|
}
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -6,11 +6,14 @@ describe('EntryList', () => {
|
||||||
cy.visit(`/#/entry/list`);
|
cy.visit(`/#/entry/list`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('View popup summary', () => {
|
it('Should create and delete entry', () => {
|
||||||
cy.createEntry();
|
cy.createEntry();
|
||||||
cy.get('.q-notification__message').eq(0).should('have.text', 'Data created');
|
cy.get('.q-notification__message').eq(0).should('have.text', 'Data created');
|
||||||
cy.waitForElement('[data-cy="entry-buys"]');
|
cy.waitForElement('[data-cy="entry-buys"]');
|
||||||
cy.deleteEntry();
|
cy.deleteEntry();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('View popup summary', () => {
|
||||||
cy.typeSearchbar('{enter}');
|
cy.typeSearchbar('{enter}');
|
||||||
cy.get('button[title="Summary"]').eq(1).should('be.visible').click();
|
cy.get('button[title="Summary"]').eq(1).should('be.visible').click();
|
||||||
cy.dataCy('entry-summary').should('be.visible');
|
cy.dataCy('entry-summary').should('be.visible');
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
describe('TravelThermographs', () => {
|
||||||
|
const selectors = {
|
||||||
|
fileInput: 'input[type="file"]',
|
||||||
|
editBtn: 'vnTableCell_editFile',
|
||||||
|
removeBtn: 'vnTableCell_removeThermograph',
|
||||||
|
temperatureField: 'vnTableCell_temperatureFk',
|
||||||
|
}
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.login('developer');
|
||||||
|
cy.visit(`/#/travel/10/thermographs`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should create thermograph', () => {
|
||||||
|
const data = {
|
||||||
|
Thermograph: { val: 138350-0, type: 'select' },
|
||||||
|
State: { val: 'Ok'},
|
||||||
|
Company: { val: 'VNL', type: 'select' },
|
||||||
|
Temperature: { val: 'Cool', type: 'select' },
|
||||||
|
Max: { val: '10' },
|
||||||
|
Min: { val: '5' },
|
||||||
|
};
|
||||||
|
|
||||||
|
cy.addBtnClick();
|
||||||
|
cy.fillInForm(data);
|
||||||
|
cy.get(selectors.fileInput).selectFile('test/cypress/fixtures/image.jpg', {
|
||||||
|
force: true,
|
||||||
|
});
|
||||||
|
cy.dataCy('FormModelPopup_save').click();
|
||||||
|
cy.checkNotification('Thermograph created');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should edit thermograph', () => {
|
||||||
|
cy.dataCy(selectors.editBtn).eq(0).click();
|
||||||
|
const updateData = {
|
||||||
|
Temperature: { val: 'Warm', type: 'select' },
|
||||||
|
}
|
||||||
|
cy.fillInForm(updateData);
|
||||||
|
cy.dataCy('FormModelPopup_save').click();
|
||||||
|
cy.dataCy(selectors.temperatureField).invoke('text').should('contain', 'warm');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should delete thermograph', () => {
|
||||||
|
cy.dataCy(selectors.removeBtn).eq(0).click();
|
||||||
|
cy.clickConfirm();
|
||||||
|
cy.checkNotification('Thermograph removed');
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue