@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,127 @@
1
+ import { fetchReportJsonData } from "@allurereport/web-commons";
2
+ import { computed, signal } from "@preact/signals";
3
+ import type { AwesomeStatus, AwesomeTree, AwesomeTreeGroup } from "types";
4
+ import type { StoreSignalState } from "@/stores/types";
5
+ import { createRecursiveTree, isRecursiveTreeEmpty } from "@/utils/treeFilters";
6
+
7
+ export type TreeSortBy = "order" | "duration" | "status" | "alphabet";
8
+ export type TreeDirection = "asc" | "desc";
9
+ export type TreeFilters = "flaky" | "retry" | "new";
10
+ export type TreeFiltersState = {
11
+ query: string;
12
+ status: AwesomeStatus;
13
+ filter: Record<TreeFilters, boolean>;
14
+ sortBy: TreeSortBy;
15
+ direction: TreeDirection;
16
+ };
17
+
18
+ export const categoriesStore = signal<StoreSignalState<AwesomeTree>>({
19
+ loading: true,
20
+ error: undefined,
21
+ data: undefined,
22
+ });
23
+
24
+ export const noTests = computed(() => !Object.keys(categoriesStore?.value?.data?.leavesById).length);
25
+
26
+ export const categoriesFiltersStore = signal<TreeFiltersState>({
27
+ query: "",
28
+ status: "total",
29
+ filter: {
30
+ flaky: false,
31
+ retry: false,
32
+ new: false,
33
+ },
34
+ sortBy: "order",
35
+ direction: "asc",
36
+ });
37
+
38
+ export const filteredCategories = computed(() => {
39
+ const { root, leavesById, groupsById } = categoriesStore.value.data;
40
+
41
+ return createRecursiveTree({
42
+ group: root as AwesomeTreeGroup,
43
+ leavesById,
44
+ groupsById,
45
+ filterOptions: categoriesFiltersStore.value,
46
+ });
47
+ });
48
+
49
+ export const noTestsFound = computed(() => {
50
+ return isRecursiveTreeEmpty(filteredCategories.value);
51
+ });
52
+
53
+ export const clearCategoriesFilters = () => {
54
+ categoriesFiltersStore.value = {
55
+ query: "",
56
+ status: "total",
57
+ filter: {
58
+ flaky: false,
59
+ retry: false,
60
+ new: false,
61
+ },
62
+ sortBy: "order",
63
+ direction: "asc",
64
+ };
65
+ };
66
+
67
+ export const setCategoriesQuery = (query: string) => {
68
+ categoriesFiltersStore.value = {
69
+ ...categoriesFiltersStore.value,
70
+ query,
71
+ };
72
+ };
73
+
74
+ export const setCategoriesStatus = (status: AwesomeStatus) => {
75
+ categoriesFiltersStore.value = {
76
+ ...categoriesFiltersStore.value,
77
+ status,
78
+ };
79
+ };
80
+
81
+ export const setCategoriesSortBy = (sortBy: TreeSortBy) => {
82
+ categoriesFiltersStore.value = {
83
+ ...categoriesFiltersStore.value,
84
+ sortBy,
85
+ };
86
+ };
87
+
88
+ export const setCategoriesDirection = (direction: TreeDirection) => {
89
+ categoriesFiltersStore.value = {
90
+ ...categoriesFiltersStore.value,
91
+ direction,
92
+ };
93
+ };
94
+
95
+ export const setCategoriesFilter = (filterKey: TreeFilters, value: boolean) => {
96
+ categoriesFiltersStore.value = {
97
+ ...categoriesFiltersStore.value,
98
+ filter: {
99
+ ...categoriesFiltersStore.value.filter,
100
+ [filterKey]: value,
101
+ },
102
+ };
103
+ };
104
+
105
+ export const fetchCategoriesData = async () => {
106
+ categoriesStore.value = {
107
+ ...categoriesStore.value,
108
+ loading: true,
109
+ error: undefined,
110
+ };
111
+
112
+ try {
113
+ const res = await fetchReportJsonData<AwesomeTree>("widgets/categories.json");
114
+
115
+ categoriesStore.value = {
116
+ data: res,
117
+ error: undefined,
118
+ loading: false,
119
+ };
120
+ } catch (e) {
121
+ categoriesStore.value = {
122
+ ...categoriesStore.value,
123
+ error: e.message,
124
+ loading: false,
125
+ };
126
+ }
127
+ };
@@ -0,0 +1,32 @@
1
+ import { fetchReportJsonData } from "@allurereport/web-commons";
2
+ import { signal } from "@preact/signals";
3
+ import { StoreSignalState } from "@/stores/types";
4
+
5
+ export const pieChartStore = signal<StoreSignalState<any>>({
6
+ loading: true,
7
+ error: undefined,
8
+ data: undefined,
9
+ });
10
+
11
+ export const fetchPieChartData = async () => {
12
+ pieChartStore.value = {
13
+ ...pieChartStore.value,
14
+ loading: true,
15
+ error: undefined,
16
+ };
17
+
18
+ try {
19
+ const res = await fetchReportJsonData("widgets/allure_pie_chart.json");
20
+
21
+ pieChartStore.value = {
22
+ data: res,
23
+ error: undefined,
24
+ loading: false,
25
+ };
26
+ } catch (err) {
27
+ pieChartStore.value = {
28
+ error: err.message,
29
+ loading: false,
30
+ };
31
+ }
32
+ };
@@ -0,0 +1,34 @@
1
+ import type { EnvironmentItem } from "@allurereport/core-api";
2
+ import { fetchReportJsonData } from "@allurereport/web-commons";
3
+ import { signal } from "@preact/signals";
4
+ import type { StoreSignalState } from "@/stores/types";
5
+
6
+ export const envInfoStore = signal<StoreSignalState<EnvironmentItem[]>>({
7
+ loading: false,
8
+ error: undefined,
9
+ data: undefined,
10
+ });
11
+
12
+ export const fetchEnvInfo = async () => {
13
+ envInfoStore.value = {
14
+ ...envInfoStore.value,
15
+ loading: true,
16
+ error: undefined,
17
+ };
18
+
19
+ try {
20
+ const res = await fetchReportJsonData<EnvironmentItem[]>("widgets/allure_environment.json");
21
+
22
+ envInfoStore.value = {
23
+ data: res,
24
+ error: undefined,
25
+ loading: false,
26
+ };
27
+ } catch (e) {
28
+ envInfoStore.value = {
29
+ ...envInfoStore.value,
30
+ error: e.message,
31
+ loading: false,
32
+ };
33
+ }
34
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./theme";
2
+ export type * from "./types";
3
+ export * from "./stats";
4
+ export * from "./locale";
@@ -0,0 +1,83 @@
1
+ import { getReportOptions } from "@allurereport/web-commons";
2
+ import { computed, signal } from "@preact/signals";
3
+ import i18next, { type TOptions } from "i18next";
4
+ import { DEFAULT_LOCALE, LANG_LOCALE, type LangLocale } from "@/translations/constants";
5
+ import type { AwesomeReportOptions } from "../../types.js";
6
+
7
+ const { reportLanguage } = getReportOptions<AwesomeReportOptions>() ?? {};
8
+
9
+ const namespaces = [
10
+ "empty",
11
+ "execution",
12
+ "filters",
13
+ "search",
14
+ "severity",
15
+ "sort-by",
16
+ "sort-by.directions",
17
+ "sort-by.values",
18
+ "statuses",
19
+ "tabs",
20
+ "testSummary",
21
+ "ui",
22
+ "welcome",
23
+ "controls",
24
+ "errors",
25
+ "nav",
26
+ ];
27
+
28
+ export const currentLocale = signal<LangLocale>("" as LangLocale);
29
+
30
+ export const currentLocaleIso = computed(() => {
31
+ const locale = currentLocale.value;
32
+
33
+ return LANG_LOCALE[locale].iso;
34
+ });
35
+
36
+ export const currentLocaleIsRTL = computed(() => {
37
+ return ["ar", "he", "fa"].includes(currentLocale.value as string);
38
+ });
39
+
40
+ export const getLocale = () => {
41
+ const locale = localStorage.getItem("currentLocale") || reportLanguage || DEFAULT_LOCALE;
42
+ setLocale(locale as LangLocale);
43
+ };
44
+
45
+ i18next
46
+ .use({
47
+ type: "backend",
48
+ read: async (
49
+ language: LangLocale,
50
+ namespace: string,
51
+ callback: (errorValue: unknown, translations: Record<string, string> | null) => void,
52
+ ) => {
53
+ try {
54
+ const resources = await import(`@/translations/${language}.json`);
55
+ callback(null, (resources[namespace] as Record<string, string>) || null);
56
+ } catch (error) {
57
+ callback(error, null);
58
+ }
59
+ },
60
+ })
61
+ .init({
62
+ lng: currentLocale.value,
63
+ fallbackLng: "en",
64
+ ns: namespaces,
65
+ interpolation: {
66
+ escapeValue: false,
67
+ },
68
+ });
69
+
70
+ export const useI18n = (namespace?: string) => {
71
+ const t = computed(() => (key: string, options?: TOptions) => i18next.t(key, { ns: namespace, ...options }));
72
+
73
+ return {
74
+ t: t.value,
75
+ currentLocale: currentLocale.value,
76
+ };
77
+ };
78
+
79
+ export const setLocale = async (locale: LangLocale) => {
80
+ await i18next.changeLanguage(locale);
81
+ localStorage.setItem("currentLocale", locale);
82
+ currentLocale.value = locale;
83
+ };
@@ -0,0 +1,127 @@
1
+ import { fetchReportJsonData } from "@allurereport/web-commons";
2
+ import { computed, signal } from "@preact/signals";
3
+ import type { AwesomeStatus, AwesomeTree, AwesomeTreeGroup } from "types";
4
+ import type { StoreSignalState } from "@/stores/types";
5
+ import { createRecursiveTree, isRecursiveTreeEmpty } from "@/utils/treeFilters";
6
+
7
+ export type TreeSortBy = "order" | "duration" | "status" | "alphabet";
8
+ export type TreeDirection = "asc" | "desc";
9
+ export type TreeFilters = "flaky" | "retry" | "new";
10
+ export type TreeFiltersState = {
11
+ query: string;
12
+ status: AwesomeStatus;
13
+ filter: Record<TreeFilters, boolean>;
14
+ sortBy: TreeSortBy;
15
+ direction: TreeDirection;
16
+ };
17
+
18
+ export const packagesStore = signal<StoreSignalState<AwesomeTree>>({
19
+ loading: true,
20
+ error: undefined,
21
+ data: undefined,
22
+ });
23
+
24
+ export const noTests = computed(() => !Object.keys(packagesStore?.value?.data?.leavesById).length);
25
+
26
+ export const packagesFiltersStore = signal<TreeFiltersState>({
27
+ query: "",
28
+ status: "total",
29
+ filter: {
30
+ flaky: false,
31
+ retry: false,
32
+ new: false,
33
+ },
34
+ sortBy: "order",
35
+ direction: "asc",
36
+ });
37
+
38
+ export const filteredPackages = computed(() => {
39
+ const { root, leavesById, groupsById } = packagesStore.value.data;
40
+
41
+ return createRecursiveTree({
42
+ group: root as AwesomeTreeGroup,
43
+ leavesById,
44
+ groupsById,
45
+ filterOptions: packagesFiltersStore.value,
46
+ });
47
+ });
48
+
49
+ export const noTestsFound = computed(() => {
50
+ return isRecursiveTreeEmpty(filteredPackages.value);
51
+ });
52
+
53
+ export const clearPackagesFilters = () => {
54
+ packagesFiltersStore.value = {
55
+ query: "",
56
+ status: "total",
57
+ filter: {
58
+ flaky: false,
59
+ retry: false,
60
+ new: false,
61
+ },
62
+ sortBy: "order",
63
+ direction: "asc",
64
+ };
65
+ };
66
+
67
+ export const setPackagesQuery = (query: string) => {
68
+ packagesFiltersStore.value = {
69
+ ...packagesFiltersStore.value,
70
+ query,
71
+ };
72
+ };
73
+
74
+ export const setPackagesStatus = (status: AwesomeStatus) => {
75
+ packagesFiltersStore.value = {
76
+ ...packagesFiltersStore.value,
77
+ status,
78
+ };
79
+ };
80
+
81
+ export const setPackagesSortBy = (sortBy: TreeSortBy) => {
82
+ packagesFiltersStore.value = {
83
+ ...packagesFiltersStore.value,
84
+ sortBy,
85
+ };
86
+ };
87
+
88
+ export const setPackagesDirection = (direction: TreeDirection) => {
89
+ packagesFiltersStore.value = {
90
+ ...packagesFiltersStore.value,
91
+ direction,
92
+ };
93
+ };
94
+
95
+ export const setPackagesFilter = (filterKey: TreeFilters, value: boolean) => {
96
+ packagesFiltersStore.value = {
97
+ ...packagesFiltersStore.value,
98
+ filter: {
99
+ ...packagesFiltersStore.value.filter,
100
+ [filterKey]: value,
101
+ },
102
+ };
103
+ };
104
+
105
+ export const fetchPackagesData = async () => {
106
+ packagesStore.value = {
107
+ ...packagesStore.value,
108
+ loading: true,
109
+ error: undefined,
110
+ };
111
+
112
+ try {
113
+ const res = await fetchReportJsonData<AwesomeTree>("widgets/packages.json");
114
+
115
+ packagesStore.value = {
116
+ data: res,
117
+ error: undefined,
118
+ loading: false,
119
+ };
120
+ } catch (e) {
121
+ packagesStore.value = {
122
+ ...packagesStore.value,
123
+ error: e.message,
124
+ loading: false,
125
+ };
126
+ }
127
+ };
@@ -0,0 +1,55 @@
1
+ import { computed, signal } from "@preact/signals";
2
+
3
+ type NavigateToString = string;
4
+ type NavigateToObject = {
5
+ tabName?: string;
6
+ params?: {
7
+ id?: string | null;
8
+ testResultId?: string | null;
9
+ };
10
+ };
11
+
12
+ const parseHash = () => {
13
+ const hash = globalThis.location.hash.slice(1);
14
+ const [tabName, ...params] = hash.split("/");
15
+ return {
16
+ tabName: tabName,
17
+ params: { id: params[0] || null, testResultId: params[1] || null },
18
+ };
19
+ };
20
+
21
+ export const route = signal(parseHash());
22
+
23
+ export const handleHashChange = () => {
24
+ const newRoute = parseHash();
25
+
26
+ if (
27
+ newRoute.tabName !== route.value.tabName ||
28
+ newRoute.params.id !== route.value.params.id ||
29
+ newRoute.params.testResultId !== route.value.params.testResultId
30
+ ) {
31
+ route.value = newRoute;
32
+ }
33
+ };
34
+
35
+ export const navigateTo = (path: NavigateToString | NavigateToObject) => {
36
+ let newHash = "";
37
+
38
+ if (typeof path === "string") {
39
+ newHash = path.startsWith("#") ? path.slice(1) : path;
40
+ } else {
41
+ const { tabName = "overview", params = {} } = path;
42
+ const { id = null, testResultId = null } = params;
43
+ newHash = `${tabName}/${id || ""}/${testResultId || ""}`;
44
+ }
45
+
46
+ history.pushState(null, "", `#${newHash}`);
47
+
48
+ handleHashChange();
49
+ };
50
+
51
+ export const openInNewTab = (path: string) => {
52
+ window.open(`#${path}`, "_blank");
53
+ };
54
+
55
+ export const activeTab = computed(() => route.value.tabName);
@@ -0,0 +1,36 @@
1
+ import type { Statistic } from "@allurereport/core-api";
2
+ import { fetchReportJsonData } from "@allurereport/web-commons";
3
+ import { signal } from "@preact/signals";
4
+ import type { StoreSignalState } from "@/stores/types";
5
+
6
+ export const statsStore = signal<StoreSignalState<Statistic>>({
7
+ loading: true,
8
+ error: undefined,
9
+ data: {
10
+ total: 0,
11
+ },
12
+ });
13
+
14
+ export const fetchStats = async () => {
15
+ statsStore.value = {
16
+ ...statsStore.value,
17
+ loading: true,
18
+ error: undefined,
19
+ };
20
+
21
+ try {
22
+ const res = await fetchReportJsonData<Statistic>("widgets/allure_statistic.json");
23
+
24
+ statsStore.value = {
25
+ data: res,
26
+ error: undefined,
27
+ loading: false,
28
+ };
29
+ } catch (err) {
30
+ statsStore.value = {
31
+ data: { total: 0 },
32
+ error: err.message,
33
+ loading: false,
34
+ };
35
+ }
36
+ };
@@ -0,0 +1,7 @@
1
+ import { signal } from "@preact/signals";
2
+
3
+ export const currentTab = signal<string | undefined>("total");
4
+
5
+ export const setCurrentTab = (tab: string) => {
6
+ currentTab.value = tab;
7
+ };
@@ -0,0 +1,66 @@
1
+ import { fetchReportJsonData } from "@allurereport/web-commons";
2
+ import { signal } from "@preact/signals";
3
+ import { type AwesomeTestResult } from "types";
4
+ import { type StoreSignalState } from "./types";
5
+
6
+ export type TestResultsStoreState = Record<string, AwesomeTestResult>;
7
+
8
+ export type TestResultNavStoreState = string[];
9
+
10
+ export const testResultStore = signal<StoreSignalState<TestResultsStoreState>>({
11
+ loading: true,
12
+ error: undefined,
13
+ data: undefined,
14
+ });
15
+
16
+ export const testResultNavStore = signal<StoreSignalState<TestResultNavStoreState>>({
17
+ loading: true,
18
+ error: undefined,
19
+ data: undefined,
20
+ });
21
+
22
+ export const fetchTestResultNav = async () => {
23
+ try {
24
+ const data = await fetchReportJsonData<string[]>("widgets/nav.json");
25
+
26
+ testResultNavStore.value = {
27
+ data,
28
+ error: undefined,
29
+ loading: false,
30
+ };
31
+ } catch (err) {
32
+ testResultNavStore.value = {
33
+ ...testResultNavStore.value,
34
+ error: err.message,
35
+ loading: false,
36
+ };
37
+ }
38
+ };
39
+
40
+ export const fetchTestResult = async (testResultId: string) => {
41
+ if (!testResultId) {
42
+ return;
43
+ }
44
+
45
+ testResultStore.value = {
46
+ ...testResultStore.value,
47
+ loading: true,
48
+ error: undefined,
49
+ };
50
+
51
+ try {
52
+ const data = await fetchReportJsonData<AwesomeTestResult>(`data/test-results/${testResultId}.json`);
53
+
54
+ testResultStore.value = {
55
+ data: { ...testResultStore.value.data, [testResultId]: data },
56
+ error: undefined,
57
+ loading: false,
58
+ };
59
+ } catch (err) {
60
+ testResultStore.value = {
61
+ ...testResultStore.value,
62
+ error: err.message,
63
+ loading: false,
64
+ };
65
+ }
66
+ };
@@ -0,0 +1,33 @@
1
+ import { getReportOptions } from "@allurereport/web-commons";
2
+ import { signal } from "@preact/signals";
3
+ import type { AwesomeReportOptions } from "../../types.js";
4
+
5
+ type Theme = "light" | "dark";
6
+
7
+ const { theme } = getReportOptions<AwesomeReportOptions>() ?? {};
8
+
9
+ export const themeStore = signal<Theme>("light");
10
+
11
+ export const setTheme = (newTheme: Theme): void => {
12
+ themeStore.value = newTheme;
13
+ document.documentElement.setAttribute("data-theme", newTheme);
14
+ window.localStorage.setItem("theme", newTheme);
15
+ };
16
+
17
+ export const toggleTheme = () => {
18
+ setTheme(themeStore.value === "light" ? "dark" : "light");
19
+ };
20
+
21
+ export const getTheme = () => {
22
+ const themeFromLS = (window.localStorage.getItem("theme") as Theme | null) || (theme as Theme);
23
+
24
+ if (themeFromLS) {
25
+ setTheme(themeFromLS);
26
+ return;
27
+ }
28
+
29
+ const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)").matches;
30
+ const initialTheme = prefersDarkScheme ? "dark" : "light";
31
+
32
+ setTheme(initialTheme);
33
+ };