@allurereport/web-classic 3.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/.babelrc--old.cjs +18 -0
  2. package/.babelrc.js +46 -0
  3. package/.eslintrc--old.cjs +125 -0
  4. package/.eslintrc.cjs +22 -0
  5. package/README.md +27 -0
  6. package/dist/multi/10.app-970f027d.js +1 -0
  7. package/dist/multi/222.app-970f027d.js +1 -0
  8. package/dist/multi/26.app-970f027d.js +1 -0
  9. package/dist/multi/302.app-970f027d.js +1 -0
  10. package/dist/multi/304.app-970f027d.js +1 -0
  11. package/dist/multi/369.app-970f027d.js +1 -0
  12. package/dist/multi/389.app-970f027d.js +1 -0
  13. package/dist/multi/498.app-970f027d.js +1 -0
  14. package/dist/multi/60.app-970f027d.js +1 -0
  15. package/dist/multi/643.app-970f027d.js +1 -0
  16. package/dist/multi/671.app-970f027d.js +1 -0
  17. package/dist/multi/725.app-970f027d.js +1 -0
  18. package/dist/multi/770.app-970f027d.js +1 -0
  19. package/dist/multi/848.app-970f027d.js +1 -0
  20. package/dist/multi/853.app-970f027d.js +1 -0
  21. package/dist/multi/872.app-970f027d.js +1 -0
  22. package/dist/multi/895.app-970f027d.js +1 -0
  23. package/dist/multi/920.app-970f027d.js +1 -0
  24. package/dist/multi/979.app-970f027d.js +1 -0
  25. package/dist/multi/991.app-970f027d.js +1 -0
  26. package/dist/multi/JetBrainsMono_vf-9e9649b6..woff2 +0 -0
  27. package/dist/multi/JetBrainsMono_vf-b9a9c326..woff +0 -0
  28. package/dist/multi/app-970f027d.js +2 -0
  29. package/dist/multi/app-970f027d.js.LICENSE.txt +25 -0
  30. package/dist/multi/manifest.json +28 -0
  31. package/dist/multi/pt-root-ui_vf-22fe60ca..woff +0 -0
  32. package/dist/multi/pt-root-ui_vf-9d251e8b..woff2 +0 -0
  33. package/dist/multi/styles-970f027d.css +283 -0
  34. package/dist/single/app-2babff54.js +2 -0
  35. package/dist/single/app-2babff54.js.LICENSE.txt +25 -0
  36. package/dist/single/manifest.json +3 -0
  37. package/package--old.json +106 -0
  38. package/package.json +107 -0
  39. package/postcss.config.js +5 -0
  40. package/src/assets/scss/_common.scss +142 -0
  41. package/src/assets/scss/code.scss +71 -0
  42. package/src/assets/scss/day.scss +51 -0
  43. package/src/assets/scss/fonts.scss +3 -0
  44. package/src/assets/scss/index.scss +9 -0
  45. package/src/assets/scss/night.scss +61 -0
  46. package/src/assets/scss/palette.scss +393 -0
  47. package/src/assets/scss/theme.scss +117 -0
  48. package/src/assets/scss/typography.scss +218 -0
  49. package/src/assets/scss/vars.scss +8 -0
  50. package/src/components/ArrowButton/index.tsx +36 -0
  51. package/src/components/ArrowButton/styles.scss +35 -0
  52. package/src/components/BaseLayout/index.tsx +23 -0
  53. package/src/components/BaseLayout/styles.scss +63 -0
  54. package/src/components/Behaviors/BehaviorsList.tsx +67 -0
  55. package/src/components/Behaviors/index.tsx +60 -0
  56. package/src/components/Behaviors/styles.scss +196 -0
  57. package/src/components/Categories/CategoriesList.tsx +67 -0
  58. package/src/components/Categories/index.tsx +60 -0
  59. package/src/components/Categories/styles.scss +196 -0
  60. package/src/components/Footer/FooterLogo.tsx +16 -0
  61. package/src/components/Footer/FooterVersion.tsx +33 -0
  62. package/src/components/Footer/index.tsx +13 -0
  63. package/src/components/Footer/styles.scss +14 -0
  64. package/src/components/Graphs/index.tsx +2 -0
  65. package/src/components/Header/index.tsx +14 -0
  66. package/src/components/Header/styles.scss +26 -0
  67. package/src/components/HeaderActions/Filters.tsx +90 -0
  68. package/src/components/HeaderActions/HeaderActions.tsx +59 -0
  69. package/src/components/HeaderActions/SortBy.tsx +128 -0
  70. package/src/components/HeaderActions/styles.scss +82 -0
  71. package/src/components/LanguagePicker/index.tsx +41 -0
  72. package/src/components/LanguagePicker/styles.scss +3 -0
  73. package/src/components/MainReport/index.tsx +19 -0
  74. package/src/components/Metadata/index.tsx +121 -0
  75. package/src/components/Metadata/styles.scss +146 -0
  76. package/src/components/MetadataButton/index.tsx +32 -0
  77. package/src/components/MetadataButton/styles.scss +53 -0
  78. package/src/components/Modal/ModalView.hbs +13 -0
  79. package/src/components/Modal/ModalView.js +43 -0
  80. package/src/components/Modal/index.tsx +174 -0
  81. package/src/components/Modal/styles.scss +126 -0
  82. package/src/components/Overview/index.tsx +9 -0
  83. package/src/components/Packages/PackagesList.tsx +67 -0
  84. package/src/components/Packages/index.tsx +59 -0
  85. package/src/components/Packages/styles.scss +196 -0
  86. package/src/components/ReportBody/Filters.tsx +92 -0
  87. package/src/components/ReportBody/HeaderActions.tsx +21 -0
  88. package/src/components/ReportBody/SortBy.tsx +132 -0
  89. package/src/components/ReportBody/context.tsx +106 -0
  90. package/src/components/ReportBody/index.tsx +71 -0
  91. package/src/components/ReportBody/styles.scss +64 -0
  92. package/src/components/ReportHeader/ReportHeaderLabelList.tsx +12 -0
  93. package/src/components/ReportHeader/ReportHeaderLogo.tsx +10 -0
  94. package/src/components/ReportHeader/ReportHeaderPie.tsx +14 -0
  95. package/src/components/ReportHeader/index.tsx +33 -0
  96. package/src/components/ReportHeader/styles.scss +49 -0
  97. package/src/components/ReportLogo/index.tsx +16 -0
  98. package/src/components/ReportLogo/styles.scss +20 -0
  99. package/src/components/ReportLogoFull/index.tsx +20 -0
  100. package/src/components/ReportLogoFull/styles.scss +7 -0
  101. package/src/components/ReportMetadata/MetadataItem.tsx +45 -0
  102. package/src/components/ReportMetadata/MetadataSummary.tsx +81 -0
  103. package/src/components/ReportMetadata/MetadataTestType.tsx +16 -0
  104. package/src/components/ReportMetadata/MetadataWithIcon.tsx +21 -0
  105. package/src/components/ReportMetadata/index.tsx +46 -0
  106. package/src/components/ReportMetadata/styles.scss +99 -0
  107. package/src/components/SideBySide/index.tsx +54 -0
  108. package/src/components/SideBySide/styles.scss +59 -0
  109. package/src/components/SideNav/SideNav.tsx +78 -0
  110. package/src/components/SideNav/SideNavView.hbs +39 -0
  111. package/src/components/SideNav/SideNavView.js +81 -0
  112. package/src/components/SideNav/styles.scss +126 -0
  113. package/src/components/Suites/index.tsx +62 -0
  114. package/src/components/Suites/styles.scss +10 -0
  115. package/src/components/Tabs/index.tsx +33 -0
  116. package/src/components/Tabs/styles.scss +56 -0
  117. package/src/components/TestResult/TestResultAttachmentsView/index.tsx +27 -0
  118. package/src/components/TestResult/TestResultAttachmentsView/styles.scss +12 -0
  119. package/src/components/TestResult/TestResultDescription/index.tsx +27 -0
  120. package/src/components/TestResult/TestResultDescription/styles.scss +12 -0
  121. package/src/components/TestResult/TestResultDropdown/index.tsx +23 -0
  122. package/src/components/TestResult/TestResultDropdown/styles.scss +34 -0
  123. package/src/components/TestResult/TestResultEmpty/index.tsx +33 -0
  124. package/src/components/TestResult/TestResultEmpty/styles.scss +25 -0
  125. package/src/components/TestResult/TestResultError/index.tsx +48 -0
  126. package/src/components/TestResult/TestResultError/styles.scss +51 -0
  127. package/src/components/TestResult/TestResultHeader/index.tsx +53 -0
  128. package/src/components/TestResult/TestResultHeader/styles.scss +43 -0
  129. package/src/components/TestResult/TestResultHistory/TestResultHistoryItem.tsx +67 -0
  130. package/src/components/TestResult/TestResultHistory/index.tsx +26 -0
  131. package/src/components/TestResult/TestResultHistory/styles.scss +63 -0
  132. package/src/components/TestResult/TestResultInfo/TestResultInfoStatuses.tsx +30 -0
  133. package/src/components/TestResult/TestResultInfo/index.tsx +79 -0
  134. package/src/components/TestResult/TestResultInfo/styles.scss +50 -0
  135. package/src/components/TestResult/TestResultLinks/index.tsx +56 -0
  136. package/src/components/TestResult/TestResultLinks/styles.scss +30 -0
  137. package/src/components/TestResult/TestResultMetadata/index.tsx +27 -0
  138. package/src/components/TestResult/TestResultMetadata/styles.scss +8 -0
  139. package/src/components/TestResult/TestResultNavigation/index.tsx +80 -0
  140. package/src/components/TestResult/TestResultNavigation/styles.scss +48 -0
  141. package/src/components/TestResult/TestResultOverview.tsx +40 -0
  142. package/src/components/TestResult/TestResultParameters/index.tsx +30 -0
  143. package/src/components/TestResult/TestResultParameters/styles.scss +8 -0
  144. package/src/components/TestResult/TestResultPrevStatuses/index.tsx +49 -0
  145. package/src/components/TestResult/TestResultPrevStatuses/styles.scss +57 -0
  146. package/src/components/TestResult/TestResultRetriesView/TestResultRetriesItem.tsx +49 -0
  147. package/src/components/TestResult/TestResultRetriesView/index.tsx +20 -0
  148. package/src/components/TestResult/TestResultRetriesView/styles.scss +69 -0
  149. package/src/components/TestResult/TestResultSetup/index.tsx +49 -0
  150. package/src/components/TestResult/TestResultSeverity/index.tsx +27 -0
  151. package/src/components/TestResult/TestResultSeverity/styles.scss +29 -0
  152. package/src/components/TestResult/TestResultStatus/index.tsx +26 -0
  153. package/src/components/TestResult/TestResultStatus/styles.scss +36 -0
  154. package/src/components/TestResult/TestResultSteps/HtmlAttachmentPreview.tsx +12 -0
  155. package/src/components/TestResult/TestResultSteps/attachment.tsx +68 -0
  156. package/src/components/TestResult/TestResultSteps/attachmentCode.tsx +20 -0
  157. package/src/components/TestResult/TestResultSteps/attachmentImage.tsx +32 -0
  158. package/src/components/TestResult/TestResultSteps/attachmentVideo.tsx +15 -0
  159. package/src/components/TestResult/TestResultSteps/index.tsx +49 -0
  160. package/src/components/TestResult/TestResultSteps/styles.scss +225 -0
  161. package/src/components/TestResult/TestResultSteps/testResultAttachment.tsx +77 -0
  162. package/src/components/TestResult/TestResultSteps/testResultAttachmentInfo.tsx +83 -0
  163. package/src/components/TestResult/TestResultSteps/testResultStep.tsx +78 -0
  164. package/src/components/TestResult/TestResultSteps/testResultStepInfo.tsx +30 -0
  165. package/src/components/TestResult/TestResultSteps/wrongAttachment.tsx +8 -0
  166. package/src/components/TestResult/TestResultTabs/index.tsx +59 -0
  167. package/src/components/TestResult/TestResultTabs/styles.scss +76 -0
  168. package/src/components/TestResult/TestResultTeardown/index.tsx +49 -0
  169. package/src/components/TestResult/TestResultView.hbs +32 -0
  170. package/src/components/TestResult/TestResultView.js +90 -0
  171. package/src/components/TestResult/index.tsx +54 -0
  172. package/src/components/TestResult/styles.scss +29 -0
  173. package/src/components/TestResultView/index.tsx +31 -0
  174. package/src/components/ThemeButton/ThemeButton.tsx +20 -0
  175. package/src/components/Timeline/index.tsx +2 -0
  176. package/src/components/Tree/Tree.tsx +76 -0
  177. package/src/components/Tree/TreeHeader.tsx +82 -0
  178. package/src/components/Tree/TreeItem.tsx +49 -0
  179. package/src/components/Tree/TreeItemIcon.tsx +32 -0
  180. package/src/components/Tree/index.tsx +60 -0
  181. package/src/components/Tree/styles.scss +185 -0
  182. package/src/favicon.ico +0 -0
  183. package/src/index.html +40 -0
  184. package/src/index.js +52 -0
  185. package/src/index.tsx +60 -0
  186. package/src/mixins.scss +128 -0
  187. package/src/rtl.scss +19 -0
  188. package/src/stores/behaviors.ts +127 -0
  189. package/src/stores/categories.ts +127 -0
  190. package/src/stores/chart.ts +32 -0
  191. package/src/stores/envInfo.ts +34 -0
  192. package/src/stores/index.ts +4 -0
  193. package/src/stores/locale.ts +83 -0
  194. package/src/stores/packages.ts +127 -0
  195. package/src/stores/router.ts +55 -0
  196. package/src/stores/stats.ts +36 -0
  197. package/src/stores/tabs.ts +7 -0
  198. package/src/stores/testResults.ts +66 -0
  199. package/src/stores/theme.ts +33 -0
  200. package/src/stores/tree.ts +127 -0
  201. package/src/stores/types.ts +5 -0
  202. package/src/styles.scss +91 -0
  203. package/src/translations/am.json +127 -0
  204. package/src/translations/az.json +127 -0
  205. package/src/translations/br.json +214 -0
  206. package/src/translations/constants.ts +124 -0
  207. package/src/translations/de.json +127 -0
  208. package/src/translations/en.json +128 -0
  209. package/src/translations/es.json +118 -0
  210. package/src/translations/fr.json +118 -0
  211. package/src/translations/he.json +118 -0
  212. package/src/translations/isv.json +216 -0
  213. package/src/translations/it.json +118 -0
  214. package/src/translations/ja.json +118 -0
  215. package/src/translations/ka.json +118 -0
  216. package/src/translations/kr.json +118 -0
  217. package/src/translations/nl.json +118 -0
  218. package/src/translations/pl.json +116 -0
  219. package/src/translations/pt.json +118 -0
  220. package/src/translations/ru.json +116 -0
  221. package/src/translations/sv.json +118 -0
  222. package/src/translations/tr.json +118 -0
  223. package/src/translations/zh.json +118 -0
  224. package/src/types/globals.d.ts +13 -0
  225. package/src/types/window.d.ts +8 -0
  226. package/src/utils/attachments.ts +156 -0
  227. package/src/utils/capitalize.ts +6 -0
  228. package/src/utils/copyToClipboard.ts +16 -0
  229. package/src/utils/isMac.ts +8 -0
  230. package/src/utils/navigate.ts +7 -0
  231. package/src/utils/statuses.js +1 -0
  232. package/src/utils/statuses.ts +55 -0
  233. package/src/utils/time.ts +17 -0
  234. package/src/utils/treeFilters.ts +139 -0
  235. package/src/variables.scss +71 -0
  236. package/test/utils/treeFilters.test.ts +448 -0
  237. package/tsconfig.json +25 -0
  238. package/types.d.ts +85 -0
  239. package/vitest.config.ts +18 -0
  240. package/webpack.config--old.js +127 -0
  241. package/webpack.config.js +108 -0
