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 thermographPaginateRef = ref();
|
||||
const saveType= ref('create');
|
||||
const warehouses = ref([]);
|
||||
const showForm = ref(false);
|
||||
const formData = ref({});
|
||||
|
@ -49,6 +50,12 @@ const thermographFilter = {
|
|||
|
||||
const TableColumns = computed(() => {
|
||||
return [
|
||||
{
|
||||
label: t('globals.id'),
|
||||
field: 'id',
|
||||
name: 'id',
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
label: t('globals.code'),
|
||||
field: 'thermographFk',
|
||||
|
@ -175,6 +182,7 @@ const removeThermograph = async (id) => {
|
|||
() => {
|
||||
formData = row;
|
||||
showForm = !showForm;
|
||||
saveType = 'update';
|
||||
}
|
||||
"
|
||||
>
|
||||
|
@ -201,6 +209,7 @@ const removeThermograph = async (id) => {
|
|||
@click="
|
||||
() => {
|
||||
formData = { dms: {} };
|
||||
saveType = 'create';
|
||||
showForm = !showForm;
|
||||
}
|
||||
"
|
||||
|
@ -214,6 +223,7 @@ const removeThermograph = async (id) => {
|
|||
<TravelThermographsForm
|
||||
:form-initial-data="formData"
|
||||
:agencyModeFk="travel?.agencyModeFk"
|
||||
:save-type="saveType"
|
||||
/>
|
||||
</QDialog>
|
||||
</template>
|
||||
|
|
|
@ -37,6 +37,10 @@ const $props = defineProps({
|
|||
type: Number,
|
||||
default: undefined,
|
||||
},
|
||||
saveType: {
|
||||
type: String,
|
||||
default: 'create',
|
||||
}
|
||||
});
|
||||
|
||||
onBeforeMount(async () => {
|
||||
|
@ -72,8 +76,7 @@ async function setCreateDefaultParams() {
|
|||
}
|
||||
|
||||
async function onSubmit(data) {
|
||||
const dataParsed = {
|
||||
travelThermographFk: data.thermographFk,
|
||||
const basicData = {
|
||||
state: data.result,
|
||||
reference: data.dms.reference,
|
||||
warehouseId: +data.warehouseFk,
|
||||
|
@ -87,6 +90,19 @@ async function onSubmit(data) {
|
|||
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();
|
||||
if (Array.isArray(data.files)) {
|
||||
dataParsed.hasFileAttached = true;
|
||||
|
@ -107,7 +123,6 @@ async function onSubmit(data) {
|
|||
}
|
||||
|
||||
async function onThermographCreated(newThermograph, data) {
|
||||
await fetchTravelThermographsRef.value.fetch();
|
||||
data = {
|
||||
...data,
|
||||
...newThermograph,
|
||||
|
@ -177,8 +192,9 @@ async function onThermographCreated(newThermograph, data) {
|
|||
<template #form>
|
||||
<CreateThermographForm
|
||||
@on-data-saved="
|
||||
(newThermograph) =>
|
||||
onThermographCreated(newThermograph, data)
|
||||
(newThermograph) =>{
|
||||
onThermographCreated(newThermograph, data);
|
||||
}
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -6,11 +6,14 @@ describe('EntryList', () => {
|
|||
cy.visit(`/#/entry/list`);
|
||||
});
|
||||
|
||||
it('View popup summary', () => {
|
||||
it('Should create and delete entry', () => {
|
||||
cy.createEntry();
|
||||
cy.get('.q-notification__message').eq(0).should('have.text', 'Data created');
|
||||
cy.waitForElement('[data-cy="entry-buys"]');
|
||||
cy.deleteEntry();
|
||||
});
|
||||
|
||||
it('View popup summary', () => {
|
||||
cy.typeSearchbar('{enter}');
|
||||
cy.get('button[title="Summary"]').eq(1).should('be.visible').click();
|
||||
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