From 69c5c8f1cd09355bf46d7fb325a23f8d89d972c2 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Mon, 25 Feb 2019 09:28:25 +0100 Subject: [PATCH 1/3] #485 --- .../components/searchbar/searchbar.spec.js | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 front/core/components/searchbar/searchbar.spec.js diff --git a/front/core/components/searchbar/searchbar.spec.js b/front/core/components/searchbar/searchbar.spec.js new file mode 100644 index 000000000..9e28d0a98 --- /dev/null +++ b/front/core/components/searchbar/searchbar.spec.js @@ -0,0 +1,84 @@ +import './searchbar.js'; + +describe('Component vnSearchbar', () => { + let controller; + let $element; + let $state; + + beforeEach(ngModule('vnCore')); + + beforeEach(angular.mock.inject(($componentController, _$state_) => { + $state = _$state_; + $element = angular.element(`
`); + controller = $componentController('vnSearchbar', {$element, $state}); + controller.panel = 'vn-client-search-panel'; + })); + + describe('$postLink()', () => { + it(`should not call onStateChange() if filter is defined`, () => { + spyOn(controller, 'onStateChange'); + controller.filter = {}; + + controller.$postLink(); + + expect(controller.onStateChange).not.toHaveBeenCalledWith(); + }); + + it(`should call onStateChange() if filter is null`, () => { + spyOn(controller, 'onStateChange'); + controller.filter = null; + + controller.$postLink(); + + expect(controller.onStateChange).toHaveBeenCalledWith(); + }); + }); + + describe('filter() setter', () => { + it(`should call $state.go()`, () => { + controller._filter = {}; + spyOn(controller.$state, 'go'); + controller.filter = {expected: 'filter'}; + + expect(controller._filter).toEqual(controller.filter); + expect(controller.$state.go).toHaveBeenCalledWith('.', Object({q: '{"expected":"filter"}'})); + }); + }); + + describe('openPanel()', () => { + it(`should do nothing if the event is prevented`, () => { + let event = { + defaultPrevented: true, + preventDefault: jasmine.createSpy('preventDefault') + }; + controller.openPanel(event); + + expect(event.preventDefault).not.toHaveBeenCalledWith(); + }); + }); + + describe('getObjectFromString()', () => { + it(`should return a formated object based on the string received for basic search`, () => { + let result = controller.getObjectFromString('Bruce Wayne'); + + expect(result).toEqual({search: 'Bruce Wayne'}); + }); + + it(`should return a formated object based on the string received for advanced search`, () => { + let result = controller.getObjectFromString('id:101 name:(Bruce Wayne)'); + + expect(result).toEqual({id: '101', name: 'Bruce Wayne'}); + }); + + it(`should format the object grouping any unmatched part of the instring of the string to the search property`, () => { + let string = 'I am the search id:101 name:(Bruce Wayne) concatenated value'; + let result = controller.getObjectFromString(string); + + expect(result).toEqual({ + id: '101', + name: 'Bruce Wayne', + search: 'I am the search concatenated value' + }); + }); + }); +}); From 11a2be6ac4e89136da78588c38a4b187e3115231 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Mon, 25 Feb 2019 11:47:28 +0100 Subject: [PATCH 2/3] #882 e2e claim.action --- e2e/helpers/selectors.js | 11 ++++ .../claim-module/04_claim_action.spec.js | 63 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 e2e/paths/claim-module/04_claim_action.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 45a3d4e3e..bd850ef3f 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -468,6 +468,17 @@ export default { secondClaimRedeliveryAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[field="claimDevelopment.claimRedeliveryFk"]', saveDevelopmentButton: `${components.vnSubmit}` }, + claimAction: { + importClaimButton: 'vn-claim-action vn-button[label="Import claim"]', + importTicketButton: 'vn-claim-action vn-button[label="Import ticket"]', + secondImportableTicket: 'vn-claim-action > vn-vertical > vn-popover > div > div.content > div > vn-table > div > vn-tbody > vn-tr:nth-child(2)', + firstLineDestination: 'vn-claim-action vn-tr:nth-child(1) vn-autocomplete[field="saleClaimed.claimDestinationFk"]', + thirdLineDestination: 'vn-claim-action vn-tr:nth-child(3) vn-autocomplete[field="saleClaimed.claimDestinationFk"]', + firstDeleteLine: 'vn-claim-action vn-tr:nth-child(1) vn-icon-button[icon="delete"]', + secondDeleteLine: 'vn-claim-action vn-tr:nth-child(2) vn-icon-button[icon="delete"]', + thirdDeleteLine: 'vn-claim-action vn-tr:nth-child(3) vn-icon-button[icon="delete"]' + + }, ordersIndex: { searchResult: `vn-order-index vn-card > div > vn-table > div > vn-tbody > a.vn-tr`, searchResultDate: `vn-order-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(4)`, diff --git a/e2e/paths/claim-module/04_claim_action.spec.js b/e2e/paths/claim-module/04_claim_action.spec.js new file mode 100644 index 000000000..2a61c088f --- /dev/null +++ b/e2e/paths/claim-module/04_claim_action.spec.js @@ -0,0 +1,63 @@ +import selectors from '../../helpers/selectors.js'; +import createNightmare from '../../helpers/nightmare'; + +describe('Claim edit basic data path', () => { + const nightmare = createNightmare(); + + beforeAll(() => { + nightmare + .loginAndModule('administrative', 'claim') + .accessToSearchResult('4') + .accessToSection('claim.card.action'); + }); + + it('should import the claim', async() => { + const result = await nightmare + .waitToClick(selectors.claimAction.importClaimButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should import the eighth ticket', async() => { + const result = await nightmare + .waitToClick(selectors.claimAction.importTicketButton) + .waitToClick(selectors.claimAction.secondImportableTicket) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should edit the fourth line destination field', async() => { + const result = await nightmare + .autocompleteSearch(selectors.claimAction.thirdLineDestination, 'Bueno') + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should delete two first lines', async() => { + const result = await nightmare + .waitToClick(selectors.claimAction.secondDeleteLine) + .waitToClick(selectors.claimAction.firstDeleteLine) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should refresh the view to check the remaining line is the expected one', async() => { + const result = await nightmare + .reloadSection('claim.card.action') + .waitToGetProperty(`${selectors.claimAction.firstLineDestination} input`, 'value'); + + expect(result).toEqual('Bueno'); + }); + + it('should delete the current first line', async() => { + const result = await nightmare + .waitToClick(selectors.claimAction.firstDeleteLine) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); +}); From 6d70a45f41e1b262d8c4377549f2cef989e1af20 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Mon, 25 Feb 2019 12:08:16 +0100 Subject: [PATCH 3/3] added a comma becouse becouse --- e2e/helpers/selectors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index bd850ef3f..1f04c4339 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -466,7 +466,7 @@ export default { secondClaimResponsibleAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[field="claimDevelopment.claimResponsibleFk"]', secondClaimWorkerAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[field="claimDevelopment.workerFk"]', secondClaimRedeliveryAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[field="claimDevelopment.claimRedeliveryFk"]', - saveDevelopmentButton: `${components.vnSubmit}` + saveDevelopmentButton: `${components.vnSubmit}`, }, claimAction: { importClaimButton: 'vn-claim-action vn-button[label="Import claim"]',