-
Notifications
You must be signed in to change notification settings - Fork 1
/
add_employee_spec.js
65 lines (52 loc) · 2.18 KB
/
add_employee_spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
let employeesList = require('../page_objects/employees_list.js');
let employeeForm = require('../page_objects/employee_form.js');
let loginForm = require('../page_objects/login_form.js');
let commonMethods = require('../helpers/common_methods.js');
let employee1 = require('../data/employees.json')[0];
let employee2 = require('../data/employees.json')[1];
let fullName1 = commonMethods.createEmployeeFullName(employee1.firstName, employee1.lastName);
let fullName2 = commonMethods.createEmployeeFullName(employee2.firstName, employee2.lastName);
describe('When user is logged in as admin and clicks \"Create\" button', function() {
beforeAll(() => {
loginForm.logInAsAdmin();
employeesList.clickCreate();
});
it('then \"Create employee form\" should be opened', function() {
employeeForm.isOpened();
});
it('then submit button in form should be disabled', function() {
expect(commonMethods.isSubmitButtonDisabled()).toEqual('true');
});
});
describe('When user filled out form', function() {
beforeAll(() => {
employeeForm.fillOutForm(employee2.firstName, employee2.lastName, employee2.startDate, employee2.email);
});
it('then input fields should contain correct data', function() {
employeeForm.checkFormData(employee2.firstName, employee2.lastName, employee2.startDate, employee2.email);
});
});
describe('When user click \"Cancel\" button in form', function() {
beforeAll(() => {
employeeForm.clickCancel();
});
it('then employees list should not contain employee full name', function() {
employeesList.checkIfListDoesNotContainEmployeeName(fullName2);
});
});
describe('When user filled out form and submit it', function() {
beforeAll(() => {
employeesList.clickCreate();
employeeForm.fillOutForm(employee1.firstName, employee1.lastName, employee1.startDate, employee1.email);
commonMethods.submitForm();
});
afterAll(() => {
employeesList.deleteSelectedEmployee(fullName1);
let alert = employeesList.waitForAlertAndGetIt();
alert.accept();
employeesList.logOut();
});
it('then employees list should contain employee full name', function() {
employeesList.checkIfListContainsEmployeeName(fullName1);
});
});