Feature: Add initial sort column as ini (#692)
This commit is contained in:
parent
ae54ee6277
commit
27208bba3b
|
@ -51,8 +51,8 @@ def pytest_addoption(parser):
|
||||||
parser.addini(
|
parser.addini(
|
||||||
"render_collapsed",
|
"render_collapsed",
|
||||||
type="string",
|
type="string",
|
||||||
default="",
|
default="passed",
|
||||||
help="Open the report with all rows collapsed. Useful for very large reports",
|
help="row(s) to render collapsed on open.",
|
||||||
)
|
)
|
||||||
parser.addini(
|
parser.addini(
|
||||||
"max_asset_filename_length",
|
"max_asset_filename_length",
|
||||||
|
@ -63,9 +63,15 @@ def pytest_addoption(parser):
|
||||||
parser.addini(
|
parser.addini(
|
||||||
"environment_table_redact_list",
|
"environment_table_redact_list",
|
||||||
type="linelist",
|
type="linelist",
|
||||||
help="A list of regexes corresponding to environment "
|
help="a list of regexes corresponding to environment "
|
||||||
"table variables whose values should be redacted from the report",
|
"table variables whose values should be redacted from the report",
|
||||||
)
|
)
|
||||||
|
parser.addini(
|
||||||
|
"initial_sort",
|
||||||
|
type="string",
|
||||||
|
default="result",
|
||||||
|
help="column to initially sort on.",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
|
|
|
@ -33,17 +33,21 @@ class ReportData:
|
||||||
}
|
}
|
||||||
|
|
||||||
collapsed = config.getini("render_collapsed")
|
collapsed = config.getini("render_collapsed")
|
||||||
if collapsed:
|
if collapsed.lower() == "true":
|
||||||
if collapsed.lower() == "true":
|
warnings.warn(
|
||||||
warnings.warn(
|
"'render_collapsed = True' is deprecated and support "
|
||||||
"'render_collapsed = True' is deprecated and support "
|
"will be removed in the next major release. "
|
||||||
"will be removed in the next major release. "
|
"Please use 'render_collapsed = all' instead.",
|
||||||
"Please use 'render_collapsed = all' instead.",
|
DeprecationWarning,
|
||||||
DeprecationWarning,
|
|
||||||
)
|
|
||||||
self.set_data(
|
|
||||||
"renderCollapsed", [outcome.lower() for outcome in collapsed.split(",")]
|
|
||||||
)
|
)
|
||||||
|
collapsed = "all"
|
||||||
|
|
||||||
|
self.set_data(
|
||||||
|
"renderCollapsed", [outcome.lower() for outcome in collapsed.split(",")]
|
||||||
|
)
|
||||||
|
|
||||||
|
initial_sort = config.getini("initial_sort")
|
||||||
|
self.set_data("initialSort", initial_sort)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def title(self):
|
def title(self):
|
||||||
|
|
|
@ -40,9 +40,9 @@ const dom = {
|
||||||
|
|
||||||
return envRow
|
return envRow
|
||||||
},
|
},
|
||||||
getListHeader: ({ resultsTableHeader }) => {
|
getListHeader: ({ initialSort, resultsTableHeader }) => {
|
||||||
const header = listHeader.content.cloneNode(true)
|
const header = listHeader.content.cloneNode(true)
|
||||||
const sortAttr = storageModule.getSort()
|
const sortAttr = storageModule.getSort(initialSort)
|
||||||
const sortAsc = JSON.parse(storageModule.getSortDirection())
|
const sortAsc = JSON.parse(storageModule.getSortDirection())
|
||||||
|
|
||||||
resultsTableHeader.forEach((html) => {
|
resultsTableHeader.forEach((html) => {
|
||||||
|
|
|
@ -43,7 +43,7 @@ const durationSort = (list, ascending) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const doInitSort = () => {
|
const doInitSort = () => {
|
||||||
const type = storageModule.getSort()
|
const type = storageModule.getSort(manager.allData.initialSort)
|
||||||
const ascending = storageModule.getSortDirection()
|
const ascending = storageModule.getSortDirection()
|
||||||
const list = manager.testSubset
|
const list = manager.testSubset
|
||||||
const initialOrder = ['Error', 'Failed', 'Rerun', 'XFailed', 'XPassed', 'Skipped', 'Passed']
|
const initialOrder = ['Error', 'Failed', 'Rerun', 'XFailed', 'XPassed', 'Skipped', 'Passed']
|
||||||
|
@ -67,7 +67,7 @@ const doInitSort = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const doSort = (type) => {
|
const doSort = (type) => {
|
||||||
const newSortType = storageModule.getSort() !== type
|
const newSortType = storageModule.getSort(manager.allData.initialSort) !== type
|
||||||
const currentAsc = storageModule.getSortDirection()
|
const currentAsc = storageModule.getSortDirection()
|
||||||
const ascending = newSortType ? true : !currentAsc
|
const ascending = newSortType ? true : !currentAsc
|
||||||
storageModule.setSort(type)
|
storageModule.setSort(type)
|
||||||
|
|
|
@ -48,9 +48,13 @@ const setFilter = (currentFilter) => {
|
||||||
history.pushState({}, null, unescape(url.href))
|
history.pushState({}, null, unescape(url.href))
|
||||||
}
|
}
|
||||||
|
|
||||||
const getSort = () => {
|
const getSort = (initialSort) => {
|
||||||
const url = new URL(window.location.href)
|
const url = new URL(window.location.href)
|
||||||
return new URLSearchParams(url.search).get('sort') || 'result'
|
let sort = new URLSearchParams(url.search).get('sort')
|
||||||
|
if (!sort) {
|
||||||
|
sort = initialSort || 'result'
|
||||||
|
}
|
||||||
|
return sort
|
||||||
}
|
}
|
||||||
const setSort = (type) => {
|
const setSort = (type) => {
|
||||||
const url = new URL(window.location.href)
|
const url = new URL(window.location.href)
|
||||||
|
|
Loading…
Reference in New Issue