- adding script to parse testcases from submitted XML (add_testcases_from_xml.pl)
- added appropriate update/delete methods to Testgroup.pm, Subgroup.pm, and Testcase.pm. These methods are called by add_testcase_from_xml.pl; - allow user to preview subgroups/testcases in the right-hand selectbox when working with testgroups/subgroups; - added generic blankForm() method to FormValidation.js - factored out JSON retrieval code to json.js git-svn-id: svn://10.0.0.236/trunk@201942 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
ab684c50c1
commit
bf0b441be4
@ -191,10 +191,24 @@ sub delete_from_testgroups() {
|
||||
|
||||
my $dbh = __PACKAGE__->db_Main();
|
||||
my $sql = "DELETE from subgroup_testgroups WHERE subgroup_id=?";
|
||||
my $rows = $dbh->do($sql,
|
||||
undef,
|
||||
$self->subgroup_id
|
||||
);
|
||||
return $dbh->do($sql,
|
||||
undef,
|
||||
$self->subgroup_id
|
||||
);
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
sub delete_from_testgroup() {
|
||||
my $self = shift;
|
||||
my $testgroup_id = shift;
|
||||
|
||||
my $dbh = __PACKAGE__->db_Main();
|
||||
my $sql = "DELETE from subgroup_testgroups WHERE subgroup_id=? AND testgroup_id=?";
|
||||
return $dbh->do($sql,
|
||||
undef,
|
||||
$self->subgroup_id,
|
||||
$testgroup_id
|
||||
);
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
@ -203,10 +217,10 @@ sub delete_from_testcases() {
|
||||
|
||||
my $dbh = __PACKAGE__->db_Main();
|
||||
my $sql = "DELETE from testcase_subgroups WHERE subgroup_id=?";
|
||||
my $rows = $dbh->do($sql,
|
||||
undef,
|
||||
$self->subgroup_id
|
||||
);
|
||||
return $dbh->do($sql,
|
||||
undef,
|
||||
$self->subgroup_id
|
||||
);
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
@ -237,6 +251,28 @@ sub update_testgroups() {
|
||||
}
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
sub update_testgroup() {
|
||||
my $self = shift;
|
||||
my $testgroup_id = shift;
|
||||
my $sort_order = shift;
|
||||
|
||||
# Sort order defaults to 1.
|
||||
if (!$sort_order) {
|
||||
$sort_order = 1;
|
||||
}
|
||||
|
||||
my $rv = $self->delete_from_testgroup($testgroup_id);
|
||||
my $dbh = __PACKAGE__->db_Main();
|
||||
my $sql = "INSERT INTO subgroup_testgroups (subgroup_id,testgroup_id,sort_order) VALUES (?,?,?)";
|
||||
return $dbh->do($sql,
|
||||
undef,
|
||||
$self->subgroup_id,
|
||||
$testgroup_id,
|
||||
$sort_order
|
||||
);
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
sub update_testcases() {
|
||||
my $self = shift;
|
||||
|
||||
@ -260,10 +260,24 @@ sub delete_from_subgroups() {
|
||||
|
||||
my $dbh = __PACKAGE__->db_Main();
|
||||
my $sql = "DELETE from testcase_subgroups WHERE testcase_id=?";
|
||||
my $rows = $dbh->do($sql,
|
||||
undef,
|
||||
$self->testcase_id
|
||||
);
|
||||
return $dbh->do($sql,
|
||||
undef,
|
||||
$self->testcase_id
|
||||
);
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
sub delete_from_subgroup() {
|
||||
my $self = shift;
|
||||
my $subgroup_id = shift;
|
||||
|
||||
my $dbh = __PACKAGE__->db_Main();
|
||||
my $sql = "DELETE from testcase_subgroups WHERE testcase_id=? AND subgroup_id=?";
|
||||
return $dbh->do($sql,
|
||||
undef,
|
||||
$self->testcase_id,
|
||||
$subgroup_id
|
||||
);
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
@ -272,11 +286,11 @@ sub delete_from_related() {
|
||||
|
||||
my $dbh = __PACKAGE__->db_Main();
|
||||
my $sql = "DELETE from related_testcases WHERE testcase_id=? OR related_testcase_id=?";
|
||||
my $rows = $dbh->do($sql,
|
||||
undef,
|
||||
$self->testcase_id,
|
||||
$self->testcase_id
|
||||
);
|
||||
return $dbh->do($sql,
|
||||
undef,
|
||||
$self->testcase_id,
|
||||
$self->testcase_id
|
||||
);
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
@ -307,6 +321,28 @@ sub update_subgroups() {
|
||||
}
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
sub update_subgroup() {
|
||||
my $self = shift;
|
||||
my $subgroup_id = shift;
|
||||
my $sort_order = shift;
|
||||
|
||||
# Sort order defaults to 1.
|
||||
if (!$sort_order) {
|
||||
$sort_order = 1;
|
||||
}
|
||||
|
||||
my $rv = $self->delete_from_subgroup($subgroup_id);
|
||||
my $dbh = __PACKAGE__->db_Main();
|
||||
my $sql = "INSERT INTO testcase_subgroups (testcase_id,subgroup_id,sort_order) VALUES (?,?,?)";
|
||||
return $dbh->do($sql,
|
||||
undef,
|
||||
$self->testcase_id,
|
||||
$subgroup_id,
|
||||
$sort_order
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
||||
@ -200,8 +200,32 @@ sub update_subgroups() {
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
#########################################################################
|
||||
sub update_branches() {
|
||||
my $self = shift;
|
||||
my $new_branch_ids = shift;
|
||||
|
||||
if (scalar @$new_branch_ids) {
|
||||
# Failing to delete branches is _not_ fatal when adding a new testgroup.
|
||||
my $rv = $self->delete_from_branches();
|
||||
my $dbh = __PACKAGE__->db_Main();
|
||||
my $sql = "INSERT INTO testgroup_branches (testgroup_id,branch_id) VALUES (?,?,?)";
|
||||
foreach my $new_branch_id (@$new_branch_ids) {
|
||||
next if (!$new_branch_id);
|
||||
# Log any failures/duplicate keys to STDERR.
|
||||
eval {
|
||||
my $rows = $dbh->do($sql,
|
||||
undef,
|
||||
$self->testgroup_id,
|
||||
$new_branch_id,
|
||||
);
|
||||
};
|
||||
if ($@) {
|
||||
print STDERR $@;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
@ -936,6 +936,7 @@ table.manage td {
|
||||
}
|
||||
|
||||
table.manage input.button {
|
||||
font-size: 1em;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
@ -1097,6 +1098,7 @@ div.section-header {
|
||||
color: #666666;
|
||||
text-transform: lowercase;
|
||||
overflow: auto;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
div.category h2, div.category h3 {
|
||||
|
||||
@ -443,3 +443,27 @@ function changeSelectedValue(selectid, optionvalue) {
|
||||
options[0].selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
function blankForm(formid) {
|
||||
var f = document.getElementById(formid);
|
||||
var ems = f.getElementsByTagName('input');
|
||||
for (var i in ems) {
|
||||
if (ems[i].type == 'submit' ||
|
||||
ems[i].value == 'Reset' ||
|
||||
ems[i].type == 'radio' ||
|
||||
ems[i].type == 'checkbox' ||
|
||||
ems[i].type == 'button') {
|
||||
continue;
|
||||
}
|
||||
ems[i].value='';
|
||||
ems[i].checked=false;
|
||||
}
|
||||
ems = f.getElementsByTagName('select');
|
||||
for (var i in ems) {
|
||||
ems[i].selectedIndex=0;
|
||||
}
|
||||
ems = f.getElementsByTagName('textarea');
|
||||
for (var i in ems) {
|
||||
ems[i].value='';
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,3 +118,22 @@ String.prototype.parseJSON = function () {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
function fetchJSON(url,callbackFunction) {
|
||||
var d = loadJSONDoc(url);
|
||||
d.addBoth(function (res) {
|
||||
d.deferred = null;
|
||||
toggleMessage('none');
|
||||
return res;
|
||||
});
|
||||
d.addCallback(callbackFunction);
|
||||
// if anything goes wrong, except for a simple cancellation,
|
||||
// then log the error and show the logger
|
||||
d.addErrback(function (err) {
|
||||
if (err instanceof CancelledError) {
|
||||
return;
|
||||
}
|
||||
logError(err);
|
||||
logger.debuggingBookmarklet();
|
||||
});
|
||||
}
|
||||
|
||||
@ -91,7 +91,6 @@ sub page_pickGroupSubgroup {
|
||||
if (!$sysconfig) {
|
||||
page_pickProduct()
|
||||
};
|
||||
print $c->header();
|
||||
$branch = $sysconfig->branch();
|
||||
} else {
|
||||
$branch = Litmus::DB::Branch->retrieve($c->param("branch"));
|
||||
@ -102,10 +101,11 @@ sub page_pickGroupSubgroup {
|
||||
$sysconfig = Litmus::SysConfig->processForm($c);
|
||||
# get the user id and set a sysconfig cookie
|
||||
$c->storeCookie($sysconfig->setCookie());
|
||||
print $c->header();
|
||||
}
|
||||
|
||||
Litmus::Auth::requireLogin("run_tests.cgi");
|
||||
|
||||
print $c->header();
|
||||
|
||||
# Get all groups for the current branch.
|
||||
my @groups = Litmus::DB::Testgroup->search_EnabledByBranch($branch->branch_id());
|
||||
|
||||
@ -124,15 +124,19 @@ var manageTestcasesHelpText="<p>The select box on the left contains all the test
|
||||
<tr>
|
||||
<td align="right">⇑ <a name="previewTestcase" onclick="previewTestcase('editform_testcases_for_product');">Preview Testcase</a></td>
|
||||
<td></td>
|
||||
<td align="right">⇑ <a name="showManageTestcasesHelp" onclick="toggleHelp(manageTestcasesHelpTitle,manageTestcasesHelpText);">Help with Managing Testcases</a></td>
|
||||
<td align="right">⇑ <a name="previewTestcase" onclick="previewTestcase('editform_subgroup_testcases');">Preview Testcase</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align="right">⇑ <a name="showManageTestcasesHelp" onclick="toggleHelp(manageTestcasesHelpTitle,manageTestcasesHelpText);">Help with Managing Testcases</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align="right"><input id="editform_reset" class="button" type="button" value="Reset" disabled /> <input class="button" type="submit" id="editform_submit" name="editform_submit" value="Submit Edits" disabled /></div>
|
||||
<td colspan="3" align="right"><input id="editform_reset" class="button" type="button" value="Reset" disabled onClick="resetSubgroup();" /> <input class="button" type="submit" id="editform_submit" name="editform_submit" value="Submit Edits" disabled /></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@ -75,8 +75,11 @@ function checkFormContents(f) {
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">⇑ <a name="showFormattingHelp" onclick="toggleHelp(formattingHelpTitle,formattingHelpText);">Formatting Help</a> | ⇑ <a name="stepsPreview" onClick="var newwin = window.open('preview.cgi?preview=' + escape(document.getElementById('editform_steps').value),'preview_window','height=400,width=400,resizeable=yes,scrollable=yes');newwin.focus();">Preview</a></td>
|
||||
<td align="right">⇑ <a name="showFormattingHelp" onclick="toggleHelp(formattingHelpTitle,formattingHelpText);">Formatting Help</a> | ⇑ <a name="resultsPreview" onClick="var newwin = window.open('preview.cgi?preview=' + escape(document.getElementById('editform_results').value),'preview_window','height=400,width=400,resizeable=yes,scrollable=yes');newwin.focus();">Preview</a></td>
|
||||
<td align="right">⇑ <a name="stepsPreview" onClick="var newwin = window.open('preview.cgi?preview=' + escape(document.getElementById('editform_steps').value),'preview_window','height=400,width=400,resizeable=yes,scrollable=yes');newwin.focus();">Preview</a></td>
|
||||
<td align="right">⇑ <a name="resultsPreview" onClick="var newwin = window.open('preview.cgi?preview=' + escape(document.getElementById('editform_results').value),'preview_window','height=400,width=400,resizeable=yes,scrollable=yes');newwin.focus();">Preview</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="right">⇑ <a name="showFormattingHelp" onclick="toggleHelp(formattingHelpTitle,formattingHelpText);">Formatting Help</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@ -151,7 +154,7 @@ function checkFormContents(f) {
|
||||
<td name="editform_testrunner_case_version" id="editform_testrunner_case_version"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align="right"><input id="editform_reset" class="button" type="button" value="Reset" disabled /> <input class="button" type="submit" id="editform_submit" name="editform_submit" value="Submit Edits" disabled /></div>
|
||||
<td colspan="3" align="right"><input id="editform_reset" class="button" type="button" value="Reset" disabled onClick="resetTestcase();" /> <input class="button" type="submit" id="editform_submit" name="editform_submit" value="Submit Edits" disabled /></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@ -120,15 +120,19 @@ var manageTestgroupsHelpText="<p>The select box on the left contains all the sub
|
||||
<tr>
|
||||
<td align="right">⇑ <a name="previewSubgroup" onclick="previewSubgroup('editform_subgroups_for_product');">Preview Subgroup</a></td>
|
||||
<td></td>
|
||||
<td align="right">⇑ <a name="showManageSubgroupsHelp" onclick="toggleHelp(manageSubgroupsHelpTitle,manageSubgroupsHelpText);">Help with Managing Subgroups</a></td>
|
||||
<td align="right">⇑ <a name="previewSubgroup" onclick="previewSubgroup('editform_testgroup_subgroups');">Preview Subgroup</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align="right">⇑ <a name="showManageSubgroupsHelp" onclick="toggleHelp(manageSubgroupsHelpTitle,manageSubgroupsHelpText);">Help with Managing Subgroups</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align="right"><input id="editform_reset" class="button" type="button" value="Reset" disabled /> <input class="button" type="submit" id="editform_submit" name="editform_submit" value="Submit Edits" disabled /></div>
|
||||
<td colspan="3" align="right"><input id="editform_reset" class="button" type="button" value="Reset" disabled onClick="resetTestgroup();" /> <input class="button" type="submit" id="editform_submit" name="editform_submit" value="Submit Edits" disabled /></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
[% INCLUDE global/litmus_header.tmpl %]
|
||||
|
||||
<script type="text/javascript">
|
||||
var d;
|
||||
var subgroup;
|
||||
var testcases=[% IF all_testcases %][% all_testcases %][% ELSE %]{}[% END %];
|
||||
|
||||
@ -57,7 +56,7 @@ function loadSubgroup() {
|
||||
document.getElementById('subgroup_display_div').style.display = 'none';
|
||||
document.getElementById('editform_div').style.display = 'none';
|
||||
disableForm('edit_subgroup_form');
|
||||
blankForm('edit_subgroup_form');
|
||||
blankSubgroupForm('edit_subgroup_form');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -66,22 +65,7 @@ function loadSubgroup() {
|
||||
disableForm('edit_subgroup_form');
|
||||
var url = 'json.cgi?subgroup_id=' + subgroup_id;
|
||||
toggleMessage('loading','Loading Subgroup ID# ' + subgroup_id + '...');
|
||||
var d = loadJSONDoc(url);
|
||||
d.addBoth(function (res) {
|
||||
d.deferred = null;
|
||||
toggleMessage('none');
|
||||
return res;
|
||||
});
|
||||
d.addCallback(populateSubgroup);
|
||||
// if anything goes wrong, except for a simple cancellation,
|
||||
// then log the error and show the logger
|
||||
d.addErrback(function (err) {
|
||||
if (err instanceof CancelledError) {
|
||||
return;
|
||||
}
|
||||
logError(err);
|
||||
logger.debuggingBookmarklet();
|
||||
});
|
||||
fetchJSON(url,populateSubgroup);
|
||||
}
|
||||
|
||||
function populateSubgroup(data) {
|
||||
@ -163,39 +147,19 @@ function populateSubgroup(data) {
|
||||
enableModeButtons();
|
||||
}
|
||||
|
||||
function blankForm(formid) {
|
||||
var f = document.getElementById(formid);
|
||||
var ems = f.getElementsByTagName('input');
|
||||
for (var i in ems) {
|
||||
ems[i].checked=false;
|
||||
if (ems[i].type == 'submit' ||
|
||||
ems[i].value == 'Reset' ||
|
||||
ems[i].type == 'radio' ||
|
||||
ems[i].type == 'checkbox' ||
|
||||
ems[i].type == 'button') {
|
||||
continue;
|
||||
}
|
||||
ems[i].value='';
|
||||
}
|
||||
ems = f.getElementsByTagName('select');
|
||||
for (var i in ems) {
|
||||
ems[i].selectedIndex=0;
|
||||
}
|
||||
ems = f.getElementsByTagName('textarea');
|
||||
for (var i in ems) {
|
||||
ems[i].value='';
|
||||
}
|
||||
function blankSubgroupForm(formid) {
|
||||
blankForm(formid);
|
||||
document.getElementById('editform_subgroup_id_display').innerHTML = '';
|
||||
var selectBoxAll = document.getElementById('editform_testcases_for_product');
|
||||
selectBoxAll.options.length = 0;
|
||||
selectBoxAll.options[selectBoxAll.length] = new Option("--No product selected--",
|
||||
"");
|
||||
selectBoxAll.selectedIndex=-1
|
||||
selectBoxAll.selectedIndex=-1;
|
||||
var selectBoxSubgroup = document.getElementById('editform_subgroup_testcases');
|
||||
selectBoxSubgroup.options.length = 0;
|
||||
selectBoxSubgroup.options[selectBoxSubgroup.length] = new Option("--No subgroup selected--",
|
||||
"");
|
||||
selectBoxSubgroup.selectedIndex=-1
|
||||
selectBoxSubgroup.selectedIndex=-1;
|
||||
|
||||
document.getElementById('editform_testrunner_group_id').innerHTML = '';
|
||||
|
||||
@ -205,7 +169,7 @@ function blankForm(formid) {
|
||||
|
||||
function switchToAdd() {
|
||||
disableModeButtons();
|
||||
blankForm('edit_subgroup_form');
|
||||
blankSubgroupForm('edit_subgroup_form');
|
||||
document.getElementById('editform_submit').value = 'Add Subgroup';
|
||||
document.getElementById('editform_mode').value = 'add';
|
||||
enableForm('edit_subgroup_form');
|
||||
@ -233,6 +197,16 @@ function populateAllTestcases() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resetSubgroup() {
|
||||
if (document.getElementById('editform_subgroup_id').value != '') {
|
||||
populateSubgroup(subgroup);
|
||||
switchToEdit();
|
||||
} else {
|
||||
switchToAdd();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div id="page">
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
[% INCLUDE global/litmus_header.tmpl %]
|
||||
|
||||
<script type="text/javascript">
|
||||
var d;
|
||||
var testcase;
|
||||
|
||||
function setAuthor(user_id) {
|
||||
@ -60,7 +59,7 @@ function loadTestcase() {
|
||||
document.getElementById('testcase_display_div').style.display = 'none';
|
||||
document.getElementById('editform_div').style.display = 'none';
|
||||
disableForm('edit_testcase_form');
|
||||
blankForm('edit_testcase_form');
|
||||
blankTestcaseForm('edit_testcase_form');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -69,22 +68,7 @@ function loadTestcase() {
|
||||
disableForm('edit_testcase_form');
|
||||
toggleMessage('loading','Loading Testcase ID# ' + testcase_id + '...');
|
||||
var url = 'json.cgi?testcase_id=' + testcase_id;
|
||||
var d = loadJSONDoc(url);
|
||||
d.addBoth(function (res) {
|
||||
d.deferred = null;
|
||||
toggleMessage('none');
|
||||
return res;
|
||||
});
|
||||
d.addCallback(populateTestcase);
|
||||
// if anything goes wrong, except for a simple cancellation,
|
||||
// then log the error and show the logger
|
||||
d.addErrback(function (err) {
|
||||
if (err instanceof CancelledError) {
|
||||
return;
|
||||
}
|
||||
logError(err);
|
||||
logger.debuggingBookmarklet();
|
||||
});
|
||||
fetchJSON(url,populateTestcase);
|
||||
}
|
||||
|
||||
function populateTestcase(data) {
|
||||
@ -213,27 +197,8 @@ function populateTestcase(data) {
|
||||
|
||||
}
|
||||
|
||||
function blankForm(formid) {
|
||||
var f = document.getElementById(formid);
|
||||
var ems = f.getElementsByTagName('input');
|
||||
for (var i in ems) {
|
||||
if (ems[i].type == 'submit' ||
|
||||
ems[i].value == 'Reset' ||
|
||||
ems[i].type == 'radio' ||
|
||||
ems[i].type == 'checkbox') {
|
||||
continue;
|
||||
}
|
||||
ems[i].value='';
|
||||
ems[i].checked=false;
|
||||
}
|
||||
ems = f.getElementsByTagName('select');
|
||||
for (var i in ems) {
|
||||
ems[i].selectedIndex=0;
|
||||
}
|
||||
ems = f.getElementsByTagName('textarea');
|
||||
for (var i in ems) {
|
||||
ems[i].value='';
|
||||
}
|
||||
function blankTestcaseForm(formid) {
|
||||
blankForm(formid);
|
||||
document.getElementById('editform_testcase_id_display').innerHTML = '';
|
||||
document.getElementById('editform_creation_date').innerHTML = '';
|
||||
document.getElementById('editform_last_updated').innerHTML = '';
|
||||
@ -246,7 +211,7 @@ function blankForm(formid) {
|
||||
|
||||
function switchToAdd() {
|
||||
disableModeButtons();
|
||||
blankForm('edit_testcase_form');
|
||||
blankTestcaseForm('edit_testcase_form');
|
||||
setAuthor([% user.user_id %]);
|
||||
document.getElementById('editform_submit').value = 'Add Testcase';
|
||||
document.getElementById('editform_mode').value = 'add';
|
||||
@ -263,6 +228,15 @@ function switchToEdit() {
|
||||
document.getElementById('editform_div').style.display = 'block';
|
||||
}
|
||||
|
||||
function resetTestcase() {
|
||||
if (document.getElementById('editform_testcase_id').value != '') {
|
||||
populateTestcase(testcase);
|
||||
switchToEdit();
|
||||
} else {
|
||||
switchToAdd();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div id="page">
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
[% INCLUDE global/litmus_header.tmpl %]
|
||||
|
||||
<script type="text/javascript">
|
||||
var d;
|
||||
var testgroup;
|
||||
var subgroups=[% IF all_subgroups %][% all_subgroups %][% ELSE %]{}[% END %];
|
||||
|
||||
@ -57,7 +56,7 @@ function loadTestgroup() {
|
||||
document.getElementById('testgroup_display_div').style.display = 'none';
|
||||
document.getElementById('editform_div').style.display = 'none';
|
||||
disableForm('edit_testgroup_form');
|
||||
blankForm('edit_testgroup_form');
|
||||
blankTestgroupForm('edit_testgroup_form');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -66,22 +65,7 @@ function loadTestgroup() {
|
||||
disableForm('edit_testgroup_form');
|
||||
toggleMessage('loading','Loading Testgroup ID# ' + testgroup_id + '...');
|
||||
var url = 'json.cgi?testgroup_id=' + testgroup_id;
|
||||
var d = loadJSONDoc(url);
|
||||
d.addBoth(function (res) {
|
||||
d.deferred = null;
|
||||
toggleMessage('none');
|
||||
return res;
|
||||
});
|
||||
d.addCallback(populateTestgroup);
|
||||
// if anything goes wrong, except for a simple cancellation,
|
||||
// then log the error and show the logger
|
||||
d.addErrback(function (err) {
|
||||
if (err instanceof CancelledError) {
|
||||
return;
|
||||
}
|
||||
logError(err);
|
||||
logger.debuggingBookmarklet();
|
||||
});
|
||||
fetchJSON(url,populateTestgroup);
|
||||
}
|
||||
|
||||
function populateTestgroup(data) {
|
||||
@ -132,39 +116,19 @@ function populateTestgroup(data) {
|
||||
enableModeButtons();
|
||||
}
|
||||
|
||||
function blankForm(formid) {
|
||||
var f = document.getElementById(formid);
|
||||
var ems = f.getElementsByTagName('input');
|
||||
for (var i in ems) {
|
||||
ems[i].checked=false;
|
||||
if (ems[i].type == 'submit' ||
|
||||
ems[i].value == 'Reset' ||
|
||||
ems[i].type == 'radio' ||
|
||||
ems[i].type == 'checkbox' ||
|
||||
ems[i].type == 'button') {
|
||||
continue;
|
||||
}
|
||||
ems[i].value='';
|
||||
}
|
||||
ems = f.getElementsByTagName('select');
|
||||
for (var i in ems) {
|
||||
ems[i].selectedIndex=0;
|
||||
}
|
||||
ems = f.getElementsByTagName('textarea');
|
||||
for (var i in ems) {
|
||||
ems[i].value='';
|
||||
}
|
||||
function blankTestgroupForm(formid) {
|
||||
blankForm(formid);
|
||||
document.getElementById('editform_testgroup_id_display').innerHTML = '';
|
||||
var selectBoxAll = document.getElementById('editform_subgroups_for_product');
|
||||
selectBoxAll.options.length = 0;
|
||||
selectBoxAll.options[selectBoxAll.length] = new Option("--No product selected--",
|
||||
"");
|
||||
selectBoxAll.selectedIndex=-1
|
||||
selectBoxAll.selectedIndex=-1;
|
||||
var selectBoxTestgroup = document.getElementById('editform_testgroup_subgroups');
|
||||
selectBoxTestgroup.options.length = 0;
|
||||
selectBoxTestgroup.options[selectBoxTestgroup.length] = new Option("--No testgroup selected--",
|
||||
"");
|
||||
selectBoxTestgroup.selectedIndex=-1
|
||||
selectBoxTestgroup.selectedIndex=-1;
|
||||
|
||||
document.getElementById('editform_testrunner_plan_id').innerHTML = '';
|
||||
|
||||
@ -173,7 +137,7 @@ function blankForm(formid) {
|
||||
|
||||
function switchToAdd() {
|
||||
disableModeButtons();
|
||||
blankForm('edit_testgroup_form');
|
||||
blankTestgroupForm('edit_testgroup_form');
|
||||
document.getElementById('editform_submit').value = 'Add Testgroup';
|
||||
document.getElementById('editform_mode').value = 'add';
|
||||
enableForm('edit_testgroup_form');
|
||||
@ -201,6 +165,15 @@ function populateAllSubgroups() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resetTestgroup() {
|
||||
if (document.getElementById('editform_testgroup_id').value != '') {
|
||||
populateTestgroup(testgroup);
|
||||
switchToEdit();
|
||||
} else {
|
||||
switchToAdd();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div id="page">
|
||||
|
||||
132
mozilla/webtools/litmus/testrunner_migration/add_testcases_from_xml.pl
Executable file
132
mozilla/webtools/litmus/testrunner_migration/add_testcases_from_xml.pl
Executable file
@ -0,0 +1,132 @@
|
||||
#!/usr/bin/perl -w
|
||||
use strict;
|
||||
use diagnostics;
|
||||
$|++;
|
||||
|
||||
use lib qw(..);
|
||||
|
||||
use Data::Dumper;
|
||||
use Date::Manip;
|
||||
use Litmus;
|
||||
use Litmus::Cache;
|
||||
use Litmus::DBI;
|
||||
use Litmus::DB::Testgroup;
|
||||
use Litmus::DB::Subgroup;
|
||||
use Litmus::DB::Testcase;
|
||||
use Litmus::DB::Product;
|
||||
use Litmus::DB::Branch;
|
||||
use Litmus::DB::User;
|
||||
use XML::XPath;
|
||||
use XML::XPath::XMLParser;
|
||||
|
||||
my $file = shift or die "No file to parse!";
|
||||
|
||||
my $xp = XML::XPath->new(filename => $file);
|
||||
|
||||
# Get all testgroups.
|
||||
my $testgroups = $xp->find('/litmus/testgroups/testgroup');
|
||||
|
||||
foreach my $testgroup_node ($testgroups->get_nodelist) {
|
||||
my $testgroup_name = $testgroup_node->findvalue('/litmus/testgroups/testgroup/name');
|
||||
next if (!$testgroup_name);
|
||||
|
||||
# Check whether testgroup already exists. Add it if not.
|
||||
my ($testgroup) = Litmus::DB::Testgroup->search(name => "$testgroup_name");
|
||||
if (!$testgroup) {
|
||||
my $product_name = $testgroup_node->findvalue('product');
|
||||
my ($product) = Litmus::DB::Product->search(name => "$product_name");
|
||||
die if (!$product);
|
||||
my $branch_name = $testgroup_node->findvalue('branch');
|
||||
my ($branch) = Litmus::DB::Branch->search(name => "$branch_name");
|
||||
die if (!$branch);
|
||||
my %hash = (
|
||||
name => $testgroup_name,
|
||||
product_id => $product->product_id,
|
||||
);
|
||||
$testgroup = Litmus::DB::Testgroup->create(\%hash);
|
||||
die if (!$testgroup);
|
||||
my @branches;
|
||||
push @branches, $branch->branch_id;
|
||||
$testgroup->update_branches(\@branches);
|
||||
}
|
||||
|
||||
# Get a list of all subgroups for the current testgroup.
|
||||
my $subgroups = $testgroup_node->find('subgroups/subgroup');
|
||||
|
||||
my $sg_default_order = 1;
|
||||
foreach my $subgroup_node ($subgroups->get_nodelist) {
|
||||
my $subgroup_name = $subgroup_node->findvalue('name');
|
||||
next if (!$subgroup_name);
|
||||
|
||||
# Check whether subgroup already exists. Add it if not.
|
||||
my ($subgroup) = Litmus::DB::Subgroup->search(name => "$subgroup_name");
|
||||
if (!$subgroup) {
|
||||
my $product_name = $subgroup_node->findvalue('product');
|
||||
my ($product) = Litmus::DB::Product->search(name => "$product_name");
|
||||
die if (!$product);
|
||||
my %hash = (
|
||||
name => $subgroup_name,
|
||||
product_id => $product->product_id,
|
||||
);
|
||||
$subgroup = Litmus::DB::Subgroup->create(\%hash);
|
||||
die if (!$subgroup);
|
||||
}
|
||||
|
||||
my $sg_sort_order = $subgroup_node->findvalue('sort_order');
|
||||
if (!$sg_sort_order) {
|
||||
$sg_sort_order = $sg_default_order;
|
||||
}
|
||||
$subgroup->update_testgroup($testgroup->testgroup_id,$sg_sort_order);
|
||||
$sg_default_order++;
|
||||
|
||||
# Get all testcases for the current subgroup.
|
||||
my $testcases = $subgroup_node->find('testcases/testcase');
|
||||
|
||||
my $tc_default_order = 1;
|
||||
foreach my $testcase_node ($testcases->get_nodelist) {
|
||||
my $testcase_name = $testcase_node->findvalue('name');
|
||||
next if (!$testcase_name);
|
||||
|
||||
# We assume that all testcases are new.
|
||||
my $product_name = $testcase_node->findvalue('product');
|
||||
my ($product) = Litmus::DB::Product->search(name => "$product_name");
|
||||
die if (!$product);
|
||||
my $email = $testcase_node->findvalue('author_email');
|
||||
my ($user) = Litmus::DB::User->search(email => "$email");
|
||||
|
||||
my $steps = $testcase_node->find('steps/*');
|
||||
my $steps_text;
|
||||
foreach my $step ($steps->get_nodelist) {
|
||||
$steps_text .= XML::XPath::XMLParser::as_string($step);
|
||||
}
|
||||
my $results = $testcase_node->find('expected_results/*');
|
||||
my $results_text;
|
||||
foreach my $result ($results->get_nodelist) {
|
||||
$results_text .= XML::XPath::XMLParser::as_string($result);
|
||||
}
|
||||
|
||||
my %hash = (
|
||||
summary => $testcase_name,
|
||||
product_id => $product->product_id,
|
||||
author_id => $user->user_id || 0,
|
||||
details => $testcase_node->findvalue('details'),
|
||||
steps => $steps_text,
|
||||
expected_results => $results_text,
|
||||
format => 1,
|
||||
);
|
||||
|
||||
my $testcase = Litmus::DB::Testcase->create(\%hash);
|
||||
die if (!$testcase);
|
||||
my $tc_sort_order = $testcase_node->findvalue('sort_order');
|
||||
if (!$tc_sort_order) {
|
||||
$tc_sort_order = $tc_default_order;
|
||||
}
|
||||
$testcase->update_subgroup($subgroup->subgroup_id,$tc_sort_order);
|
||||
$tc_default_order++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
rebuildCache();
|
||||
Loading…
x
Reference in New Issue
Block a user