diff --git a/back/methods/starred-module/specs/getStarredModules.spec.js b/back/methods/starred-module/specs/getStarredModules.spec.js index b5d2f25c8..c962bc471 100644 --- a/back/methods/starred-module/specs/getStarredModules.spec.js +++ b/back/methods/starred-module/specs/getStarredModules.spec.js @@ -19,11 +19,11 @@ describe('getStarredModules()', () => { }); it(`should return the starred modules for a given user`, async() => { - const newStarred = await app.models.StarredModule.create({workerFk: 9, moduleFk: 'Clients', position: 1}); + const newStarred = await app.models.StarredModule.create({workerFk: 9, moduleFk: 'customer', position: 1}); const starredModules = await app.models.StarredModule.getStarredModules(ctx); expect(starredModules.length).toEqual(1); - expect(starredModules[0].moduleFk).toEqual('Clients'); + expect(starredModules[0].moduleFk).toEqual('customer'); // restores await app.models.StarredModule.destroyById(newStarred.id); diff --git a/back/methods/starred-module/specs/setPosition.spec.js b/back/methods/starred-module/specs/setPosition.spec.js index 6ac9cab16..5421bd62b 100644 --- a/back/methods/starred-module/specs/setPosition.spec.js +++ b/back/methods/starred-module/specs/setPosition.spec.js @@ -26,29 +26,29 @@ describe('setPosition()', () => { const filter = { where: { workerFk: ctx.req.accessToken.userId, - moduleFk: 'Orders' + moduleFk: 'order' } }; try { const options = {transaction: tx}; - await app.models.StarredModule.toggleStarredModule(ctx, 'Orders', options); - await app.models.StarredModule.toggleStarredModule(ctx, 'Clients', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'order', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'customer', options); let orders = await app.models.StarredModule.findOne(filter, options); - filter.where.moduleFk = 'Clients'; + filter.where.moduleFk = 'customer'; let clients = await app.models.StarredModule.findOne(filter, options); expect(orders.position).toEqual(1); expect(clients.position).toEqual(2); - await app.models.StarredModule.setPosition(ctx, 'Clients', 'left', options); + await app.models.StarredModule.setPosition(ctx, 'customer', 'left', options); - filter.where.moduleFk = 'Clients'; + filter.where.moduleFk = 'customer'; clients = await app.models.StarredModule.findOne(filter, options); - filter.where.moduleFk = 'Orders'; + filter.where.moduleFk = 'order'; orders = await app.models.StarredModule.findOne(filter, options); expect(clients.position).toEqual(1); @@ -67,29 +67,29 @@ describe('setPosition()', () => { const filter = { where: { workerFk: ctx.req.accessToken.userId, - moduleFk: 'Orders' + moduleFk: 'order' } }; try { const options = {transaction: tx}; - await app.models.StarredModule.toggleStarredModule(ctx, 'Orders', options); - await app.models.StarredModule.toggleStarredModule(ctx, 'Clients', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'order', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'customer', options); let orders = await app.models.StarredModule.findOne(filter, options); - filter.where.moduleFk = 'Clients'; + filter.where.moduleFk = 'customer'; let clients = await app.models.StarredModule.findOne(filter, options); expect(orders.position).toEqual(1); expect(clients.position).toEqual(2); - await app.models.StarredModule.setPosition(ctx, 'Orders', 'right', options); + await app.models.StarredModule.setPosition(ctx, 'order', 'right', options); - filter.where.moduleFk = 'Orders'; + filter.where.moduleFk = 'order'; orders = await app.models.StarredModule.findOne(filter, options); - filter.where.moduleFk = 'Clients'; + filter.where.moduleFk = 'customer'; clients = await app.models.StarredModule.findOne(filter, options); expect(orders.position).toEqual(2); @@ -108,35 +108,35 @@ describe('setPosition()', () => { const filter = { where: { workerFk: ctx.req.accessToken.userId, - moduleFk: 'Items' + moduleFk: 'item' } }; try { const options = {transaction: tx}; - await app.models.StarredModule.toggleStarredModule(ctx, 'Clients', options); - await app.models.StarredModule.toggleStarredModule(ctx, 'Orders', options); - await app.models.StarredModule.toggleStarredModule(ctx, 'Clients', options); - await app.models.StarredModule.toggleStarredModule(ctx, 'Orders', options); - await app.models.StarredModule.toggleStarredModule(ctx, 'Items', options); - await app.models.StarredModule.toggleStarredModule(ctx, 'Claims', options); - await app.models.StarredModule.toggleStarredModule(ctx, 'Clients', options); - await app.models.StarredModule.toggleStarredModule(ctx, 'Orders', options); - await app.models.StarredModule.toggleStarredModule(ctx, 'Zones', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'customer', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'order', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'customer', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'order', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'item', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'claim', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'customer', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'order', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'zone', options); const items = await app.models.StarredModule.findOne(filter, options); - filter.where.moduleFk = 'Claims'; + filter.where.moduleFk = 'claim'; const claims = await app.models.StarredModule.findOne(filter, options); - filter.where.moduleFk = 'Clients'; + filter.where.moduleFk = 'customer'; let clients = await app.models.StarredModule.findOne(filter, options); - filter.where.moduleFk = 'Orders'; + filter.where.moduleFk = 'order'; let orders = await app.models.StarredModule.findOne(filter, options); - filter.where.moduleFk = 'Zones'; + filter.where.moduleFk = 'zone'; const zones = await app.models.StarredModule.findOne(filter, options); expect(items.position).toEqual(1); @@ -145,12 +145,12 @@ describe('setPosition()', () => { expect(orders.position).toEqual(4); expect(zones.position).toEqual(5); - await app.models.StarredModule.setPosition(ctx, 'Clients', 'right', options); + await app.models.StarredModule.setPosition(ctx, 'customer', 'right', options); - filter.where.moduleFk = 'Orders'; + filter.where.moduleFk = 'order'; orders = await app.models.StarredModule.findOne(filter, options); - filter.where.moduleFk = 'Clients'; + filter.where.moduleFk = 'customer'; clients = await app.models.StarredModule.findOne(filter, options); expect(orders.position).toEqual(3); @@ -169,31 +169,31 @@ describe('setPosition()', () => { const filter = { where: { workerFk: ctx.req.accessToken.userId, - moduleFk: 'Items' + moduleFk: 'item' } }; try { const options = {transaction: tx}; - await app.models.StarredModule.toggleStarredModule(ctx, 'Items', options); - await app.models.StarredModule.toggleStarredModule(ctx, 'Clients', options); - await app.models.StarredModule.toggleStarredModule(ctx, 'Claims', options); - await app.models.StarredModule.toggleStarredModule(ctx, 'Orders', options); - await app.models.StarredModule.toggleStarredModule(ctx, 'Zones', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'item', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'customer', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'claim', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'order', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'zone', options); const items = await app.models.StarredModule.findOne(filter, options); - filter.where.moduleFk = 'Clients'; + filter.where.moduleFk = 'customer'; let clients = await app.models.StarredModule.findOne(filter, options); - filter.where.moduleFk = 'Claims'; + filter.where.moduleFk = 'claim'; const claims = await app.models.StarredModule.findOne(filter, options); - filter.where.moduleFk = 'Orders'; + filter.where.moduleFk = 'order'; let orders = await app.models.StarredModule.findOne(filter, options); - filter.where.moduleFk = 'Zones'; + filter.where.moduleFk = 'zone'; const zones = await app.models.StarredModule.findOne(filter, options); expect(items.position).toEqual(1); @@ -202,13 +202,13 @@ describe('setPosition()', () => { expect(orders.position).toEqual(4); expect(zones.position).toEqual(5); - await app.models.StarredModule.toggleStarredModule(ctx, 'Claims', options); - await app.models.StarredModule.setPosition(ctx, 'Clients', 'right', options); + await app.models.StarredModule.toggleStarredModule(ctx, 'claim', options); + await app.models.StarredModule.setPosition(ctx, 'customer', 'right', options); - filter.where.moduleFk = 'Clients'; + filter.where.moduleFk = 'customer'; clients = await app.models.StarredModule.findOne(filter, options); - filter.where.moduleFk = 'Orders'; + filter.where.moduleFk = 'order'; orders = await app.models.StarredModule.findOne(filter, options); expect(orders.position).toEqual(2); diff --git a/back/methods/starred-module/specs/toggleStarredModule.spec.js b/back/methods/starred-module/specs/toggleStarredModule.spec.js index 1aed4f54a..1195834e7 100644 --- a/back/methods/starred-module/specs/toggleStarredModule.spec.js +++ b/back/methods/starred-module/specs/toggleStarredModule.spec.js @@ -21,15 +21,15 @@ describe('toggleStarredModule()', () => { }); it('should create a new starred module and then remove it by calling the method again with same args', async() => { - const starredModule = await app.models.StarredModule.toggleStarredModule(ctx, 'Orders'); + const starredModule = await app.models.StarredModule.toggleStarredModule(ctx, 'order'); let starredModules = await app.models.StarredModule.getStarredModules(ctx); expect(starredModules.length).toEqual(1); - expect(starredModule.moduleFk).toEqual('Orders'); + expect(starredModule.moduleFk).toEqual('order'); expect(starredModule.workerFk).toEqual(activeCtx.accessToken.userId); expect(starredModule.position).toEqual(starredModules.length); - await app.models.StarredModule.toggleStarredModule(ctx, 'Orders'); + await app.models.StarredModule.toggleStarredModule(ctx, 'order'); starredModules = await app.models.StarredModule.getStarredModules(ctx); expect(starredModules.length).toEqual(0); diff --git a/front/salix/components/home/home.spec.js b/front/salix/components/home/home.spec.js index 4a8a58a55..5559ca1d4 100644 --- a/front/salix/components/home/home.spec.js +++ b/front/salix/components/home/home.spec.js @@ -19,7 +19,7 @@ describe('Salix Component vnHome', () => { describe('getStarredModules()', () => { it('should not set any of the modules as starred if there are no starred modules for the user', () => { const expectedResponse = []; - controller._modules = [{module: 'client', name: 'Clients'}]; + controller._modules = [{code: 'client', name: 'Clients'}]; $httpBackend.whenRoute('GET', 'starredModules/getStarredModules').respond(expectedResponse); $httpBackend.expectGET('starredModules/getStarredModules').respond(expectedResponse); @@ -31,8 +31,8 @@ describe('Salix Component vnHome', () => { }); it('should set the example module as starred since its the starred module for the user', () => { - const expectedResponse = [{id: 1, moduleFk: 'Clients', workerFk: 9}]; - controller._modules = [{module: 'client', name: 'Clients'}]; + const expectedResponse = [{id: 1, moduleFk: 'customer', workerFk: 9}]; + controller._modules = [{code: 'client', name: 'Clients'}]; $httpBackend.whenRoute('GET', 'starredModules/getStarredModules').respond(expectedResponse); $httpBackend.expectGET('starredModules/getStarredModules').respond(expectedResponse); @@ -48,7 +48,7 @@ describe('Salix Component vnHome', () => { it(`should set the received module as starred if it wasn't starred`, () => { const expectedResponse = [{id: 1, moduleFk: 'Clients', workerFk: 9}]; const event = new Event('target'); - controller._modules = [{module: 'client', name: 'Clients'}]; + controller._modules = [{code: 'client', name: 'Clients'}]; $httpBackend.whenRoute('GET', 'starredModules/getStarredModules').respond(expectedResponse); $httpBackend.expectPOST('starredModules/toggleStarredModule').respond(expectedResponse); @@ -61,7 +61,7 @@ describe('Salix Component vnHome', () => { it('should set the received module as regular if it was starred', () => { const event = new Event('target'); - controller._modules = [{module: 'client', name: 'Clients', starred: true}]; + controller._modules = [{code: 'client', name: 'Clients', starred: true}]; $httpBackend.whenRoute('GET', 'starredModules/getStarredModules').respond([]); $httpBackend.expectPOST('starredModules/toggleStarredModule').respond(undefined); @@ -76,18 +76,18 @@ describe('Salix Component vnHome', () => { describe('moveModule()', () => { it('should perform a query to setPosition and the apply the position to the moved and pushed modules', () => { const starredModules = [ - {id: 1, moduleFk: 'Clients', workerFk: 9}, - {id: 2, moduleFk: 'Orders', workerFk: 9} + {id: 1, moduleFk: 'customer', workerFk: 9}, + {id: 2, moduleFk: 'order', workerFk: 9} ]; const movedModules = { - movingModule: {position: 2, moduleFk: 'Clients'}, - pushedModule: {position: 1, moduleFk: 'Orders'} + movingModule: {position: 2, moduleFk: 'customer'}, + pushedModule: {position: 1, moduleFk: 'order'} }; const event = new Event('target'); controller._modules = [ - {module: 'client', name: 'Clients', position: 1}, - {module: 'orders', name: 'Orders', position: 2} + {code: 'client', name: 'Clients', position: 1}, + {code: 'order', name: 'Orders', position: 2} ]; $httpBackend.whenRoute('GET', 'starredModules/getStarredModules').respond(starredModules);