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

126 lines
5.0 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors';
import getBrowser from '../../helpers/puppeteer';
2019-01-28 12:41:57 +00:00
2019-01-28 12:44:03 +00:00
describe('User config', () => {
let browser;
2019-12-31 11:00:16 +00:00
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
2019-12-31 11:00:16 +00:00
});
afterAll(async() => {
browser.close();
2019-12-31 11:00:16 +00:00
});
2019-01-28 12:41:57 +00:00
describe('as salesPerson', () => {
2019-12-31 11:00:16 +00:00
it('should login', async() => {
await page.login('salesPerson');
2019-01-28 12:41:57 +00:00
});
it('should now open the user config form to check the settings', async() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.globalItems.userMenuButton);
let userLocalWarehouse = await page
2019-01-28 12:41:57 +00:00
.getProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value');
2019-12-31 11:00:16 +00:00
let userLocalBank = await page
2019-01-28 12:41:57 +00:00
.getProperty(`${selectors.globalItems.userLocalBank} input`, 'value');
2019-12-31 11:00:16 +00:00
let userLocalCompany = await page
2019-01-28 12:41:57 +00:00
.getProperty(`${selectors.globalItems.userLocalCompany} input`, 'value');
2019-12-31 11:00:16 +00:00
let userWarehouse = await page
2019-01-28 12:41:57 +00:00
.waitToGetProperty(`${selectors.globalItems.userWarehouse} input`, 'value');
2019-12-31 11:00:16 +00:00
let userCompany = await page
2019-01-28 12:41:57 +00:00
.waitToGetProperty(`${selectors.globalItems.userCompany} input`, 'value');
expect(userLocalWarehouse).toEqual('');
expect(userLocalBank).toEqual('');
expect(userLocalCompany).toEqual('');
expect(userWarehouse).toEqual('Warehouse Three');
2019-02-18 13:46:25 +00:00
expect(userCompany).toEqual('VNH');
2019-01-28 12:41:57 +00:00
});
});
describe('as employee', () => {
2019-12-31 11:00:16 +00:00
it('should log in', async() => {
await page.login('employee');
2019-01-28 12:41:57 +00:00
});
it('should open the user config form to check the settings', async() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.globalItems.userMenuButton);
let userLocalWarehouse = await page
.getProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value');
2019-12-31 11:00:16 +00:00
let userLocalBank = await page
.getProperty(`${selectors.globalItems.userLocalBank} input`, 'value');
2019-12-31 11:00:16 +00:00
let userLocalCompany = await page
.getProperty(`${selectors.globalItems.userLocalCompany} input`, 'value');
2019-12-31 11:00:16 +00:00
let userWarehouse = await page
.waitToGetProperty(`${selectors.globalItems.userWarehouse} input`, 'value');
2019-12-31 11:00:16 +00:00
let userCompany = await page
.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() => {
2019-12-31 11:00:16 +00:00
await page.autocompleteSearch(selectors.globalItems.userLocalWarehouse, 'Warehouse Four');
await page.autocompleteSearch(selectors.globalItems.userLocalBank, 'Pay on receipt');
await page.autocompleteSearch(selectors.globalItems.userLocalCompany, 'VNL');
let result = await page.waitForLastSnackbar();
2019-01-28 12:41:57 +00:00
expect(result).toEqual('Data saved!');
});
});
describe('as salesPerson 2nd run', () => {
2019-12-31 11:00:16 +00:00
it('should log in once more', async() => {
await page.login('salesPerson');
2019-01-28 12:41:57 +00:00
});
it('should again open the user config form to check the local settings', async() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.globalItems.userMenuButton);
let userLocalWarehouse = await page
2019-01-28 12:41:57 +00:00
.waitToGetProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value');
2019-12-31 11:00:16 +00:00
let userLocalBank = await page
2019-01-28 12:41:57 +00:00
.waitToGetProperty(`${selectors.globalItems.userLocalBank} input`, 'value');
2019-12-31 11:00:16 +00:00
let userLocalCompany = await page
2019-01-28 12:41:57 +00:00
.waitToGetProperty(`${selectors.globalItems.userLocalCompany} input`, 'value');
2019-12-31 11:00:16 +00:00
let userWarehouse = await page
2019-01-28 12:41:57 +00:00
.waitToGetProperty(`${selectors.globalItems.userWarehouse} input`, 'value');
2019-12-31 11:00:16 +00:00
let userCompany = await page
2019-01-28 12:41:57 +00:00
.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');
2019-02-18 13:46:25 +00:00
expect(userCompany).toEqual('VNH');
2019-01-28 12:41:57 +00:00
});
it('should now clear the local settings', async() => {
2019-12-31 11:00:16 +00:00
await page.clearInput(selectors.globalItems.userConfigFirstAutocomplete);
await page.clearInput(selectors.globalItems.userConfigSecondAutocomplete);
await page.clearInput(selectors.globalItems.userConfigThirdAutocomplete);
let result = await page.waitForLastSnackbar();
2019-01-28 12:41:57 +00:00
expect(result).toEqual('Data saved!');
});
});
});