132 lines
5.2 KiB
JavaScript
132 lines
5.2 KiB
JavaScript
import selectors from '../../helpers/selectors';
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
describe('User config', () => {
|
|
let browser;
|
|
let page;
|
|
beforeAll(async() => {
|
|
browser = await getBrowser();
|
|
page = browser.page;
|
|
});
|
|
|
|
afterAll(async() => {
|
|
await browser.close();
|
|
});
|
|
|
|
describe('as salesPerson', () => {
|
|
it('should login', async() => {
|
|
await page.login('salesPerson');
|
|
await page.waitForContentLoaded();
|
|
});
|
|
|
|
it('should now open the user config form to check the settings', async() => {
|
|
await page.waitToClick(selectors.globalItems.userMenuButton);
|
|
await page.waitFor(1000);
|
|
|
|
let expectedLocalWarehouse = await page
|
|
.expectPropertyValue(selectors.globalItems.userLocalWarehouse, 'value', '');
|
|
|
|
|
|
let expectedLocalBank = await page
|
|
.expectPropertyValue(selectors.globalItems.userLocalBank, 'value', '');
|
|
|
|
let expectedLocalCompany = await page
|
|
.expectPropertyValue(selectors.globalItems.userLocalCompany, 'value', '');
|
|
|
|
let userWarehouse = await page
|
|
.waitToGetProperty(selectors.globalItems.userWarehouse, 'value');
|
|
|
|
let userCompany = await page
|
|
.waitToGetProperty(selectors.globalItems.userCompany, 'value');
|
|
|
|
expect(expectedLocalWarehouse).toBeTruthy();
|
|
expect(expectedLocalBank).toBeTruthy();
|
|
expect(expectedLocalCompany).toBeTruthy();
|
|
expect(userWarehouse).toEqual('Warehouse Three');
|
|
expect(userCompany).toEqual('VNH');
|
|
});
|
|
});
|
|
|
|
describe('as employee', () => {
|
|
it('should log in', async() => {
|
|
await page.login('employee');
|
|
await page.waitForContentLoaded();
|
|
});
|
|
|
|
it('should open the user config form to check the settings', async() => {
|
|
await page.waitToClick(selectors.globalItems.userMenuButton);
|
|
await page.waitFor(1000);
|
|
let expectedLocalWarehouse = await page
|
|
.expectPropertyValue(selectors.globalItems.userLocalWarehouse, 'value', '');
|
|
|
|
|
|
let expectedLocalBank = await page
|
|
.expectPropertyValue(selectors.globalItems.userLocalBank, 'value', '');
|
|
|
|
let expectedLocalCompany = await page
|
|
.expectPropertyValue(selectors.globalItems.userLocalCompany, 'value', '');
|
|
|
|
let userWarehouse = await page
|
|
.waitToGetProperty(selectors.globalItems.userWarehouse, 'value');
|
|
|
|
let userCompany = await page
|
|
.waitToGetProperty(selectors.globalItems.userCompany, 'value');
|
|
|
|
expect(expectedLocalWarehouse).toBeTruthy();
|
|
expect(expectedLocalBank).toBeTruthy();
|
|
expect(expectedLocalCompany).toBeTruthy();
|
|
expect(userWarehouse).toEqual('Warehouse Two');
|
|
expect(userCompany).toEqual('CCs');
|
|
});
|
|
|
|
it('should now edit the user config data', async() => {
|
|
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();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
});
|
|
|
|
describe('as salesPerson 2nd run', () => {
|
|
it('should log in once more', async() => {
|
|
await page.login('salesPerson');
|
|
await page.waitForContentLoaded();
|
|
});
|
|
|
|
it('should again open the user config form to check the local settings', async() => {
|
|
await page.waitToClick(selectors.globalItems.userMenuButton);
|
|
let userLocalWarehouse = await page
|
|
.waitToGetProperty(selectors.globalItems.userLocalWarehouse, 'value');
|
|
|
|
let userLocalBank = await page
|
|
.waitToGetProperty(selectors.globalItems.userLocalBank, 'value');
|
|
|
|
let userLocalCompany = await page
|
|
.waitToGetProperty(selectors.globalItems.userLocalCompany, 'value');
|
|
|
|
let userWarehouse = await page
|
|
.waitToGetProperty(selectors.globalItems.userWarehouse, 'value');
|
|
|
|
let userCompany = await page
|
|
.waitToGetProperty(selectors.globalItems.userCompany, 'value');
|
|
|
|
expect(userLocalWarehouse).toContain('Warehouse Four');
|
|
expect(userLocalBank).toContain('Pay on receipt');
|
|
expect(userLocalCompany).toContain('VNL');
|
|
expect(userWarehouse).toEqual('Warehouse Three');
|
|
expect(userCompany).toEqual('VNH');
|
|
});
|
|
|
|
it('should now clear the local settings', async() => {
|
|
await page.clearInput(selectors.globalItems.userConfigFirstAutocomplete);
|
|
await page.clearInput(selectors.globalItems.userConfigSecondAutocomplete);
|
|
await page.clearInput(selectors.globalItems.userConfigThirdAutocomplete);
|
|
let result = await page.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
});
|
|
});
|