Protractor tests.
diff --git a/Pages/CustomFields.js b/Pages/CustomFields.js
index e559211..f29e813 100644
--- a/Pages/CustomFields.js
+++ b/Pages/CustomFields.js
@@ -8,9 +8,9 @@
var nameInput = $("fims-text-input[controlname='name'] input");
var descriptionInput = $("textarea[formcontrolname='description']");
var identifierInput = $$("fims-id-input[controlname='identifier'] input");
-var labelInput = $$("fims-text-input[controlname='label'] input");
+var labelInput = $$("fims-custom-field-form fims-text-input[controlname='label'] input");
var hintInput = $$("fims-text-input[controlname='hint'] input");
-var checkboxMandatory = $("md-checkbox[formcontrolname='mandatory']");
+var checkboxMandatory = $$("md-checkbox[formcontrolname='mandatory']");
var descriptionInputField = $$("textarea[formcontrolname='description']");
var radioButtonGroupDataType = $$("md-radio-group[formcontrolname='dataType']");
@@ -55,7 +55,7 @@
browser.wait(EC.elementToBeClickable(identifierInput.get(fieldNumber-1)), 5000);
identifierInput.get(fieldNumber-1).click().clear().sendKeys(text);
},
- enterTextIntoLabelInputFieldForField: function(text, fieldNumber) {
+ enterTextIntoLabelInputField: function(text, fieldNumber) {
browser.wait(EC.elementToBeClickable(labelInput.get(fieldNumber-1)), 5000);
labelInput.get(fieldNumber-1).click().clear().sendKeys(text);
},
@@ -101,12 +101,12 @@
browser.wait(EC.elementToBeClickable(maxValueInput.get(fieldNumber-1)), 5000);
maxValueInput.get(fieldNumber-1).click().clear().sendKeys(number);
},
- clickButtonAddOption: function(){
+ clickButtonAddOption: function(optionNumber){
buttons.filter(function(elem, index) {
return elem.$("span").getText().then(function(text) {
return text === "Add option";
});
- }).click();
+ }).get(optionNumber-1).click();
},
enterTextIntoLabelInputFieldForOption: function(text, option){
$$("div[formarrayname='options'] fims-text-input[controlname='label'] input").get(option-1).click().clear().sendKeys(text);
@@ -131,6 +131,20 @@
});
}).click();
},
+ verifyButtonCreateCustomFieldsDisabled: function(){
+ expect(primaryButtons.filter(function(elem, index) {
+ return elem.$("span").getText().then(function(text) {
+ return text === "CREATE CUSTOM FIELDS";
+ });
+ }).first().isEnabled()).toBe(false);
+ },
+ verifyButtonCreateCustomFieldsEnabled: function(){
+ expect(primaryButtons.filter(function(elem, index) {
+ return elem.$("span").getText().then(function(text) {
+ return text === "CREATE CUSTOM FIELDS";
+ });
+ }).first().isEnabled()).toBe(true);
+ },
clickUpdateCustomFieldsButton: function () {
browser.sleep(500);
browser.executeScript("arguments[0].scrollIntoView();", primaryButtons.first().getWebElement());
@@ -153,7 +167,149 @@
clickDeleteCatalogButton: function(){
$("button[title='Delete this catalog']").click();
},
- checkCheckboxMandatory: function(){
- checkboxMandatory.click();
- }
+ checkCheckboxMandatoryForField: function(fieldNumber){
+ checkboxMandatory.get(fieldNumber-1).click();
+ },
+ verifyNameForCatalogIs: function(name) {
+ expect($$("fims-layout-card-over .mat-list-text").filter(function (elem, index) {
+ return elem.$("h3").getText().then(function (text) {
+ return text === "Name";
+ });
+ }).first().$("p").getText().then(function (text) {
+ return text === name;
+ })).toBe(true);
+ },
+ verifyDescriptionForCatalogIs: function(desc) {
+ expect($$("fims-layout-card-over .mat-list-text").filter(function (elem, index) {
+ return elem.$("h3").getText().then(function (text) {
+ return text === "Description";
+ });
+ }).first().$("p").getText().then(function (text) {
+ return text === desc;
+ })).toBe(true);
+ },
+ verifyCreatedByForCatalogIs: function(createdBy){
+ expect($$("fims-layout-card-over .mat-list-text").filter(function (elem, index) {
+ return elem.$("h3").getText().then(function (text) {
+ return text === "Created by";
+ });
+ }).first().$("p").getText().then(function (text) {
+ return text.indexOf(createdBy) >= 0;
+ })).toBe(true);
+ },
+ verifyLastModifiedByForCatalogIs: function(lastModifiedBy){
+ expect($$("fims-layout-card-over .mat-list-text").filter(function (elem, index) {
+ return elem.$("h3").getText().then(function (text) {
+ return text === "Last modified by";
+ });
+ }).first().$("p").getText().then(function (text) {
+ return text.indexOf(lastModifiedBy) >= 0;
+ })).toBe(true);
+ },
+ verifyDataTypeForRow: function(dataType, row) {
+ browser.wait(EC.visibilityOf($("table tbody")), 3000);
+ expect($$("table tbody tr").get(row - 1).$$(".td-data-table-cell").get(1).getText()).toEqual(dataType);
+ },
+ verifyLabelForRow: function(label, row) {
+ browser.wait(EC.visibilityOf($("table tbody")), 3000);
+ expect($$("table tbody tr").get(row - 1).$$(".td-data-table-cell").get(2).getText()).toEqual(label);
+ },
+ verifyHintForRow: function(hint, row) {
+ browser.wait(EC.visibilityOf($("table tbody")), 3000);
+ expect($$("table tbody tr").get(row - 1).$$(".td-data-table-cell").get(3).getText()).toEqual(hint);
+ },
+ verifyDescriptionForRow: function(description, row) {
+ browser.wait(EC.visibilityOf($("table tbody")), 3000);
+ expect($$("table tbody tr").get(row - 1).$$(".td-data-table-cell").get(1).getText()).toEqual(description);
+ },
+ verifyDataTypeForFieldIs: function(dataType) {
+ expect($$("fims-layout-card-over .mat-list-text").filter(function (elem, index) {
+ return elem.$("h3").getText().then(function (text) {
+ return text === "Data type";
+ });
+ }).first().$("p").getText().then(function (text) {
+ return text === dataType;
+ })).toBe(true);
+ },
+ verifyLabelForFieldIs: function(label) {
+ expect($$("fims-layout-card-over .mat-list-text").filter(function (elem, index) {
+ return elem.$("h3").getText().then(function (text) {
+ return text === "Label";
+ });
+ }).first().$("p").getText().then(function (text) {
+ return text === label;
+ })).toBe(true);
+ },
+ verifyHintForFieldIs: function(hint) {
+ expect($$("fims-layout-card-over .mat-list-text").filter(function (elem, index) {
+ return elem.$("h3").getText().then(function (text) {
+ return text === "Hint";
+ });
+ }).first().$("p").getText().then(function (text) {
+ return text === hint;
+ })).toBe(true);
+ },
+ verifyMandatoryForFieldIs: function(mandatory) {
+ expect($$("fims-layout-card-over .mat-list-text").filter(function (elem, index) {
+ return elem.$("h3").getText().then(function (text) {
+ return text === "Mandatory";
+ });
+ }).first().$("p").getText().then(function (text) {
+ return text === mandatory;
+ })).toBe(true);
+ },
+ verifyLengthForFieldIs: function(length) {
+ expect($$("fims-layout-card-over .mat-list-text").filter(function (elem, index) {
+ return elem.$("h3").getText().then(function (text) {
+ return text === "Length";
+ });
+ }).first().$("p").getText().then(function (text) {
+ return text === length;
+ })).toBe(true);
+ },
+ verifyCreatedByForFieldIs: function(createdBy){
+ expect($$("fims-layout-card-over .mat-list-text").filter(function (elem, index) {
+ return elem.$("h3").getText().then(function (text) {
+ return text === "Created by";
+ });
+ }).first().$("p").getText().then(function (text) {
+ return text.indexOf(createdBy) >= 0;
+ })).toBe(true);
+ },
+ verifyCustomFieldsTitle: function(title){
+ browser.wait(EC.visibilityOf($("fims-custom-fields-component form h4")), 2000);
+ expect($("fims-custom-fields-component form h4").getText()).toEqual(title);
+ },
+ enterTextIntoCustomFieldOfTypeText: function(text, fieldId){
+ elem = $('input[id= "' + fieldId +'"]');
+ elem.clear().click().sendKeys(text);
+ },
+ enterTextIntoCustomFieldOfTypeNumber: function(text, fieldId){
+ elem = $('input[id= "' + fieldId +'"]');
+ elem.clear().click().sendKeys(text);
+ },
+ enterTextIntoCustomDateInputField: function (date, fieldId) {
+ elem = $('input[id= "' + fieldId +'"]');
+ elem.click().sendKeys(protractor.Key.ARROW_LEFT);
+ elem.sendKeys(protractor.Key.ARROW_LEFT);
+ elem.sendKeys(date);
+ },
+ selectRadioButtonForSingleSelection: function(optionNumber, fieldId){
+ elem = $('md-radio-group[ng-reflect-name= "' + fieldId +'"]');
+ elem.$$("md-radio-button").get(optionNumber-1).click();
+ },
+ selectOptionForMultiSelection: function(option, fieldId){
+ elem = $('td-chips[ng-reflect-name= "' + fieldId +'"]');
+ elem.click();
+ browser.wait(EC.visibilityOf($(".mat-option")), 5000);
+ element(by.cssContainingText('.mat-option',option)).click();
+ },
+ verifyCustomTextFieldInputHasError: function(fieldId, errorMessage) {
+ elem = $('input[id= "' + fieldId +'"]');
+ expect(elem.element(by.xpath("..")).element(by.xpath("..")).element(by.xpath("..")).$("md-error").getText()).toEqual(errorMessage);
+ },
+ verifyCustomNumberFieldInputHasError: function(fieldId, errorMessage) {
+ elem = $('input[id= "' + fieldId +'"]');
+ expect(elem.element(by.xpath("..")).element(by.xpath("..")).element(by.xpath("..")).$("md-error").getText()).toEqual(errorMessage);
+ },
};
diff --git a/Pages/Customers.js b/Pages/Customers.js
index 8347aaa..af3b898 100644
--- a/Pages/Customers.js
+++ b/Pages/Customers.js
@@ -81,6 +81,7 @@
cityInput.click().sendKeys(text);
},
enterTextIntoEmailInputField: function (text) {
+ browser.wait(EC.elementToBeClickable(emailInput), 5000);
emailInput.click().sendKeys(text);
},
enterTextIntoPhoneInputField: function (text) {
@@ -345,5 +346,23 @@
});
}).click();
},
+ goToStepCustomFields: function(){
+ browser.wait(EC.elementToBeClickable($$(".td-step-label").get(5)), 3000);
+ $$(".td-step-label").get(5).click();
+ },
+ verifyButtonCreateMemberDisabled: function(){
+ expect(primaryButton.filter(function(elem, index) {
+ return elem.$("span").getText().then(function(text) {
+ return text === "CREATE MEMBER";
+ });
+ }).first().isEnabled()).toBe(false);
+ },
+ verifyButtonCreateMemberEnabled: function(){
+ expect(primaryButton.filter(function(elem, index) {
+ return elem.$("span").getText().then(function(text) {
+ return text === "CREATE MEMBER";
+ });
+ }).first().isEnabled()).toBe(true);
+ },
};
diff --git a/Specs/custom_fields_members.js b/Specs/custom_fields_members.js
index 83c8000..4b1b702 100644
--- a/Specs/custom_fields_members.js
+++ b/Specs/custom_fields_members.js
@@ -11,11 +11,16 @@
var Roles = require('../Pages/Roles');
var Customers = require('../Pages/Customers');
-describe('payrolls', function() {
+describe('custom_fields_members', function() {
var EC = protractor.ExpectedConditions;
employeeIdentifier = helper.getRandomString(6);
identifier1 = helper.getRandomString(3);
identifier2 = helper.getRandomString(3);
+ identifier3 = helper.getRandomString(3);
+ identifier4 = helper.getRandomString(3);
+ identifier5 = helper.getRandomString(3);
+ customerAccount = helper.getRandomString(5);
+
it('should create a new administrator role', function () {
Common.waitForThePageToFinishLoading();
@@ -32,6 +37,7 @@
Employees.createEmployee(employeeIdentifier, "Kate", "Atkinson", "Administrator", "abc123!!");
Login.signOut();
Login.logInForFirstTimeWithTenantUserAndPassword("playground", employeeIdentifier, "abc123!!", "abc123??");
+ //browser.pause();
});
it('should be able to create custom fields for members', function () {
Customers.goToManageCustomersViaSidePanel();
@@ -41,37 +47,60 @@
CustomFields.clickButtonCreateCustomFields();
CustomFields.enterTextIntoNameInputField("My custom fields");
CustomFields.enterTextIntoDescriptionInputField("Custom fields for my members");
+ //add text field
CustomFields.clickButtonAddField();
CustomFields.enterTextIntoIdentifierInputFieldForField(identifier1, 1);
- CustomFields.enterTextIntoLabelInputFieldForField("My field #1", 1);
+ CustomFields.enterTextIntoLabelInputField("My field #1", 1);
CustomFields.verifyRadioTextIsSelectedForField(1);
CustomFields.enterTextIntoLengthInputFieldForField("12", 1);
+ //add number field
CustomFields.clickButtonAddField();
CustomFields.enterTextIntoIdentifierInputFieldForField(identifier2, 2);
- CustomFields.enterTextIntoLabelInputFieldForField("My field #2", 2);
+ CustomFields.enterTextIntoLabelInputField("My field #2", 2);
CustomFields.selectRadioButtonNumberForField(2);
CustomFields.enterNumberIntoMaxDigitsInputFieldForField("5", 1);
CustomFields.clickCreateCustomFieldsButton();
Common.verifyMessagePopupIsDisplayed("Catalog is going to be saved");
+ //name, description, created by, last modified by
+ CustomFields.verifyNameForCatalogIs("My custom fields");
+ CustomFields.verifyDescriptionForCatalogIs("Custom fields for my members");
+ //CustomFields.verifyCreatedByForCatalogIs(employeeIdentifier);
+ CustomFields.verifyDataTypeForRow("Text", 1);
+ CustomFields.verifyLabelForRow("My field #1", 1);
+ CustomFields.verifyDataTypeForRow("Number", 2);
+ CustomFields.verifyLabelForRow("My field #2", 2);
});
it('should be able to update custom fields for members', function () {
Common.clickLinkShowForRowWithId(identifier1);
//verify details
+ CustomFields.verifyDataTypeForFieldIs("TEXT");
+ CustomFields.verifyLabelForFieldIs("My field #1");
+ CustomFields.verifyMandatoryForFieldIs("false");
+ CustomFields.verifyLengthForFieldIs("12");
+ //created by not set yet
+ //CustomFields.verifyCreatedByForFieldIs(employeeIdentifier);
+ //update text field
CustomFields.clickButtonEditCustomFieldForField(identifier1);
//verify identifier and type can no longer be updated
CustomFields.verifyRadioTextIsDisabledForField(1);
//update label, hint and mandatory status
- CustomFields.enterTextIntoLabelInputFieldForField("Updated label", 1);
+ CustomFields.enterTextIntoLabelInputField("Updated label", 1);
CustomFields.enterTextIntoHintInputFieldForField("Hint, hint, hint.", 1);
- CustomFields.checkCheckboxMandatory();
+ CustomFields.checkCheckboxMandatoryForField(1);
+ //cannot change length; no longer displayed
CustomFields.clickUpdateCustomFieldsButton();
Common.verifyMessagePopupIsDisplayed("Field is going to be updated");
//verify details
+ CustomFields.verifyDataTypeForFieldIs("TEXT");
+ CustomFields.verifyLabelForFieldIs("Updated label");
+ CustomFields.verifyMandatoryForFieldIs("true");
+ CustomFields.verifyLengthForFieldIs("12");
});
it('should be able to delete custom field', function () {
CustomFields.clickDeleteFieldButton();
Common.confirmAction();
Common.verifyMessagePopupIsDisplayed("Field is going to be deleted");
+ //field has been deleted
});
it('should be able to delete catalog', function () {
CustomFields.clickDeleteCatalogButton();
@@ -81,10 +110,108 @@
CustomFields.verifyNoCustomFieldsFoundYet();
});
it('should create a new catalog with different fields', function () {
-
+ CustomFields.clickButtonCreateCustomFields();
+ CustomFields.enterTextIntoNameInputField("My custom fields #2");
+ CustomFields.enterTextIntoDescriptionInputField("Custom fields for my members");
+ //add text field
+ CustomFields.clickButtonAddField();
+ CustomFields.enterTextIntoIdentifierInputFieldForField(identifier1, 1);
+ CustomFields.enterTextIntoLabelInputField("My field #1", 1);
+ CustomFields.verifyRadioTextIsSelectedForField(1);
+ CustomFields.enterTextIntoLengthInputFieldForField("3", 1);
+ //add number field (min - max value)
+ CustomFields.clickButtonAddField();
+ CustomFields.enterTextIntoIdentifierInputFieldForField(identifier2, 2);
+ CustomFields.enterTextIntoLabelInputField("My field #2", 2);
+ CustomFields.selectRadioButtonNumberForField(2);
+ CustomFields.enterNumberIntoMinValueInputFieldForField("1", 1);
+ CustomFields.enterNumberIntoMaxValueInputFieldForField("100", 1);
+ //add date field
+ CustomFields.clickButtonAddField();
+ CustomFields.enterTextIntoIdentifierInputFieldForField(identifier3, 3);
+ CustomFields.enterTextIntoLabelInputField("My field #3", 3);
+ CustomFields.selectRadioButtonDateForField(3);
+ //add single selection
+ CustomFields.clickButtonAddField();
+ CustomFields.enterTextIntoIdentifierInputFieldForField(identifier4, 4);
+ CustomFields.enterTextIntoLabelInputField("My field #4", 4);
+ CustomFields.checkCheckboxMandatoryForField(4);
+ CustomFields.selectRadioButtonSingleSelectionForField(4);
+ CustomFields.clickButtonAddOption(1);
+ CustomFields.enterTextIntoLabelInputFieldForOption("Option 1", 1);
+ CustomFields.enterTextIntoValueInputFieldForOption("1", 1);
+ CustomFields.clickButtonAddOption(1);
+ CustomFields.enterTextIntoLabelInputFieldForOption("Option 2", 2);
+ CustomFields.enterTextIntoValueInputFieldForOption("2", 2);
+ //add multi selection
+ CustomFields.clickButtonAddField();
+ CustomFields.enterTextIntoIdentifierInputFieldForField(identifier5, 5);
+ CustomFields.enterTextIntoLabelInputField("My field #5", 7);
+ CustomFields.selectRadioButtonMultiSelectionForField(5);
+ CustomFields.clickButtonAddOption(2);
+ CustomFields.enterTextIntoLabelInputFieldForOption("Option 1", 3);
+ CustomFields.enterTextIntoValueInputFieldForOption("100", 3);
+ CustomFields.clickButtonAddOption(2);
+ CustomFields.enterTextIntoLabelInputFieldForOption("Option 2", 4);
+ CustomFields.enterTextIntoValueInputFieldForOption("100", 4);
+ //error message is displayed
+ CustomFields.enterTextIntoValueInputFieldForOption("200", 4);
+ CustomFields.clickCreateCustomFieldsButton();
+ Common.verifyMessagePopupIsDisplayed("Catalog is going to be saved");
+ //name, description, created by
+ CustomFields.verifyDataTypeForRow("Text", 1);
+ CustomFields.verifyLabelForRow("My field #1", 1);
+ CustomFields.verifyDataTypeForRow("Number", 2);
+ CustomFields.verifyLabelForRow("My field #2", 2);
+ CustomFields.verifyDataTypeForRow("Date", 3);
+ CustomFields.verifyLabelForRow("My field #3", 3);
+ CustomFields.verifyDataTypeForRow("Single selection", 4);
+ CustomFields.verifyLabelForRow("My field #4", 4);
+ CustomFields.verifyDataTypeForRow("Multi selection", 5);
+ CustomFields.verifyLabelForRow("My field #5", 5);
+ Common.clickBackButtonInTitleBar();
});
it('should create member', function () {
-
+ Customers.clickButtonOrLinkCreateNewCustomer();
+ Common.verifyCardHasTitle("Create new member");
+ Customers.enterTextIntoAccountInputField(customerAccount);
+ Customers.enterTextIntoFirstNameInputField("Thomas");
+ Customers.enterTextIntoLastNameInputField("Pynchon");
+ Customers.enterTextIntoDayOfBirthInputField("9211978");
+ Customers.verifyIsMemberCheckboxSelected();
+ Customers.clickEnabledContinueButtonForCustomerDetails();
+ Customers.enterTextIntoStreetInputField("800 Chatham Road #326");
+ Customers.enterTextIntoCityInputField("Winston-Salem");
+ Customers.selectCountryByName("Germany");
+ Customers.clickEnabledContinueButtonForCustomerAddress();
+ Customers.enterTextIntoEmailInputField("nds@yahoo.de");
+ Customers.clickEnabledContinueButtonForCustomerContact();
+ Customers.goToStepCustomFields();
+ CustomFields.verifyCustomFieldsTitle("My custom fields #2");
+ //CREATE MEMBER disabled if no radio button selected (mandatory field); bug
+ //Customers.verifyButtonCreateMemberDisabled();
+ CustomFields.enterTextIntoCustomFieldOfTypeText("abc", identifier1);
+ CustomFields.enterTextIntoCustomFieldOfTypeNumber("100", identifier2);
+ CustomFields.enterTextIntoCustomDateInputField("09/04/1999", identifier3);
+ CustomFields.selectOptionForMultiSelection("Option 1", identifier5);
+ //Customers.verifyButtonCreateMemberDisabled();
+ CustomFields.selectRadioButtonForSingleSelection(1, identifier4);
+ Customers.verifyButtonCreateMemberEnabled();
+ CustomFields.enterTextIntoCustomFieldOfTypeText("This text is too long.", identifier1);
+ CustomFields.verifyCustomTextFieldInputHasError(identifier1, "Only 3 characters allowed.");
+ Customers.verifyButtonCreateMemberDisabled();
+ CustomFields.enterTextIntoCustomFieldOfTypeText("bcd", identifier1);
+ Customers.verifyButtonCreateMemberEnabled();
+ CustomFields.enterTextIntoCustomFieldOfTypeNumber("101", identifier2);
+ CustomFields.verifyCustomNumberFieldInputHasError(identifier2, "Value must be smaller than or equal to 100");
+ Customers.verifyButtonCreateMemberDisabled();
+ CustomFields.enterTextIntoCustomFieldOfTypeNumber("0", identifier2);
+ CustomFields.verifyCustomNumberFieldInputHasError(identifier2, "Value must be greater than or equal to 1");
+ Customers.verifyButtonCreateMemberDisabled();
+ CustomFields.enterTextIntoCustomFieldOfTypeNumber("1", identifier2);
+ Customers.verifyButtonCreateMemberEnabled();
+ Customers.clickEnabledCreateCustomerButton();
+ Common.verifyMessagePopupIsDisplayed("Member is going to be saved")
});
//should it be able to update/delete fields once in use???
it('should not be able to delete custom fields anymore', function () {
diff --git a/Specs/gate1.js b/Specs/gate1.js
index 6692b2c..5f781b2 100644
--- a/Specs/gate1.js
+++ b/Specs/gate1.js
@@ -155,7 +155,7 @@
Customers.selectCountryByName("Germany");
Customers.clickEnabledContinueButtonForCustomerAddress();
Customers.clickEnabledCreateCustomerButton();
- Common.verifyMessagePopupIsDisplayed("Member is going to be saved")
+ Common.verifyMessagePopupIsDisplayed("Member is going to be saved");
Common.verifyCardHasTitle("Manage members");
Common.clickSearchButtonToMakeSearchInputFieldAppear();
Common.enterTextInSearchInputFieldAndApplySearch(customerAccount);