#1055 e2e user configuration

This commit is contained in:
Carlos Jimenez Ruiz 2019-01-28 13:41:57 +01:00
parent 7a879f5431
commit 01fd9fd5fe
2 changed files with 107 additions and 0 deletions

View File

@ -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: {

View File

@ -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!');
});
});
});