5528-entry.latest-buys_fixEditBuys #1611

Merged
vicent merged 6 commits from 5528-entry.latest-buys_fixEditBuys into dev 2023-06-22 10:54:00 +00:00
2 changed files with 31 additions and 2 deletions

View File

@ -75,7 +75,7 @@ module.exports = Self => {
value[field] = newValue;
if (filter) {
ctx.args.filter = {where: filter, limit: null};
ctx.args = {where: filter, limit: null};
lines = await models.Buy.latestBuysFilter(ctx, null, myOptions);
}

View File

@ -53,7 +53,36 @@ describe('Buy editLatestsBuys()', () => {
const options = {transaction: tx};
try {
const filter = {'i.typeFk': 1};
const filter = {'categoryFk': 1, 'tags': []};
const ctx = {
args: {
filter: filter
},
req: {accessToken: {userId: 1}}
};
const field = 'size';
const newValue = 88;
await models.Buy.editLatestBuys(ctx, field, newValue, null, filter, options);
const [result] = await models.Buy.latestBuysFilter(ctx, null, options);
expect(result[field]).toEqual(newValue);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should change the value of a given column for filter tags', async() => {
const tx = await models.Buy.beginTransaction({});
const options = {transaction: tx};
try {
const filter = {'tags': [{tagFk: 1, value: 'Brown'}]};
const ctx = {
args: {
filter: filter