Skip to content

Commit caad1d7

Browse files
authored
Merge pull request #18 from edcdavid/filter-in-report
Filter-in-report
2 parents 01b7e33 + 6da0474 commit caad1d7

File tree

3 files changed

+64
-24
lines changed

3 files changed

+64
-24
lines changed

html/index.js

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,14 @@ function generateTestCasesStatsElement (tableElement, tableName, optionalMandato
313313
testText = '<thead><tr><th style="width:15%" scope="col">' + optionalMandatory + ' Test summary (' + tableNameMap[tableName] + ')</th><th scope="col">Test feedback</th></tr></thead><tbody>'
314314
}
315315

316-
testText += '<tr><td class="align-top"><b>Total:</b> ' + testsTotal + '<br><b><tg>Passed:</tg></b> ' + testsPassed + ' '
317-
testText += '<input type="checkbox" id="filter-' + optionalMandatory + '-passed-' + tableName + '" checked onclick="filterTestCasesBasedOnStateHandler(\'' + tableElement + '\',\'' + tableName + '\', \'passed\',\'' + optionalMandatory + '\' )" >'
318-
testText += '<br><b><tgy>Skipped:</tgy></b> ' + testsSkipped + ' '
319-
testText += '<input type="checkbox" id="filter-' + optionalMandatory + '-skipped-' + tableName + '" checked onclick="filterTestCasesBasedOnStateHandler(\'' + tableElement + '\',\'' + tableName + '\', \'skipped\', \'' + optionalMandatory + '\' )" >'
320-
testText += '<br><b><' + colorFailed + '>Failed:</' + colorFailed + '></b> ' + testsFailed + ' '
321-
testText += '<input type="checkbox" id="filter-' + optionalMandatory + '-failed-' + tableName + '" checked onclick="filterTestCasesBasedOnStateHandler(\'' + tableElement + '\',\'' + tableName + '\', \'failed\', \'' + optionalMandatory + '\' )" >'
322-
testText += '<br><b><tpurple>Aborted:</tpurple></b> ' + testsAborted + ' '
323-
testText += '<input type="checkbox" id="filter-' + optionalMandatory + '-aborted-' + tableName + '" checked onclick="filterTestCasesBasedOnStateHandler(\'' + tableElement + '\',\'' + tableName + '\', \'aborted\', \'' + optionalMandatory + '\' )" >'
316+
testText += '<tr><td class="align-top"><b><tblack>Total:</tblack></b><tblack> ' + testsTotal + '</tblack><br><b><tg>Passed:</tg></b> <tblack>' + testsPassed + '</tblack> '
317+
testText += '<input type="checkbox" class="larger-checkbox" id="filter-' + optionalMandatory + '-passed-' + tableName + '" checked onclick="filterTestCasesBasedOnStateHandler(\'' + tableElement + '\',\'' + tableName + '\', \'passed\',\'' + optionalMandatory + '\' )" >'
318+
testText += '<br><b><tgy>Skipped:</tgy></b> <tblack>' + testsSkipped + '</tblack> '
319+
testText += '<input type="checkbox" class="larger-checkbox" id="filter-' + optionalMandatory + '-skipped-' + tableName + '" checked onclick="filterTestCasesBasedOnStateHandler(\'' + tableElement + '\',\'' + tableName + '\', \'skipped\', \'' + optionalMandatory + '\' )" >'
320+
testText += '<br><b><' + colorFailed + '>Failed:</' + colorFailed + '></b> <tblack>' + testsFailed + '</tblack> '
321+
testText += '<input type="checkbox" class="larger-checkbox" id="filter-' + optionalMandatory + '-failed-' + tableName + '" checked onclick="filterTestCasesBasedOnStateHandler(\'' + tableElement + '\',\'' + tableName + '\', \'failed\', \'' + optionalMandatory + '\' )" >'
322+
testText += '<br><b><tpurple>Aborted:</tpurple></b> <tblack>' + testsAborted + '</tblack> '
323+
testText += '<input type="checkbox" class="larger-checkbox" id="filter-' + optionalMandatory + '-aborted-' + tableName + '" checked onclick="filterTestCasesBasedOnStateHandler(\'' + tableElement + '\',\'' + tableName + '\', \'aborted\', \'' + optionalMandatory + '\' )" >'
324324
testText += '</td><td>'
325325
testText += '<div class="accordion" id="results-accordion">'
326326
return testText
@@ -593,6 +593,36 @@ function getHtmlResults () {
593593
const doc = document.implementation.createHTMLDocument()
594594
const head = doc.head
595595
const body = doc.body
596+
597+
const script = doc.createElement('script')
598+
script.type = 'text/javascript'
599+
script.textContent = `
600+
function filterTestCasesBasedOnStateHandler(tableId, tableName, state, mandatoryOptional) { // eslint-disable-line no-unused-vars
601+
const checkBox = document.getElementById('filter-' + mandatoryOptional + '-' + state + '-' + tableName)
602+
const show = checkBox.checked
603+
if (show) {
604+
checkBox.setAttribute('checked', '')
605+
} else {
606+
checkBox.removeAttribute('checked')
607+
}
608+
const tableIdClean = tableId.replace(/#/g, '')
609+
const table = document.getElementById(tableIdClean)
610+
const elements = table.getElementsByClassName('accordion-item')
611+
for (let i = 0; i < elements.length; i++) {
612+
const element = elements[i]
613+
const id = element.getAttribute('data-id')
614+
if (id === state) {
615+
if (show === true) {
616+
element.removeAttribute('hidden')
617+
} else {
618+
element.setAttribute('hidden', 'hidden')
619+
}
620+
}
621+
}
622+
}
623+
`
624+
doc.head.appendChild(script)
625+
596626
selectScenarioComboBox = document.getElementById('selectScenarioComboBox')
597627
insertResults(body, 'mandatory')
598628
if (selectScenarioComboBox.value !== 'all') {
@@ -611,13 +641,8 @@ function getHtmlResults () {
611641
})
612642

613643
// Make document read-only
614-
const checkboxes = doc.querySelectorAll('input[type="checkbox"]')
615644
const textareas = doc.querySelectorAll('textarea')
616645

617-
checkboxes.forEach(checkbox => {
618-
checkbox.setAttribute('disabled', 'disabled')
619-
})
620-
621646
textareas.forEach(textarea => {
622647
textarea.readOnly = true
623648
})

0 commit comments

Comments
 (0)