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

126 lines
5.0 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');
});
it('should now open the user config form to check the settings', async() => {
await page.waitToClick(selectors.globalItems.userMenuButton);
let userLocalWarehouse = await page
.getProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value');
let userLocalBank = await page
.getProperty(`${selectors.globalItems.userLocalBank} input`, 'value');
let userLocalCompany = await page
.getProperty(`${selectors.globalItems.userLocalCompany} input`, 'value');
let userWarehouse = await page
.waitToGetProperty(`${selectors.globalItems.userWarehouse} input`, 'value');
let userCompany = await page
.waitToGetProperty(`${selectors.globalItems.userCompany} input`, 'value');
expect(userLocalWarehouse).toEqual('');
expect(userLocalBank).toEqual('');
expect(userLocalCompany).toEqual('');
expect(userWarehouse).toEqual('Warehouse Three');
expect(userCompany).toEqual('VNH');
});
});
describe('as employee', () => {
it('should log in', async() => {
await page.login('employee');
});
it('should open the user config form to check the settings', async() => {
await page.waitToClick(selectors.globalItems.userMenuButton);
let userLocalWarehouse = await page
.getProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value');
let userLocalBank = await page
.getProperty(`${selectors.globalItems.userLocalBank} input`, 'value');
let userLocalCompany = await page
.getProperty(`${selectors.globalItems.userLocalCompany} input`, 'value');
let userWarehouse = await page
.waitToGetProperty(`${selectors.globalItems.userWarehouse} input`, 'value');
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');
});
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');
});
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} input`, 'value');
let userLocalBank = await page
.waitToGetProperty(`${selectors.globalItems.userLocalBank} input`, 'value');
let userLocalCompany = await page
.waitToGetProperty(`${selectors.globalItems.userLocalCompany} input`, 'value');
let userWarehouse = await page
.waitToGetProperty(`${selectors.globalItems.userWarehouse} input`, 'value');
let userCompany = await page
.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('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!');
});
});
});