Merge pull request '5528-entry.latest-buys_fixEditBuys' (!1611) from 5528-entry.latest-buys_fixEditBuys into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #1611
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
Vicent Llopis 2023-06-22 10:53:57 +00:00
commit 2d21da1faa
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