diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 7c0d67e93..897048b41 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -9,6 +9,15 @@ export default { ticketsButton: `vn-main-menu [vn-id="apps-menu"] ul > li[ui-sref="ticket.index"]`, claimsButton: `vn-main-menu [vn-id="apps-menu"] ul > li[ui-sref="claim.index"]`, returnToModuleIndexButton: `a[translate-attr="{title: 'Return to module index'}"]`, + userMenuButton: `vn-topbar #user`, + userLocalWarehouse: `vn-topbar vn-popover vn-autocomplete[field="$ctrl.localWarehouseFk"]`, + userLocalBank: `vn-topbar vn-popover vn-autocomplete[field="$ctrl.localBankFk"]`, + userLocalCompany: `vn-topbar vn-popover vn-autocomplete[field="$ctrl.localCompanyFk"]`, + userWarehouse: `vn-topbar vn-popover vn-autocomplete[field="$ctrl.warehouseFk"]`, + userCompany: `vn-topbar vn-popover vn-autocomplete[field="$ctrl.companyFk"]`, + userConfigFirstAutocompleteClear: '#localWarehouse > div > div > div > vn-icon.clear', + userConfigSecondAutocompleteClear: '#localBank > div > div > div > vn-icon.clear', + userConfigThirdAutocompleteClear: '#localCompany > div > div > div > vn-icon.clear', acceptVnConfirm: `vn-confirm button[response=ACCEPT]` }, clientsIndex: { diff --git a/e2e/paths/client-module/15_user_config.spec.js b/e2e/paths/client-module/15_user_config.spec.js new file mode 100644 index 000000000..aa67b1686 --- /dev/null +++ b/e2e/paths/client-module/15_user_config.spec.js @@ -0,0 +1,98 @@ +import selectors from '../../helpers/selectors.js'; +import createNightmare from '../../helpers/nightmare'; + +describe('User config', () => { + const nightmare = createNightmare(); + + describe('as salesPerson', () => { + beforeAll(() => { + nightmare + .waitForLogin('salesPerson'); + }); + + it('should now open the user config form to check the settings', async() => { + let userLocalWarehouse = await nightmare + .waitToClick(selectors.globalItems.userMenuButton) + .getProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value'); + + let userLocalBank = await nightmare + .getProperty(`${selectors.globalItems.userLocalBank} input`, 'value'); + + let userLocalCompany = await nightmare + .getProperty(`${selectors.globalItems.userLocalCompany} input`, 'value'); + + let userWarehouse = await nightmare + .waitToGetProperty(`${selectors.globalItems.userWarehouse} input`, 'value'); + + let userCompany = await nightmare + .waitToGetProperty(`${selectors.globalItems.userCompany} input`, 'value'); + + expect(userLocalWarehouse).toEqual(''); + expect(userLocalBank).toEqual(''); + expect(userLocalCompany).toEqual(''); + expect(userWarehouse).toEqual('Warehouse Three'); + expect(userCompany).toEqual('FTH'); + }); + }); + + describe('as employee', () => { + beforeAll(() => { + nightmare + .waitForLogin('employee'); + }); + + it('should now edit the user config data', async() => { + let result = await nightmare + .waitToClick(selectors.globalItems.userMenuButton) + .autocompleteSearch(selectors.globalItems.userLocalWarehouse, 'Warehouse Four') + .autocompleteSearch(selectors.globalItems.userLocalBank, 'Pay on receipt') + .autocompleteSearch(selectors.globalItems.userLocalCompany, 'VNL') + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + }); + + describe('as salesPerson 2nd run', () => { + beforeAll(() => { + nightmare + .waitForLogin('salesPerson'); + }); + + it('should again open the user config form to check the local settings', async() => { + let userLocalWarehouse = await nightmare + .waitToClick(selectors.globalItems.userMenuButton) + .waitToGetProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value'); + + let userLocalBank = await nightmare + .waitToGetProperty(`${selectors.globalItems.userLocalBank} input`, 'value'); + + let userLocalCompany = await nightmare + .waitToGetProperty(`${selectors.globalItems.userLocalCompany} input`, 'value'); + + let userWarehouse = await nightmare + .waitToGetProperty(`${selectors.globalItems.userWarehouse} input`, 'value'); + + let userCompany = await nightmare + .waitToGetProperty(`${selectors.globalItems.userCompany} input`, 'value'); + + expect(userLocalWarehouse).toContain('Warehouse Four'); + expect(userLocalBank).toContain('Pay on receipt'); + expect(userLocalCompany).toContain('VNL'); + expect(userWarehouse).toEqual('Warehouse Three'); + expect(userCompany).toEqual('FTH'); + }); + + it('should now clear the local settings', async() => { + let result = await nightmare + .waitToClick(selectors.globalItems.userMenuButton) + .waitToClick(selectors.globalItems.userConfigFirstAutocompleteClear) + .waitToClick(selectors.globalItems.userConfigSecondAutocompleteClear) + .waitToClick(selectors.globalItems.userConfigThirdAutocompleteClear) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + }); +}); +