salix/e2e/paths/02-client/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() => {
await 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);
await page.waitForContentLoaded();
2019-12-31 11:00:16 +00:00
2020-02-03 14:55:11 +00:00
let expectedLocalWarehouse = await page
.expectPropertyValue(selectors.globalItems.userLocalWarehouse, 'value', '');
2019-01-28 12:41:57 +00:00
2020-02-03 14:55:11 +00:00
let expectedLocalBank = await page
.expectPropertyValue(selectors.globalItems.userLocalBank, 'value', '');
2019-01-28 12:41:57 +00:00
2020-02-03 14:55:11 +00:00
let expectedLocalCompany = await page
.expectPropertyValue(selectors.globalItems.userLocalCompany, 'value', '');
2019-01-28 12:41:57 +00:00
2019-12-31 11:00:16 +00:00
let userWarehouse = await page
.waitToGetProperty(selectors.globalItems.userWarehouse, 'value');
2019-01-28 12:41:57 +00:00
2019-12-31 11:00:16 +00:00
let userCompany = await page
.waitToGetProperty(selectors.globalItems.userCompany, 'value');
2019-01-28 12:41:57 +00:00
2020-02-03 14:55:11 +00:00
expect(expectedLocalWarehouse).toBeTruthy();
expect(expectedLocalBank).toBeTruthy();
expect(expectedLocalCompany).toBeTruthy();
2019-01-28 12:41:57 +00:00
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);
2020-02-03 14:55:11 +00:00
let expectedLocalWarehouse = await page
.expectPropertyValue(selectors.globalItems.userLocalWarehouse, 'value', '');
2020-02-03 14:55:11 +00:00
let expectedLocalBank = await page
.expectPropertyValue(selectors.globalItems.userLocalBank, 'value', '');
let expectedLocalCompany = await page
.expectPropertyValue(selectors.globalItems.userLocalCompany, 'value', '');
2019-12-31 11:00:16 +00:00
let userWarehouse = await page
.waitToGetProperty(selectors.globalItems.userWarehouse, 'value');
2019-12-31 11:00:16 +00:00
let userCompany = await page
.waitToGetProperty(selectors.globalItems.userCompany, 'value');
2020-02-03 14:55:11 +00:00
expect(expectedLocalWarehouse).toBeTruthy();
expect(expectedLocalBank).toBeTruthy();
expect(expectedLocalCompany).toBeTruthy();
2020-12-23 11:42:41 +00:00
expect(userWarehouse).toEqual('Warehouse One');
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');
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2019-01-28 12:41:57 +00:00
2020-04-08 09:24:40 +00:00
expect(message.type).toBe('success');
2019-01-28 12:41:57 +00:00
});
});
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
.waitToGetProperty(selectors.globalItems.userLocalWarehouse, 'value');
2019-01-28 12:41:57 +00:00
2019-12-31 11:00:16 +00:00
let userLocalBank = await page
.waitToGetProperty(selectors.globalItems.userLocalBank, 'value');
2019-01-28 12:41:57 +00:00
2019-12-31 11:00:16 +00:00
let userLocalCompany = await page
.waitToGetProperty(selectors.globalItems.userLocalCompany, 'value');
2019-01-28 12:41:57 +00:00
2019-12-31 11:00:16 +00:00
let userWarehouse = await page
.waitToGetProperty(selectors.globalItems.userWarehouse, 'value');
2019-01-28 12:41:57 +00:00
2019-12-31 11:00:16 +00:00
let userCompany = await page
.waitToGetProperty(selectors.globalItems.userCompany, 'value');
2019-01-28 12:41:57 +00:00
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);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2019-01-28 12:41:57 +00:00
2020-04-08 09:24:40 +00:00
expect(message.type).toBe('success');
2019-01-28 12:41:57 +00:00
});
});
});