Skip to content

Commit 87a5b0c

Browse files
authored
Merge branch 'release/1.11.0' into add-chart-for-report
2 parents 77b71c8 + fa67f30 commit 87a5b0c

File tree

2 files changed

+76
-12
lines changed

2 files changed

+76
-12
lines changed

CHANGELOG.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99
### Added
10-
- Based on [Add `only` as an annotation for the `describe/test`](https://github.com/scripterio-js/scripterio/issues/14):
11-
- Retry functionality for tests:
12-
- `describe.only()` Declares an exclusive `describe` that will be executed. If used, all other describes are skipped.
13-
- `test.only()` Declares an exclusive `test` that will be executed. If used, all other tests are skipped.
14-
- Based on [Add `todo` as an annotation for the `describe/test`](https://github.com/scripterio-js/scripterio/issues/46)
15-
- The test(s) is/are marked as pending and will not be executed. Helpful for planning and organizing future tests.
16-
- `describe.todo()` Declares a test group as "to-do."
17-
- `test.todo()` Declares a test as "to-do."
18-
- Added test time execution to the `HTML` report:
19-
- Based on [Review&Add additional `unit-tests`](https://github.com/scripterio-js/scripterio/issues/58)
10+
- Based on [Add `only` as an annotation for `describe`/`test`](https://github.com/scripterio-js/scripterio/issues/14):
11+
- Exclusive execution for tests:
12+
- `describe.only()` — Runs only this `describe` block; all others are skipped.
13+
- `test.only()` — Runs only this test; all others are skipped.
14+
- Based on [Add `todo` as an annotation for `describe`/`test`](https://github.com/scripterio-js/scripterio/issues/46):
15+
- Mark tests as pending to help plan and organize future work. Pending tests are not executed.
16+
- `describe.todo()` — Marks a test group as "to-do."
17+
- `test.todo()` — Marks a test as "to-do."
18+
- Added test execution time to the HTML report.
19+
- Added a filter to the HTML report for quick navigation.
20+
- Based on [Review & Add additional unit tests](https://github.com/scripterio-js/scripterio/issues/58):
2021
- Added unit tests for:
21-
-`config.mjs`
22-
-`setup.mjs`
22+
- `config.mjs`
23+
- `setup.mjs`
2324

2425
- Contributors:
2526
- [Vadym Nastoiashchyi](https://github.com/VadimNastoyashchy)

src/reporters/html-template.mjs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,70 @@ export const template = ({
246246
details.classList.toggle('show');
247247
element.textContent = isShowing ? 'Show API details' : 'Hide API details';
248248
}
249+
250+
function setFilter(filter) {
251+
document.querySelectorAll('.stat').forEach(stat => {
252+
stat.classList.remove('active-filter');
253+
});
254+
if (filter) {
255+
document.querySelector('.stat.' + filter).classList.add('active-filter');
256+
} else {
257+
document.querySelector('.stat.total').classList.add('active-filter');
258+
}
259+
260+
document.querySelectorAll('.test-case').forEach(tc => {
261+
const nameDiv = tc.querySelector('.test-name');
262+
if (!filter || nameDiv.classList.contains(filter)) {
263+
tc.style.display = '';
264+
} else {
265+
tc.style.display = 'none';
266+
}
267+
});
268+
269+
function updateDescribeVisibility(describe) {
270+
let hasVisible = false;
271+
const content = describe.querySelector(':scope > .describe-content');
272+
if (content) {
273+
content.childNodes.forEach(child => {
274+
if (child.nodeType !== 1) return; // skip non-elements
275+
if (child.classList.contains('describe-group')) {
276+
if (updateDescribeVisibility(child)) {
277+
child.style.display = '';
278+
hasVisible = true;
279+
} else {
280+
child.style.display = 'none';
281+
}
282+
} else if (child.classList.contains('test-case')) {
283+
if (child.style.display !== 'none') {
284+
hasVisible = true;
285+
}
286+
}
287+
});
288+
}
289+
describe.style.display = hasVisible ? '' : 'none';
290+
return hasVisible;
291+
}
292+
document.querySelectorAll('.describe-group').forEach(group => {
293+
updateDescribeVisibility(group);
294+
});
295+
}
296+
297+
document.addEventListener('DOMContentLoaded', () => {
298+
document.querySelector('.stat.total').addEventListener('click', () => setFilter(null));
299+
document.querySelector('.stat.passed').addEventListener('click', () => setFilter('passed'));
300+
document.querySelector('.stat.failed').addEventListener('click', () => setFilter('failed'));
301+
document.querySelector('.stat.todo').addEventListener('click', () => setFilter('todo'));
302+
document.querySelector('.stat.total').classList.add('active-filter');
303+
});
249304
</script>
305+
<style>
306+
.stat.active-filter {
307+
outline: 2px solid #1976d2;
308+
box-shadow: 0 0 0 2px #1976d233;
309+
cursor: pointer;
310+
}
311+
.stat { cursor: pointer; }
312+
</style>
250313
</body>
251314
</html>
252315
`

0 commit comments

Comments
 (0)