-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-dropdown.svelte
110 lines (95 loc) · 2.88 KB
/
test-dropdown.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<script>
import TestDropdown from "./test-dropdown.svelte";
import ResultBall from "./result-ball.svelte";
export let selected = null;
export let test;
export let level = 0;
export let show = null;
$: name = test.name ?? "Test Run";
$: childSuites = Array.from(test._children).filter((c) =>
["test-run", "test-suite"].includes(c._name)
);
$: childTests = Array.from(test._children).filter(
(c) => c._name == "test-case"
);
function select(element) {
selected = element;
}
function shouldShow(show, test) {
if (!show) return true;
return show.filter(s => test.allResults.includes(s)).length > 0;
}
</script>
<details class="root level{Math.min(Number(level), 9)}" open>
<summary class:selected={test === selected}>
<ResultBall result={test.result} />
<a href="#" on:click={select(test)}>{name}</a>
</summary>
<div>
{#each childSuites as t}
{#if shouldShow(show, t) }
<TestDropdown test={t} level="{Number(level) + 1}" bind:selected show="{show}" />
{/if}
{/each}
</div>
{#each childTests as t}
{#if !show || show.includes(t.result) }
<div
class="testCase"
class:selected={t === selected}
on:click={select(t)}>
<ResultBall result={t.result} />
{t.name}
</div>
{/if}
{/each}
</details>
<style>
details {
padding: 0;
margin: 0;
border-radius: 0;
border-top: none;
border-right: none;
border-bottom: none;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
user-select: none;
}
details > summary {
margin: 0;
}
a {
display: inline-block;
width: 100%;
color: var(--nc-tx-1);
text-decoration: none;
font-weight: lighter;
padding: 0.1rem;
}
div.testCase {
cursor: pointer;
}
.selected {
background-color: #8fc7ff;
}
.level1 summary { padding-left: 15px }
.level2 summary { padding-left: 30px }
.level3 summary { padding-left: 45px }
.level4 summary { padding-left: 60px }
.level5 summary { padding-left: 75px }
.level6 summary { padding-left: 90px }
.level7 summary { padding-left: 105px }
.level8 summary { padding-left: 120px }
.level9 summary { padding-left: 135px }
.level1 .testCase { padding-left: 30px }
.level2 .testCase { padding-left: 45px }
.level3 .testCase { padding-left: 60px }
.level4 .testCase { padding-left: 75px }
.level5 .testCase { padding-left: 90px }
.level6 .testCase { padding-left: 105px }
.level7 .testCase { padding-left: 120px }
.level8 .testCase { padding-left: 135px }
.level9 .testCase { padding-left: 150px }
</style>