@allurereport/web-awesome 3.0.1 → 3.1.0

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 (140) hide show
  1. package/dist/multi/173.app-79c65c7bff941abcbc51.js +1 -0
  2. package/dist/multi/174.app-79c65c7bff941abcbc51.js +1 -0
  3. package/dist/multi/252.app-79c65c7bff941abcbc51.js +1 -0
  4. package/dist/multi/282.app-79c65c7bff941abcbc51.js +1 -0
  5. package/dist/multi/29.app-79c65c7bff941abcbc51.js +1 -0
  6. package/dist/multi/416.app-79c65c7bff941abcbc51.js +1 -0
  7. package/dist/multi/527.app-79c65c7bff941abcbc51.js +1 -0
  8. package/dist/multi/600.app-79c65c7bff941abcbc51.js +1 -0
  9. package/dist/multi/605.app-79c65c7bff941abcbc51.js +1 -0
  10. package/dist/multi/638.app-79c65c7bff941abcbc51.js +1 -0
  11. package/dist/multi/672.app-79c65c7bff941abcbc51.js +1 -0
  12. package/dist/multi/686.app-79c65c7bff941abcbc51.js +1 -0
  13. package/dist/multi/725.app-79c65c7bff941abcbc51.js +1 -0
  14. package/dist/multi/741.app-79c65c7bff941abcbc51.js +1 -0
  15. package/dist/multi/755.app-79c65c7bff941abcbc51.js +1 -0
  16. package/dist/multi/894.app-79c65c7bff941abcbc51.js +1 -0
  17. package/dist/multi/91.app-79c65c7bff941abcbc51.js +1 -0
  18. package/dist/multi/943.app-79c65c7bff941abcbc51.js +1 -0
  19. package/dist/multi/980.app-79c65c7bff941abcbc51.js +1 -0
  20. package/dist/multi/app-79c65c7bff941abcbc51.js +2 -0
  21. package/dist/multi/{app-bae2a0fe5738d77cd976.js.LICENSE.txt → app-79c65c7bff941abcbc51.js.LICENSE.txt} +7 -0
  22. package/dist/multi/manifest.json +21 -21
  23. package/dist/multi/styles-9e390bad7ce54a807a8e.css +49 -0
  24. package/dist/single/app-3ca67f29d0f1166c08ca.js +2 -0
  25. package/dist/single/{app-996d3b5869f8fc942b66.js.LICENSE.txt → app-3ca67f29d0f1166c08ca.js.LICENSE.txt} +7 -0
  26. package/dist/single/manifest.json +1 -1
  27. package/package.json +7 -7
  28. package/src/assets/scss/vars.scss +3 -0
  29. package/src/components/BaseLayout/index.tsx +25 -21
  30. package/src/components/BaseLayout/styles.scss +1 -0
  31. package/src/components/Charts/index.tsx +5 -2
  32. package/src/components/Footer/FooterVersion.tsx +14 -8
  33. package/src/components/Header/index.tsx +9 -7
  34. package/src/components/HeaderControls/index.tsx +5 -2
  35. package/src/components/MainReport/styles.scss +1 -0
  36. package/src/components/Metadata/index.tsx +24 -7
  37. package/src/components/ReportBody/HeaderActions.tsx +4 -13
  38. package/src/components/ReportBody/SortBy.tsx +27 -13
  39. package/src/components/ReportBody/index.tsx +1 -1
  40. package/src/components/ReportBody/styles.scss +4 -1
  41. package/src/components/ReportFilters/BaseFilters.tsx +345 -0
  42. package/src/components/ReportFilters/RetryFlaky.tsx +29 -0
  43. package/src/components/ReportFilters/TagsFilter.tsx +41 -0
  44. package/src/components/ReportFilters/TransitionFilter.tsx +49 -0
  45. package/src/components/ReportFilters/index.tsx +44 -0
  46. package/src/components/ReportFilters/styles.scss +55 -0
  47. package/src/components/ReportSearch/index.tsx +29 -0
  48. package/src/components/ReportTabs/index.tsx +1 -1
  49. package/src/components/SectionPicker/index.tsx +1 -1
  50. package/src/components/SplitLayout/index.tsx +7 -3
  51. package/src/components/TestResult/TrEnvironmentItem/index.tsx +2 -2
  52. package/src/components/TestResult/TrHeader/TrBreadcrumbs.tsx +2 -2
  53. package/src/components/TestResult/TrHistory/TrHistoryItem.tsx +38 -7
  54. package/src/components/TestResult/TrHistory/index.tsx +18 -8
  55. package/src/components/TestResult/TrHistory/styles.scss +4 -7
  56. package/src/components/TestResult/TrInfo/styles.scss +1 -0
  57. package/src/components/TestResult/TrNavigation/index.tsx +109 -68
  58. package/src/components/TestResult/TrNavigation/styles.scss +15 -25
  59. package/src/components/TestResult/TrPwTraces/PwTraceButton.tsx +1 -8
  60. package/src/components/TestResult/TrRetriesView/TrRetriesItem.tsx +2 -3
  61. package/src/components/TestResult/TrRetriesView/index.tsx +4 -3
  62. package/src/components/TestResult/TrSteps/TrAttachment.tsx +5 -3
  63. package/src/components/TestResult/TrSteps/TrAttachmentInfo.tsx +10 -3
  64. package/src/components/TestResult/TrTabs/index.tsx +7 -23
  65. package/src/components/TestResult/index.tsx +9 -4
  66. package/src/components/TestResult/styles.scss +1 -0
  67. package/src/components/Tree/index.tsx +14 -9
  68. package/src/index.html +19 -18
  69. package/src/index.tsx +20 -27
  70. package/src/locales/az.json +39 -11
  71. package/src/locales/de.json +39 -11
  72. package/src/locales/en.json +39 -11
  73. package/src/locales/es.json +39 -11
  74. package/src/locales/fr.json +39 -11
  75. package/src/locales/he.json +39 -11
  76. package/src/locales/hy.json +39 -11
  77. package/src/locales/it.json +39 -11
  78. package/src/locales/ja.json +39 -11
  79. package/src/locales/ka.json +39 -11
  80. package/src/locales/kr.json +39 -11
  81. package/src/locales/nl.json +39 -11
  82. package/src/locales/pl.json +39 -11
  83. package/src/locales/pt.json +39 -11
  84. package/src/locales/ru.json +39 -11
  85. package/src/locales/sv.json +39 -11
  86. package/src/locales/tr.json +39 -11
  87. package/src/locales/ua.json +39 -11
  88. package/src/locales/zh.json +39 -11
  89. package/src/stores/chart.ts +2 -2
  90. package/src/stores/env.ts +6 -6
  91. package/src/stores/envInfo.ts +2 -2
  92. package/src/stores/globals.ts +1 -1
  93. package/src/stores/index.ts +0 -1
  94. package/src/stores/layout.ts +20 -11
  95. package/src/stores/locale.ts +2 -1
  96. package/src/stores/qualityGate.ts +2 -2
  97. package/src/stores/router.ts +25 -91
  98. package/src/stores/sections.ts +32 -45
  99. package/src/stores/stats.ts +4 -4
  100. package/src/stores/testResult.ts +5 -0
  101. package/src/stores/testResults.ts +7 -5
  102. package/src/stores/tree.ts +20 -13
  103. package/src/stores/treeFilters/actions.ts +48 -52
  104. package/src/stores/treeFilters/constants.ts +11 -5
  105. package/src/stores/treeFilters/model.ts +51 -0
  106. package/src/stores/treeFilters/store.ts +260 -60
  107. package/src/stores/treeFilters/utils.ts +132 -0
  108. package/src/stores/treeSort.ts +71 -0
  109. package/src/stores/variables.ts +3 -3
  110. package/src/utils/treeFilters.ts +48 -66
  111. package/test/components/Header.test.tsx +49 -58
  112. package/test/utils/treeFilters.test.ts +18 -321
  113. package/types.d.ts +2 -1
  114. package/dist/multi/173.app-bae2a0fe5738d77cd976.js +0 -1
  115. package/dist/multi/174.app-bae2a0fe5738d77cd976.js +0 -1
  116. package/dist/multi/252.app-bae2a0fe5738d77cd976.js +0 -1
  117. package/dist/multi/282.app-bae2a0fe5738d77cd976.js +0 -1
  118. package/dist/multi/29.app-bae2a0fe5738d77cd976.js +0 -1
  119. package/dist/multi/416.app-bae2a0fe5738d77cd976.js +0 -1
  120. package/dist/multi/527.app-bae2a0fe5738d77cd976.js +0 -1
  121. package/dist/multi/600.app-bae2a0fe5738d77cd976.js +0 -1
  122. package/dist/multi/605.app-bae2a0fe5738d77cd976.js +0 -1
  123. package/dist/multi/638.app-bae2a0fe5738d77cd976.js +0 -1
  124. package/dist/multi/672.app-bae2a0fe5738d77cd976.js +0 -1
  125. package/dist/multi/686.app-bae2a0fe5738d77cd976.js +0 -1
  126. package/dist/multi/725.app-bae2a0fe5738d77cd976.js +0 -1
  127. package/dist/multi/741.app-bae2a0fe5738d77cd976.js +0 -1
  128. package/dist/multi/755.app-bae2a0fe5738d77cd976.js +0 -1
  129. package/dist/multi/894.app-bae2a0fe5738d77cd976.js +0 -1
  130. package/dist/multi/91.app-bae2a0fe5738d77cd976.js +0 -1
  131. package/dist/multi/943.app-bae2a0fe5738d77cd976.js +0 -1
  132. package/dist/multi/980.app-bae2a0fe5738d77cd976.js +0 -1
  133. package/dist/multi/app-bae2a0fe5738d77cd976.js +0 -2
  134. package/dist/multi/styles-bbf68b2ba63c38b53c38.css +0 -48
  135. package/dist/single/app-996d3b5869f8fc942b66.js +0 -2
  136. package/src/components/ReportBody/Filters.tsx +0 -122
  137. package/src/stores/theme.ts +0 -30
  138. package/src/stores/treeFilters/index.ts +0 -3
  139. package/src/stores/treeFilters/types.ts +0 -12
  140. package/test/stores/treeFilters.test.ts +0 -302
