This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
/
Payroll.js
218 lines (209 loc) · 10.5 KB
/
Payroll.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
//Payroll.js
//Actions specific to the everything relating to payrolls (Member > Payroll / Accounting > Payrolls)
var EC = protractor.ExpectedConditions;
var mainAccountSelect = $("mat-select[formcontrolname='mainAccountNumber'] .mat-select-trigger");
var amountInput = $$("fims-number-input[controlname='amount'] input");
var allocationAccountSelect = $$("mat-select[formcontrolname='accountNumber'] .mat-select-trigger");
var checkboxProportional = $$("mat-checkbox[formcontrolname='proportional']");
var fromAccountInput = $("fims-account-select[formcontrolname='sourceAccountNumber'] input");
var memberInput = $$("fims-customer-select[formcontrolname='customerIdentifier'] input");
var employerInput = $$("fims-text-input[controlname='employer'] input");
var salaryInput = $$("fims-number-input[controlname='salary'] input");
var primaryButtons = $$(".mat-raised-button.mat-primary");
var buttons = $$(".mat-button");
var removeAllocationButtons = $$("fims-customer-payroll-form .mat-button");
var removePaymentButtons = $$("fims-payroll-form .mat-button");
module.exports = {
clickButtonEditPayrollDistribution: function(customer){
link = "/customers/detail/" + customer + "/payroll/edit";
browser.wait(EC.elementToBeClickable($('a[href="' + link + '"]')), 6000);
$('a[href="' + link + '"]').click();
},
enterTextIntoAmountInputFieldForAllocation: function(text, allocationNumber) {
browser.wait(EC.elementToBeClickable(amountInput.get(allocationNumber-1)), 5000);
amountInput.get(allocationNumber-1).click().clear().sendKeys(text);
},
clickButtonAddAllocations: function(){
browser.sleep(200);
buttons.filter(function(elem, index) {
return elem.$("span").getText().then(function(text) {
return text === "Add allocation";
});
}).click();
},
clickButtonRemoveAllocation: function(allocationNumber){
removeAllocationButtons.filter(function(elem, index) {
return elem.$("span").getText().then(function(text) {
return text === "Remove";
});
}).get(allocationNumber-1).click();
},
clickButtonUpdateAllocations: function(){
primaryButtons.filter(function(elem, index) {
return elem.$("span").getText().then(function(text) {
return text === "UPDATE ALLOCATIONS";
});
}).click();
},
verifyButtonUpdateAllocationsDisabled: function(){
expect(primaryButtons.filter(function(elem, index) {
return elem.$("span").getText().then(function(text) {
return text === "UPDATE ALLOCATIONS";
});
}).first().isEnabled()).toBe(false);
},
verifyButtonUpdateAllocationsEnabled: function(){
expect(primaryButtons.filter(function(elem, index) {
return elem.$("span").getText().then(function(text) {
return text === "UPDATE ALLOCATIONS";
});
}).first().isEnabled()).toBe(true);
},
checkCheckboxProportionalForAllocation: function(allocationNumber){
checkboxProportional.get(allocationNumber-1).click();
},
uncheckCheckboxProportionalForAllocation: function(allocationNumber){
checkboxProportional.get(allocationNumber-1).click();
},
selectAllocationAccountForAllocation: function(accountIdentifier, allocationNumber){
browser.wait(EC.elementToBeClickable(allocationAccountSelect.get(allocationNumber-1)), 3000);
allocationAccountSelect.get(allocationNumber-1).click();
browser.wait(EC.visibilityOf($(".mat-option")), 5000);
element(by.cssContainingText('.mat-option', accountIdentifier)).click();
},
selectAllocationAccountFromOpenList: function(accountIdentifier){
browser.wait(EC.visibilityOf($(".mat-option")), 5000);
element(by.cssContainingText('.mat-option', accountIdentifier)).click();
},
verifyAccountNotOfferedForSelection: function(accountIdentifier, allocationNumber){
browser.wait(EC.elementToBeClickable(allocationAccountSelect.get(allocationNumber-1)), 3000);
allocationAccountSelect.get(allocationNumber-1).click();
browser.wait(EC.visibilityOf($(".mat-option")), 5000);
expect(element(by.cssContainingText('.mat-option', accountIdentifier)).isPresent()).toBe(false);
},
selectMainAccount: function(accountIdentifier){
browser.sleep(500);
browser.executeScript("arguments[0].scrollIntoView();", mainAccountSelect.getWebElement());
browser.wait(EC.elementToBeClickable(mainAccountSelect), 3000);
mainAccountSelect.click();
browser.wait(EC.visibilityOf($(".mat-option")), 5000);
//browser.executeScript("arguments[0].scrollIntoView();", element(by.cssContainingText('.mat-option', accountIdentifier)).getWebElement());
element(by.cssContainingText('.mat-option', accountIdentifier)).click();
},
//Accounting > Payrolls
clickButtonCreatePayroll: function(){
link = "/accounting/payrolls/create";
browser.wait(EC.elementToBeClickable($('a[href="' + link + '"]')), 6000);
$('a[href="' + link + '"]').click();
},
clickCreatePaymentsButton: function(){
browser.wait(EC.elementToBeClickable(primaryButtons.get(0)), 5000);
primaryButtons.filter(function(elem, index) {
return elem.$("span").getText().then(function(text) {
return text === "CREATE PAYMENTS";
});
}).click();
},
verifyCreatePaymentsButtonIsDisabled: function(){
expect(primaryButtons.filter(function(elem, index) {
return elem.$("span").getText().then(function(text) {
return text === "CREATE PAYMENTS";
});
}).first().isEnabled()).toBe(false);
},
verifyCreatePaymentsButtonIsEnabled: function(){
expect(primaryButtons.filter(function(elem, index) {
return elem.$("span").getText().then(function(text) {
return text === "CREATE PAYMENTS";
});
}).first().isEnabled()).toBe(true);
},
clickButtonAddPayment: function(){
buttons.filter(function(elem, index) {
return elem.$("span").getText().then(function(text) {
return text === "Add payment";
});
}).click();
},
clickButtonRemovePayment: function(paymentNumber){
removePaymentButtons.filter(function(elem, index) {
return elem.$("span").getText().then(function(text) {
return text === "Remove";
});
}).get(paymentNumber-1).click();
},
enterTextIntoFromAccountInputFieldForPayment: function(text) {
browser.wait(EC.elementToBeClickable(fromAccountInput), 5000);
fromAccountInput.click().clear().sendKeys(text);
},
enterTextIntoMemberInputFieldForPayment: function(text, paymentNumber) {
browser.wait(EC.elementToBeClickable(memberInput.get(paymentNumber-1)), 5000);
memberInput.get(paymentNumber-1).click().clear().sendKeys(text);
},
verifyMemberInputFieldHasError: function(errorMessage) {
browser.wait(EC.textToBePresentInElement($$("mat-hint").get(1), "Invalid member or has no payroll created"), 2000);
expect(memberInput.first().element(by.xpath("..")).element(by.xpath("..")).element(by.xpath("..")).$("mat-hint").getText()).toEqual(errorMessage);
},
enterTextIntoEmployerInputFieldForPayment: function(text, paymentNumber) {
browser.wait(EC.elementToBeClickable(employerInput.get(paymentNumber-1)), 5000);
employerInput.get(paymentNumber-1).click().clear().sendKeys(text);
},
enterTextIntoSalaryInputFieldForPayment: function(text, paymentNumber) {
browser.wait(EC.elementToBeClickable(salaryInput.get(paymentNumber-1)), 5000);
salaryInput.get(paymentNumber-1).click().clear().sendKeys(text);
},
verifyMemberIDForPaymentInRow: function(memberID, row){
browser.wait(EC.visibilityOf($("table tbody")), 3000);
browser.sleep(1000);
expect($$("table tbody tr").get(row - 1).$$(".td-data-table-cell").get(0).getText()).toEqual(memberID);
},
verifyEmployerForPaymentInRow: function(employer, row){
browser.wait(EC.visibilityOf($("table tbody")), 3000);
expect($$("table tbody tr").get(row - 1).$$(".td-data-table-cell").get(1).getText()).toEqual(employer);
},
verifySalaryForPaymentInRow: function(salary, row){
browser.wait(EC.visibilityOf($("table tbody")), 3000);
expect($$("table tbody tr").get(row - 1).$$(".td-data-table-cell").get(2).getText()).toEqual(salary);
},
verifyCreatedByForPayrollInRow: function(createdBy, row){
browser.wait(EC.visibilityOf($("table tbody")), 3000);
expect($$("table tbody tr").get(row - 1).$$(".td-data-table-cell").get(0).getText()).toEqual(createdBy);
},
verifyAccountNumberForPayrollInRow: function(accountNumber, row){
browser.wait(EC.visibilityOf($("table tbody")), 3000);
expect($$("table tbody tr").get(row - 1).$$(".td-data-table-cell").get(2).getText()).toEqual(accountNumber);
},
verifyPayrollInfo: function(heading, value) {
expect($$(".mat-list-item .mat-list-text").filter(function (elem, index) {
return elem.$("h3").getText().then(function (text) {
return text === heading;
}).$(p).getText().then(function (text) {
return text === value;
}).toBe(true);
}));
},
verifyErrorIsDisplayedIfSameAccountSelectedTwice: function() {
browser.wait(EC.textToBePresentInElement($(".tc-red-600"),"Allocation accounts can't use main account or overlap with other allocation accounts."), 2000);
expect($(".tc-red-600").getText()).toMatch("Allocation accounts can't use main account or overlap with other allocation accounts.");
},
};