salix/e2e/paths/client-module/15_user_config.spec.js

121 lines
5.0 KiB
JavaScript
Raw Normal View History

2019-01-28 12:41:57 +00:00
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
2019-01-28 12:44:03 +00:00
describe('User config', () => {
2019-01-28 12:41:57 +00:00
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 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 Two');
expect(userCompany).toEqual('CCs');
});
2019-01-28 12:41:57 +00:00
it('should now edit the user config data', async() => {
let result = await nightmare
.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!');
});
});
});