2023-01-03 13:50:29 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
|
2023-01-16 11:19:03 +00:00
|
|
|
describe('Worker create path', () => {
|
2023-01-03 13:50:29 +00:00
|
|
|
let browser;
|
|
|
|
let page;
|
|
|
|
let newWorker;
|
|
|
|
beforeAll(async() => {
|
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
|
|
|
await page.loginAndModule('hr', 'worker');
|
|
|
|
await page.waitToClick(selectors.workerCreate.newWorkerButton);
|
|
|
|
await page.waitForState('worker.create');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async() => {
|
|
|
|
await browser.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should insert default data', async() => {
|
|
|
|
await page.write(selectors.workerCreate.firstname, 'Victor');
|
|
|
|
await page.write(selectors.workerCreate.lastname, 'Von Doom');
|
|
|
|
await page.write(selectors.workerCreate.fi, '78457139E');
|
|
|
|
await page.write(selectors.workerCreate.phone, '12356789');
|
|
|
|
await page.write(selectors.workerCreate.postcode, '46680');
|
2023-01-16 11:19:03 +00:00
|
|
|
await page.write(selectors.workerCreate.street, 'S/ Doomstadt');
|
2023-01-03 13:50:29 +00:00
|
|
|
await page.write(selectors.workerCreate.email, 'doctorDoom@marvel.com');
|
|
|
|
await page.write(selectors.workerCreate.iban, 'ES9121000418450200051332');
|
|
|
|
|
2023-01-16 11:19:03 +00:00
|
|
|
// should check for autocompleted worker code and worker user name
|
2023-01-03 13:50:29 +00:00
|
|
|
const workerCode = await page
|
|
|
|
.waitToGetProperty(selectors.workerCreate.code, 'value');
|
|
|
|
|
|
|
|
newWorker = await page
|
|
|
|
.waitToGetProperty(selectors.workerCreate.user, 'value');
|
|
|
|
|
|
|
|
expect(workerCode).toEqual('VVD');
|
|
|
|
expect(newWorker).toContain('victorvd');
|
|
|
|
|
2023-01-16 11:19:03 +00:00
|
|
|
// should fail if necessary data is void
|
2023-01-03 13:50:29 +00:00
|
|
|
await page.waitToClick(selectors.workerCreate.createButton);
|
2023-01-16 11:19:03 +00:00
|
|
|
let message = await page.waitForSnackbar();
|
2023-01-03 13:50:29 +00:00
|
|
|
|
|
|
|
expect(message.text).toContain('is a required argument');
|
|
|
|
|
2023-01-16 11:19:03 +00:00
|
|
|
// should create a new worker and go to worker basic data'
|
2023-01-03 13:50:29 +00:00
|
|
|
await page.pickDate(selectors.workerCreate.birth, new Date(1962, 8, 5));
|
|
|
|
await page.autocompleteSearch(selectors.workerCreate.boss, 'deliveryBoss');
|
|
|
|
await page.waitToClick(selectors.workerCreate.createButton);
|
2023-01-16 11:19:03 +00:00
|
|
|
message = await page.waitForSnackbar();
|
2023-01-03 13:50:29 +00:00
|
|
|
await page.waitForState('worker.card.basicData');
|
|
|
|
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
|
|
|
2023-01-16 11:19:03 +00:00
|
|
|
// 'rollback'
|
2023-01-03 13:50:29 +00:00
|
|
|
await page.loginAndModule('sysadmin', 'account');
|
|
|
|
await page.accessToSearchResult(newWorker);
|
2023-01-04 08:23:18 +00:00
|
|
|
|
2023-01-03 13:50:29 +00:00
|
|
|
await page.waitToClick(selectors.accountDescriptor.menuButton);
|
2023-01-04 08:23:18 +00:00
|
|
|
await page.waitToClick(selectors.accountDescriptor.deactivateUser);
|
2023-01-03 13:50:29 +00:00
|
|
|
await page.waitToClick(selectors.accountDescriptor.acceptButton);
|
2023-01-16 11:19:03 +00:00
|
|
|
message = await page.waitForSnackbar();
|
2023-01-04 08:23:18 +00:00
|
|
|
|
|
|
|
expect(message.text).toContain('User deactivated!');
|
|
|
|
|
|
|
|
await page.waitToClick(selectors.accountDescriptor.menuButton);
|
|
|
|
await page.waitToClick(selectors.accountDescriptor.disableAccount);
|
|
|
|
await page.waitToClick(selectors.accountDescriptor.acceptButton);
|
|
|
|
message = await page.waitForSnackbar();
|
2023-01-03 13:50:29 +00:00
|
|
|
|
2023-01-04 08:23:18 +00:00
|
|
|
expect(message.text).toContain('Account disabled!');
|
2023-01-03 13:50:29 +00:00
|
|
|
});
|
|
|
|
});
|