Skip to content

Commit b982449

Browse files
Ft subscription form (#63)
* unused elements removed * FT_subscription_form
1 parent 6ea5d19 commit b982449

File tree

7 files changed

+67
-63
lines changed

7 files changed

+67
-63
lines changed

src/functionaltest/java/com/ericsson/ei/frontend/SubscriptionHandlingFunctionality.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,15 @@ public void testSubscription() throws Exception {
139139
subscriptionPage.clickAddSubscription();
140140
String formHeaderID = "formHeader";
141141
assert ((new WebDriverWait(driver, 10).until((webdriver) -> subscriptionPage.presenceOfHeader(formHeaderID))));
142-
142+
143+
// Test form "Cancel" button:Click "Cancel" button and verify that "Subscription Form" is closed
144+
subscriptionPage.clickFormsCancelBtn();
145+
assert (!subscriptionPage.presenceOfHeader(formHeaderID));
146+
147+
// Again, click "Add Subscription" button and verify that "Subscription Form" is open
148+
subscriptionPage.clickAddSubscription();
149+
assert ((new WebDriverWait(driver, 10).until((webdriver) -> subscriptionPage.presenceOfHeader(formHeaderID))));
150+
143151
// On subscription form, select the template as "Mail Trigger" and verify
144152
String selectID = "selectTemplate";
145153
String tempMail = "Mail Trigger";
@@ -177,13 +185,31 @@ public void testSubscription() throws Exception {
177185
String tokenID = "tokenInput";
178186
String subName = "Selenium_test_subscription";
179187
String subNameID = "subscriptionNameInput";
188+
String selectRepeatID = "selectRepeat";
189+
String repeatValue = "true";
190+
String conditionFieldID = "conditionID";
191+
String requirementFieldID = "requirementID";
180192

181193
subscriptionPage.selectDropdown(selectAuthID, authValue);
194+
182195
subscriptionPage.addFieldValue(userNameID, userName);
183196
subscriptionPage.addFieldValue(tokenID, token);
184197
String kvID = "kvID";
185-
subscriptionPage.clickKVbtn(kvID);
198+
subscriptionPage.clickKVbtn(kvID);
186199
assert (new WebDriverWait(driver, 10).until((webdriver) -> driver.getPageSource().contains("Authorization")));
200+
201+
// Test "Repeat" dropdown: Select repeat value as "true" and then verify the selected value
202+
subscriptionPage.selectDropdown(selectRepeatID, repeatValue);
203+
assert (new WebDriverWait(driver, 10)
204+
.until((webdriver) -> (subscriptionPage.getValueFromSelectRepeat().equals(repeatValue))));
205+
206+
// Test "Add Condition" button: click add condition button and check that it adds an additional "condition" field
207+
subscriptionPage.clickAddConditionBtn();
208+
assertEquals(2, subscriptionPage.countElements(conditionFieldID));
209+
210+
// Test "Add Requirement" button: click the button and assert that it adds an additional "requirement" field
211+
subscriptionPage.clickAddRequirementBtn();
212+
assertEquals(2, subscriptionPage.countElements(requirementFieldID));
187213

188214
// Test save subscription form: add subscription name as
189215
// "selenium_test_subscription" and then click "save" button verification
@@ -192,6 +218,7 @@ public void testSubscription() throws Exception {
192218
String responseSave = this.getJSONStringFromFile(SUBSCRIPTION_FOR_SAVE_TEST_FILE_PATH);
193219
subscriptionPage.addFieldValue(subNameID, subName);
194220
subscriptionPage.clickFormsSaveBtn(responseSave);
195-
assert (subscriptionPage.textExistsInTable("Selenium_test_subscription"));
221+
assert (subscriptionPage.textExistsInTable("Selenium_test_subscription"));
222+
196223
}
197224
}

src/functionaltest/java/com/ericsson/ei/frontend/TestAlarm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public void testAlarm() throws IOException {
2525

2626
//Click alarm button few times
2727
IntStream.range(0, 5).forEachOrdered(i -> indexPageObject.clickAlarmButton());
28-
assertEquals(3, driver.findElements(By.className("dropdown-item")).size());
28+
assertEquals(2, driver.findElements(By.className("dropdown-item")).size());
2929
}
3030
}

src/functionaltest/java/com/ericsson/ei/frontend/pageobjects/SubscriptionPage.java

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.mockito.Mockito;
99
import org.openqa.selenium.By;
1010
import org.openqa.selenium.NoSuchElementException;
11+
import org.openqa.selenium.TimeoutException;
1112
import org.openqa.selenium.WebElement;
1213
import org.openqa.selenium.firefox.FirefoxDriver;
1314
import org.openqa.selenium.support.ui.ExpectedConditions;
@@ -24,7 +25,7 @@ public boolean presenceOfHeader(String loc) {
2425
try {
2526
new WebDriverWait(driver, TIMEOUT_TIMER).until(ExpectedConditions.elementToBeClickable(By.id(loc)));
2627
return true;
27-
} catch (NoSuchElementException e) {
28+
} catch ( TimeoutException e) {
2829
return false;
2930
}
3031
}
@@ -36,8 +37,8 @@ public void clickAddSubscription() {
3637
}
3738

3839
public void clickFormsCancelBtn() {
39-
new WebDriverWait(driver, TIMEOUT_TIMER).until(ExpectedConditions.elementToBeClickable(By.id("cancelButton")));
40-
WebElement cancelBtn = driver.findElement(By.id("cancelButton"));
40+
new WebDriverWait(driver, TIMEOUT_TIMER).until(ExpectedConditions.elementToBeClickable(By.id("btnFormCancel")));
41+
WebElement cancelBtn = driver.findElement(By.id("btnFormCancel"));
4142
cancelBtn.click();
4243
}
4344

@@ -107,6 +108,14 @@ public String getValueFromSelect() {
107108
Select dropdown = new Select(selectNotificationType);
108109
return dropdown.getFirstSelectedOption().getText();
109110
}
111+
112+
public String getValueFromSelectRepeat() {
113+
new WebDriverWait(driver, TIMEOUT_TIMER)
114+
.until(ExpectedConditions.elementToBeClickable(By.id("selectRepeat")));
115+
WebElement selectNotificationType = driver.findElement(By.id("selectRepeat"));
116+
Select dropdown = new Select(selectNotificationType);
117+
return dropdown.getFirstSelectedOption().getText();
118+
}
110119

111120
public String getValueFromElement() {
112121
new WebDriverWait(driver, TIMEOUT_TIMER).until(ExpectedConditions.elementToBeClickable(By.id("metaData")));
@@ -163,6 +172,18 @@ public void clickFormCloseBtn() {
163172
WebElement viewBtn = driver.findElement(By.className("close"));
164173
viewBtn.click();
165174
}
175+
176+
public void clickAddConditionBtn() {
177+
new WebDriverWait(driver, TIMEOUT_TIMER).until(ExpectedConditions.elementToBeClickable(By.id("addCondition")));
178+
WebElement viewBtn = driver.findElement(By.id("addCondition"));
179+
viewBtn.click();
180+
}
181+
182+
public void clickAddRequirementBtn(){
183+
new WebDriverWait(driver, TIMEOUT_TIMER).until(ExpectedConditions.elementToBeClickable(By.id("addRequirement")));
184+
WebElement viewBtn = driver.findElement(By.id("addRequirement"));
185+
viewBtn.click();
186+
}
166187

167188
public String getSubscriptionNameFromSubscription() {
168189
new WebDriverWait(driver, TIMEOUT_TIMER)
@@ -210,4 +231,8 @@ public boolean clickElementByXPath(String loc) {
210231
}
211232
return true;
212233
}
234+
235+
public int countElements(String id) {
236+
return driver.findElements(By.id(id)).size();
237+
}
213238
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.dropdown-menu {
22
max-height: 400px;
33
overflow-y: auto;
4-
margin-left: -50px;
4+
margin-left: -300px;
55
}

src/main/resources/static/js/errorMessages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function model(data){
2020
}
2121
}
2222
function logMessages(messageErr){
23-
$.jGrowl(messageErr, {sticky: false, theme: 'Error'});
23+
$.jGrowl(messageErr, {sticky: false, theme: 'Error', position:'center'});
2424
errorsStore.push({message:messageErr});
2525
sessionStorage.setItem('errorsStore', JSON.stringify(errorsStore));
2626
$('div.dropdown-menu').replaceWith("<div id=\"alerts\" style=\"display: none;\" class=\"dropdown-menu\" aria-labelledby=\"alertsDropdown\" data-bind=\"foreach: errorMessages\">" +

src/main/resources/templates/index.html

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -98,42 +98,6 @@
9898
</li>
9999
</ul>
100100
<ul class="navbar-nav ml-auto">
101-
<li class="nav-item dropdown">
102-
<a class="nav-link dropdown-toggle mr-lg-2" id="messagesDropdown" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
103-
<i class="fa fa-fw fa-envelope"></i>
104-
<span class="d-lg-none">Messages
105-
<span class="badge badge-pill badge-primary">12 New</span>
106-
</span>
107-
<span class="indicator text-primary d-none d-lg-block">
108-
<i class="fa fa-fw fa-circle"></i>
109-
</span>
110-
</a>
111-
<div class="dropdown-menu" aria-labelledby="messagesDropdown">
112-
<h6 class="dropdown-header">New Messages:</h6>
113-
<div class="dropdown-divider"></div>
114-
<a class="dropdown-item" href="#">
115-
<strong>David Miller</strong>
116-
<span class="small float-right text-muted">11:21 AM</span>
117-
<div class="dropdown-message small">Hey there! This new version of SB Admin is pretty awesome! These messages clip off when they reach the end
118-
of the box so they don't overflow over to the sides!</div>
119-
</a>
120-
<div class="dropdown-divider"></div>
121-
<a class="dropdown-item" href="#">
122-
<strong>Jane Smith</strong>
123-
<span class="small float-right text-muted">11:21 AM</span>
124-
<div class="dropdown-message small">I was wondering if you could meet for an appointment at 3:00 instead of 4:00. Thanks!</div>
125-
</a>
126-
<div class="dropdown-divider"></div>
127-
<a class="dropdown-item" href="#">
128-
<strong>John Doe</strong>
129-
<span class="small float-right text-muted">11:21 AM</span>
130-
<div class="dropdown-message small">I've sent the final files over to you for review. When you're able to sign off of them let me know and we can
131-
discuss distribution.</div>
132-
</a>
133-
<div class="dropdown-divider"></div>
134-
<a class="dropdown-item small" href="#">View all messages</a>
135-
</div>
136-
</li>
137101
<li class="nav-item dropdown">
138102
<a class="nav-link dropdown-toggle mr-lg-2" id="alertsDropdown">
139103
<i class="fa fa-fw fa-bell"></i>
@@ -151,18 +115,6 @@ <h6 class="dropdown-header">New Messages:</h6>
151115
</a>
152116
</div>
153117
</li>
154-
<li class="nav-item">
155-
<form class="form-inline my-2 my-lg-0 mr-lg-2">
156-
<div class="input-group">
157-
<input class="form-control" type="text" placeholder="Search for..." />
158-
<span class="input-group-btn">
159-
<button class="btn btn-primary" type="button">
160-
<i class="fa fa-search"></i>
161-
</button>
162-
</span>
163-
</div>
164-
</form>
165-
</li>
166118
<li class="nav-item">
167119
<a class="nav-link" id="userName"></a>
168120
</li>

src/main/resources/templates/subscription.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ <h3 class="modal-title text-center" id="formHeader">Subscription Form</h3>
220220
<div class="pt-3 form-group">
221221
<label class="pl-1 control-label font-weight-bold">Repeat</label>
222222
<div>
223-
<select data-toggle="tooltip" title="Choose if to repeat or not to repeat" data-bind="options: $root.repeat_in,
223+
<select id="selectRepeat" data-toggle="tooltip" title="Choose if to repeat or not to repeat" data-bind="options: $root.repeat_in,
224224
optionsText: $data.repeat(),
225225
value: $data.repeat,
226226
optionsCaption: 'Choose...'"></select>
@@ -244,10 +244,10 @@ <h3 class="modal-title text-center" id="formHeader">Subscription Form</h3>
244244
</div>
245245
<div class="p-1 border border-primary form-group">
246246
<label class="control-label font-weight-bold">Requirement</label>
247-
<div>
247+
<div id="requirementID">
248248

249249
<!-- ko foreach: requirements_item.conditions -->
250-
<div>
250+
<div id="conditionID">
251251
<label class="control-label font-weight-bold">Condition</label>
252252
<textarea data-toggle="tooltip" title="Write a Subscription Rule(JmePath)" data-bind="textInput:$data.jmespath()" name="jmespath"
253253
placeholder="jmespath" class="form-control" type="text"></textarea>
@@ -262,7 +262,7 @@ <h3 class="modal-title text-center" id="formHeader">Subscription Form</h3>
262262
<!-- /ko -->
263263

264264
<div class="pt-1 d-flex justify-content-end">
265-
<button data-bind="click: function(data, event) { $root.add_condition(data, event, $index()); }, clickBubble: false" data-toggle="tooltip"
265+
<button id="addCondition" data-bind="click: function(data, event) { $root.add_condition(data, event, $index()); }, clickBubble: false" data-toggle="tooltip"
266266
title="Add a new condition" class="btn btn-success">
267267
<i class="glyphicon glyphicon-plus"></i> Add Condition
268268
</button>
@@ -271,7 +271,7 @@ <h3 class="modal-title text-center" id="formHeader">Subscription Form</h3>
271271
</div>
272272
<!-- /ko -->
273273

274-
<button data-bind="click: $root.add_requirement, clickBubble: false" data-toggle="tooltip" title="Add a new requirement"
274+
<button id="addRequirement" data-bind="click: $root.add_requirement, clickBubble: false" data-toggle="tooltip" title="Add a new requirement"
275275
class="btn btn-success float-left">
276276
<i class="glyphicon glyphicon-plus float-right"></i> Add Requirement
277277
</button>
@@ -285,7 +285,7 @@ <h3 class="modal-title text-center" id="formHeader">Subscription Form</h3>
285285
<button data-toggle="tooltip" title="Save the changes to EI." type="button" id="btnSave" class="btn btn-primary save_record">
286286
Save
287287
</button>
288-
<button data-toggle="tooltip" title="Cancel and abort all changes" type="button" class="btn btn-danger" data-dismiss="modal">Cancel
288+
<button data-toggle="tooltip" title="Cancel and abort all changes" type="button" id="btnFormCancel" class="btn btn-danger" data-dismiss="modal">Cancel
289289
</button>
290290
</div>
291291
</div>

0 commit comments

Comments
 (0)