@@ -0,0 +1,448 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { createRecursiveTree, filterLeaves } from "../../src/utils/treeFilters.js";
3
+ import type { AwesomeTestResult } from "../../types.js";
4
+
5
+ describe("utils > treeFilters", () => {
6
+ describe("filterLeaves", () => {
7
+ it("returns the leaves as is when no filter options are provided", () => {
8
+ const baseDate = Date.now();
9
+ const leaves = ["a1", "b2", "c3"];
10
+ const leavesById = {
11
+ a1: {
12
+ name: "a1",
13
+ start: baseDate,
14
+ } as AwesomeTestResult,
15
+ b2: {
16
+ name: "b2",
17
+ start: baseDate + 1000,
18
+ } as AwesomeTestResult,
19
+ c3: {
20
+ name: "c3",
21
+ start: baseDate + 2000,
22
+ } as AwesomeTestResult,
23
+ };
24
+ const result = filterLeaves(leaves, leavesById, {
25
+ query: "",
26
+ status: "total",
27
+ filter: {
28
+ flaky: false,
29
+ retry: false,
30
+ new: false,
31
+ },
32
+ sortBy: "order",
33
+ direction: "asc",
34
+ });
35
+
36
+ expect(result).toEqual([
37
+ expect.objectContaining({ name: "a1" }),
38
+ expect.objectContaining({ name: "b2" }),
39
+ expect.objectContaining({ name: "c3" }),
40
+ ]);
41
+ });
42
+
43
+ it("returns the leaves only matched the status filter", () => {
44
+ const baseDate = Date.now();
45
+ const leaves = ["a1", "b2", "c3"];
46
+ const leavesById = {
47
+ a1: {
48
+ name: "a1",
49
+ status: "passed",
50
+ start: baseDate,
51
+ } as AwesomeTestResult,
52
+ b2: {
53
+ name: "b2",
54
+ status: "failed",
55
+ start: baseDate + 1000,
56
+ } as AwesomeTestResult,
57
+ c3: {
58
+ name: "c3",
59
+ status: "passed",
60
+ start: baseDate + 2000,
61
+ } as AwesomeTestResult,
62
+ };
63
+ const result = filterLeaves(leaves, leavesById, {
64
+ query: "",
65
+ status: "passed",
66
+ filter: {
67
+ flaky: false,
68
+ retry: false,
69
+ new: false,
70
+ },
71
+ sortBy: "order",
72
+ direction: "asc",
73
+ });
74
+
75
+ expect(result).toEqual([expect.objectContaining({ name: "a1" }), expect.objectContaining({ name: "c3" })]);
76
+ });
77
+
78
+ it("returns the flaky leaves", () => {
79
+ const baseDate = Date.now();
80
+ const leaves = ["a1", "b2", "c3"];
81
+ const leavesById = {
82
+ a1: {
83
+ name: "a1",
84
+ start: baseDate,
85
+ flaky: true,
86
+ } as AwesomeTestResult,
87
+ b2: {
88
+ name: "b2",
89
+ start: baseDate + 1000,
90
+ flaky: false,
91
+ } as AwesomeTestResult,
92
+ c3: {
93
+ name: "c3",
94
+ start: baseDate + 2000,
95
+ flaky: true,
96
+ } as AwesomeTestResult,
97
+ };
98
+ const result = filterLeaves(leaves, leavesById, {
99
+ query: "",
100
+ status: "total",
101
+ filter: {
102
+ flaky: true,
103
+ retry: false,
104
+ new: false,
105
+ },
106
+ sortBy: "order",
107
+ direction: "asc",
108
+ });
109
+
110
+ expect(result).toEqual([expect.objectContaining({ name: "a1" }), expect.objectContaining({ name: "c3" })]);
111
+ });
112
+
113
+ it("returns leaves which contains retries", () => {
114
+ const baseDate = Date.now();
115
+ const leaves = ["a1", "b2", "c3"];
116
+ const leavesById = {
117
+ a1: {
118
+ name: "a1",
119
+ start: baseDate,
120
+ retry: true,
121
+ } as AwesomeTestResult,
122
+ b2: {
123
+ name: "b2",
124
+ start: baseDate + 1000,
125
+ retry: false,
126
+ } as AwesomeTestResult,
127
+ c3: {
128
+ name: "c3",
129
+ start: baseDate + 2000,
130
+ retry: false,
131
+ } as AwesomeTestResult,
132
+ };
133
+ const result = filterLeaves(leaves, leavesById, {
134
+ filter: {
135
+ retry: true,
136
+ },
137
+ });
138
+
139
+ expect(result).toEqual([expect.objectContaining({ name: "a1" })]);
140
+ });
141
+
142
+ it("sorts leave by duration in ascending order", () => {
143
+ const leaves = ["a1", "b2", "c3"];
144
+ const leavesById = {
145
+ a1: {
146
+ name: "a1",
147
+ duration: 1000,
148
+ } as AwesomeTestResult,
149
+ b2: {
150
+ name: "b2",
151
+ duration: 2000,
152
+ } as AwesomeTestResult,
153
+ c3: {
154
+ name: "c3",
155
+ duration: 3000,
156
+ } as AwesomeTestResult,
157
+ };
158
+ const result = filterLeaves(leaves, leavesById, {
159
+ direction: "asc",
160
+ sortBy: "duration",
161
+ });
162
+
163
+ expect(result).toEqual([
164
+ expect.objectContaining({ name: "a1" }),
165
+ expect.objectContaining({ name: "b2" }),
166
+ expect.objectContaining({ name: "c3" }),
167
+ ]);
168
+ });
169
+
170
+ it("sorts leave by duration in descending order", () => {
171
+ const leaves = ["a1", "b2", "c3"];
172
+ const leavesById = {
173
+ a1: {
174
+ name: "a1",
175
+ duration: 1000,
176
+ } as AwesomeTestResult,
177
+ b2: {
178
+ name: "b2",
179
+ duration: 2000,
180
+ } as AwesomeTestResult,
181
+ c3: {
182
+ name: "c3",
183
+ duration: 3000,
184
+ } as AwesomeTestResult,
185
+ };
186
+ const result = filterLeaves(leaves, leavesById, {
187
+ direction: "desc",
188
+ sortBy: "duration",
189
+ });
190
+
191
+ expect(result).toEqual([
192
+ expect.objectContaining({ name: "c3" }),
193
+ expect.objectContaining({ name: "b2" }),
194
+ expect.objectContaining({ name: "a1" }),
195
+ ]);
196
+ });
197
+
198
+ it("sorts leaves by title in ascending order", () => {
199
+ const leaves = ["a1", "b2", "c3"];
200
+ const leavesById = {
201
+ a1: {
202
+ name: "a1",
203
+ } as AwesomeTestResult,
204
+ b2: {
205
+ name: "b2",
206
+ } as AwesomeTestResult,
207
+ c3: {
208
+ name: "c3",
209
+ } as AwesomeTestResult,
210
+ };
211
+ const result = filterLeaves(leaves, leavesById, {
212
+ direction: "asc",
213
+ sortBy: "alphabet",
214
+ });
215
+
216
+ expect(result).toEqual([
217
+ expect.objectContaining({ name: "a1" }),
218
+ expect.objectContaining({ name: "b2" }),
219
+ expect.objectContaining({ name: "c3" }),
220
+ ]);
221
+ });
222
+
223
+ it("sorts leaves by title in descending order", () => {
224
+ const leaves = ["a1", "b2", "c3"];
225
+ const leavesById = {
226
+ a1: {
227
+ name: "a1",
228
+ } as AwesomeTestResult,
229
+ b2: {
230
+ name: "b2",
231
+ } as AwesomeTestResult,
232
+ c3: {
233
+ name: "c3",
234
+ } as AwesomeTestResult,
235
+ };
236
+ const result = filterLeaves(leaves, leavesById, {
237
+ direction: "desc",
238
+ sortBy: "alphabet",
239
+ });
240
+
241
+ expect(result).toEqual([
242
+ expect.objectContaining({ name: "c3" }),
243
+ expect.objectContaining({ name: "b2" }),
244
+ expect.objectContaining({ name: "a1" }),
245
+ ]);
246
+ });
247
+
248
+ it("sorts leaves by status in ascending order", () => {
249
+ const leaves = ["a1", "b2", "c3", "d4", "e5"];
250
+ const leavesById = {
251
+ a1: {
252
+ name: "a1",
253
+ status: "passed",
254
+ } as AwesomeTestResult,
255
+ b2: {
256
+ name: "b2",
257
+ status: "failed",
258
+ } as AwesomeTestResult,
259
+ c3: {
260
+ name: "c3",
261
+ status: "broken",
262
+ } as AwesomeTestResult,
263
+ d4: {
264
+ name: "d4",
265
+ status: "unknown",
266
+ } as AwesomeTestResult,
267
+ e5: {
268
+ name: "e5",
269
+ status: "skipped",
270
+ } as AwesomeTestResult,
271
+ };
272
+ const result = filterLeaves(leaves, leavesById, {
273
+ direction: "asc",
274
+ sortBy: "status",
275
+ });
276
+
277
+ expect(result).toEqual([
278
+ expect.objectContaining({ name: "b2" }),
279
+ expect.objectContaining({ name: "c3" }),
280
+ expect.objectContaining({ name: "a1" }),
281
+ expect.objectContaining({ name: "e5" }),
282
+ expect.objectContaining({ name: "d4" }),
283
+ ]);
284
+ });
285
+
286
+ it("sorts leaves by status in descending order", () => {
287
+ const leaves = ["a1", "b2", "c3", "d4", "e5"];
288
+ const leavesById = {
289
+ a1: {
290
+ name: "a1",
291
+ status: "passed",
292
+ } as AwesomeTestResult,
293
+ b2: {
294
+ name: "b2",
295
+ status: "failed",
296
+ } as AwesomeTestResult,
297
+ c3: {
298
+ name: "c3",
299
+ status: "broken",
300
+ } as AwesomeTestResult,
301
+ d4: {
302
+ name: "d4",
303
+ status: "unknown",
304
+ } as AwesomeTestResult,
305
+ e5: {
306
+ name: "e5",
307
+ status: "skipped",
308
+ } as AwesomeTestResult,
309
+ };
310
+ const result = filterLeaves(leaves, leavesById, {
311
+ direction: "desc",
312
+ sortBy: "status",
313
+ });
314
+
315
+ expect(result).toEqual([
316
+ expect.objectContaining({ name: "d4" }),
317
+ expect.objectContaining({ name: "e5" }),
318
+ expect.objectContaining({ name: "a1" }),
319
+ expect.objectContaining({ name: "c3" }),
320
+ expect.objectContaining({ name: "b2" }),
321
+ ]);
322
+ });
323
+
324
+ it("sorts leaves by order number in ascending order", () => {
325
+ const baseDate = Date.now();
326
+ const leaves = ["a1", "b2", "c3"];
327
+ const leavesById = {
328
+ a1: {
329
+ name: "a1",
330
+ start: baseDate + 2000,
331
+ groupOrder: 3,
332
+ } as AwesomeTestResult,
333
+ b2: {
334
+ name: "b2",
335
+ start: baseDate + 1000,
336
+ groupOrder: 2,
337
+ } as AwesomeTestResult,
338
+ c3: {
339
+ name: "c3",
340
+ start: baseDate,
341
+ groupOrder: 1,
342
+ } as AwesomeTestResult,
343
+ };
344
+ const result = filterLeaves(leaves, leavesById, {
345
+ direction: "asc",
346
+ sortBy: "order",
347
+ });
348
+
349
+ expect(result).toEqual([
350
+ expect.objectContaining({ name: "c3" }),
351
+ expect.objectContaining({ name: "b2" }),
352
+ expect.objectContaining({ name: "a1" }),
353
+ ]);
354
+ });
355
+
356
+ it("sorts leaves by order number in descending order", () => {
357
+ const baseDate = Date.now();
358
+ const leaves = ["a1", "b2", "c3"];
359
+ const leavesById = {
360
+ a1: {
361
+ name: "a1",
362
+ start: baseDate + 2000,
363
+ groupOrder: 3,
364
+ } as AwesomeTestResult,
365
+ b2: {
366
+ name: "b2",
367
+ start: baseDate + 1000,
368
+ groupOrder: 2,
369
+ } as AwesomeTestResult,
370
+ c3: {
371
+ name: "c3",
372
+ start: baseDate,
373
+ groupOrder: 1,
374
+ } as AwesomeTestResult,
375
+ };
376
+ const result = filterLeaves(leaves, leavesById, {
377
+ direction: "desc",
378
+ sortBy: "order",
379
+ });
380
+
381
+ expect(result).toEqual([
382
+ expect.objectContaining({ name: "a1" }),
383
+ expect.objectContaining({ name: "b2" }),
384
+ expect.objectContaining({ name: "c3" }),
385
+ ]);
386
+ });
387
+ });
388
+
389
+ describe("createRecursiveTree", () => {
390
+ it("creates recursive tree with filtered and sorted leaves objects", () => {
391
+ const baseDate = Date.now();
392
+ const group = {
393
+ leaves: ["a1"],
394
+ groups: ["a1"],
395
+ };
396
+ const leavesById = {
397
+ a1: {
398
+ name: "a1",
399
+ start: baseDate,
400
+ } as AwesomeTestResult,
401
+ b2: {
402
+ name: "b2",
403
+ start: baseDate + 1000,
404
+ } as AwesomeTestResult,
405
+ c3: {
406
+ name: "c3",
407
+ start: baseDate + 2000,
408
+ } as AwesomeTestResult,
409
+ };
410
+ const groupsById = {
411
+ a1: {
412
+ leaves: ["b2"],
413
+ groups: ["b2"],
414
+ },
415
+ b2: {
416
+ leaves: ["c3"],
417
+ groups: [],
418
+ },
419
+ };
420
+ const result = createRecursiveTree({
421
+ group,
422
+ leavesById,
423
+ groupsById,
424
+ filterOptions: {
425
+ sortBy: "alphabet",
426
+ direction: "asc",
427
+ },
428
+ });
429
+
430
+ expect(result).toEqual(
431
+ expect.objectContaining({
432
+ leaves: [expect.objectContaining({ name: "a1" })],
433
+ trees: [
434
+ expect.objectContaining({
435
+ leaves: [expect.objectContaining({ name: "b2" })],
436
+ trees: [
437
+ expect.objectContaining({
438
+ leaves: [expect.objectContaining({ name: "c3" })],
439
+ trees: [],
440
+ }),
441
+ ],
442
+ }),
443
+ ],
444
+ }),
445
+ );
446
+ });
447
+ });
448
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": "./",
4
+ "paths": {
5
+ "@/*": ["src/*"],
6
+ },
7
+ "jsx": "preserve",
8
+ "jsxFactory": "h",
9
+ "jsxFragmentFactory": "Fragment",
10
+ "jsxImportSource": "preact",
11
+ "target": "ESNext",
12
+ "module": "ESNext",
13
+ "moduleResolution": "node",
14
+ "allowSyntheticDefaultImports": true,
15
+ "useUnknownInCatchVariables": false,
16
+ "noEmit": true,
17
+ "resolveJsonModule": true,
18
+ "esModuleInterop": true,
19
+ "lib": ["ES2019", "dom"],
20
+ // node types should not be used in web-commons
21
+ "types": []
22
+ },
23
+ "include": ["src"],
24
+ "exclude": ["node_modules"]
25
+ }
package/types.d.ts ADDED
@@ -0,0 +1,85 @@
1
+ import type {
2
+ AttachmentTestStepResult,
3
+ DefaultTreeGroup,
4
+ HistoryTestResult,
5
+ TestFixtureResult,
6
+ TestResult,
7
+ TestStatus,
8
+ TestStepResult,
9
+ TreeData,
10
+ WithChildren,
11
+ } from "@allurereport/core-api";
12
+
13
+ export type Allure2ReportOptions = {
14
+ reportName?: string;
15
+ reportLanguage?: string;
16
+ createdAt: number;
17
+ };
18
+
19
+ export type AwesomeReportOptions = {
20
+ reportName?: string;
21
+ logo?: string;
22
+ theme?: "light" | "dark";
23
+ groupBy?: string[];
24
+ reportLanguage?: "en" | "ru";
25
+ createdAt: number;
26
+ reportUuid: string;
27
+ };
28
+
29
+ export type AwesomeFixtureResult = Omit<
30
+ TestFixtureResult,
31
+ "testResultIds" | "start" | "stop" | "sourceMetadata" | "steps"
32
+ > & {
33
+ steps: AwesomeTestStepResult[];
34
+ };
35
+
36
+ export type AwesomeStatus = TestStatus | "total";
37
+
38
+ export type AwesomeTestStepResult = TestStepResult;
39
+
40
+ type AwesomeBreadcrumbItem = string[] | string[][];
41
+
42
+ export type AwesomeTestResult = Omit<
43
+ TestResult,
44
+ | "runSelector"
45
+ | "sourceMetadata"
46
+ | "expectedResult"
47
+ | "expectedResultHtml"
48
+ | "precondition"
49
+ | "preconditionHtml"
50
+ | "steps"
51
+ > & {
52
+ setup: AwesomeFixtureResult[];
53
+ teardown: AwesomeFixtureResult[];
54
+ steps: AwesomeTestStepResult[];
55
+ history: HistoryTestResult[];
56
+ retries?: TestResult[];
57
+ groupedLabels: Record<string, string[]>;
58
+ attachments?: AttachmentTestStepResult[];
59
+ breadcrumbs: AwesomeBreadcrumbItem[];
60
+ order?: number;
61
+ groupOrder?: number;
62
+ retry: boolean;
63
+ time?: Record<string, string[]>;
64
+ extra?: { severity: string };
65
+ };
66
+
67
+ export type AwesomeTreeLeaf = Pick<
68
+ AwesomeTestResult,
69
+ "duration" | "name" | "start" | "status" | "groupOrder" | "flaky" | "retry"
70
+ > & {
71
+ nodeId: string;
72
+ };
73
+
74
+ export type AwesomeTreeGroup = WithChildren & DefaultTreeGroup & { nodeId: string };
75
+
76
+ export type AwesomeTree = TreeData<AwesomeTreeLeaf, AwesomeTreeGroup>;
77
+
78
+ /**
79
+ * Tree which contains tree leaves instead of their IDs and recursive trees structure instead of groups
80
+ */
81
+ export type AwesomeRecursiveTree = DefaultTreeGroup & {
82
+ nodeId: string;
83
+ leaves: AwesomeTreeLeaf[];
84
+ trees: AwesomeRecursiveTree[];
85
+ };
@@ -0,0 +1,18 @@
1
+ import { createRequire } from "node:module";
2
+ import { defineConfig } from "vitest/config";
3
+
4
+ const require = createRequire(import.meta.url);
5
+
6
+ export default defineConfig({
7
+ test: {
8
+ include: ["./test/**/*.test.ts"],
9
+ setupFiles: [require.resolve("allure-vitest/setup")],
10
+ reporters: [
11
+ "default",
12
+ [
13
+ "allure-vitest/reporter",
14
+ { resultsDir: "./out/allure-results", globalLabels: [{ name: "module", value: "web-awesome" }] },
15
+ ],
16
+ ],
17
+ },
18
+ });
@@ -0,0 +1,127 @@
1
+ import MiniCssExtractPlugin from "mini-css-extract-plugin";
2
+ import { dirname, join } from "node:path";
3
+ import { env } from "node:process";
4
+ import { fileURLToPath } from "node:url";
5
+ import SpriteLoaderPlugin from "svg-sprite-loader/plugin.js";
6
+ import webpack from "webpack";
7
+ import { WebpackManifestPlugin } from "webpack-manifest-plugin";
8
+ import * as utils from "./webpack/utils.js";
9
+
10
+ const { SINGLE_FILE_MODE } = env;
11
+ const __dirname = dirname(fileURLToPath(import.meta.url));
12
+
13
+ export default (env, argv) => {
14
+ const config = {
15
+ entry: "./src/index.js",
16
+ output: {
17
+ path: join(__dirname, SINGLE_FILE_MODE ? "dist/single" : "dist/multi"),
18
+ filename: "app-[hash:8].js",
19
+ assetModuleFilename: `[name]-[hash:8][ext]`,
20
+ },
21
+ module: {
22
+ rules: [
23
+ {
24
+ test: /\.(ts|js)x?$/,
25
+ use: "babel-loader",
26
+ exclude: /node_modules/,
27
+ },
28
+ {
29
+ test: /\.css$/,
30
+ use: [MiniCssExtractPlugin.loader, "css-loader"]
31
+ },
32
+ {
33
+ test: /\.scss$/,
34
+ use: [
35
+ MiniCssExtractPlugin.loader,
36
+ {
37
+ loader: "css-loader",
38
+ // TODO: uncomment when we'll start migration to preact
39
+ // options: {
40
+ // modules: true,
41
+ // },
42
+ },
43
+ {
44
+ loader: "sass-loader",
45
+ options: {
46
+ api: "modern",
47
+ }
48
+ },
49
+ ],
50
+ },
51
+ {
52
+ test: /\.hbs$/,
53
+ use: {
54
+ loader: "handlebars-loader",
55
+ options: {
56
+ helperDirs: [
57
+ utils.root("src/helpers"),
58
+ utils.root("src/blocks"),
59
+ ],
60
+ },
61
+ },
62
+ },
63
+ {
64
+ test: /translations\/\D+\.json$/,
65
+ type: "asset/source",
66
+ },
67
+ // FIXME: how can we solve the problem with svg in css?
68
+ // {
69
+ // test: /\.svg$/,
70
+ // type: "asset/inline",
71
+ // resourceQuery: /inline/,
72
+ // },
73
+ {
74
+ test: /\.svg$/,
75
+ loader: "svg-sprite-loader",
76
+ },
77
+ {
78
+ test: /\.(ico)(\?.*)?$/,
79
+ loader: "file-loader",
80
+ },
81
+ {
82
+ test: /\.(png|jpe?g|gif|woff2?|otf|ttf|eot)$/i,
83
+ type: SINGLE_FILE_MODE ? "asset/inline" : "asset/resource",
84
+ },
85
+ ],
86
+ },
87
+ devServer: {
88
+ open: true,
89
+ hot: true,
90
+ },
91
+ plugins: [
92
+ new webpack.DefinePlugin({
93
+ "DEVELOPMENT": argv?.mode === "development",
94
+ "process.env": {
95
+ DEBUG_INFO_ENABLED: argv?.mode === "development",
96
+ },
97
+ }),
98
+ new MiniCssExtractPlugin({
99
+ filename: "styles-[hash:8].css",
100
+ }),
101
+ new SpriteLoaderPlugin(),
102
+ new WebpackManifestPlugin({
103
+ publicPath: "",
104
+ }),
105
+ ],
106
+ resolve: {
107
+ modules: ["node_modules"],
108
+ extensions: [".js", ".json"],
109
+ alias: {
110
+ "@": join(__dirname, "src"),
111
+ },
112
+ },
113
+ };
114
+
115
+ if (SINGLE_FILE_MODE) {
116
+ config.optimization = {
117
+ splitChunks: false,
118
+ }
119
+ config.plugins.push(
120
+ new webpack.optimize.LimitChunkCountPlugin({
121
+ maxChunks: 1,
122
+ }),
123
+ );
124
+ }
125
+
126
+ return config;
127
+ };