Skip to content

Commit

Permalink
Introduced ajax to view steps to avoid large size html
Browse files Browse the repository at this point in the history
  • Loading branch information
asurendra authored and asurendra committed Jan 20, 2016
1 parent bb61a27 commit da31922
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,15 @@ public String testcaseEdit(Model model, HttpServletRequest request, HttpSession
return "testcase_form";
}

@RequestMapping(value = "/testcase_view", method = RequestMethod.GET)
public String testcaseView(Model model, HttpServletRequest request, HttpSession session, @RequestParam(value = "testcaseId", required = true) Long testcaseId) {
EcTestcase tc = tcDao.findOne(testcaseId);
List<EcTeststep> tsLst = tsDao.findByTestcaseId(tc);
model.addAttribute("tc", tc);
model.addAttribute("tsLst", tsLst);
return "testcase_step";
}

@RequestMapping(value = "/testcase_req_link", method = RequestMethod.POST)
public String testCaseRequirementLink(Model model, HttpServletRequest request, HttpSession session, @RequestParam(value = "nodeId", required = true) Long nodeId, @RequestParam(value = "testcaseChk") List<Long> testcaseChkLst) {
String clipboardLinkTc = StringUtils.arrayToCommaDelimitedString(testcaseChkLst.toArray());
Expand Down
24 changes: 14 additions & 10 deletions src/main/resources/public/js/custom/testcase.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
$(document).ready(function () {

$(".teststepsTable").hide();
$(".teststepShow").click(function () {
event.preventDefault();
var testcaseId = $(this).attr("id");
if ($("#tcstep_" + testcaseId).html().length > 0) {
$("#tcstep_" + testcaseId).html("");
} else {
$.ajax({url: "/testcase_view?testcaseId=" + testcaseId, success: function (result) {
$("#tcstep_" + testcaseId).html(result);
}
});
}
});


$("#checkAll").click(function (event) {
$('input:checkbox').not(this).prop('checked', this.checked);
});

$(".teststepShow").click(function (event) {
event.preventDefault();
var id = $(this).attr("id");
$("#teststeps_" + id).toggle();
});


$("#addFolder").click(function (event) {
event.preventDefault();

var folderPath = $("#breadCrumbPath").val();
bootbox.prompt("Parent folder path: " + folderPath + ",<br/> Please enter folder name:", function (result) {
if (result !== null) {
Expand All @@ -35,7 +39,7 @@ $(document).ready(function () {
bootbox.alert("Please check a testcase!");
}
});

$("#linkTestcaseRequirement").click(function (event) {
event.preventDefault();
if ($('input[name="testcaseChk"]:checked').length > 0) {
Expand Down
15 changes: 9 additions & 6 deletions src/main/resources/public/js/custom/testplan_run.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
$(document).ready(function () {

$(".teststepsTable").hide();

$("#checkAll").click(function (event) {
$('input:checkbox').not(this).prop('checked', this.checked);
});


$("#testplanRunForm").submit(function (event) {
if ($('input[name="testcaseChk"]:checked').length <= 0) {
bootbox.alert("Please check a testcase!");
Expand All @@ -16,9 +13,15 @@ $(document).ready(function () {

$(".teststepShow").click(function (event) {
event.preventDefault();

var id = $(this).attr("id");
$("#teststeps_" + id).toggle();
var testcaseId = $(this).attr("id");
if ($("#tcstep_" + testcaseId).html().length > 0) {
$("#tcstep_" + testcaseId).html("");
} else {
$.ajax({url: "/testcase_view?testcaseId=" + testcaseId, success: function (result) {
$("#tcstep_" + testcaseId).html(result);
}
});
}
});

});
39 changes: 1 addition & 38 deletions src/main/resources/templates/testcase.ftl.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,49 +140,12 @@
</tr>
<tr>
<td colspan="6">
<table id="teststeps_${tc.id?c}" class="teststepsTable table table-bordered" width="100%" cellspacing="0">
<tr>
<td colspan="3">
<b>Description</b>: ${tc.description?replace("\n", "<br/>")}
<br/>
<b>Type</b>: ${tc.caseType}
<br/>
<b>Product</b>: ${tc.product}
<br/>
<b>Feature</b>: ${tc.feature}
<br/>
<b>Added Version</b>: ${tc.addedVersion}
<br/>
<b>Deprecated Version</b>: ${tc.deprecatedVersion}
<br/>
<b>Bug Id</b>: ${tc.bugId}
</td>
</tr>
<#if tc.ecTeststepList??>
<#list tc.ecTeststepList as step>
<tr>
<td>
${step.stepNumber}
</td>
<td style="width:45%;">
${step.description?replace("\n", "<br/>")}
</td>
<td style="width:50%;">
${step.expected?replace("\n", "<br/>")}
</td>
</tr>
</#list>
</#if>
</table>
<div id="tcstep_${tc.id?c}"></div>
</td>
</tr>

</#list>

</tbody>
</table>


</div>
</div>
</form>
Expand Down
34 changes: 34 additions & 0 deletions src/main/resources/templates/testcase_step.ftl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<table class="table table-bordered" width="100%" cellspacing="0">
<tr>
<td colspan="3">
<b>Description</b>: ${tc.description?replace("\n", "<br/>")}
<br/>
<b>Type</b>: ${tc.caseType}
<br/>
<b>Product</b>: ${tc.product}
<br/>
<b>Feature</b>: ${tc.feature}
<br/>
<b>Added Version</b>: ${tc.addedVersion}
<br/>
<b>Deprecated Version</b>: ${tc.deprecatedVersion}
<br/>
<b>Bug Id</b>: ${tc.bugId}
</td>
</tr>
<#if tc.ecTeststepList??>
<#list tc.ecTeststepList as step>
<tr>
<td>
${step.stepNumber}
</td>
<td style="width:45%;">
${step.description?replace("\n", "<br/>")}
</td>
<td style="width:50%;">
${step.expected?replace("\n", "<br/>")}
</td>
</tr>
</#list>
</#if>
</table>
40 changes: 1 addition & 39 deletions src/main/resources/templates/testplan_run.ftl.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,45 +117,7 @@ <h3>Run Test Plan</h3>
</tr>
<tr>
<td colspan="12" class="no-sort">
<table id="teststeps_${tc.id?c}" class="teststepsTable table table-bordered" width="100%" cellspacing="0">
<tr>
<td colspan="3">

<b>Description</b>: ${tc.description?replace("\n", "<br/>")}
<br/>
<b>Automated</b>: ${tc.automated?c}
<br/>
<b>Type</b>: ${tc.caseType}
<br/>
<b>Product</b>: ${tc.product}
<br/>
<b>Feature</b>: ${tc.feature}
<br/>
<b>Added Version</b>: ${tc.addedVersion}
<br/>
<b>Deprecated Version</b>: ${tc.deprecatedVersion}
<br/>
<b>Bug Id</b>: ${tc.bugId}
<br/>
<b>Time to Run</b>: ${tc.timeToRun} mins
</td>
</tr>
<#if tc.ecTeststepList??>
<#list tc.ecTeststepList as step>
<tr>
<td>
${step.stepNumber}
</td>
<td style="width:45%">
${step.description?replace("\n", "<br/>")}
</td>
<td style="width:50%">
${step.expected?replace("\n", "<br/>")}
</td>
</tr>
</#list>
</#if>
</table>
<div id="tcstep_${tc.id?c}"></div>
</td>
</tr>
</#list>
Expand Down

0 comments on commit da31922

Please sign in to comment.