From 06ac8f9910991c4991d3c10359233e78af4ca02c Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 28 Mar 2023 09:41:39 +0200 Subject: [PATCH 01/10] refs #5275 fix: si tenia valor el minPrice el checkbox siempre se marcaba. El checkbox no funcionaba cuando le pulsabas --- modules/item/back/methods/fixed-price/upsertFixedPrice.js | 2 +- modules/item/front/fixed-price/index.html | 3 ++- modules/item/front/fixed-price/index.js | 2 -- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/item/back/methods/fixed-price/upsertFixedPrice.js b/modules/item/back/methods/fixed-price/upsertFixedPrice.js index eb3eec1bd..edbd23604 100644 --- a/modules/item/back/methods/fixed-price/upsertFixedPrice.js +++ b/modules/item/back/methods/fixed-price/upsertFixedPrice.js @@ -87,7 +87,7 @@ module.exports = Self => { await targetItem.updateAttributes({ minPrice: args.minPrice, - hasMinPrice: args.minPrice ? true : false + hasMinPrice: args.hasMinPrice }, myOptions); const itemFields = [ diff --git a/modules/item/front/fixed-price/index.html b/modules/item/front/fixed-price/index.html index ce7cefe7a..43fe89552 100644 --- a/modules/item/front/fixed-price/index.html +++ b/modules/item/front/fixed-price/index.html @@ -140,7 +140,8 @@ + ng-model="price.hasMinPrice" + on-change="$ctrl.upsertPrice(price)"> Date: Tue, 28 Mar 2023 10:30:02 +0200 Subject: [PATCH 02/10] =?UTF-8?q?refs=20#5275=20fix:=20al=20a=C3=B1adir=20?= =?UTF-8?q?art=C3=ADculo=20desde=20cero=20se=20muestra=20el=20nombre=20y?= =?UTF-8?q?=20se=20establecen=20las=20fechas=20por=20defecto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../back/methods/fixed-price/upsertFixedPrice.js | 2 +- modules/item/front/fixed-price/index.html | 3 ++- modules/item/front/fixed-price/index.js | 12 +++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/item/back/methods/fixed-price/upsertFixedPrice.js b/modules/item/back/methods/fixed-price/upsertFixedPrice.js index edbd23604..d815ed426 100644 --- a/modules/item/back/methods/fixed-price/upsertFixedPrice.js +++ b/modules/item/back/methods/fixed-price/upsertFixedPrice.js @@ -87,7 +87,7 @@ module.exports = Self => { await targetItem.updateAttributes({ minPrice: args.minPrice, - hasMinPrice: args.hasMinPrice + hasMinPrice: args.hasMinPrice ? args.hasMinPrice : false }, myOptions); const itemFields = [ diff --git a/modules/item/front/fixed-price/index.html b/modules/item/front/fixed-price/index.html index 43fe89552..584c4b14e 100644 --- a/modules/item/front/fixed-price/index.html +++ b/modules/item/front/fixed-price/index.html @@ -64,6 +64,7 @@ - {{price.name}} + {{itemFk.selection.name}}

{{price.subName}}