@@ -1,63 +1,50 @@
1
1
  import { getReportOptions } from "@allurereport/web-commons";
2
- import { effect, signal } from "@preact/signals";
3
- import { navigateTo, parseHash, route } from "@/stores/router";
2
+ import { computed, effect } from "@preact/signals";
4
3
  import type { AwesomeReportOptions } from "../../types.js";
4
+ import { navigateToRoot, navigateToSection, sectionRoute } from "./router";
5
5
 
6
6
  const DEFAULT_SECTION = "default";
7
- type Section = string;
8
7
 
9
- export const currentSection = signal<Section>("");
10
- export const availableSections = signal<Section[]>([]);
8
+ type Section = "timeline" | "charts" | "default";
11
9
 
12
- const updateSectionState = (section: Section): void => {
13
- currentSection.value = section;
14
- document.documentElement.setAttribute("data-section", section);
15
- globalThis.localStorage.setItem("chosenSection", section);
16
- };
10
+ const reportOptions = getReportOptions<AwesomeReportOptions>();
11
+ const defaultSectionFromReportOptions: Section = (reportOptions?.defaultSection as Section) ?? "default";
17
12
 
18
- export const setSection = (chosenSection: Section): void => {
19
- const isDefaultSection = chosenSection === DEFAULT_SECTION;
20
- const isValidSection = availableSections.value?.includes(chosenSection);
21
- const isSectionChanged = currentSection.value !== chosenSection;
13
+ export const availableSections = (reportOptions?.sections ?? []) as Section[];
22
14
 
23
- updateSectionState(chosenSection);
15
+ const onInit = () => {
16
+ const isSectionRoute = sectionRoute.peek().matches;
17
+ const isDefaultSection = defaultSectionFromReportOptions === DEFAULT_SECTION;
18
+ const isValidSection = availableSections.includes(defaultSectionFromReportOptions);
24
19
 
25
- if (isDefaultSection) {
26
- navigateTo({ category: "" });
27
- return;
28
- }
29
-
30
- if (isSectionChanged && isValidSection) {
31
- navigateTo({ category: chosenSection });
20
+ if (!isSectionRoute && !isDefaultSection && isValidSection) {
21
+ navigateToSection({ section: defaultSectionFromReportOptions });
32
22
  }
33
23
  };
34
24
 
35
- export const getSection = () => {
36
- const { category } = parseHash();
37
- availableSections.value = getReportOptions<AwesomeReportOptions>()?.sections ?? [];
38
- const defaultSectionFromReportOptions = getReportOptions<AwesomeReportOptions>()?.defaultSection ?? "";
39
- const sectionFromUrl = parseHash().category;
40
- const sectionFromLS =
41
- globalThis.localStorage.getItem("chosenSection") === ""
42
- ? ""
43
- : globalThis.localStorage.getItem("chosenSection") || defaultSectionFromReportOptions;
44
- currentSection.value = sectionFromUrl || sectionFromLS;
45
-
46
- if (category) {
47
- setSection(category);
48
- return;
25
+ onInit();
26
+
27
+ export const currentSection = computed(() => sectionRoute.value.params.section ?? "default");
28
+
29
+ effect(() => {
30
+ const section = currentSection.value;
31
+
32
+ if (section) {
33
+ document.documentElement.setAttribute("data-section", section);
49
34
  }
35
+ });
36
+
37
+ export const setSection = (chosenSection: Section | string): void => {
38
+ const isDefaultSection = chosenSection === DEFAULT_SECTION;
39
+ const isValidSection = availableSections.includes(chosenSection as Section);
40
+ const isSectionChanged = currentSection.peek() !== chosenSection;
50
41
 
51
- if (sectionFromLS) {
52
- setSection(sectionFromLS);
42
+ if (isDefaultSection) {
43
+ navigateToRoot();
53
44
  return;
54
45
  }
55
46
 
56
- setSection("");
47
+ if (isSectionChanged && isValidSection) {
48
+ navigateToSection({ section: chosenSection as "timeline" | "charts" });
49
+ }
57
50
  };
58
-
59
- effect(() => {
60
- const category = route.value.category;
61
-
62
- setSection(category || "");
63
- });
@@ -20,7 +20,7 @@ export const statsByEnvStore = signal<StoreSignalState<Record<string, Statistic>
20
20
 
21
21
  export const fetchReportStats = async () => {
22
22
  reportStatsStore.value = {
23
- ...reportStatsStore.value,
23
+ ...reportStatsStore.peek(),
24
24
  loading: true,
25
25
  error: undefined,
26
26
  };
@@ -43,7 +43,7 @@ export const fetchReportStats = async () => {
43
43
  };
44
44
 
45
45
  export const fetchEnvStats = async (envs: string[]) => {
46
- const envsToFetch = envs.filter((env) => !statsByEnvStore.value.data?.[env]);
46
+ const envsToFetch = envs.filter((env) => !statsByEnvStore.peek().data?.[env]);
47
47
 
48
48
  // all envs have already been fetched
49
49
  if (envsToFetch.length === 0) {
@@ -51,7 +51,7 @@ export const fetchEnvStats = async (envs: string[]) => {
51
51
  }
52
52
 
53
53
  statsByEnvStore.value = {
54
- ...statsByEnvStore.value,
54
+ ...statsByEnvStore.peek(),
55
55
  loading: true,
56
56
  error: undefined,
57
57
  };
@@ -73,7 +73,7 @@ export const fetchEnvStats = async (envs: string[]) => {
73
73
  };
74
74
  } catch (err) {
75
75
  statsByEnvStore.value = {
76
- ...statsByEnvStore.value,
76
+ ...statsByEnvStore.peek(),
77
77
  error: err.message,
78
78
  loading: false,
79
79
  };
@@ -0,0 +1,5 @@
1
+ import { computed } from "@preact/signals";
2
+ import { testResultRoute } from "./router";
3
+
4
+ export const trCurrentTab = computed(() => testResultRoute.value.params.tab ?? "overview");
5
+ export const currentTrId = computed(() => testResultRoute.value.params.testResultId);
@@ -32,7 +32,7 @@ export const fetchTestResultNav = async (env?: string) => {
32
32
  };
33
33
  } catch (err) {
34
34
  testResultNavStore.value = {
35
- ...testResultNavStore.value,
35
+ ...testResultNavStore.peek(),
36
36
  error: err.message,
37
37
  loading: false,
38
38
  };
@@ -40,12 +40,14 @@ export const fetchTestResultNav = async (env?: string) => {
40
40
  };
41
41
 
42
42
  export const fetchTestResult = async (testResultId: string) => {
43
- if (!testResultId || (testResultStore.value.data && testResultId in testResultStore.value.data)) {
43
+ const trData = testResultStore.peek().data;
44
+
45
+ if (!testResultId || (trData && testResultId in trData)) {
44
46
  return;
45
47
  }
46
48
 
47
49
  testResultStore.value = {
48
- ...testResultStore.value,
50
+ ...testResultStore.peek(),
49
51
  loading: true,
50
52
  error: undefined,
51
53
  };
@@ -56,13 +58,13 @@ export const fetchTestResult = async (testResultId: string) => {
56
58
  });
57
59
 
58
60
  testResultStore.value = {
59
- data: { ...testResultStore.value.data, [testResultId]: data },
61
+ data: { ...testResultStore.peek().data, [testResultId]: data },
60
62
  error: undefined,
61
63
  loading: false,
62
64
  };
63
65
  } catch (err) {
64
66
  testResultStore.value = {
65
- ...testResultStore.value,
67
+ ...testResultStore.peek(),
66
68
  error: err.message,
67
69
  loading: false,
68
70
  };
@@ -1,11 +1,12 @@
1
- import { fetchReportJsonData } from "@allurereport/web-commons";
1
+ import { buildFilterPredicate, fetchReportJsonData } from "@allurereport/web-commons";
2
2
  import type { RecursiveTree } from "@allurereport/web-components/global";
3
3
  import { computed, effect, signal } from "@preact/signals";
4
4
  import type { AwesomeTree, AwesomeTreeGroup } from "types";
5
5
  import type { StoreSignalState } from "@/stores/types";
6
6
  import { loadFromLocalStorage } from "@/utils/loadFromLocalStorage";
7
7
  import { createRecursiveTree, isRecursiveTreeEmpty } from "@/utils/treeFilters";
8
- import { treeDirection, treeFilter, treeQuery, treeSortBy, treeStatus } from "./treeFilters";
8
+ import { treeFilters } from "./treeFilters/store";
9
+ import { sortBy } from "./treeSort";
9
10
 
10
11
  export const treeStore = signal<StoreSignalState<Record<string, AwesomeTree>>>({
11
12
  loading: true,
@@ -36,7 +37,7 @@ export const toggleTree = (id: string) => {
36
37
  };
37
38
 
38
39
  export const fetchEnvTreesData = async (envs: string[]) => {
39
- const envsToFetch = envs.filter((env) => !treeStore.value.data?.[env]);
40
+ const envsToFetch = envs.filter((env) => !treeStore.peek().data?.[env]);
40
41
 
41
42
  // all envs have already been fetched
42
43
  if (envsToFetch.length === 0) {
@@ -44,7 +45,7 @@ export const fetchEnvTreesData = async (envs: string[]) => {
44
45
  }
45
46
 
46
47
  treeStore.value = {
47
- ...treeStore.value,
48
+ ...treeStore.peek(),
48
49
  loading: true,
49
50
  error: undefined,
50
51
  };
@@ -54,7 +55,7 @@ export const fetchEnvTreesData = async (envs: string[]) => {
54
55
  envsToFetch.map((env) => fetchReportJsonData<AwesomeTree>(`widgets/${env}/tree.json`, { bustCache: true })),
55
56
  );
56
57
 
57
- const previous = treeStore.value.data;
58
+ const previous = treeStore.peek().data;
58
59
  treeStore.value = {
59
60
  data: envsToFetch.reduce(
60
61
  (acc, env, index) => {
@@ -70,7 +71,7 @@ export const fetchEnvTreesData = async (envs: string[]) => {
70
71
  };
71
72
  } catch (e) {
72
73
  treeStore.value = {
73
- ...treeStore.value,
74
+ ...treeStore.peek(),
74
75
  error: e.message,
75
76
  loading: false,
76
77
  };
@@ -79,6 +80,16 @@ export const fetchEnvTreesData = async (envs: string[]) => {
79
80
 
80
81
  const treeEntries = computed(() => (treeStore.value.data ? Object.entries(treeStore.value.data) : []));
81
82
 
83
+ const alwaysTruePredicate = () => true;
84
+
85
+ const filterPredicate = computed(() => {
86
+ if (treeFilters.value.length === 0) {
87
+ return alwaysTruePredicate;
88
+ }
89
+
90
+ return buildFilterPredicate(treeFilters.value);
91
+ });
92
+
82
93
  export const filteredTree = computed(() => {
83
94
  return treeEntries.value.reduce(
84
95
  (acc, [key, value]) => {
@@ -87,17 +98,13 @@ export const filteredTree = computed(() => {
87
98
  }
88
99
 
89
100
  const { root, leavesById, groupsById } = value;
101
+
90
102
  const tree = createRecursiveTree({
91
103
  group: root as AwesomeTreeGroup,
92
104
  leavesById,
93
105
  groupsById,
94
- filterOptions: {
95
- query: treeQuery.value,
96
- status: treeStatus.value,
97
- filter: treeFilter.value,
98
- sortBy: treeSortBy.value,
99
- direction: treeDirection.value,
100
- },
106
+ filterPredicate: filterPredicate.value,
107
+ sortBy: sortBy.value,
101
108
  });
102
109
 
103
110
  return Object.assign(acc, {
@@ -1,67 +1,63 @@
1
- import type { TestStatusTransition } from "@allurereport/core-api";
2
- import { batch } from "@preact/signals";
3
- import type { AwesomeStatus } from "types";
4
- import { treeDirection, treeFilter, treeQuery, treeSortBy, treeStatus } from ".";
5
- import { transitionFiltersList } from "./constants";
6
- import type { TreeDirection, TreeSortBy } from "./types";
7
-
8
- export const clearTreeFilters = () => {
9
- batch(() => {
10
- treeQuery.value = "";
11
- treeStatus.value = "total";
12
- treeFilter.value = {
13
- flaky: false,
14
- retry: false,
15
- new: false,
16
- fixed: false,
17
- regressed: false,
18
- malfunctioned: false,
19
- };
1
+ import type { TestStatus, TestStatusTransition } from "@allurereport/core-api";
2
+ import { ReportFetchError, fetchReportJsonData, setParams } from "@allurereport/web-commons";
3
+ import { PARAMS } from "./constants";
4
+ import type { TreeFiltersData } from "./model";
5
+ import { treeTags } from "./store";
6
+
7
+ export const setQueryFilter = (query?: string) => {
8
+ setParams({
9
+ key: PARAMS.QUERY,
10
+ value: query?.trim() === "" ? undefined : query,
20
11
  });
21
12
  };
22
13
 
23
- export const setTreeQuery = (query: string) => {
24
- treeQuery.value = query;
14
+ export const setStatusFilter = (status?: TestStatus) => {
15
+ setParams({
16
+ key: PARAMS.STATUS,
17
+ value: status,
18
+ });
25
19
  };
26
20
 
27
- export const setTreeStatus = (status: AwesomeStatus) => {
28
- treeStatus.value = status;
21
+ export const setFlakyFilter = (flaky?: boolean) => {
22
+ setParams({
23
+ key: PARAMS.FLAKY,
24
+ value: flaky ? "true" : undefined,
25
+ });
29
26
  };
30
27
 
31
- export const setTreeSortBy = (sortBy: TreeSortBy) => {
32
- treeSortBy.value = sortBy;
28
+ export const setRetryFilter = (retry?: boolean) => {
29
+ setParams({
30
+ key: PARAMS.RETRY,
31
+ value: retry ? "true" : undefined,
32
+ });
33
33
  };
34
34
 
35
- export const setTreeDirection = (direction: TreeDirection) => {
36
- treeDirection.value = direction;
35
+ export const setTransitionFilter = (transitions: TestStatusTransition[]) => {
36
+ setParams({
37
+ key: PARAMS.TRANSITION,
38
+ value: transitions,
39
+ });
37
40
  };
38
41
 
39
- export const setFilters = (filters: Record<string, boolean>) => {
40
- treeFilter.value = {
41
- ...treeFilter.peek(),
42
- ...filters,
43
- };
42
+ export const setTagsFilter = (tags: string[]) => {
43
+ setParams({
44
+ key: PARAMS.TAGS,
45
+ value: tags,
46
+ });
44
47
  };
45
48
 
46
- export const setTestTypeFilter = (testType: "flaky" | "retry", value: boolean) => {
47
- treeFilter.value = {
48
- ...treeFilter.peek(),
49
- [testType]: value,
50
- };
51
- };
49
+ export const fetchTreeFiltersData = async () => {
50
+ try {
51
+ const response = await fetchReportJsonData<TreeFiltersData>("widgets/tree-filters.json", { bustCache: true });
52
+
53
+ treeTags.value = response.tags;
54
+ } catch (error) {
55
+ if (error instanceof ReportFetchError && error.response.status === 404) {
56
+ treeTags.value = [];
57
+ return;
58
+ }
52
59
 
53
- export const setTransitionFilter = (transition: TestStatusTransition, value: boolean) => {
54
- treeFilter.value = {
55
- ...treeFilter.peek(),
56
- ...transitionFiltersList.reduce(
57
- (acc, t) => {
58
- acc[t] = false;
59
- if (t === transition) {
60
- acc[t] = value;
61
- }
62
- return acc;
63
- },
64
- {} as Record<TestStatusTransition, boolean>,
65
- ),
66
- };
60
+ // eslint-disable-next-line no-console
61
+ console.error("Failed to fetch tree filters data:\n\n", error);
62
+ }
67
63
  };
@@ -1,7 +1,13 @@
1
- import type { TestStatusTransition } from "@allurereport/core-api";
1
+ import type { TestStatus, TestStatusTransition } from "@allurereport/core-api";
2
2
 
3
- export const testTypeFiltersList = ["flaky", "retry"];
3
+ export const TRANSITIONS: TestStatusTransition[] = ["new", "fixed", "regressed", "malfunctioned"];
4
+ export const STATUSES: TestStatus[] = ["passed", "failed", "skipped", "broken", "unknown"];
4
5
 
5
- export const transitionFiltersList = ["new", "fixed", "regressed", "malfunctioned"] as TestStatusTransition[];
6
-
7
- export const filtersList = [...testTypeFiltersList, ...transitionFiltersList] as const;
6
+ export const PARAMS = {
7
+ QUERY: "query",
8
+ STATUS: "status",
9
+ FLAKY: "flaky",
10
+ RETRY: "retry",
11
+ TRANSITION: "transition",
12
+ TAGS: "tags",
13
+ } as const;
@@ -0,0 +1,51 @@
1
+ import type { TestStatus, TestStatusTransition } from "@allurereport/core-api";
2
+ import type {
3
+ ArrayField,
4
+ BooleanField,
5
+ Field,
6
+ FieldFilter,
7
+ FieldFilterGroup,
8
+ StringField,
9
+ } from "@allurereport/web-commons";
10
+ import type { AwesomeTreeLeaf } from "types";
11
+
12
+ export type Filters = {
13
+ query?: string;
14
+ status?: TestStatus;
15
+ flaky?: boolean;
16
+ retry?: boolean;
17
+ transition?: TestStatusTransition[];
18
+ tags?: string[];
19
+ };
20
+
21
+ export type AwesomeFieldFilter = FieldFilter<keyof AwesomeTreeLeaf>;
22
+
23
+ export type AwesomeFieldFilterGroup = FieldFilterGroup<keyof AwesomeTreeLeaf> & {
24
+ fieldKey?: keyof AwesomeTreeLeaf;
25
+ };
26
+
27
+ export type AwesomeFilterGroupSimple = AwesomeFieldFilterGroup & {
28
+ value: AwesomeFieldFilter[];
29
+ };
30
+
31
+ export type AwesomeFilter = AwesomeFieldFilter | AwesomeFilterGroupSimple;
32
+
33
+ export type AwesomeField = Field<keyof AwesomeTreeLeaf>;
34
+
35
+ export type AwesomeBooleanField = BooleanField<keyof AwesomeTreeLeaf>;
36
+
37
+ export type AwesomeStringFieldFilter = AwesomeFieldFilter & {
38
+ value: StringField<keyof AwesomeTreeLeaf>;
39
+ };
40
+
41
+ export type AwesomeArrayFieldFilter = AwesomeFieldFilter & {
42
+ value: ArrayField<keyof AwesomeTreeLeaf>;
43
+ };
44
+
45
+ export type AwesomeBooleanFieldFilter = AwesomeFieldFilter & {
46
+ value: AwesomeBooleanField;
47
+ };
48
+
49
+ export type TreeFiltersData = {
50
+ tags: string[];
51
+ };