diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 27590c4ea..e311df432 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -266,11 +266,11 @@ let actions = { }); }, - waitForTextInElement: function(selector, name, done) { + waitForTextInElement: function(selector, text, done) { this.wait(selector) - .wait((selector, name) => { - return document.querySelector(selector).innerText.toLowerCase().includes(name.toLowerCase()); - }, selector, name) + .wait((selector, text) => { + return document.querySelector(selector).innerText.toLowerCase().includes(text.toLowerCase()); + }, selector, text) .then(done) .catch(done); }, diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 0094dca9a..941c86038 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -171,9 +171,9 @@ export default { itemsIndex: { goBackToModuleIndexButton: `vn-ticket-descriptor a[href="#!/ticket/index"]`, createItemButton: `${components.vnFloatButton}`, - searchResult: `vn-item-product a`, - searchResultPreviewButton: `vn-item-product .buttons > [icon="desktop_windows"]`, - searchResultCloneButton: `vn-item-product .buttons > [icon="icon-clone"]`, + searchResult: `vn-item-index a.vn-tr`, + searchResultPreviewButton: `vn-item-index .buttons > [icon="desktop_windows"]`, + searchResultCloneButton: `vn-item-index .buttons > [icon="icon-clone"]`, acceptClonationAlertButton: `vn-item-index [vn-id="clone"] [response="ACCEPT"]`, searchItemInput: `vn-searchbar vn-textfield input`, searchButton: `vn-searchbar vn-icon[icon="search"]`, diff --git a/front/core/lib/module-loader.js b/front/core/lib/module-loader.js index 163d103bb..477b1c943 100644 --- a/front/core/lib/module-loader.js +++ b/front/core/lib/module-loader.js @@ -19,7 +19,7 @@ export function factory($http, $window, $ocLazyLoad, $translatePartialLoader, $t if (loaded[moduleName] instanceof Promise) return loaded[moduleName]; if (loaded[moduleName] === false) - return $q.reject(new Error(`Module dependency loop detected: ${moduleName}`)); + return Promise.resolve(true); loaded[moduleName] = false; @@ -37,10 +37,7 @@ export function factory($http, $window, $ocLazyLoad, $translatePartialLoader, $t $translatePartialLoader.addPart(moduleName); promises.push(new Promise(resolve => { - $translate.refresh().then( - () => resolve(), - () => resolve() - ); + $translate.refresh().then(resolve, resolve); })); if (validations) { diff --git a/front/core/lib/specs/module-loader.spec.js b/front/core/lib/specs/module-loader.spec.js index c8def1634..bc705f40f 100644 --- a/front/core/lib/specs/module-loader.spec.js +++ b/front/core/lib/specs/module-loader.spec.js @@ -28,19 +28,5 @@ describe('factory vnModuleLoader', () => { expect(result).toEqual(jasmine.any(Promise)); }); - - it('should return an error if the module wasnt loaded', done => { - vnModuleLoader._loaded.myModule = false; - - vnModuleLoader.load('myModule', {myValidations: () => {}}) - .then(() => { - done.fail('this must fail'); - }) - .catch(error => { - expect(error.toString()).toEqual(`Error: Module dependency loop detected: myModule`); - done(); - }); - $scope.$apply(); - }); }); }); diff --git a/front/salix/components/user-configuration-popover/index.js b/front/salix/components/user-configuration-popover/index.js index 18a8aae7e..5f8eeb330 100644 --- a/front/salix/components/user-configuration-popover/index.js +++ b/front/salix/components/user-configuration-popover/index.js @@ -92,7 +92,7 @@ class Controller { this.company = value; if (value && (!window.localStorage.localCompanyFk || window.localStorage.localCompanyFk === 'null')) - window.localStorage.defaultCompanyFk = value; + window.localStorage.setItem('localCompanyFk', value); this.setUserConfig('companyFk', value); } @@ -118,13 +118,13 @@ class Controller { if (res.data && res.data.warehouseFk) { this.warehouse = res.data.warehouseFk; if (res.data.warehouseFk && !window.localStorage.localWarehouseFk) - window.localStorage.defaultWarehouseFk = res.data.warehouseFk; + window.localStorage.setItem('localWarehouseFk', res.data.warehouseFk); } if (res.data && res.data.companyFk) { this.company = res.data.companyFk; if (res.data.companyFk && !window.localStorage.localCompanyFk) - window.localStorage.defaultCompanyFk = res.data.companyFk; + window.localStorage.setItem('defaultCompanyFk', res.data.companyFk); } }); } diff --git a/gulpfile.js b/gulpfile.js index d69dd5d0d..b6427cdd1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -74,7 +74,7 @@ defaultTask.description = `Starts all application services`; // Backend tests -async function backTestOnly() { +async function backTestOnce() { let bootOptions; if (argv['random']) @@ -107,11 +107,19 @@ async function backTestOnly() { await app.disconnect(); } -backTestOnly.description = `Runs the backend tests only, can receive --junit arg to save reports on a xml file`; +backTestOnce.description = `Runs the backend tests once, can receive --junit arg to save reports on a xml file`; + +async function backTestDockerOnce() { + let containerId = await docker(); + await backTestOnce(); + if (argv['random']) + await execP(`docker rm -fv ${containerId}`); +} +backTestDockerOnce.description = `Runs backend tests using in site container once`; async function backTestDocker() { let containerId = await docker(); - await backTestOnly(); + await backTest(); if (argv['random']) await execP(`docker rm -fv ${containerId}`); } @@ -122,7 +130,7 @@ function backTest(done) { nodemon({ exec: ['node ./node_modules/gulp/bin/gulp.js'], - args: ['backTestOnly'], + args: ['backTestOnce'], watch: backSources, done: done }); @@ -484,8 +492,9 @@ module.exports = { back, backOnly, backWatch, + backTestOnce, + backTestDockerOnce, backTest, - backTestOnly, backTestDocker, e2e, e2eOnly, diff --git a/modules/agency/front/location/index.js b/modules/agency/front/location/index.js index cdb89829a..92e893297 100644 --- a/modules/agency/front/location/index.js +++ b/modules/agency/front/location/index.js @@ -10,7 +10,7 @@ class Controller { } onSearch() { - this.$scope.$$postDigest(() => { + this.$scope.$applyAsync(() => { this.$scope.treeview.refresh(); }); } diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js index 316fd2ef6..cc047c608 100644 --- a/modules/item/back/methods/item/filter.js +++ b/modules/item/back/methods/item/filter.js @@ -32,12 +32,19 @@ module.exports = Self => { let stmt = new ParameterizedSQL( `SELECT i.id, i.image, i.name, i.description, i.size, i.tag5, i.value5, i.tag6, i.value6, - i.tag7, i.value7, i.tag8, i.value8, - t.name type, u.nickname userNickname + i.tag7, i.value7, i.tag8, i.value8, i.isActive, + t.name type, u.nickname userNickname, + intr.description AS intrastat, i.stems, + ori.code AS origin, t.name AS type, + ic.name AS category FROM item i JOIN itemType t ON t.id = i.typeFk + LEFT JOIN itemCategory ic ON ic.id = t.categoryFk JOIN worker w ON w.id = t.workerFk - JOIN account.user u ON u.id = w.userFk` + JOIN account.user u ON u.id = w.userFk + LEFT JOIN intrastat intr ON intr.id = i.intrastatFk + LEFT JOIN producer pr ON pr.id = i.producerFk + LEFT JOIN origin ori ON ori.id = i.originFk` ); if (tags) { diff --git a/modules/item/front/descriptor/index.html b/modules/item/front/descriptor/index.html index 56f64c3aa..02e1267dc 100644 --- a/modules/item/front/descriptor/index.html +++ b/modules/item/front/descriptor/index.html @@ -92,7 +92,7 @@
- Regularize + Regularize stock
{ + this.$scope.$applyAsync(() => { if (this.$stateParams.warehouseFk) this.warehouseFk = this.$stateParams.warehouseFk; else if (value) diff --git a/modules/item/front/diary/index.spec.js b/modules/item/front/diary/index.spec.js index 454a8b25f..9286f2863 100644 --- a/modules/item/front/diary/index.spec.js +++ b/modules/item/front/diary/index.spec.js @@ -69,23 +69,23 @@ describe('Item', () => { describe('set item()', () => { it(`should set warehouseFk property based on itemType warehouseFk`, () => { - spyOn(controller.$scope, '$$postDigest').and.callThrough(); + spyOn(controller.$scope, '$applyAsync').and.callThrough(); controller.item = {id: 1, itemType: {warehouseFk: 1}}; - expect(controller.$scope.$$postDigest).toHaveBeenCalledWith(jasmine.any(Function)); - $scope.$digest(); + expect(controller.$scope.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function)); + $scope.$apply(); expect(controller.warehouseFk).toEqual(1); expect(controller.item.id).toEqual(1); }); it(`should set warehouseFk property based on url query warehouseFk`, () => { - spyOn(controller.$scope, '$$postDigest').and.callThrough(); + spyOn(controller.$scope, '$applyAsync').and.callThrough(); controller.$stateParams.warehouseFk = 4; controller.item = {id: 1, itemType: {warehouseFk: 1}}; - expect(controller.$scope.$$postDigest).toHaveBeenCalledWith(jasmine.any(Function)); - $scope.$digest(); + expect(controller.$scope.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function)); + $scope.$apply(); expect(controller.warehouseFk).toEqual(4); expect(controller.item.id).toEqual(1); diff --git a/modules/item/front/index.js b/modules/item/front/index.js index c2f9a66f6..3bb2942a8 100644 --- a/modules/item/front/index.js +++ b/modules/item/front/index.js @@ -7,10 +7,6 @@ import './create'; import './card'; import './descriptor'; import './descriptor-popover'; -import './ticket-descriptor'; -import './ticket-descriptor/addStowaway'; -import './ticket-descriptor/removeStowaway'; -import './ticket-descriptor-popover'; import './data'; import './tags'; import './tax'; diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html index e2d2df6e5..d4def30a2 100644 --- a/modules/item/front/index/index.html +++ b/modules/item/front/index/index.html @@ -1,10 +1,10 @@ + auto-load="true">
@@ -17,23 +17,76 @@ vn-focus> - - - - +
+ + + + + + Id + Description + Stems + Type + Category + Intrastat + Origin + Sales person + Active + + + + + + + + + {{::item.id | zeroFill:6}} + + + + + {{::item.stems}} + {{::item.type}} + {{::item.category}} + {{::item.intrastat}} + {{::item.origin}} + {{::item.userNickname}} + + + + + + + + + + + + + + + No results - - Enter a new search - - - -
+ + +
diff --git a/modules/item/front/index/index.js b/modules/item/front/index/index.js index 7926c33c6..e2decd07b 100644 --- a/modules/item/front/index/index.js +++ b/modules/item/front/index/index.js @@ -8,6 +8,12 @@ class Controller { this.$state = $state; this.$ = $scope; this.itemSelected = null; + this.imagesPath = '//verdnatura.es/vn-image-data/catalog'; + + this.showFields = { + id: false, + actions: false + }; } exprBuilder(param, value) { @@ -25,6 +31,23 @@ class Controller { } } + showDescriptor(event, itemFk) { + this.quicklinks = { + btnThree: { + icon: 'icon-transaction', + state: `item.card.diary({ + id: ${itemFk}, + warehouseFk: ${this.ticket.warehouseFk}, + ticketFk: ${this.ticket.id} + })`, + tooltip: 'Item diary' + } + }; + this.$scope.descriptor.itemFk = itemFk; + this.$scope.descriptor.parent = event.target; + this.$scope.descriptor.show(); + } + paramBuilder(param, value) { switch (param) { case 'tags': @@ -32,7 +55,9 @@ class Controller { } } - cloneItem(item) { + cloneItem(event, item) { + event.preventDefault(); + event.stopImmediatePropagation(); this.itemSelected = item; this.$.clone.show(); } @@ -49,7 +74,9 @@ class Controller { this.itemSelected = null; } - showItemPreview(item) { + preview(event, item) { + event.preventDefault(); + event.stopImmediatePropagation(); this.itemSelected = item; this.$.preview.show(); } diff --git a/modules/item/front/index/style.scss b/modules/item/front/index/style.scss index b73c1e32c..0dc1f3049 100644 --- a/modules/item/front/index/style.scss +++ b/modules/item/front/index/style.scss @@ -25,3 +25,10 @@ vn-item-product { margin-top: 0.9em; } } + +vn-table { + img { + border-radius: 50%; + max-width: 50px; + } +} \ No newline at end of file diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json index b81625e06..35651ef5b 100644 --- a/modules/item/front/routes.json +++ b/modules/item/front/routes.json @@ -3,7 +3,7 @@ "name": "Items", "icon": "inbox", "validations" : true, - "dependencies": ["client"], + "dependencies": ["client", "ticket"], "menu": [ {"state": "item.card.data", "icon": "settings"}, {"state": "item.card.tags", "icon": "icon-tags"}, diff --git a/modules/item/front/ticket-descriptor-popover/index.spec.js b/modules/item/front/ticket-descriptor-popover/index.spec.js deleted file mode 100644 index 9e3d39e4b..000000000 --- a/modules/item/front/ticket-descriptor-popover/index.spec.js +++ /dev/null @@ -1,126 +0,0 @@ -import './index.js'; - -describe('Item', () => { - describe('Component vnTicketDescriptorPopover', () => { - let $httpBackend; - let $scope; - let controller; - let $element; - let $timeout; - - beforeEach(ngModule('item')); - - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$timeout_) => { - $httpBackend = _$httpBackend_; - $timeout = _$timeout_; - $element = angular.element(`
`); - $scope = $rootScope.$new(); - $scope.popover = {relocate: () => {}, show: () => {}}; - controller = $componentController('vnTicketDescriptorPopover', {$scope, $element}); - })); - - describe('ticketFk()', () => { - it(`should not apply any changes if the received id is the same stored in _ticketFk`, () => { - controller.ticket = 'I exist!'; - controller._ticketFk = 1; - spyOn(controller, 'getCard'); - controller.ticketFk = 1; - - expect(controller.ticket).toEqual('I exist!'); - expect(controller._ticketFk).toEqual(1); - expect(controller.getCard).not.toHaveBeenCalled(); - }); - - it(`should set the received id into _ticketFk, set the ticket to null and then call getCard()`, () => { - controller.ticket = `Please don't`; - controller._ticketFk = 1; - spyOn(controller, 'getCard'); - controller.ticketFk = 999; - - expect(controller.ticket).toBeNull(); - expect(controller._ticketFk).toEqual(999); - expect(controller.getCard).toHaveBeenCalledWith(); - }); - }); - - describe('ticket()', () => { - it(`should save the ticket into _ticket and then call relocate()`, () => { - spyOn(controller.$.popover, 'relocate'); - controller.ticket = `i'm the ticket!`; - $timeout.flush(); - - expect(controller._ticket).toEqual(`i'm the ticket!`); - expect(controller.$.popover.relocate).toHaveBeenCalledWith(); - }); - }); - - describe('show()', () => { - it(`should call the show()`, () => { - spyOn(controller.$.popover, 'show'); - controller.show(); - - expect(controller.$.popover.show).toHaveBeenCalledWith(); - }); - }); - - describe('getCard()', () => { - it(`should perform a get query to store the ticket data into the controller`, () => { - controller.ticketFk = 1; - controller.canceler = null; - let response = {}; - - let filter = { - include: [ - { - relation: 'warehouse', - scope: { - fields: ['name'] - } - }, - { - relation: 'agencyMode', - scope: { - fields: ['name'] - } - }, - { - relation: 'client', - scope: { - fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'], - include: { - relation: 'salesPerson', - scope: { - fields: ['userFk'], - include: { - relation: 'user', - scope: { - fields: ['nickname'] - } - } - } - } - } - }, - { - relation: 'state', - scope: { - fields: ['stateFk'], - include: { - relation: 'state', - fields: ['id', 'name'], - } - } - } - ] - }; - let json = encodeURIComponent(JSON.stringify(filter)); - $httpBackend.when('GET', `/ticket/api/Tickets/${controller._ticketFk}?filter=${json}`).respond(response); - $httpBackend.expect('GET', `/ticket/api/Tickets/${controller._ticketFk}?filter=${json}`); - controller.getCard(); - $httpBackend.flush(); - - expect(controller.ticket).toEqual(response); - }); - }); - }); -}); diff --git a/modules/order/front/filter/index.js b/modules/order/front/filter/index.js index 9f1013b35..c2bfb8e4b 100644 --- a/modules/order/front/filter/index.js +++ b/modules/order/front/filter/index.js @@ -28,7 +28,7 @@ class Controller { this._order = value; - this.$scope.$$postDigest(() => { + this.$scope.$applyAsync(() => { let category; let type; diff --git a/modules/order/front/filter/index.spec.js b/modules/order/front/filter/index.spec.js index 3d9888c57..c31e87500 100644 --- a/modules/order/front/filter/index.spec.js +++ b/modules/order/front/filter/index.spec.js @@ -6,10 +6,12 @@ describe('Order', () => { let $scope; let $state; let controller; + let $httpBackend; beforeEach(ngModule('order')); - beforeEach(angular.mock.inject(($componentController, _$state_, $rootScope) => { + beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_, $rootScope) => { + $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $scope.model = crudModel; $scope.search = {}; @@ -27,12 +29,14 @@ describe('Order', () => { })); describe('order() setter', () => { - it(`should call scope $$postDigest() method and apply filters from state params`, () => { - spyOn(controller.$scope, '$$postDigest').and.callThrough(); + it(`should call scope $applyAsync() method and apply filters from state params`, () => { + $httpBackend.expect('GET', `/item/api/ItemCategories/1/itemTypes`).respond(); + spyOn(controller.$scope, '$applyAsync').and.callThrough(); controller.order = {id: 4}; - expect(controller.$scope.$$postDigest).toHaveBeenCalledWith(jasmine.any(Function)); - $scope.$digest(); + expect(controller.$scope.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function)); + $scope.$apply(); + expect(controller.category).toEqual({id: 1, value: 'My Category'}); expect(controller.type).toEqual({id: 1, value: 'My type'}); @@ -96,28 +100,38 @@ describe('Order', () => { }); describe('applyFilters()', () => { - it(`should set type property to null, call updateStateParams() method and not call applyFilters()`, () => { - spyOn(controller.catalog.$scope.model, 'applyFilter'); - controller.order = {id: 4}; - $scope.$digest(); + it(`should call model applyFilter() method with a new filter`, () => { + let model = controller.catalog.$scope.model; + spyOn(model, 'applyFilter'); + controller._category = {id: 1, value: 'My Category'}; + controller._type = {id: 1, value: 'My type'}; + controller._order = {id: 4}; + controller.applyFilters(); - expect(controller.catalog.$scope.model.applyFilter).toHaveBeenCalledWith( + expect(model.applyFilter).toHaveBeenCalledWith( {where: {categoryFk: 1, typeFk: 1}}, {orderFk: 4, orderBy: controller.catalog.getOrderBy(), tags: []}); }); }); describe('remove()', () => { - it(`should remove a filter from tags property and then call applyFilters()`, () => { - spyOn(controller, 'applyFilters'); - controller.order = {id: 4}; + it(`should remove a tag from tags property`, () => { controller.tags = [{tagFk: 1, value: 'Blue'}, {tagFk: 2, value: '70'}]; - $scope.$digest(); controller.remove(0); expect(controller.tags.length).toEqual(1); expect(controller.tags[0].tagFk).toEqual(2); + }); + + it(`should remove a tag from tags property and call applyFilters() if there's no more tags`, () => { + spyOn(controller, 'applyFilters'); + controller._category = {id: 1, value: 'My Category'}; + controller._type = {id: 1, value: 'My type'}; + controller.tags = [{tagFk: 1, value: 'Blue'}]; + controller.remove(0); + + expect(controller.tags.length).toEqual(0); expect(controller.applyFilters).toHaveBeenCalledWith(); }); }); @@ -125,10 +139,10 @@ describe('Order', () => { describe('updateStateParams()', () => { it(`should call state go() method passing category and type state params`, () => { spyOn(controller.$state, 'go'); - controller.order = {id: 4}; - $scope.$digest(); - + controller._category = {id: 1, value: 'My Category'}; + controller._type = {id: 1, value: 'My type'}; let result = {category: '{"id":1,"value":"My Category"}', type: '{"id":1,"value":"My type"}'}; + controller.updateStateParams(); expect(controller.$state.go).toHaveBeenCalledWith('my.current.state', result); }); diff --git a/modules/order/front/prices-popover/index.js b/modules/order/front/prices-popover/index.js index c44ff7109..e89f04774 100644 --- a/modules/order/front/prices-popover/index.js +++ b/modules/order/front/prices-popover/index.js @@ -35,6 +35,9 @@ class Controller { }; this.$http.get(`/item/api/ItemTags?filter=${JSON.stringify(filter)}`).then(response => { this.tags = response.data; + this.$.$applyAsync(() => { + this.$.popover.relocate(); + }); }); } show(event, item) { @@ -42,8 +45,8 @@ class Controller { this.prices = this.item.prices; this.getTags(); this.$.popover.parent = event.target; - this.$.popover.relocate(); this.$.popover.show(); + this.$.popover.relocate(); } clear() { this.item = {}; diff --git a/modules/item/front/ticket-descriptor-popover/index.html b/modules/ticket/front/descriptor-popover/index.html similarity index 100% rename from modules/item/front/ticket-descriptor-popover/index.html rename to modules/ticket/front/descriptor-popover/index.html diff --git a/modules/item/front/ticket-descriptor-popover/index.js b/modules/ticket/front/descriptor-popover/index.js similarity index 100% rename from modules/item/front/ticket-descriptor-popover/index.js rename to modules/ticket/front/descriptor-popover/index.js diff --git a/modules/ticket/front/descriptor-popover/index.spec.js b/modules/ticket/front/descriptor-popover/index.spec.js new file mode 100644 index 000000000..499ca5413 --- /dev/null +++ b/modules/ticket/front/descriptor-popover/index.spec.js @@ -0,0 +1,125 @@ +import './index.js'; + +describe('ticket Component vnTicketDescriptorPopover', () => { + let $httpBackend; + let $scope; + let controller; + let $element; + let $timeout; + + beforeEach(ngModule('ticket')); + + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$timeout_) => { + $httpBackend = _$httpBackend_; + $timeout = _$timeout_; + $element = angular.element(`
`); + $scope = $rootScope.$new(); + $scope.popover = {relocate: () => {}, show: () => {}}; + controller = $componentController('vnTicketDescriptorPopover', {$scope, $element}); + })); + + describe('ticketFk()', () => { + it(`should not apply any changes if the received id is the same stored in _ticketFk`, () => { + controller.ticket = 'I exist!'; + controller._ticketFk = 1; + spyOn(controller, 'getCard'); + controller.ticketFk = 1; + + expect(controller.ticket).toEqual('I exist!'); + expect(controller._ticketFk).toEqual(1); + expect(controller.getCard).not.toHaveBeenCalled(); + }); + + it(`should set the received id into _ticketFk, set the ticket to null and then call getCard()`, () => { + controller.ticket = `Please don't`; + controller._ticketFk = 1; + spyOn(controller, 'getCard'); + controller.ticketFk = 999; + + expect(controller.ticket).toBeNull(); + expect(controller._ticketFk).toEqual(999); + expect(controller.getCard).toHaveBeenCalledWith(); + }); + }); + + describe('ticket()', () => { + it(`should save the ticket into _ticket and then call relocate()`, () => { + spyOn(controller.$.popover, 'relocate'); + controller.ticket = `i'm the ticket!`; + $timeout.flush(); + + expect(controller._ticket).toEqual(`i'm the ticket!`); + expect(controller.$.popover.relocate).toHaveBeenCalledWith(); + }); + }); + + describe('show()', () => { + it(`should call the show()`, () => { + spyOn(controller.$.popover, 'show'); + controller.show(); + + expect(controller.$.popover.show).toHaveBeenCalledWith(); + }); + }); + + describe('getCard()', () => { + it(`should perform a get query to store the ticket data into the controller`, () => { + controller.ticketFk = 1; + controller.canceler = null; + let response = {}; + + let filter = { + include: [ + { + relation: 'warehouse', + scope: { + fields: ['name'] + } + }, + { + relation: 'agencyMode', + scope: { + fields: ['name'] + } + }, + { + relation: 'client', + scope: { + fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'], + include: { + relation: 'salesPerson', + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + } + } + } + }, + { + relation: 'state', + scope: { + fields: ['stateFk'], + include: { + relation: 'state', + fields: ['id', 'name'], + } + } + } + ] + }; + let json = encodeURIComponent(JSON.stringify(filter)); + $httpBackend.when('GET', `/ticket/api/Tickets/${controller._ticketFk}?filter=${json}`).respond(response); + $httpBackend.expect('GET', `/ticket/api/Tickets/${controller._ticketFk}?filter=${json}`); + controller.getCard(); + $httpBackend.flush(); + + expect(controller.ticket).toEqual(response); + }); + }); +}); + diff --git a/modules/item/front/ticket-descriptor-popover/style.scss b/modules/ticket/front/descriptor-popover/style.scss similarity index 100% rename from modules/item/front/ticket-descriptor-popover/style.scss rename to modules/ticket/front/descriptor-popover/style.scss diff --git a/modules/item/front/ticket-descriptor/addStowaway.html b/modules/ticket/front/descriptor/addStowaway.html similarity index 100% rename from modules/item/front/ticket-descriptor/addStowaway.html rename to modules/ticket/front/descriptor/addStowaway.html diff --git a/modules/item/front/ticket-descriptor/addStowaway.js b/modules/ticket/front/descriptor/addStowaway.js similarity index 100% rename from modules/item/front/ticket-descriptor/addStowaway.js rename to modules/ticket/front/descriptor/addStowaway.js diff --git a/modules/item/front/ticket-descriptor/index.html b/modules/ticket/front/descriptor/index.html similarity index 100% rename from modules/item/front/ticket-descriptor/index.html rename to modules/ticket/front/descriptor/index.html diff --git a/modules/item/front/ticket-descriptor/index.js b/modules/ticket/front/descriptor/index.js similarity index 100% rename from modules/item/front/ticket-descriptor/index.js rename to modules/ticket/front/descriptor/index.js diff --git a/modules/item/front/ticket-descriptor/index.spec.js b/modules/ticket/front/descriptor/index.spec.js similarity index 96% rename from modules/item/front/ticket-descriptor/index.spec.js rename to modules/ticket/front/descriptor/index.spec.js index 51293f462..2c2359299 100644 --- a/modules/item/front/ticket-descriptor/index.spec.js +++ b/modules/ticket/front/descriptor/index.spec.js @@ -1,12 +1,10 @@ import './index.js'; -describe('Item Component vnTicketDescriptor', () => { +describe('Ticket Component vnTicketDescriptor', () => { let $httpBackend; let controller; - beforeEach(() => { - ngModule('item'); - }); + beforeEach(ngModule('ticket')); beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { $httpBackend = _$httpBackend_; diff --git a/modules/item/front/ticket-descriptor/locale/es.yml b/modules/ticket/front/descriptor/locale/es.yml similarity index 100% rename from modules/item/front/ticket-descriptor/locale/es.yml rename to modules/ticket/front/descriptor/locale/es.yml diff --git a/modules/item/front/ticket-descriptor/removeStowaway.html b/modules/ticket/front/descriptor/removeStowaway.html similarity index 100% rename from modules/item/front/ticket-descriptor/removeStowaway.html rename to modules/ticket/front/descriptor/removeStowaway.html diff --git a/modules/item/front/ticket-descriptor/removeStowaway.js b/modules/ticket/front/descriptor/removeStowaway.js similarity index 100% rename from modules/item/front/ticket-descriptor/removeStowaway.js rename to modules/ticket/front/descriptor/removeStowaway.js diff --git a/modules/item/front/ticket-descriptor/style.scss b/modules/ticket/front/descriptor/style.scss similarity index 100% rename from modules/item/front/ticket-descriptor/style.scss rename to modules/ticket/front/descriptor/style.scss diff --git a/modules/ticket/front/index.js b/modules/ticket/front/index.js index 325dc11d8..1269a60db 100644 --- a/modules/ticket/front/index.js +++ b/modules/ticket/front/index.js @@ -3,6 +3,10 @@ export * from './module'; import './index/'; import './search-panel'; import './card'; +import './descriptor'; +import './descriptor/addStowaway'; +import './descriptor/removeStowaway'; +import './descriptor-popover'; import './create/card'; import './create/index'; import './summary'; diff --git a/package.json b/package.json index cea470bbc..3a587e8e0 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,6 @@ "yaml-loader": "^0.5.0" }, "scripts": { - "test": "nodemon -q back/tests.js -w modules", "dbtest": "nodemon -q services/db/tests.js -w services/db/tests", "back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back", "lint": "eslint ./ --cache --ignore-pattern .gitignore", diff --git a/services/db/install/changes/1.2-CHECK/01-workerDepartment.sql b/services/db/install/changes/1.2-CHECK/01-workerDepartment.sql new file mode 100644 index 000000000..b52f29182 --- /dev/null +++ b/services/db/install/changes/1.2-CHECK/01-workerDepartment.sql @@ -0,0 +1,18 @@ +USE `vn`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn`.`workerDepartment` AS + SELECT + `p`.`id_trabajador` AS `workerFk`, + `d`.`id` AS `departmentFk` + FROM + (((`postgresql`.`person` `p` + JOIN `postgresql`.`profile` `pr` ON ((`pr`.`person_id` = `p`.`person_id`))) + LEFT JOIN (`postgresql`.`business` `b` + LEFT JOIN `postgresql`.`business_labour` `bl` ON ((`b`.`business_id` = `bl`.`business_id`))) ON ((`pr`.`profile_id` = `b`.`client_id`))) + JOIN `vn`.`department` `d` ON ((`d`.`id` = `bl`.`department_id`))) + WHERE + (ISNULL(`b`.`date_end`) + OR (`b`.`date_end` > CURDATE())); diff --git a/services/db/install/changes/1.2-CHECK/03-acl.sql b/services/db/install/changes/1.2-CHECK/03-acl.sql new file mode 100644 index 000000000..32ec03b5c --- /dev/null +++ b/services/db/install/changes/1.2-CHECK/03-acl.sql @@ -0,0 +1 @@ +INSERT INTO salix.ACL(id,model, property, accessType, permission, principalType, principalId)VALUES(147,'UserConfigView', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/services/db/tests.js b/services/db/tests.js index 88afa942e..bf2f45b2e 100644 --- a/services/db/tests.js +++ b/services/db/tests.js @@ -9,7 +9,9 @@ let verbose = false; if (process.argv[2] === '--v') verbose = true; -loopbackApp = `vn-loopback/server/server`; +let app = require(`vn-loopback/server/server`); +app.boot(); +loopbackApp = 'vn-loopback/server/server'; let Jasmine = require('jasmine'); let jasmine = new Jasmine(); diff --git a/services/db/tests/vn/buyUltimate.spec.js b/services/db/tests/vn/buyUltimate.spec.js index f5a26c1fe..4ff6c4708 100644 --- a/services/db/tests/vn/buyUltimate.spec.js +++ b/services/db/tests/vn/buyUltimate.spec.js @@ -1,4 +1,4 @@ -const app = require(`${loopbackApp}`); +const app = require('vn-loopback/server/server'); const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; describe('buyUltimate()', () => { diff --git a/services/db/tests/vn/buyUltimateFromInterval.spec.js b/services/db/tests/vn/buyUltimateFromInterval.spec.js index 6a22fb34b..b416b5cb2 100644 --- a/services/db/tests/vn/buyUltimateFromInterval.spec.js +++ b/services/db/tests/vn/buyUltimateFromInterval.spec.js @@ -1,4 +1,4 @@ -const app = require(`${loopbackApp}`); +const app = require('vn-loopback/server/server'); const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; describe('buyUltimateFromInterval()', () => { diff --git a/services/db/tests/vn/logAddWithUser.spec.js b/services/db/tests/vn/logAddWithUser.spec.js index 48bc70aac..8711769d0 100644 --- a/services/db/tests/vn/logAddWithUser.spec.js +++ b/services/db/tests/vn/logAddWithUser.spec.js @@ -1,4 +1,4 @@ -const app = require(`${loopbackApp}`); +const app = require('vn-loopback/server/server'); const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; describe('logAddWithUser()', () => { diff --git a/services/db/tests/vn/ticketCalculateClon.spec.js b/services/db/tests/vn/ticketCalculateClon.spec.js index 3c7bd0c2e..0b3969f1f 100644 --- a/services/db/tests/vn/ticketCalculateClon.spec.js +++ b/services/db/tests/vn/ticketCalculateClon.spec.js @@ -1,4 +1,4 @@ -const app = require(`${loopbackApp}`); +const app = require('vn-loopback/server/server'); const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; describe('ticket ticketCalculateClon()', () => { diff --git a/services/db/tests/vn/ticketComponentUpdateSale.spec.js b/services/db/tests/vn/ticketComponentUpdateSale.spec.js index 50e7cd265..45551c165 100644 --- a/services/db/tests/vn/ticketComponentUpdateSale.spec.js +++ b/services/db/tests/vn/ticketComponentUpdateSale.spec.js @@ -1,4 +1,4 @@ -const app = require(`${loopbackApp}`); +const app = require('vn-loopback/server/server'); const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; describe('ticketComponentUpdateSale()', () => { diff --git a/services/db/tests/vn/ticketCreateWithUser.spec.js b/services/db/tests/vn/ticketCreateWithUser.spec.js index e8c5b5be8..52a8a1183 100644 --- a/services/db/tests/vn/ticketCreateWithUser.spec.js +++ b/services/db/tests/vn/ticketCreateWithUser.spec.js @@ -1,4 +1,4 @@ -const app = require(`${loopbackApp}`); +const app = require('vn-loopback/server/server'); const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; describe('ticket ticketCreateWithUser()', () => {