diff --git a/src/pages/Travel/Card/TravelThermographs.vue b/src/pages/Travel/Card/TravelThermographs.vue index fddbda2a1..62cd7ae27 100644 --- a/src/pages/Travel/Card/TravelThermographs.vue +++ b/src/pages/Travel/Card/TravelThermographs.vue @@ -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) => { diff --git a/src/pages/Travel/Card/TravelThermographsForm.vue b/src/pages/Travel/Card/TravelThermographsForm.vue index 71a4a8074..db9f60378 100644 --- a/src/pages/Travel/Card/TravelThermographsForm.vue +++ b/src/pages/Travel/Card/TravelThermographsForm.vue @@ -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) { diff --git a/test/cypress/integration/entry/entryList.spec.js b/test/cypress/integration/entry/entryList.spec.js index fc76f6d87..6fe91792d 100644 --- a/test/cypress/integration/entry/entryList.spec.js +++ b/test/cypress/integration/entry/entryList.spec.js @@ -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'); diff --git a/test/cypress/integration/travel/travelThermographs.spec.js b/test/cypress/integration/travel/travelThermographs.spec.js new file mode 100644 index 000000000..0dde38abe --- /dev/null +++ b/test/cypress/integration/travel/travelThermographs.spec.js @@ -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'); + }); +}); \ No newline at end of file