2020-01-14 08:20:14 +00:00
|
|
|
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', () => {
|
2020-01-14 08:20:14 +00:00
|
|
|
let browser;
|
2019-12-31 11:00:16 +00:00
|
|
|
let page;
|
|
|
|
beforeAll(async() => {
|
2020-01-14 08:20:14 +00:00
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
2019-12-31 11:00:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async() => {
|
2020-01-14 08:40:50 +00:00
|
|
|
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');
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.waitForContentLoaded();
|
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);
|
2020-02-12 06:21:53 +00:00
|
|
|
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
|
|
|
|
2019-12-31 11:00:16 +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
|
2020-01-29 13:54:07 +00:00
|
|
|
.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
|
2020-01-29 13:54:07 +00:00
|
|
|
.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');
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.waitForContentLoaded();
|
2019-01-28 12:41:57 +00:00
|
|
|
});
|
|
|
|
|
2019-01-28 12:42:11 +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
|
|
|
await page.waitFor(1000);
|
|
|
|
let expectedLocalWarehouse = await page
|
|
|
|
.expectPropertyValue(selectors.globalItems.userLocalWarehouse, 'value', '');
|
2019-01-28 12:42:11 +00:00
|
|
|
|
|
|
|
|
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-01-28 12:42:11 +00:00
|
|
|
|
2019-12-31 11:00:16 +00:00
|
|
|
let userWarehouse = await page
|
2020-01-29 13:54:07 +00:00
|
|
|
.waitToGetProperty(selectors.globalItems.userWarehouse, 'value');
|
2019-01-28 12:42:11 +00:00
|
|
|
|
2019-12-31 11:00:16 +00:00
|
|
|
let userCompany = await page
|
2020-01-29 13:54:07 +00:00
|
|
|
.waitToGetProperty(selectors.globalItems.userCompany, 'value');
|
2019-01-28 12:42:11 +00:00
|
|
|
|
2020-02-03 14:55:11 +00:00
|
|
|
expect(expectedLocalWarehouse).toBeTruthy();
|
|
|
|
expect(expectedLocalBank).toBeTruthy();
|
|
|
|
expect(expectedLocalCompany).toBeTruthy();
|
2019-01-28 12:42:11 +00:00
|
|
|
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');
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.waitForContentLoaded();
|
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
|
2020-01-29 13:54:07 +00:00
|
|
|
.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
|
2020-01-29 13:54:07 +00:00
|
|
|
.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
|
2020-01-29 13:54:07 +00:00
|
|
|
.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
|
2020-01-29 13:54:07 +00:00
|
|
|
.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
|
2020-01-29 13:54:07 +00:00
|
|
|
.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);
|
|
|
|
let result = await page.waitForLastSnackbar();
|
2019-01-28 12:41:57 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|