add test assets
This commit is contained in:
parent
7519014416
commit
ad8f3a3891
5 changed files with 2662 additions and 0 deletions
770
tests/assets/html_merge/test_authentik_blueprint_api.html
Normal file
770
tests/assets/html_merge/test_authentik_blueprint_api.html
Normal file
|
|
@ -0,0 +1,770 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title id="head-title">test_authentik_blueprint_api.html</title>
|
||||
<link href="assets\style.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="title">test_authentik_blueprint_api.html</h1>
|
||||
<p>Report generated on 09-Dec-2023 at 12:22:45 by <a href="https://pypi.python.org/pypi/pytest-html">pytest-html</a>
|
||||
v4.1.1</p>
|
||||
<div id="environment-header">
|
||||
<h2>Environment</h2>
|
||||
</div>
|
||||
<table id="environment"></table>
|
||||
<!-- TEMPLATES -->
|
||||
<template id="template_environment_row">
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</template>
|
||||
<template id="template_results-table__body--empty">
|
||||
<tbody class="results-table-row">
|
||||
<tr id="not-found-message">
|
||||
<td colspan="4">No results found. Check the filters.</th>
|
||||
</tr>
|
||||
</template>
|
||||
<template id="template_results-table__tbody">
|
||||
<tbody class="results-table-row">
|
||||
<tr class="collapsible">
|
||||
</tr>
|
||||
<tr class="extras-row">
|
||||
<td class="extra" colspan="4">
|
||||
<div class="extraHTML"></div>
|
||||
<div class="media">
|
||||
<div class="media-container">
|
||||
<div class="media-container__nav--left"><</div>
|
||||
<div class="media-container__viewport">
|
||||
<img src="" />
|
||||
<video controls>
|
||||
<source src="" type="video/mp4">
|
||||
</video>
|
||||
</div>
|
||||
<div class="media-container__nav--right">></div>
|
||||
</div>
|
||||
<div class="media__name"></div>
|
||||
<div class="media__counter"></div>
|
||||
</div>
|
||||
<div class="logwrapper">
|
||||
<div class="logexpander"></div>
|
||||
<div class="log"></div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</template>
|
||||
<!-- END TEMPLATES -->
|
||||
<div class="summary">
|
||||
<div class="summary__data">
|
||||
<h2>Summary</h2>
|
||||
<div class="additional-summary prefix">
|
||||
</div>
|
||||
<p class="run-count">1 test took 00:00:01.</p>
|
||||
<p class="filter">(Un)check the boxes to filter the results.</p>
|
||||
<div class="summary__reload">
|
||||
<div class="summary__reload__button hidden" onclick="location.reload()">
|
||||
<div>There are still tests running. <br />Reload this page to get the latest results!</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="summary__spacer"></div>
|
||||
<div class="controls">
|
||||
<div class="filters">
|
||||
<input checked="true" class="filter" name="filter_checkbox" type="checkbox" data-test-result="failed" />
|
||||
<span class="failed">1 Failed,</span>
|
||||
<input checked="true" class="filter" name="filter_checkbox" type="checkbox" data-test-result="passed" disabled/>
|
||||
<span class="passed">0 Passed,</span>
|
||||
<input checked="true" class="filter" name="filter_checkbox" type="checkbox" data-test-result="skipped" disabled/>
|
||||
<span class="skipped">0 Skipped,</span>
|
||||
<input checked="true" class="filter" name="filter_checkbox" type="checkbox" data-test-result="xfailed" disabled/>
|
||||
<span class="xfailed">0 Expected failures,</span>
|
||||
<input checked="true" class="filter" name="filter_checkbox" type="checkbox" data-test-result="xpassed" disabled/>
|
||||
<span class="xpassed">0 Unexpected passes,</span>
|
||||
<input checked="true" class="filter" name="filter_checkbox" type="checkbox" data-test-result="error" disabled/>
|
||||
<span class="error">0 Errors,</span>
|
||||
<input checked="true" class="filter" name="filter_checkbox" type="checkbox" data-test-result="rerun" disabled/>
|
||||
<span class="rerun">0 Reruns</span>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<button id="show_all_details">Show all details</button> / <button id="hide_all_details">Hide all details</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="additional-summary summary">
|
||||
</div>
|
||||
<div class="additional-summary postfix">
|
||||
</div>
|
||||
</div>
|
||||
<table id="results-table">
|
||||
<thead id="results-table-head">
|
||||
<tr>
|
||||
<th class="sortable" data-column-type="result">Result</th>
|
||||
<th class="sortable" data-column-type="testId">Test</th>
|
||||
<th class="sortable" data-column-type="duration">Duration</th>
|
||||
<th>Links</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</body>
|
||||
<footer>
|
||||
<div id="data-container" data-jsonblob="{"environment": {"Python": "3.10.13", "Platform": "Windows-10-10.0.19045-SP0", "Packages": {"pytest": "7.4.3", "pluggy": "1.3.0"}, "Plugins": {"abra": "0.2.0", "base-url": "2.0.0", "html": "4.1.1", "metadata": "3.0.0", "playwright": "0.4.3"}}, "tests": {"recipes/authentik/tests_authentik/test_authentik_blueprint_api.py::test_should_create_bug_report": [{"extras": [{"name": "Authentik Blueprint Status", "format_type": "text", "content": "assets\\recipes_authentik_tests_authentik_test_authentik_blueprint_api.py__test_should_create_bug_report_0_0.txt", "mime_type": "text/plain", "extension": "txt"}], "result": "Failed", "testId": "recipes/authentik/tests_authentik/test_authentik_blueprint_api.py::test_should_create_bug_report", "duration": "00:00:01", "resultsTableRow": ["<td class=\"col-result\">Failed</td>", "<td class=\"col-testId\">recipes/authentik/tests_authentik/test_authentik_blueprint_api.py::test_should_create_bug_report</td>", "<td class=\"col-duration\">00:00:01</td>", "<td class=\"col-links\"><a target=\"_blank\" href=\"assets\\recipes_authentik_tests_authentik_test_authentik_blueprint_api.py__test_should_create_bug_report_0_0.txt\" class=\"col-links__extra text\">Authentik Blueprint Status</a></td>"], "log": "api_request_context = &lt;playwright._impl._fetch.APIRequestContext object at 0x0000016EF237C0A0&gt;\nURL = BaseUrl(netloc=&#x27;login.test.dev.local-it.cloud&#x27;, scheme=&#x27;https&#x27;, path=&#x27;&#x27;, params=&#x27;&#x27;, query=&#x27;&#x27;, fragment=&#x27;&#x27;)\nextras = [{&#x27;content&#x27;: &#x27;name enabled status\\n---------------------------... True successful&#x27;, &#x27;extension&#x27;: &#x27;txt&#x27;, &#x27;format_type&#x27;: &#x27;text&#x27;, &#x27;mime_type&#x27;: &#x27;text/plain&#x27;, ...}]\n\n def test_should_create_bug_report(\n api_request_context: APIRequestContext,\n URL: BaseUrl,\n extras,\n ) -&gt; None:\n blueprints = api_request_context.get(URL.get(&quot;api/v3/managed/blueprints&quot;))\n assert blueprints.ok\n blueprints_data = blueprints.json()\n ic(blueprints_data)\n \n # fake failed blueprint\n blueprints_data[&quot;results&quot;][10][&quot;status&quot;] = &quot;failed&quot;\n \n table_data_all = []\n table_data_failed = []\n for item in blueprints_data[&quot;results&quot;]:\n row = [item[&quot;name&quot;], item[&quot;enabled&quot;], item[&quot;status&quot;]]\n table_data_all.append(row)\n if item[&quot;status&quot;] != &quot;successful&quot;:\n table_data_failed.append(row)\n \n table = tabulate(table_data_all, headers=[&quot;name&quot;, &quot;enabled&quot;, &quot;status&quot;])\n extras.append(pytest_html.extras.text(table, name=&quot;Authentik Blueprint Status&quot;))\n \n&gt; assert (\n table_data_failed == []\n ), &quot;One or more blueprints were not successful. See Authentik Blueprint Status in html report&quot;\nE AssertionError: One or more blueprints were not successful. See Authentik Blueprint Status in html report\nE assert [[&#x27;Default - ...ue, &#x27;failed&#x27;]] == []\nE Left contains one more item: [&#x27;Default - Provider authorization flow (explicit consent)&#x27;, True, &#x27;failed&#x27;]\nE Full diff:\nE - []\nE + [[&#x27;Default - Provider authorization flow (explicit consent)&#x27;, True, &#x27;failed&#x27;]]\n\nrecipes\\authentik\\tests_authentik\\test_authentik_blueprint_api.py:36: AssertionError\n"}]}, "renderCollapsed": ["passed"], "initialSort": "result", "title": "test_authentik_blueprint_api.html"}"></div>
|
||||
<script>
|
||||
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||
const { getCollapsedCategory, setCollapsedIds } = require('./storage.js')
|
||||
|
||||
class DataManager {
|
||||
setManager(data) {
|
||||
const collapsedCategories = [...getCollapsedCategory(data.renderCollapsed)]
|
||||
const collapsedIds = []
|
||||
const tests = Object.values(data.tests).flat().map((test, index) => {
|
||||
const collapsed = collapsedCategories.includes(test.result.toLowerCase())
|
||||
const id = `test_${index}`
|
||||
if (collapsed) {
|
||||
collapsedIds.push(id)
|
||||
}
|
||||
return {
|
||||
...test,
|
||||
id,
|
||||
collapsed,
|
||||
}
|
||||
})
|
||||
const dataBlob = { ...data, tests }
|
||||
this.data = { ...dataBlob }
|
||||
this.renderData = { ...dataBlob }
|
||||
setCollapsedIds(collapsedIds)
|
||||
}
|
||||
|
||||
get allData() {
|
||||
return { ...this.data }
|
||||
}
|
||||
|
||||
resetRender() {
|
||||
this.renderData = { ...this.data }
|
||||
}
|
||||
|
||||
setRender(data) {
|
||||
this.renderData.tests = [...data]
|
||||
}
|
||||
|
||||
toggleCollapsedItem(id) {
|
||||
this.renderData.tests = this.renderData.tests.map((test) =>
|
||||
test.id === id ? { ...test, collapsed: !test.collapsed } : test,
|
||||
)
|
||||
}
|
||||
|
||||
set allCollapsed(collapsed) {
|
||||
this.renderData = { ...this.renderData, tests: [...this.renderData.tests.map((test) => (
|
||||
{ ...test, collapsed }
|
||||
))] }
|
||||
}
|
||||
|
||||
get testSubset() {
|
||||
return [...this.renderData.tests]
|
||||
}
|
||||
|
||||
get environment() {
|
||||
return this.renderData.environment
|
||||
}
|
||||
|
||||
get initialSort() {
|
||||
return this.data.initialSort
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
manager: new DataManager(),
|
||||
}
|
||||
|
||||
},{"./storage.js":8}],2:[function(require,module,exports){
|
||||
const mediaViewer = require('./mediaviewer.js')
|
||||
const templateEnvRow = document.getElementById('template_environment_row')
|
||||
const templateResult = document.getElementById('template_results-table__tbody')
|
||||
|
||||
function htmlToElements(html) {
|
||||
const temp = document.createElement('template')
|
||||
temp.innerHTML = html
|
||||
return temp.content.childNodes
|
||||
}
|
||||
|
||||
const find = (selector, elem) => {
|
||||
if (!elem) {
|
||||
elem = document
|
||||
}
|
||||
return elem.querySelector(selector)
|
||||
}
|
||||
|
||||
const findAll = (selector, elem) => {
|
||||
if (!elem) {
|
||||
elem = document
|
||||
}
|
||||
return [...elem.querySelectorAll(selector)]
|
||||
}
|
||||
|
||||
const dom = {
|
||||
getStaticRow: (key, value) => {
|
||||
const envRow = templateEnvRow.content.cloneNode(true)
|
||||
const isObj = typeof value === 'object' && value !== null
|
||||
const values = isObj ? Object.keys(value).map((k) => `${k}: ${value[k]}`) : null
|
||||
|
||||
const valuesElement = htmlToElements(
|
||||
values ? `<ul>${values.map((val) => `<li>${val}</li>`).join('')}<ul>` : `<div>${value}</div>`)[0]
|
||||
const td = findAll('td', envRow)
|
||||
td[0].textContent = key
|
||||
td[1].appendChild(valuesElement)
|
||||
|
||||
return envRow
|
||||
},
|
||||
getResultTBody: ({ testId, id, log, extras, resultsTableRow, tableHtml, result, collapsed }) => {
|
||||
const resultBody = templateResult.content.cloneNode(true)
|
||||
resultBody.querySelector('tbody').classList.add(result.toLowerCase())
|
||||
resultBody.querySelector('tbody').id = testId
|
||||
resultBody.querySelector('.collapsible').dataset.id = id
|
||||
|
||||
resultsTableRow.forEach((html) => {
|
||||
const t = document.createElement('template')
|
||||
t.innerHTML = html
|
||||
resultBody.querySelector('.collapsible').appendChild(t.content)
|
||||
})
|
||||
|
||||
if (log) {
|
||||
// Wrap lines starting with "E" with span.error to color those lines red
|
||||
const wrappedLog = log.replace(/^E.*$/gm, (match) => `<span class="error">${match}</span>`)
|
||||
resultBody.querySelector('.log').innerHTML = wrappedLog
|
||||
} else {
|
||||
resultBody.querySelector('.log').remove()
|
||||
}
|
||||
|
||||
if (collapsed) {
|
||||
resultBody.querySelector('.collapsible > td')?.classList.add('collapsed')
|
||||
resultBody.querySelector('.extras-row').classList.add('hidden')
|
||||
} else {
|
||||
resultBody.querySelector('.collapsible > td')?.classList.remove('collapsed')
|
||||
}
|
||||
|
||||
const media = []
|
||||
extras?.forEach(({ name, format_type, content }) => {
|
||||
if (['image', 'video'].includes(format_type)) {
|
||||
media.push({ path: content, name, format_type })
|
||||
}
|
||||
|
||||
if (format_type === 'html') {
|
||||
resultBody.querySelector('.extraHTML').insertAdjacentHTML('beforeend', `<div>${content}</div>`)
|
||||
}
|
||||
})
|
||||
mediaViewer.setup(resultBody, media)
|
||||
|
||||
// Add custom html from the pytest_html_results_table_html hook
|
||||
tableHtml?.forEach((item) => {
|
||||
resultBody.querySelector('td[class="extra"]').insertAdjacentHTML('beforeend', item)
|
||||
})
|
||||
|
||||
return resultBody
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
dom,
|
||||
htmlToElements,
|
||||
find,
|
||||
findAll,
|
||||
}
|
||||
|
||||
},{"./mediaviewer.js":6}],3:[function(require,module,exports){
|
||||
const { manager } = require('./datamanager.js')
|
||||
const { doSort } = require('./sort.js')
|
||||
const storageModule = require('./storage.js')
|
||||
|
||||
const getFilteredSubSet = (filter) =>
|
||||
manager.allData.tests.filter(({ result }) => filter.includes(result.toLowerCase()))
|
||||
|
||||
const doInitFilter = () => {
|
||||
const currentFilter = storageModule.getVisible()
|
||||
const filteredSubset = getFilteredSubSet(currentFilter)
|
||||
manager.setRender(filteredSubset)
|
||||
}
|
||||
|
||||
const doFilter = (type, show) => {
|
||||
if (show) {
|
||||
storageModule.showCategory(type)
|
||||
} else {
|
||||
storageModule.hideCategory(type)
|
||||
}
|
||||
|
||||
const currentFilter = storageModule.getVisible()
|
||||
const filteredSubset = getFilteredSubSet(currentFilter)
|
||||
manager.setRender(filteredSubset)
|
||||
|
||||
const sortColumn = storageModule.getSort()
|
||||
doSort(sortColumn, true)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
doFilter,
|
||||
doInitFilter,
|
||||
}
|
||||
|
||||
},{"./datamanager.js":1,"./sort.js":7,"./storage.js":8}],4:[function(require,module,exports){
|
||||
const { redraw, bindEvents, renderStatic } = require('./main.js')
|
||||
const { doInitFilter } = require('./filter.js')
|
||||
const { doInitSort } = require('./sort.js')
|
||||
const { manager } = require('./datamanager.js')
|
||||
const data = JSON.parse(document.getElementById('data-container').dataset.jsonblob)
|
||||
|
||||
function init() {
|
||||
manager.setManager(data)
|
||||
doInitFilter()
|
||||
doInitSort()
|
||||
renderStatic()
|
||||
redraw()
|
||||
bindEvents()
|
||||
}
|
||||
|
||||
init()
|
||||
|
||||
},{"./datamanager.js":1,"./filter.js":3,"./main.js":5,"./sort.js":7}],5:[function(require,module,exports){
|
||||
const { dom, find, findAll } = require('./dom.js')
|
||||
const { manager } = require('./datamanager.js')
|
||||
const { doSort } = require('./sort.js')
|
||||
const { doFilter } = require('./filter.js')
|
||||
const {
|
||||
getVisible,
|
||||
getCollapsedIds,
|
||||
setCollapsedIds,
|
||||
getSort,
|
||||
getSortDirection,
|
||||
possibleFilters,
|
||||
} = require('./storage.js')
|
||||
|
||||
const removeChildren = (node) => {
|
||||
while (node.firstChild) {
|
||||
node.removeChild(node.firstChild)
|
||||
}
|
||||
}
|
||||
|
||||
const renderStatic = () => {
|
||||
const renderEnvironmentTable = () => {
|
||||
const environment = manager.environment
|
||||
const rows = Object.keys(environment).map((key) => dom.getStaticRow(key, environment[key]))
|
||||
const table = document.getElementById('environment')
|
||||
removeChildren(table)
|
||||
rows.forEach((row) => table.appendChild(row))
|
||||
}
|
||||
renderEnvironmentTable()
|
||||
}
|
||||
|
||||
const addItemToggleListener = (elem) => {
|
||||
elem.addEventListener('click', ({ target }) => {
|
||||
const id = target.parentElement.dataset.id
|
||||
manager.toggleCollapsedItem(id)
|
||||
|
||||
const collapsedIds = getCollapsedIds()
|
||||
if (collapsedIds.includes(id)) {
|
||||
const updated = collapsedIds.filter((item) => item !== id)
|
||||
setCollapsedIds(updated)
|
||||
} else {
|
||||
collapsedIds.push(id)
|
||||
setCollapsedIds(collapsedIds)
|
||||
}
|
||||
redraw()
|
||||
})
|
||||
}
|
||||
|
||||
const renderContent = (tests) => {
|
||||
const sortAttr = getSort(manager.initialSort)
|
||||
const sortAsc = JSON.parse(getSortDirection())
|
||||
const rows = tests.map(dom.getResultTBody)
|
||||
const table = document.getElementById('results-table')
|
||||
const tableHeader = document.getElementById('results-table-head')
|
||||
|
||||
const newTable = document.createElement('table')
|
||||
newTable.id = 'results-table'
|
||||
|
||||
// remove all sorting classes and set the relevant
|
||||
findAll('.sortable', tableHeader).forEach((elem) => elem.classList.remove('asc', 'desc'))
|
||||
tableHeader.querySelector(`.sortable[data-column-type="${sortAttr}"]`)?.classList.add(sortAsc ? 'desc' : 'asc')
|
||||
newTable.appendChild(tableHeader)
|
||||
|
||||
if (!rows.length) {
|
||||
const emptyTable = document.getElementById('template_results-table__body--empty').content.cloneNode(true)
|
||||
newTable.appendChild(emptyTable)
|
||||
} else {
|
||||
rows.forEach((row) => {
|
||||
if (!!row) {
|
||||
findAll('.collapsible td:not(.col-links', row).forEach(addItemToggleListener)
|
||||
find('.logexpander', row).addEventListener('click',
|
||||
(evt) => evt.target.parentNode.classList.toggle('expanded'),
|
||||
)
|
||||
newTable.appendChild(row)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
table.replaceWith(newTable)
|
||||
}
|
||||
|
||||
const renderDerived = () => {
|
||||
const currentFilter = getVisible()
|
||||
possibleFilters.forEach((result) => {
|
||||
const input = document.querySelector(`input[data-test-result="${result}"]`)
|
||||
input.checked = currentFilter.includes(result)
|
||||
})
|
||||
}
|
||||
|
||||
const bindEvents = () => {
|
||||
const filterColumn = (evt) => {
|
||||
const { target: element } = evt
|
||||
const { testResult } = element.dataset
|
||||
|
||||
doFilter(testResult, element.checked)
|
||||
const collapsedIds = getCollapsedIds()
|
||||
const updated = manager.renderData.tests.map((test) => {
|
||||
return {
|
||||
...test,
|
||||
collapsed: collapsedIds.includes(test.id),
|
||||
}
|
||||
})
|
||||
manager.setRender(updated)
|
||||
redraw()
|
||||
}
|
||||
|
||||
const header = document.getElementById('environment-header')
|
||||
header.addEventListener('click', () => {
|
||||
const table = document.getElementById('environment')
|
||||
table.classList.toggle('hidden')
|
||||
header.classList.toggle('collapsed')
|
||||
})
|
||||
|
||||
findAll('input[name="filter_checkbox"]').forEach((elem) => {
|
||||
elem.addEventListener('click', filterColumn)
|
||||
})
|
||||
|
||||
findAll('.sortable').forEach((elem) => {
|
||||
elem.addEventListener('click', (evt) => {
|
||||
const { target: element } = evt
|
||||
const { columnType } = element.dataset
|
||||
doSort(columnType)
|
||||
redraw()
|
||||
})
|
||||
})
|
||||
|
||||
document.getElementById('show_all_details').addEventListener('click', () => {
|
||||
manager.allCollapsed = false
|
||||
setCollapsedIds([])
|
||||
redraw()
|
||||
})
|
||||
document.getElementById('hide_all_details').addEventListener('click', () => {
|
||||
manager.allCollapsed = true
|
||||
const allIds = manager.renderData.tests.map((test) => test.id)
|
||||
setCollapsedIds(allIds)
|
||||
redraw()
|
||||
})
|
||||
}
|
||||
|
||||
const redraw = () => {
|
||||
const { testSubset } = manager
|
||||
|
||||
renderContent(testSubset)
|
||||
renderDerived()
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
redraw,
|
||||
bindEvents,
|
||||
renderStatic,
|
||||
}
|
||||
|
||||
},{"./datamanager.js":1,"./dom.js":2,"./filter.js":3,"./sort.js":7,"./storage.js":8}],6:[function(require,module,exports){
|
||||
class MediaViewer {
|
||||
constructor(assets) {
|
||||
this.assets = assets
|
||||
this.index = 0
|
||||
}
|
||||
|
||||
nextActive() {
|
||||
this.index = this.index === this.assets.length - 1 ? 0 : this.index + 1
|
||||
return [this.activeFile, this.index]
|
||||
}
|
||||
|
||||
prevActive() {
|
||||
this.index = this.index === 0 ? this.assets.length - 1 : this.index -1
|
||||
return [this.activeFile, this.index]
|
||||
}
|
||||
|
||||
get currentIndex() {
|
||||
return this.index
|
||||
}
|
||||
|
||||
get activeFile() {
|
||||
return this.assets[this.index]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const setup = (resultBody, assets) => {
|
||||
if (!assets.length) {
|
||||
resultBody.querySelector('.media').classList.add('hidden')
|
||||
return
|
||||
}
|
||||
|
||||
const mediaViewer = new MediaViewer(assets)
|
||||
const container = resultBody.querySelector('.media-container')
|
||||
const leftArrow = resultBody.querySelector('.media-container__nav--left')
|
||||
const rightArrow = resultBody.querySelector('.media-container__nav--right')
|
||||
const mediaName = resultBody.querySelector('.media__name')
|
||||
const counter = resultBody.querySelector('.media__counter')
|
||||
const imageEl = resultBody.querySelector('img')
|
||||
const sourceEl = resultBody.querySelector('source')
|
||||
const videoEl = resultBody.querySelector('video')
|
||||
|
||||
const setImg = (media, index) => {
|
||||
if (media?.format_type === 'image') {
|
||||
imageEl.src = media.path
|
||||
|
||||
imageEl.classList.remove('hidden')
|
||||
videoEl.classList.add('hidden')
|
||||
} else if (media?.format_type === 'video') {
|
||||
sourceEl.src = media.path
|
||||
|
||||
videoEl.classList.remove('hidden')
|
||||
imageEl.classList.add('hidden')
|
||||
}
|
||||
|
||||
mediaName.innerText = media?.name
|
||||
counter.innerText = `${index + 1} / ${assets.length}`
|
||||
}
|
||||
setImg(mediaViewer.activeFile, mediaViewer.currentIndex)
|
||||
|
||||
const moveLeft = () => {
|
||||
const [media, index] = mediaViewer.prevActive()
|
||||
setImg(media, index)
|
||||
}
|
||||
const doRight = () => {
|
||||
const [media, index] = mediaViewer.nextActive()
|
||||
setImg(media, index)
|
||||
}
|
||||
const openImg = () => {
|
||||
window.open(mediaViewer.activeFile.path, '_blank')
|
||||
}
|
||||
if (assets.length === 1) {
|
||||
container.classList.add('media-container--fullscreen')
|
||||
} else {
|
||||
leftArrow.addEventListener('click', moveLeft)
|
||||
rightArrow.addEventListener('click', doRight)
|
||||
}
|
||||
imageEl.addEventListener('click', openImg)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
setup,
|
||||
}
|
||||
|
||||
},{}],7:[function(require,module,exports){
|
||||
const { manager } = require('./datamanager.js')
|
||||
const storageModule = require('./storage.js')
|
||||
|
||||
const genericSort = (list, key, ascending, customOrder) => {
|
||||
let sorted
|
||||
if (customOrder) {
|
||||
sorted = list.sort((a, b) => {
|
||||
const aValue = a.result.toLowerCase()
|
||||
const bValue = b.result.toLowerCase()
|
||||
|
||||
const aIndex = customOrder.findIndex((item) => item.toLowerCase() === aValue)
|
||||
const bIndex = customOrder.findIndex((item) => item.toLowerCase() === bValue)
|
||||
|
||||
// Compare the indices to determine the sort order
|
||||
return aIndex - bIndex
|
||||
})
|
||||
} else {
|
||||
sorted = list.sort((a, b) => a[key] === b[key] ? 0 : a[key] > b[key] ? 1 : -1)
|
||||
}
|
||||
|
||||
if (ascending) {
|
||||
sorted.reverse()
|
||||
}
|
||||
return sorted
|
||||
}
|
||||
|
||||
const durationSort = (list, ascending) => {
|
||||
const parseDuration = (duration) => {
|
||||
if (duration.includes(':')) {
|
||||
// If it's in the format "HH:mm:ss"
|
||||
const [hours, minutes, seconds] = duration.split(':').map(Number)
|
||||
return (hours * 3600 + minutes * 60 + seconds) * 1000
|
||||
} else {
|
||||
// If it's in the format "nnn ms"
|
||||
return parseInt(duration)
|
||||
}
|
||||
}
|
||||
const sorted = list.sort((a, b) => parseDuration(a['duration']) - parseDuration(b['duration']))
|
||||
if (ascending) {
|
||||
sorted.reverse()
|
||||
}
|
||||
return sorted
|
||||
}
|
||||
|
||||
const doInitSort = () => {
|
||||
const type = storageModule.getSort(manager.initialSort)
|
||||
const ascending = storageModule.getSortDirection()
|
||||
const list = manager.testSubset
|
||||
const initialOrder = ['Error', 'Failed', 'Rerun', 'XFailed', 'XPassed', 'Skipped', 'Passed']
|
||||
|
||||
storageModule.setSort(type)
|
||||
storageModule.setSortDirection(ascending)
|
||||
|
||||
if (type?.toLowerCase() === 'original') {
|
||||
manager.setRender(list)
|
||||
} else {
|
||||
let sortedList
|
||||
switch (type) {
|
||||
case 'duration':
|
||||
sortedList = durationSort(list, ascending)
|
||||
break
|
||||
case 'result':
|
||||
sortedList = genericSort(list, type, ascending, initialOrder)
|
||||
break
|
||||
default:
|
||||
sortedList = genericSort(list, type, ascending)
|
||||
break
|
||||
}
|
||||
manager.setRender(sortedList)
|
||||
}
|
||||
}
|
||||
|
||||
const doSort = (type, skipDirection) => {
|
||||
const newSortType = storageModule.getSort(manager.initialSort) !== type
|
||||
const currentAsc = storageModule.getSortDirection()
|
||||
let ascending
|
||||
if (skipDirection) {
|
||||
ascending = currentAsc
|
||||
} else {
|
||||
ascending = newSortType ? false : !currentAsc
|
||||
}
|
||||
storageModule.setSort(type)
|
||||
storageModule.setSortDirection(ascending)
|
||||
|
||||
const list = manager.testSubset
|
||||
const sortedList = type === 'duration' ? durationSort(list, ascending) : genericSort(list, type, ascending)
|
||||
manager.setRender(sortedList)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
doInitSort,
|
||||
doSort,
|
||||
}
|
||||
|
||||
},{"./datamanager.js":1,"./storage.js":8}],8:[function(require,module,exports){
|
||||
const possibleFilters = [
|
||||
'passed',
|
||||
'skipped',
|
||||
'failed',
|
||||
'error',
|
||||
'xfailed',
|
||||
'xpassed',
|
||||
'rerun',
|
||||
]
|
||||
|
||||
const getVisible = () => {
|
||||
const url = new URL(window.location.href)
|
||||
const settings = new URLSearchParams(url.search).get('visible')
|
||||
const lower = (item) => {
|
||||
const lowerItem = item.toLowerCase()
|
||||
if (possibleFilters.includes(lowerItem)) {
|
||||
return lowerItem
|
||||
}
|
||||
return null
|
||||
}
|
||||
return settings === null ?
|
||||
possibleFilters :
|
||||
[...new Set(settings?.split(',').map(lower).filter((item) => item))]
|
||||
}
|
||||
|
||||
const hideCategory = (categoryToHide) => {
|
||||
const url = new URL(window.location.href)
|
||||
const visibleParams = new URLSearchParams(url.search).get('visible')
|
||||
const currentVisible = visibleParams ? visibleParams.split(',') : [...possibleFilters]
|
||||
const settings = [...new Set(currentVisible)].filter((f) => f !== categoryToHide).join(',')
|
||||
|
||||
url.searchParams.set('visible', settings)
|
||||
window.history.pushState({}, null, unescape(url.href))
|
||||
}
|
||||
|
||||
const showCategory = (categoryToShow) => {
|
||||
if (typeof window === 'undefined') {
|
||||
return
|
||||
}
|
||||
const url = new URL(window.location.href)
|
||||
const currentVisible = new URLSearchParams(url.search).get('visible')?.split(',').filter(Boolean) ||
|
||||
[...possibleFilters]
|
||||
const settings = [...new Set([categoryToShow, ...currentVisible])]
|
||||
const noFilter = possibleFilters.length === settings.length || !settings.length
|
||||
|
||||
noFilter ? url.searchParams.delete('visible') : url.searchParams.set('visible', settings.join(','))
|
||||
window.history.pushState({}, null, unescape(url.href))
|
||||
}
|
||||
|
||||
const getSort = (initialSort) => {
|
||||
const url = new URL(window.location.href)
|
||||
let sort = new URLSearchParams(url.search).get('sort')
|
||||
if (!sort) {
|
||||
sort = initialSort || 'result'
|
||||
}
|
||||
return sort
|
||||
}
|
||||
|
||||
const setSort = (type) => {
|
||||
const url = new URL(window.location.href)
|
||||
url.searchParams.set('sort', type)
|
||||
window.history.pushState({}, null, unescape(url.href))
|
||||
}
|
||||
|
||||
const getCollapsedCategory = (renderCollapsed) => {
|
||||
let categories
|
||||
if (typeof window !== 'undefined') {
|
||||
const url = new URL(window.location.href)
|
||||
const collapsedItems = new URLSearchParams(url.search).get('collapsed')
|
||||
switch (true) {
|
||||
case !renderCollapsed && collapsedItems === null:
|
||||
categories = ['passed']
|
||||
break
|
||||
case collapsedItems?.length === 0 || /^["']{2}$/.test(collapsedItems):
|
||||
categories = []
|
||||
break
|
||||
case /^all$/.test(collapsedItems) || collapsedItems === null && /^all$/.test(renderCollapsed):
|
||||
categories = [...possibleFilters]
|
||||
break
|
||||
default:
|
||||
categories = collapsedItems?.split(',').map((item) => item.toLowerCase()) || renderCollapsed
|
||||
break
|
||||
}
|
||||
} else {
|
||||
categories = []
|
||||
}
|
||||
return categories
|
||||
}
|
||||
|
||||
const getSortDirection = () => JSON.parse(sessionStorage.getItem('sortAsc')) || false
|
||||
const setSortDirection = (ascending) => sessionStorage.setItem('sortAsc', ascending)
|
||||
|
||||
const getCollapsedIds = () => JSON.parse(sessionStorage.getItem('collapsedIds')) || []
|
||||
const setCollapsedIds = (list) => sessionStorage.setItem('collapsedIds', JSON.stringify(list))
|
||||
|
||||
module.exports = {
|
||||
getVisible,
|
||||
hideCategory,
|
||||
showCategory,
|
||||
getCollapsedIds,
|
||||
setCollapsedIds,
|
||||
getSort,
|
||||
setSort,
|
||||
getSortDirection,
|
||||
setSortDirection,
|
||||
getCollapsedCategory,
|
||||
possibleFilters,
|
||||
}
|
||||
|
||||
},{}]},{},[4]);
|
||||
</script>
|
||||
</footer>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue