salix/e2e/paths/03-worker/06_create.spec.js

74 lines
3.0 KiB
JavaScript
Raw Normal View History

2023-01-03 13:50:29 +00:00
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
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-07-14 11:48:36 +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');
// 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');
// should fail if necessary data is void
2023-01-03 13:50:29 +00:00
await page.waitToClick(selectors.workerCreate.createButton);
let message = await page.waitForSnackbar();
2023-01-03 13:50:29 +00:00
expect(message.text).toContain('is a required argument');
// 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));
2023-06-21 11:34:27 +00:00
await page.autocompleteSearch(selectors.workerCreate.boss, 'deliveryAssistant');
2023-01-03 13:50:29 +00:00
await page.waitToClick(selectors.workerCreate.createButton);
message = await page.waitForSnackbar();
2023-01-03 13:50:29 +00:00
await page.waitForState('worker.card.basicData');
expect(message.text).toContain('Data saved!');
// 'rollback'
2023-05-23 07:44:07 +00:00
await page.loginAndModule('itManagement', 'account');
2023-01-03 13:50:29 +00:00
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);
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
});
});