Merge branch 'dev' into Fix-EntrySummary
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
582b4f68e0
|
@ -0,0 +1,56 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import EditForm from 'components/EditTableCellValueForm.vue';
|
||||
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
const fieldA = 'fieldA';
|
||||
const fieldB = 'fieldB';
|
||||
|
||||
describe('EditForm', () => {
|
||||
let vm;
|
||||
const mockRows = [
|
||||
{ id: 1, itemFk: 101 },
|
||||
{ id: 2, itemFk: 102 },
|
||||
];
|
||||
const mockFieldsOptions = [
|
||||
{ label: 'Field A', field: fieldA, component: 'input', attrs: {} },
|
||||
{ label: 'Field B', field: fieldB, component: 'date', attrs: {} },
|
||||
];
|
||||
const editUrl = '/api/edit';
|
||||
|
||||
beforeAll(() => {
|
||||
vi.spyOn(axios, 'post').mockResolvedValue({ status: 200 });
|
||||
vm = createWrapper(EditForm, {
|
||||
props: {
|
||||
rows: mockRows,
|
||||
fieldsOptions: mockFieldsOptions,
|
||||
editUrl,
|
||||
},
|
||||
}).vm;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it('should call axios.post with the correct parameters in the payload', async () => {
|
||||
const selectedField = { field: fieldA, component: 'input', attrs: {} };
|
||||
const newValue = 'Test Value';
|
||||
|
||||
vm.selectedField = selectedField;
|
||||
vm.newValue = newValue;
|
||||
|
||||
await vm.onSubmit();
|
||||
|
||||
const payload = axios.post.mock.calls[0][1];
|
||||
|
||||
expect(axios.post).toHaveBeenCalledWith(editUrl, expect.any(Object));
|
||||
expect(payload.field).toEqual(fieldA);
|
||||
expect(payload.newValue).toEqual(newValue);
|
||||
|
||||
expect(payload.lines).toEqual(expect.arrayContaining(mockRows));
|
||||
|
||||
expect(vm.isLoading).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -84,6 +84,7 @@ const columns = computed(() => [
|
|||
label: t('Creation date'),
|
||||
format: ({ created }) => toDateHourMin(created),
|
||||
cardVisible: true,
|
||||
style: 'color: var(--vn-label-color)',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
|
|
|
@ -59,7 +59,7 @@ const columns = computed(() => [
|
|||
},
|
||||
{
|
||||
label: t('basicData.item'),
|
||||
name: 'packagingItemFk',
|
||||
name: 'longName',
|
||||
align: 'left',
|
||||
cardVisible: true,
|
||||
columnFilter: {
|
||||
|
@ -321,12 +321,18 @@ onMounted(async () => {
|
|||
"
|
||||
order="created DESC"
|
||||
>
|
||||
<template #column-packagingItemFk="{ row }">
|
||||
<template #column-freightItemName="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.packagingItemFk }}
|
||||
{{ row.freightItemName }}
|
||||
<ItemDescriptorProxy :id="row.packagingItemFk" />
|
||||
</span>
|
||||
</template>
|
||||
<template #column-longName="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.longName }}
|
||||
<ItemDescriptorProxy :id="row.itemFk" />
|
||||
</span>
|
||||
</template>
|
||||
</VnTable>
|
||||
<QDialog ref="newTicketDialogRef" transition-show="scale" transition-hide="scale">
|
||||
<ExpeditionNewTicket
|
||||
|
|
Loading…
Reference in New Issue