diff --git a/modules/item/front/fixed-price/index.js b/modules/item/front/fixed-price/index.js index 2eb53cfbd..1a7bf6466 100644 --- a/modules/item/front/fixed-price/index.js +++ b/modules/item/front/fixed-price/index.js @@ -36,7 +36,17 @@ export default class Controller extends Section { if (!this.$.model.data || this.$.model.data.length == 0) { this.$.model.data = []; this.$.model.proxiedData = []; - this.$.model.insert({}); + + const today = Date.vnNew(); + + const millisecsInDay = 86400000; + const daysInWeek = 7; + const nextWeek = new Date(today.getTime() + daysInWeek * millisecsInDay); + + this.$.model.insert({ + started: today, + ended: nextWeek + }); return; } -- 2.40.1 From b4e04fcdad29c33815329b4c7492bb69cc8eff17 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 28 Mar 2023 14:40:14 +0200 Subject: [PATCH 03/10] refs #5275 feat: colorear fechas --- modules/item/front/fixed-price/index.html | 24 +++++++----- modules/item/front/fixed-price/index.js | 22 +++++++++++ modules/item/front/fixed-price/style.scss | 46 +++++++++++++++-------- 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/modules/item/front/fixed-price/index.html b/modules/item/front/fixed-price/index.html index 584c4b14e..0bc53aa3f 100644 --- a/modules/item/front/fixed-price/index.html +++ b/modules/item/front/fixed-price/index.html @@ -152,18 +152,22 @@
- - + + + + - - + + + + 0) return 'warning'; + } + add() { if (!this.$.model.data || this.$.model.data.length == 0) { this.$.model.data = []; diff --git a/modules/item/front/fixed-price/style.scss b/modules/item/front/fixed-price/style.scss index ba3878dba..d1f968c37 100644 --- a/modules/item/front/fixed-price/style.scss +++ b/modules/item/front/fixed-price/style.scss @@ -1,20 +1,34 @@ @import "variables"; -smart-table table{ - [shrink-field]{ - width: 80px; - max-width: 80px; +vn-fixed-price{ + smart-table table{ + [shrink-field]{ + width: 80px; + max-width: 80px; + } + [shrink-field-expand]{ + width: 150px; + max-width: 150px; + } } - [shrink-field-expand]{ - width: 150px; - max-width: 150px; + + .minPrice { + align-items: center; + text-align: center; + vn-input-number { + width: 90px; + max-width: 90px; + } + } + + smart-table table tbody > * > td .chip { + padding: 0px; + } + + smart-table table tbody > * > td .chip.warning { + color: $color-font-bg + } + + .vn-field > .container > .infix > .control > input { + color: inherit; } } - -.minPrice { - align-items: center; - text-align: center; - vn-input-number { - width: 90px; - max-width: 90px; - } -} \ No newline at end of file -- 2.40.1 From c53c54b6cd1f18b8c9c0f16e7c72272f4274b8ed Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 28 Mar 2023 14:59:08 +0200 Subject: [PATCH 04/10] refs #5275 feat: modificar masivamente --- modules/item/front/fixed-price/index.html | 113 ++++++++++++++++--- modules/item/front/fixed-price/index.js | 99 +++++++++++++++- modules/item/front/fixed-price/locale/es.yml | 2 + modules/item/front/fixed-price/style.scss | 12 ++ 4 files changed, 209 insertions(+), 17 deletions(-) diff --git a/modules/item/front/fixed-price/index.html b/modules/item/front/fixed-price/index.html index 0bc53aa3f..af41b1bc8 100644 --- a/modules/item/front/fixed-price/index.html +++ b/modules/item/front/fixed-price/index.html @@ -31,15 +31,21 @@ + - + + - +
+ + + Item ID Description - Warehouse - Grouping price @@ -57,11 +63,21 @@ Ended + Warehouse +
+ + + - - - - {{price.rate2 | currency: 'EUR':2}} + + {{price.rate2 | currency: 'EUR':2}} + - {{price.rate3 | currency: 'EUR':2}} + + {{price.rate3 | currency: 'EUR':2}} + @@ -169,6 +180,15 @@ + + + + +
+ + + + +
+ + + Edit + + {{::$ctrl.totalChecked}} + + buy(s) + + + + + + + + + + + + + + + + + + + diff --git a/modules/item/front/fixed-price/index.js b/modules/item/front/fixed-price/index.js index 0decf7275..eacd54ff6 100644 --- a/modules/item/front/fixed-price/index.js +++ b/modules/item/front/fixed-price/index.js @@ -5,6 +5,9 @@ import './style.scss'; export default class Controller extends Section { constructor($element, $) { super($element, $); + this.editedColumn; + this.checkAll = false; + this.checkedFixedPrices = []; this.smartTableOptions = { activeButtons: { @@ -30,6 +33,98 @@ export default class Controller extends Section { } ] }; + + this.filterParams = { + warehouseFk: this.vnConfig.warehouseFk + }; + } + + getFilterParams() { + return { + warehouseFk: this.vnConfig.warehouseFk + }; + } + + get columns() { + if (this._columns) return this._columns; + + this._columns = [ + {field: 'rate2', displayName: this.$t('Grouping price')}, + {field: 'rate3', displayName: this.$t('Packing price')}, + {field: 'hasMinPrice', displayName: this.$t('Has min price')}, + {field: 'minPrice', displayName: this.$t('Min price')}, + {field: 'started', displayName: this.$t('Started')}, + {field: 'ended', displayName: this.$t('Ended')}, + {field: 'warehouseFk', displayName: this.$t('Warehouse')} + ]; + + return this._columns; + } + + get checked() { + const fixedPrices = this.$.model.data || []; + const checkedBuys = []; + for (let fixedPrice of fixedPrices) { + if (fixedPrice.checked) + checkedBuys.push(fixedPrice); + } + + return checkedBuys; + } + + uncheck() { + this.checkAll = false; + this.checkedFixedPrices = []; + } + + get totalChecked() { + if (this.checkedDummyCount) + return this.checkedDummyCount; + + return this.checked.length; + } + + saveChecked(fixedPriceId) { + const index = this.checkedFixedPrices.indexOf(fixedPriceId); + if (index !== -1) + return this.checkedFixedPrices.splice(index, 1); + return this.checkedFixedPrices.push(fixedPriceId); + } + + reCheck() { + if (!this.$.model.data) return; + if (!this.checkedFixedPrices.length) return; + + this.$.model.data.forEach(fixedPrice => { + if (this.checkedFixedPrices.includes(fixedPrice.id)) + fixedPrice.checked = true; + }); + } + + onEditAccept() { + for (const fixedPrice of this.checked) { + fixedPrice[this.editedColumn.field] = this.editedColumn.newValue; + console.log(fixedPrice); + + this.upsertPrice(fixedPrice, false); + } + + // if (this.checkedDummyCount && this.checkedDummyCount > 0) { + // const params = {}; + // if (this.$.model.userParams) { + // const userParams = this.$.model.userParams; + // for (let param in userParams) { + // let newParam = this.exprBuilder(param, userParams[param]); + // if (!newParam) + // newParam = {[param]: userParams[param]}; + // Object.assign(params, newParam); + // } + // } + // if (this.$.model.userFilter) + // Object.assign(params, this.$.model.userFilter.where); + + // data.filter = params; + // } } isBigger(date) { @@ -98,8 +193,8 @@ export default class Controller extends Section { if (resetMinPrice) delete price['minPrice']; - let requiredFields = ['itemFk', 'started', 'ended', 'rate2', 'rate3']; - for (let field of requiredFields) + const requiredFields = ['itemFk', 'started', 'ended', 'rate2', 'rate3']; + for (const field of requiredFields) if (price[field] == undefined) return; const query = 'FixedPrices/upsertFixedPrice'; diff --git a/modules/item/front/fixed-price/locale/es.yml b/modules/item/front/fixed-price/locale/es.yml index 6bdfcb678..6dacf96c9 100644 --- a/modules/item/front/fixed-price/locale/es.yml +++ b/modules/item/front/fixed-price/locale/es.yml @@ -3,3 +3,5 @@ Search prices by item ID or code: Buscar por ID de artículo o código Search fixed prices: Buscar precios fijados Add fixed price: Añadir precio fijado This row will be removed: Esta linea se eliminará +Edit fixed price(s): Editar precio(s) fijado(s) +Has min price: Tiene precio mínimo diff --git a/modules/item/front/fixed-price/style.scss b/modules/item/front/fixed-price/style.scss index d1f968c37..97ceaf7cd 100644 --- a/modules/item/front/fixed-price/style.scss +++ b/modules/item/front/fixed-price/style.scss @@ -24,6 +24,12 @@ vn-fixed-price{ padding: 0px; } + smart-table table tbody > * > td{ + padding: 0px; + padding-left: 5px; + padding-right: 5px; + } + smart-table table tbody > * > td .chip.warning { color: $color-font-bg } @@ -31,4 +37,10 @@ vn-fixed-price{ .vn-field > .container > .infix > .control > input { color: inherit; } + + vn-input-number.inactive{ + input { + color: $color-font-light !important; + } + } } -- 2.40.1 From 3b615d98796b7e95445f77bf3b72233012df6d82 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 29 Mar 2023 09:11:40 +0200 Subject: [PATCH 05/10] refs #5275 fix: actualiza correctamete los elementos del checkedDummy --- .../methods/fixed-price/editFixedPrice.js | 96 +++++++++++++++++++ .../item/back/methods/fixed-price/filter.js | 3 +- modules/item/back/models/fixed-price.js | 1 + modules/item/front/fixed-price/index.js | 49 ++++++---- 4 files changed, 127 insertions(+), 22 deletions(-) create mode 100644 modules/item/back/methods/fixed-price/editFixedPrice.js diff --git a/modules/item/back/methods/fixed-price/editFixedPrice.js b/modules/item/back/methods/fixed-price/editFixedPrice.js new file mode 100644 index 000000000..13e0fc41b --- /dev/null +++ b/modules/item/back/methods/fixed-price/editFixedPrice.js @@ -0,0 +1,96 @@ +module.exports = Self => { + Self.remoteMethodCtx('editFixedPrice', { + description: 'Updates a column for one or more fixed price', + accessType: 'WRITE', + accepts: [{ + arg: 'field', + type: 'string', + required: true, + description: `the column to edit` + }, + { + arg: 'newValue', + type: 'any', + required: true, + description: `The new value to save` + }, + { + arg: 'lines', + type: ['object'], + required: true, + description: `the buys which will be modified` + }, + { + arg: 'filter', + type: 'object', + description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string' + }], + returns: { + type: 'object', + root: true + }, + http: { + path: `/editFixedPrice`, + verb: 'POST' + } + }); + + Self.editFixedPrice = async(ctx, field, newValue, lines, filter, options) => { + let tx; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + let modelName; + let identifier; + + switch (field) { + case 'hasMinPrice': + case 'minPrice': + modelName = 'Item'; + identifier = 'itemFk'; + break; + case 'rate2': + case 'rate3': + case 'started': + case 'ended': + case 'warehouseFk': + modelName = 'FixedPrice'; + identifier = 'id'; + } + + const models = Self.app.models; + const model = models[modelName]; + try { + const promises = []; + const value = {}; + value[field] = newValue; + + if (filter) { + filter = {where: filter}; + lines = await models.FixedPrice.filter(ctx, filter, myOptions); + } + + const targets = lines.map(line => { + return line[identifier]; + }); + for (let target of targets) + promises.push(model.upsertWithWhere({id: target}, value, myOptions)); + + const result = await Promise.all(promises); + + if (tx) await tx.commit(); + + return result; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/item/back/methods/fixed-price/filter.js b/modules/item/back/methods/fixed-price/filter.js index c15ae67f0..9c91886c1 100644 --- a/modules/item/back/methods/fixed-price/filter.js +++ b/modules/item/back/methods/fixed-price/filter.js @@ -184,8 +184,7 @@ module.exports = Self => { } } - stmt.merge(conn.makeWhere(filter.where)); - stmt.merge(conn.makePagination(filter)); + stmt.merge(conn.makeSuffix(filter)); const fixedPriceIndex = stmts.push(stmt) - 1; const sql = ParameterizedSQL.join(stmts, ';'); diff --git a/modules/item/back/models/fixed-price.js b/modules/item/back/models/fixed-price.js index 91010805f..45f8d79ef 100644 --- a/modules/item/back/models/fixed-price.js +++ b/modules/item/back/models/fixed-price.js @@ -2,4 +2,5 @@ module.exports = Self => { require('../methods/fixed-price/filter')(Self); require('../methods/fixed-price/upsertFixedPrice')(Self); require('../methods/fixed-price/getRate2')(Self); + require('../methods/fixed-price/editFixedPrice')(Self); }; diff --git a/modules/item/front/fixed-price/index.js b/modules/item/front/fixed-price/index.js index eacd54ff6..a39cd6602 100644 --- a/modules/item/front/fixed-price/index.js +++ b/modules/item/front/fixed-price/index.js @@ -102,29 +102,38 @@ export default class Controller extends Section { } onEditAccept() { - for (const fixedPrice of this.checked) { - fixedPrice[this.editedColumn.field] = this.editedColumn.newValue; - console.log(fixedPrice); + const rowsToEdit = []; + for (let row of this.checked) + rowsToEdit.push({id: row.id, itemFk: row.itemFk}); - this.upsertPrice(fixedPrice, false); + const data = { + field: this.editedColumn.field, + newValue: this.editedColumn.newValue, + lines: rowsToEdit + }; + + if (this.checkedDummyCount && this.checkedDummyCount > 0) { + const params = {}; + if (this.$.model.userParams) { + const userParams = this.$.model.userParams; + for (let param in userParams) { + let newParam = this.exprBuilder(param, userParams[param]); + if (!newParam) + newParam = {[param]: userParams[param]}; + Object.assign(params, newParam); + } + } + if (this.$.model.userFilter) + Object.assign(params, this.$.model.userFilter.where); + + data.filter = params; } - // if (this.checkedDummyCount && this.checkedDummyCount > 0) { - // const params = {}; - // if (this.$.model.userParams) { - // const userParams = this.$.model.userParams; - // for (let param in userParams) { - // let newParam = this.exprBuilder(param, userParams[param]); - // if (!newParam) - // newParam = {[param]: userParams[param]}; - // Object.assign(params, newParam); - // } - // } - // if (this.$.model.userFilter) - // Object.assign(params, this.$.model.userFilter.where); - - // data.filter = params; - // } + return this.$http.post('FixedPrices/editFixedPrice', data) + .then(() => { + this.uncheck(); + this.$.model.refresh(); + }); } isBigger(date) { -- 2.40.1 From 67689695e4e8bc329800f540bcf5ad42921d9780 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 30 Mar 2023 14:29:19 +0200 Subject: [PATCH 06/10] refs #5275 filtra por defecto por el this.vnConfig.warehouseFk --- modules/item/front/fixed-price/index.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/item/front/fixed-price/index.html b/modules/item/front/fixed-price/index.html index af41b1bc8..a82fd2742 100644 --- a/modules/item/front/fixed-price/index.html +++ b/modules/item/front/fixed-price/index.html @@ -1,6 +1,7 @@ -- 2.40.1 From e97b5a9f80fa944ddf6ac553a70b3379ad66d752 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 5 Apr 2023 07:54:56 +0200 Subject: [PATCH 07/10] refs #5275 fix backTest --- .../back/methods/fixed-price/specs/upsertFixedPrice.spec.js | 6 +++--- modules/item/back/methods/fixed-price/upsertFixedPrice.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js b/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js index 86f73122d..823406500 100644 --- a/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js +++ b/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js @@ -42,7 +42,7 @@ describe('upsertFixedPrice()', () => { delete ctx.args.started; delete ctx.args.ended; - ctx.args.hasMinPrice = true; + ctx.args.hasMinPrice = false; expect(result).toEqual(jasmine.objectContaining(ctx.args)); @@ -74,7 +74,7 @@ describe('upsertFixedPrice()', () => { delete ctx.args.started; delete ctx.args.ended; - ctx.args.hasMinPrice = false; + ctx.args.hasMinPrice = true; expect(result).toEqual(jasmine.objectContaining(ctx.args)); @@ -105,7 +105,7 @@ describe('upsertFixedPrice()', () => { rate2: rate2, rate3: firstRate3, minPrice: 0, - hasMinPrice: false + hasMinPrice: true }}; // create new fixed price diff --git a/modules/item/back/methods/fixed-price/upsertFixedPrice.js b/modules/item/back/methods/fixed-price/upsertFixedPrice.js index d815ed426..edbd23604 100644 --- a/modules/item/back/methods/fixed-price/upsertFixedPrice.js +++ b/modules/item/back/methods/fixed-price/upsertFixedPrice.js @@ -87,7 +87,7 @@ module.exports = Self => { await targetItem.updateAttributes({ minPrice: args.minPrice, - hasMinPrice: args.hasMinPrice ? args.hasMinPrice : false + hasMinPrice: args.hasMinPrice }, myOptions); const itemFields = [ -- 2.40.1 From fb5969a120a58749cdd6e11da90d0656f3fe0611 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 5 Apr 2023 08:43:47 +0200 Subject: [PATCH 08/10] refs #5275 add test --- .../fixed-price/specs/editFixedPrice.spec.js | 63 ++++++++++++++ modules/item/front/fixed-price/index.spec.js | 84 +++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 modules/item/back/methods/fixed-price/specs/editFixedPrice.spec.js diff --git a/modules/item/back/methods/fixed-price/specs/editFixedPrice.spec.js b/modules/item/back/methods/fixed-price/specs/editFixedPrice.spec.js new file mode 100644 index 000000000..a5e6cd35a --- /dev/null +++ b/modules/item/back/methods/fixed-price/specs/editFixedPrice.spec.js @@ -0,0 +1,63 @@ +const models = require('vn-loopback/server/server').models; + +describe('Item editFixedPrice()', () => { + it('should change the value of a given column for the selected buys', async() => { + const tx = await models.FixedPrice.beginTransaction({}); + const options = {transaction: tx}; + + try { + const ctx = { + args: { + search: '1' + }, + req: {accessToken: {userId: 1}} + }; + + const [original] = await models.FixedPrice.filter(ctx, null, options); + + const field = 'rate2'; + const newValue = 99; + const lines = [{itemFk: original.itemFk, id: original.id}]; + + await models.FixedPrice.editFixedPrice(ctx, field, newValue, lines, null, options); + + const [result] = await models.FixedPrice.filter(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', async() => { + const tx = await models.FixedPrice.beginTransaction({}); + const options = {transaction: tx}; + + try { + const filter = {'it.categoryFk': 1}; + const ctx = { + args: { + filter: filter + }, + req: {accessToken: {userId: 1}} + }; + + const field = 'rate2'; + const newValue = 88; + + await models.FixedPrice.editFixedPrice(ctx, field, newValue, null, filter, options); + + const [result] = await models.FixedPrice.filter(ctx, null, options); + + expect(result[field]).toEqual(newValue); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/item/front/fixed-price/index.spec.js b/modules/item/front/fixed-price/index.spec.js index 42dd898b3..ae24da60b 100644 --- a/modules/item/front/fixed-price/index.spec.js +++ b/modules/item/front/fixed-price/index.spec.js @@ -12,8 +12,92 @@ describe('fixed price', () => { const $scope = $rootScope.$new(); const $element = angular.element(''); controller = $componentController('vnFixedPrice', {$element, $scope}); + controller.$ = { + model: {refresh: () => {}}, + edit: {hide: () => {}} + }; })); + describe('get columns', () => { + it(`should return a set of columns`, () => { + let result = controller.columns; + + let length = result.length; + let anyColumn = Object.keys(result[Math.floor(Math.random() * Math.floor(length))]); + + expect(anyColumn).toContain('field', 'displayName'); + }); + }); + + describe('get checked', () => { + it(`should return a set of checked lines`, () => { + controller.$.model.data = [ + {checked: true, id: 1}, + {checked: true, id: 2}, + {checked: true, id: 3}, + {checked: false, id: 4}, + ]; + + let result = controller.checked; + + expect(result.length).toEqual(3); + }); + }); + + describe('reCheck()', () => { + it(`should recheck buys`, () => { + controller.$.model.data = [ + {checked: false, id: 1}, + {checked: false, id: 2}, + {checked: false, id: 3}, + {checked: false, id: 4}, + ]; + controller.checkedFixedPrices = [1, 2]; + + controller.reCheck(); + + expect(controller.$.model.data[0].checked).toEqual(true); + expect(controller.$.model.data[1].checked).toEqual(true); + expect(controller.$.model.data[2].checked).toEqual(false); + expect(controller.$.model.data[3].checked).toEqual(false); + }); + }); + + describe('saveChecked()', () => { + it(`should check buy`, () => { + const buyCheck = 3; + controller.checkedFixedPrices = [1, 2]; + + controller.saveChecked(buyCheck); + + expect(controller.checkedFixedPrices[2]).toEqual(buyCheck); + }); + + it(`should uncheck buy`, () => { + const buyUncheck = 3; + controller.checkedFixedPrices = [1, 2, 3]; + + controller.saveChecked(buyUncheck); + + expect(controller.checkedFixedPrices[2]).toEqual(undefined); + }); + }); + + describe('onEditAccept()', () => { + it(`should perform a query to update columns`, () => { + controller.editedColumn = {field: 'my field', newValue: 'the new value'}; + const query = 'FixedPrices/editFixedPrice'; + + $httpBackend.expectPOST(query).respond(); + controller.onEditAccept(); + $httpBackend.flush(); + + const result = controller.checked; + + expect(result.length).toEqual(0); + }); + }); + describe('upsertPrice()', () => { it('should do nothing if one or more required arguments are missing', () => { jest.spyOn(controller.vnApp, 'showSuccess'); -- 2.40.1 From 3450e7ffdf3491116a7cef7e4f25a8c01556d4c0 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 5 Apr 2023 09:20:56 +0200 Subject: [PATCH 09/10] refs #5275 fix test e2e --- e2e/helpers/selectors.js | 3 ++- e2e/paths/04-item/13_fixedPrice.spec.js | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 32a60a4e2..06d6ed082 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -426,7 +426,8 @@ export default { fourthStarted: 'vn-fixed-price tr:nth-child(5) vn-date-picker[ng-model="price.started"]', fourthEnded: 'vn-fixed-price tr:nth-child(5) vn-date-picker[ng-model="price.ended"]', fourthDeleteIcon: 'vn-fixed-price tr:nth-child(5) > td:nth-child(9) > vn-icon-button[icon="delete"]', - orderColumnId: 'vn-fixed-price th[field="itemFk"]' + orderColumnId: 'vn-fixed-price th[field="itemFk"]', + removeWarehouseFilter: 'vn-searchbar > form > vn-textfield > div.container > div.prepend > prepend > div > span:nth-child(1) > vn-icon > i' }, itemCreateView: { temporalName: 'vn-item-create vn-textfield[ng-model="$ctrl.item.provisionalName"]', diff --git a/e2e/paths/04-item/13_fixedPrice.spec.js b/e2e/paths/04-item/13_fixedPrice.spec.js index 1b0f82d83..ec8238b87 100644 --- a/e2e/paths/04-item/13_fixedPrice.spec.js +++ b/e2e/paths/04-item/13_fixedPrice.spec.js @@ -15,8 +15,9 @@ describe('Item fixed prices path', () => { await browser.close(); }); - it('should click on the add new foxed price button', async() => { - await page.doSearch(); + it('should click on the add new fixed price button', async() => { + await page.waitToClick(selectors.itemFixedPrice.removeWarehouseFilter); + await page.waitForSpinnerLoad(); await page.waitToClick(selectors.itemFixedPrice.add); await page.waitForSelector(selectors.itemFixedPrice.fourthFixedPrice); }); @@ -37,7 +38,8 @@ describe('Item fixed prices path', () => { it('should reload the section and check the created price has the expected ID', async() => { await page.accessToSection('item.index'); await page.accessToSection('item.fixedPrice'); - await page.doSearch(); + await page.waitToClick(selectors.itemFixedPrice.removeWarehouseFilter); + await page.waitForSpinnerLoad(); const result = await page.waitToGetProperty(selectors.itemFixedPrice.fourthItemID, 'value'); -- 2.40.1 From de31d98e2ef4f65921ab548027deec83bc61e199 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 5 Apr 2023 13:03:18 +0200 Subject: [PATCH 10/10] refs #5275 fix test e2e --- .../01-salix/03_smartTable_searchBar_integrations.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js index ad558ace2..a3d747f1c 100644 --- a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js +++ b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js @@ -90,7 +90,7 @@ describe('SmartTable SearchBar integration', () => { await page.waitToClick(selectors.itemFixedPrice.orderColumnId); const result = await page.waitToGetProperty(selectors.itemFixedPrice.firstItemID, 'value'); - expect(result).toEqual('13'); + expect(result).toEqual('3'); }); it('should reload page and have same order', async() => { @@ -99,7 +99,7 @@ describe('SmartTable SearchBar integration', () => { }); const result = await page.waitToGetProperty(selectors.itemFixedPrice.firstItemID, 'value'); - expect(result).toEqual('13'); + expect(result).toEqual('3'); }); }); }); -- 2.40.1