@platforma-sdk/ui-vue 1.87.0 → 1.88.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 (143) hide show
  1. package/.turbo/turbo-build.log +36 -13
  2. package/.turbo/turbo-formatter$colon$check.log +1 -1
  3. package/.turbo/turbo-linter$colon$check.log +1 -1
  4. package/CHANGELOG.md +30 -0
  5. package/dist/columnLinkViews.d.ts +97 -0
  6. package/dist/columnLinkViews.d.ts.map +1 -0
  7. package/dist/columnLinkViews.js +208 -0
  8. package/dist/columnLinkViews.js.map +1 -0
  9. package/dist/columnLinkViews.test.d.ts +2 -0
  10. package/dist/columnLinkViews.test.d.ts.map +1 -0
  11. package/dist/columnLinks.d.ts +5 -0
  12. package/dist/columnLinks.d.ts.map +1 -0
  13. package/dist/columnLinks.js +5 -0
  14. package/dist/columnLinks.js.map +1 -0
  15. package/dist/components/PlAnnotations/components/PlAnnotations.vue2.js.map +1 -1
  16. package/dist/components/PlBlockDependencies/PlBlockDependencies.js +7 -0
  17. package/dist/components/PlBlockDependencies/PlBlockDependencies.js.map +1 -0
  18. package/dist/components/PlBlockDependencies/PlBlockDependencies.jsdomtest.d.ts +2 -0
  19. package/dist/components/PlBlockDependencies/PlBlockDependencies.jsdomtest.d.ts.map +1 -0
  20. package/dist/components/PlBlockDependencies/PlBlockDependencies.style.css +1 -0
  21. package/dist/components/PlBlockDependencies/PlBlockDependencies.style.js +13 -0
  22. package/dist/components/PlBlockDependencies/PlBlockDependencies.style.js.map +1 -0
  23. package/dist/components/PlBlockDependencies/PlBlockDependencies.vue.d.ts +4 -0
  24. package/dist/components/PlBlockDependencies/PlBlockDependencies.vue.d.ts.map +1 -0
  25. package/dist/components/PlBlockDependencies/PlBlockDependencies.vue2.js +79 -0
  26. package/dist/components/PlBlockDependencies/PlBlockDependencies.vue2.js.map +1 -0
  27. package/dist/components/PlBlockDependencies/fold.d.ts +25 -0
  28. package/dist/components/PlBlockDependencies/fold.d.ts.map +1 -0
  29. package/dist/components/PlBlockDependencies/fold.js +55 -0
  30. package/dist/components/PlBlockDependencies/fold.js.map +1 -0
  31. package/dist/components/PlBlockDependencies/index.d.ts +2 -0
  32. package/dist/components/PlBlockDependencies/index.d.ts.map +1 -0
  33. package/dist/components/PlBlockDependencies/index.js +1 -0
  34. package/dist/components/PlBlockName/PlBlockName.js +7 -0
  35. package/dist/components/PlBlockName/PlBlockName.js.map +1 -0
  36. package/dist/components/PlBlockName/PlBlockName.jsdomtest.d.ts +2 -0
  37. package/dist/components/PlBlockName/PlBlockName.jsdomtest.d.ts.map +1 -0
  38. package/dist/components/PlBlockName/PlBlockName.style.css +1 -0
  39. package/dist/components/PlBlockName/PlBlockName.style.js +5 -0
  40. package/dist/components/PlBlockName/PlBlockName.style.js.map +1 -0
  41. package/dist/components/PlBlockName/PlBlockName.vue.d.ts +14 -0
  42. package/dist/components/PlBlockName/PlBlockName.vue.d.ts.map +1 -0
  43. package/dist/components/PlBlockName/PlBlockName.vue2.js +33 -0
  44. package/dist/components/PlBlockName/PlBlockName.vue2.js.map +1 -0
  45. package/dist/components/PlBlockName/index.d.ts +2 -0
  46. package/dist/components/PlBlockName/index.d.ts.map +1 -0
  47. package/dist/components/PlBlockName/index.js +1 -0
  48. package/dist/components/PlColumnValueDropdown/PlColumnValueDropdown.js +6 -0
  49. package/dist/components/PlColumnValueDropdown/PlColumnValueDropdown.js.map +1 -0
  50. package/dist/components/PlColumnValueDropdown/PlColumnValueDropdown.jsdomtest.d.ts +2 -0
  51. package/dist/components/PlColumnValueDropdown/PlColumnValueDropdown.jsdomtest.d.ts.map +1 -0
  52. package/dist/components/PlColumnValueDropdown/PlColumnValueDropdown.vue.d.ts +26 -0
  53. package/dist/components/PlColumnValueDropdown/PlColumnValueDropdown.vue.d.ts.map +1 -0
  54. package/dist/components/PlColumnValueDropdown/PlColumnValueDropdown.vue2.js +37 -0
  55. package/dist/components/PlColumnValueDropdown/PlColumnValueDropdown.vue2.js.map +1 -0
  56. package/dist/components/PlColumnValueDropdown/PlColumnValueDropdownMulti.js +6 -0
  57. package/dist/components/PlColumnValueDropdown/PlColumnValueDropdownMulti.js.map +1 -0
  58. package/dist/components/PlColumnValueDropdown/PlColumnValueDropdownMulti.vue.d.ts +26 -0
  59. package/dist/components/PlColumnValueDropdown/PlColumnValueDropdownMulti.vue.d.ts.map +1 -0
  60. package/dist/components/PlColumnValueDropdown/PlColumnValueDropdownMulti.vue2.js +37 -0
  61. package/dist/components/PlColumnValueDropdown/PlColumnValueDropdownMulti.vue2.js.map +1 -0
  62. package/dist/components/PlColumnValueDropdown/index.d.ts +5 -0
  63. package/dist/components/PlColumnValueDropdown/index.d.ts.map +1 -0
  64. package/dist/components/PlColumnValueDropdown/index.js +4 -0
  65. package/dist/components/PlColumnValueDropdown/settings.d.ts +34 -0
  66. package/dist/components/PlColumnValueDropdown/settings.d.ts.map +1 -0
  67. package/dist/components/PlColumnValueDropdown/settings.js +25 -0
  68. package/dist/components/PlColumnValueDropdown/settings.js.map +1 -0
  69. package/dist/components/PlColumnValueDropdown/settings.test.d.ts +2 -0
  70. package/dist/components/PlColumnValueDropdown/settings.test.d.ts.map +1 -0
  71. package/dist/components/PlColumnValueDropdown/useColumnValueOptions.d.ts +20 -0
  72. package/dist/components/PlColumnValueDropdown/useColumnValueOptions.d.ts.map +1 -0
  73. package/dist/components/PlColumnValueDropdown/useColumnValueOptions.js +45 -0
  74. package/dist/components/PlColumnValueDropdown/useColumnValueOptions.js.map +1 -0
  75. package/dist/components/PlColumnValueDropdown/useColumnValueOptions.test.d.ts +2 -0
  76. package/dist/components/PlColumnValueDropdown/useColumnValueOptions.test.d.ts.map +1 -0
  77. package/dist/components/PlDatasetSelector/PlDatasetSelector.js.map +1 -1
  78. package/dist/components/PlDatasetSelector/PlDatasetSelector.vue.d.ts.map +1 -1
  79. package/dist/components/PlDatasetSelector/PlDatasetSelector.vue2.js +49 -35
  80. package/dist/components/PlDatasetSelector/PlDatasetSelector.vue2.js.map +1 -1
  81. package/dist/components/PlDatasetSelector/__tests__/missingValueHint.jsdomtest.d.ts +2 -0
  82. package/dist/components/PlDatasetSelector/__tests__/missingValueHint.jsdomtest.d.ts.map +1 -0
  83. package/dist/components/ValuePickers/ValuePickers.jsdomtest.d.ts +2 -0
  84. package/dist/components/ValuePickers/ValuePickers.jsdomtest.d.ts.map +1 -0
  85. package/dist/components/ValuePickers/columnLinksMissingValue.d.ts +25 -0
  86. package/dist/components/ValuePickers/columnLinksMissingValue.d.ts.map +1 -0
  87. package/dist/components/ValuePickers/columnLinksMissingValue.js +35 -0
  88. package/dist/components/ValuePickers/columnLinksMissingValue.js.map +1 -0
  89. package/dist/components/ValuePickers/columnLinksMissingValue.jsdomtest.d.ts +2 -0
  90. package/dist/components/ValuePickers/columnLinksMissingValue.jsdomtest.d.ts.map +1 -0
  91. package/dist/components/ValuePickers/index.d.ts +276 -0
  92. package/dist/components/ValuePickers/index.d.ts.map +1 -0
  93. package/dist/components/ValuePickers/index.js +22 -0
  94. package/dist/components/ValuePickers/index.js.map +1 -0
  95. package/dist/composition/useOpenBlock.d.ts +12 -0
  96. package/dist/composition/useOpenBlock.d.ts.map +1 -0
  97. package/dist/composition/useOpenBlock.js +20 -0
  98. package/dist/composition/useOpenBlock.js.map +1 -0
  99. package/dist/composition/useOpenBlock.test.d.ts +2 -0
  100. package/dist/composition/useOpenBlock.test.d.ts.map +1 -0
  101. package/dist/defineApp.d.ts +2 -0
  102. package/dist/defineApp.d.ts.map +1 -1
  103. package/dist/defineApp.js +30 -29
  104. package/dist/defineApp.js.map +1 -1
  105. package/dist/index.js +48 -40
  106. package/dist/index.js.map +1 -1
  107. package/dist/internal/createAppV3.d.ts +3 -1
  108. package/dist/internal/createAppV3.d.ts.map +1 -1
  109. package/dist/internal/createAppV3.js +2 -1
  110. package/dist/internal/createAppV3.js.map +1 -1
  111. package/dist/lib.d.ts +5 -0
  112. package/dist/lib.d.ts.map +1 -1
  113. package/dist/lib.js +49 -38
  114. package/package.json +6 -6
  115. package/src/columnLinkViews.test.ts +540 -0
  116. package/src/columnLinkViews.ts +368 -0
  117. package/src/columnLinks.ts +6 -0
  118. package/src/components/PlBlockDependencies/PlBlockDependencies.jsdomtest.ts +101 -0
  119. package/src/components/PlBlockDependencies/PlBlockDependencies.vue +132 -0
  120. package/src/components/PlBlockDependencies/fold.ts +85 -0
  121. package/src/components/PlBlockDependencies/index.ts +1 -0
  122. package/src/components/PlBlockName/PlBlockName.jsdomtest.ts +52 -0
  123. package/src/components/PlBlockName/PlBlockName.vue +56 -0
  124. package/src/components/PlBlockName/index.ts +1 -0
  125. package/src/components/PlColumnValueDropdown/PlColumnValueDropdown.jsdomtest.ts +144 -0
  126. package/src/components/PlColumnValueDropdown/PlColumnValueDropdown.vue +50 -0
  127. package/src/components/PlColumnValueDropdown/PlColumnValueDropdownMulti.vue +50 -0
  128. package/src/components/PlColumnValueDropdown/index.ts +4 -0
  129. package/src/components/PlColumnValueDropdown/settings.test.ts +86 -0
  130. package/src/components/PlColumnValueDropdown/settings.ts +59 -0
  131. package/src/components/PlColumnValueDropdown/useColumnValueOptions.test.ts +114 -0
  132. package/src/components/PlColumnValueDropdown/useColumnValueOptions.ts +77 -0
  133. package/src/components/PlDatasetSelector/PlDatasetSelector.vue +36 -1
  134. package/src/components/PlDatasetSelector/__tests__/missingValueHint.jsdomtest.ts +81 -0
  135. package/src/components/ValuePickers/ValuePickers.jsdomtest.ts +77 -0
  136. package/src/components/ValuePickers/columnLinksMissingValue.jsdomtest.ts +82 -0
  137. package/src/components/ValuePickers/columnLinksMissingValue.ts +56 -0
  138. package/src/components/ValuePickers/index.ts +66 -0
  139. package/src/composition/useOpenBlock.test.ts +49 -0
  140. package/src/composition/useOpenBlock.ts +41 -0
  141. package/src/defineApp.ts +8 -8
  142. package/src/internal/createAppV3.ts +6 -1
  143. package/src/lib.ts +14 -0
@@ -0,0 +1,540 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import {
3
+ createColumnValueId,
4
+ createGlobalPObjectId,
5
+ type ColumnLink,
6
+ type ColumnValue,
7
+ type LinkCheck,
8
+ } from "@platforma-sdk/model";
9
+ import {
10
+ ALERTS,
11
+ blockName,
12
+ describeMissingValue,
13
+ linkAlerts,
14
+ linkSections,
15
+ type LinkSection,
16
+ } from "./columnLinkViews";
17
+
18
+ const REF = createGlobalPObjectId("producer", "out");
19
+
20
+ describe("linkSections", () => {
21
+ test("yields both sides, also when they have no links", () => {
22
+ const sections = linkSections({
23
+ dependents: [],
24
+ dependencies: [],
25
+ });
26
+ expect(sections.map((section) => [section.side, section.rows])).toEqual([
27
+ ["usedBy", []],
28
+ ["uses", []],
29
+ ]);
30
+ });
31
+
32
+ test("merges picks of one block from one output, keeping a whole-column use apart", () => {
33
+ const [usedBy] = linkSections({
34
+ dependents: [
35
+ dependent("b1", "out", ["1", "a"]),
36
+ dependent("b1", "out", ["1", "b"]),
37
+ dependent("b1", "out", null),
38
+ dependent("b2", "out", ["a"]),
39
+ ],
40
+ dependencies: [],
41
+ });
42
+ expect(usedBy.rows.map((row) => [blockName(LABELS, row.blockId), row.values])).toEqual([
43
+ ["Enrichment", ["1", "a", "b"]],
44
+ ["Enrichment", null],
45
+ ["Block b2", ["a"]],
46
+ ]);
47
+ });
48
+
49
+ test("keeps the column label, and the output name apart from it", () => {
50
+ const [, uses] = linkSections({
51
+ dependents: [],
52
+ dependencies: [
53
+ dependency("p1", "out1", null, { type: "unavailable" }),
54
+ dependency("p1", "out2", null, { type: "ok" }, "Condition"),
55
+ ],
56
+ });
57
+ expect(uses.rows.map((row) => [row.column.name, row.columnLabel])).toEqual([
58
+ ["out1", null],
59
+ ["out2", "Condition"],
60
+ ]);
61
+ });
62
+
63
+ test("takes a label from any merged reference", () => {
64
+ const [, uses] = linkSections({
65
+ dependents: [],
66
+ dependencies: [
67
+ dependency("p1", "out", ["a"], { type: "pending" }),
68
+ dependency("p1", "out", ["b"], { type: "ok" }, "Condition"),
69
+ ],
70
+ });
71
+ expect(uses.rows[0].columnLabel).toBe("Condition");
72
+ });
73
+
74
+ test("merged references take the status needing attention most, uniting missing values", () => {
75
+ const [, uses] = linkSections({
76
+ dependents: [],
77
+ dependencies: [
78
+ dependency("p1", "out", ["a"], { type: "ok" }),
79
+ dependency("p1", "out", ["b"], { type: "unreadable" }),
80
+ dependency("p1", "out", ["c"], { type: "pending" }),
81
+ dependency("p2", "out", ["a"], missingValues(["1"])),
82
+ dependency("p2", "out", ["b"], missingValues(["1", "b"])),
83
+ dependency("p2", "out", ["c"], { type: "ok" }),
84
+ dependency("p3", "out", ["a"], missingValues(["a"])),
85
+ dependency("p3", "out", ["b"], { type: "unavailable" }),
86
+ ],
87
+ });
88
+ expect(uses.rows.map((row) => row.check)).toEqual([
89
+ { type: "pending" },
90
+ { type: "missingValues", values: ["1", "b"] },
91
+ { type: "unavailable" },
92
+ ]);
93
+ });
94
+
95
+ test("missing values of a dependent block are listed as they are", () => {
96
+ const [usedBy] = linkSections({
97
+ dependents: [dependent("b1", "out", ["a"], { type: "missingValues", values: ["2"] })],
98
+ dependencies: [],
99
+ });
100
+ expect(usedBy.rows[0].check).toEqual({ type: "missingValues", values: ["2"] });
101
+ });
102
+
103
+ test("an output another block uses and this block does not export is not exported", () => {
104
+ const [usedBy] = linkSections({
105
+ dependents: [dependent("b1", "out", ["a"], notExported())],
106
+ dependencies: [],
107
+ });
108
+ expect(usedBy.rows.map((row) => row.check)).toEqual([{ type: "unavailable" }]);
109
+ });
110
+
111
+ test("keeps the reason a link was not checked on both sides", () => {
112
+ const [usedBy, uses] = linkSections({
113
+ dependents: [dependent("b1", "out", ["a"], { type: "unreadable" })],
114
+ dependencies: [dependency("p1", "out", ["a"], { type: "unreadable" })],
115
+ });
116
+ const statuses = [{ type: "unreadable" }];
117
+ expect(usedBy.rows.map((row) => row.check)).toEqual(statuses);
118
+ expect(uses.rows.map((row) => row.check)).toEqual(statuses);
119
+ });
120
+
121
+ test("an output of a block not run keeps that state on both sides", () => {
122
+ const [usedBy, uses] = linkSections({
123
+ dependents: [dependent("b1", "out", ["a"], { type: "notRun" })],
124
+ dependencies: [dependency("p1", "out", ["a"], { type: "notRun" })],
125
+ });
126
+ expect(usedBy.rows.map((row) => row.check)).toEqual([{ type: "notRun" }]);
127
+ expect(uses.rows.map((row) => row.check)).toEqual([{ type: "notRun" }]);
128
+ });
129
+ });
130
+
131
+ describe("linkAlerts", () => {
132
+ test("lists only links that are broken or lack values, one alert per side", () => {
133
+ const sections = linkSections({
134
+ dependents: [
135
+ dependent("b1", "out", ["x", "y"], { type: "missingValues", values: ["x", "y"] }),
136
+ dependent("b1", "other", ["x"], notExported()),
137
+ dependent("b1", "third", ["x"], { type: "unreadable" }),
138
+ ],
139
+ dependencies: [
140
+ dependency("p1", "out1", null, { type: "unavailable" }),
141
+ dependency("p1", "out2", ["a"], missingValues(["a"]), "Condition"),
142
+ dependency("p1", "out3", ["a"], { type: "pending" }),
143
+ dependency("p1", "out4", null, { type: "ok" }),
144
+ ],
145
+ });
146
+ expect(
147
+ linkAlerts(sections).map((alert) => [
148
+ alert.side,
149
+ ALERTS[alert.side].label,
150
+ ALERTS[alert.side].hint,
151
+ alert.issues.map((issue) => `${blockName(LABELS, issue.blockId)} ${issue.text}`),
152
+ ]),
153
+ ).toEqual([
154
+ [
155
+ "usedBy",
156
+ "Some blocks are missing data from this block",
157
+ "Checked against the last run of this block. Add the missing data and run it, or " +
158
+ "reconfigure those blocks.",
159
+ [
160
+ 'Enrichment uses "x", "y", which this block\'s data no longer has',
161
+ "Enrichment uses data this block does not export",
162
+ ],
163
+ ],
164
+ [
165
+ "uses",
166
+ "Links to blocks this block takes data from are broken",
167
+ null,
168
+ ["Samples does not provide data this block uses", 'Samples has no "a" in "Condition"'],
169
+ ],
170
+ ]);
171
+ });
172
+
173
+ test("names a column by its quoted label", () => {
174
+ const alerts = linkAlerts(
175
+ linkSections({
176
+ dependents: [
177
+ dependent("b1", "out", ["x"], notExported(), "Clonotypes"),
178
+ dependent("b1", "other", ["x"], { type: "missingValues", values: ["x"] }, "Samples"),
179
+ ],
180
+ dependencies: [
181
+ dependency("p1", "out", null, { type: "unavailable" }, "Condition"),
182
+ dependency("p1", "other", ["a"], missingValues(["a"]), "Condition"),
183
+ ],
184
+ }),
185
+ );
186
+ expect(alerts.map((alert) => alert.issues.map((issue) => issue.text))).toEqual([
187
+ [
188
+ 'uses "Clonotypes", which this block does not export',
189
+ 'uses "x" of "Samples", which this block no longer has',
190
+ ],
191
+ ['does not provide "Condition"', 'has no "a" in "Condition"'],
192
+ ]);
193
+ });
194
+
195
+ test("says the links are checked against the last run of this block", () => {
196
+ const [usedBy] = linkAlerts(
197
+ linkSections({
198
+ dependents: [dependent("b1", "out", ["a"], notExported())],
199
+ dependencies: [],
200
+ }),
201
+ );
202
+
203
+ expect(usedBy?.side).toBe("usedBy");
204
+ expect(ALERTS.usedBy.hint).toBe(
205
+ "Checked against the last run of this block. Add the missing data and run it, or " +
206
+ "reconfigure those blocks.",
207
+ );
208
+ });
209
+
210
+ test("never names an output by its name, which is kept for a hint", () => {
211
+ const [usedBy, uses] = linkAlerts(
212
+ linkSections({
213
+ dependents: [
214
+ dependent("b1", "pf.dataset.X", null, notExported()),
215
+ dependent("b1", "pf.metadata.Y", ["a"], { type: "missingValues", values: ["a"] }),
216
+ ],
217
+ dependencies: [
218
+ dependency("p1", "pf.dataset.X", null, { type: "unavailable" }),
219
+ dependency("p1", "pf.metadata.Y", ["a"], missingValues(["a"])),
220
+ ],
221
+ }),
222
+ );
223
+ const issues = [...usedBy.issues, ...uses.issues];
224
+ for (const issue of issues) expect(issue.text).not.toMatch(/pf\./);
225
+ expect(issues.map((issue) => issue.outputs)).toEqual([
226
+ ["pf.dataset.X"],
227
+ ["pf.metadata.Y"],
228
+ ["pf.dataset.X"],
229
+ ["pf.metadata.Y"],
230
+ ]);
231
+ });
232
+
233
+ test("outputs of one block that are not exported and have no label share a line", () => {
234
+ const [usedBy, uses] = linkAlerts(
235
+ linkSections({
236
+ dependents: [
237
+ dependent("b1", "out1", ["a"], notExported()),
238
+ dependent("b1", "out1", null, notExported()),
239
+ dependent("b2", "out1", null, notExported()),
240
+ dependent("b1", "out2", null, notExported()),
241
+ dependent("b1", "out3", null, notExported(), "Clonotypes"),
242
+ ],
243
+ dependencies: [
244
+ dependency("p1", "out1", null, { type: "unavailable" }),
245
+ dependency("p1", "out2", ["a"], { type: "unavailable" }),
246
+ ],
247
+ }),
248
+ );
249
+ expect(
250
+ usedBy.issues.map((issue) => [blockName(LABELS, issue.blockId), issue.text, issue.outputs]),
251
+ ).toEqual([
252
+ ["Enrichment", "uses 2 outputs this block does not export", ["out1", "out2"]],
253
+ ["Block b2", "uses data this block does not export", ["out1"]],
254
+ ["Enrichment", 'uses "Clonotypes", which this block does not export', ["out3"]],
255
+ ]);
256
+ expect(
257
+ uses.issues.map((issue) => [blockName(LABELS, issue.blockId), issue.text, issue.outputs]),
258
+ ).toEqual([["Samples", "does not provide 2 outputs this block uses", ["out1", "out2"]]]);
259
+ });
260
+
261
+ test("issues name the other block by id, for opening it", () => {
262
+ const [usedBy] = linkAlerts(
263
+ linkSections({
264
+ dependents: [dependent("b1", "out", ["a"], notExported())],
265
+ dependencies: [],
266
+ }),
267
+ );
268
+ expect(usedBy.issues.map((issue) => [issue.blockId, blockName(LABELS, issue.blockId)])).toEqual(
269
+ [["b1", "Enrichment"]],
270
+ );
271
+ });
272
+
273
+ test("a side with no links needing attention has no alert", () => {
274
+ const alerts = linkAlerts(
275
+ linkSections({
276
+ dependents: [dependent("b1", "out", ["a"], { type: "pending" })],
277
+ dependencies: [dependency("p1", "out", null, { type: "ok" })],
278
+ }),
279
+ );
280
+ expect(alerts).toEqual([]);
281
+ });
282
+
283
+ test("links to a block that has not run say it does not provide the data", () => {
284
+ const [usedBy, uses] = linkAlerts(
285
+ linkSections({
286
+ dependents: [dependent("b1", "out", ["a"], { type: "notRun" }, "Path")],
287
+ dependencies: [dependency("p1", "out", null, { type: "notRun" }, "Path")],
288
+ }),
289
+ );
290
+ expect([ALERTS.usedBy.type, ALERTS.usedBy.hint]).toEqual([
291
+ "warn",
292
+ "Checked against the last run of this block. Add the missing data and run it, or " +
293
+ "reconfigure those blocks.",
294
+ ]);
295
+ expect(usedBy.issues.map((issue) => issue.text)).toEqual([
296
+ 'uses "Path", which this block does not export',
297
+ ]);
298
+ expect([ALERTS.uses.type, ALERTS.uses.hint]).toEqual(["error", null]);
299
+ expect(uses.issues.map((issue) => issue.text)).toEqual(['does not provide "Path"']);
300
+ });
301
+
302
+ test("broken links this block uses are an error", () => {
303
+ const [uses] = linkAlerts(
304
+ linkSections({
305
+ dependents: [],
306
+ dependencies: [dependency("p1", "out", ["a"], missingValues(["a"]))],
307
+ }),
308
+ );
309
+ expect([uses.side, ALERTS.uses.type]).toEqual(["uses", "error"]);
310
+ });
311
+
312
+ test("blocks using an output this block does not export are a warning", () => {
313
+ const [usedBy] = linkAlerts(
314
+ linkSections({
315
+ dependents: [
316
+ dependent("b1", "out", ["a"], { type: "missingValues", values: ["a"] }),
317
+ dependent("b2", "out", ["a"], notExported()),
318
+ ],
319
+ dependencies: [],
320
+ }),
321
+ );
322
+ expect([usedBy.side, ALERTS.usedBy.type]).toEqual(["usedBy", "warn"]);
323
+ });
324
+
325
+ test("blocks picking values this block's output lacks are a warning", () => {
326
+ const [usedBy] = linkAlerts(
327
+ linkSections({
328
+ dependents: [dependent("b1", "out", ["a"], { type: "missingValues", values: ["a"] })],
329
+ dependencies: [],
330
+ }),
331
+ );
332
+ expect([usedBy.side, ALERTS.usedBy.type]).toEqual(["usedBy", "warn"]);
333
+ });
334
+
335
+ test("keys are unique across sides", () => {
336
+ const sections: LinkSection[] = linkSections({
337
+ dependents: [dependent("p1", "out", ["a"], { type: "missingValues", values: ["a"] })],
338
+ dependencies: [dependency("p1", "out", ["a"], missingValues(["a"]))],
339
+ });
340
+ const keys = linkAlerts(sections).flatMap((alert) => alert.issues.map((issue) => issue.key));
341
+ expect(keys).toHaveLength(2);
342
+ expect(new Set(keys).size).toBe(keys.length);
343
+ });
344
+ });
345
+
346
+ describe("blockName", () => {
347
+ test("falls back to a short id", () => {
348
+ expect(blockName({ b1: "Enrichment" }, "b1")).toBe("Enrichment");
349
+ expect(blockName({}, "0123456789abcdef")).toBe("Block 01234567");
350
+ });
351
+ });
352
+
353
+ // Internals
354
+
355
+ /** Labels of the other blocks the links name. */
356
+ const LABELS = { b1: "Enrichment", p1: "Samples" };
357
+
358
+ /** The block whose links these are. */
359
+ const THIS = "this";
360
+
361
+ const PATH = createGlobalPObjectId("samples", "metadata.path");
362
+ const ty1 = createColumnValueId({ column: PATH, value: "Ty1" });
363
+
364
+ describe("describeMissingValue", () => {
365
+ test("names the block that does not provide the column", () => {
366
+ const cause = describeMissingValue([pathEntry({ type: "unavailable" })], ty1);
367
+ expect(cause).toEqual({
368
+ type: "source",
369
+ name: "Ty1",
370
+ blockId: "samples",
371
+ text: "does not provide “Path”.",
372
+ });
373
+ });
374
+
375
+ test("names the block whose column lacks the value", () => {
376
+ const cause = describeMissingValue(
377
+ [pathEntry({ type: "missingValues", values: ["Ty1"] })],
378
+ ty1,
379
+ );
380
+ expect(cause?.text).toBe("has no “Ty1” in “Path”.");
381
+ });
382
+
383
+ test("tells nothing of a value the column still has", () => {
384
+ const cause = describeMissingValue(
385
+ [pathEntry({ type: "missingValues", values: ["Ty2"] })],
386
+ ty1,
387
+ );
388
+ expect(cause).toBeUndefined();
389
+ });
390
+
391
+ test("names a block that has not been run as not providing the column", () => {
392
+ const cause = describeMissingValue([pathEntry({ type: "notRun" })], ty1);
393
+ expect(cause?.text).toBe("does not provide “Path”.");
394
+ });
395
+
396
+ test("names the block still computing the column", () => {
397
+ const cause = describeMissingValue([pathEntry({ type: "pending" })], ty1);
398
+ expect(cause?.text).toBe("is still computing “Path”.");
399
+ });
400
+
401
+ test("tells nothing of a column that is fine or was not checked", () => {
402
+ for (const status of [{ type: "ok" }, { type: "unreadable" }] satisfies LinkCheck[]) {
403
+ expect(describeMissingValue([pathEntry(status)], ty1)).toBeUndefined();
404
+ }
405
+ });
406
+
407
+ test("tells a provided column waits for the other inputs of the block", () => {
408
+ for (const status of [
409
+ { type: "notRun" },
410
+ { type: "pending" },
411
+ { type: "unavailable" },
412
+ ] satisfies LinkCheck[]) {
413
+ const dependencies = [pathEntry({ type: "ok" }), abundanceEntry(status)];
414
+ const text = "Waiting for the other inputs of this block.";
415
+ expect(describeMissingValue(dependencies, PATH)).toEqual({
416
+ type: "waiting",
417
+ name: "Path",
418
+ text,
419
+ });
420
+ expect(describeMissingValue(dependencies, ty1)).toEqual({
421
+ type: "waiting",
422
+ name: "Ty1",
423
+ text,
424
+ });
425
+ }
426
+ });
427
+
428
+ test("does not tell a column waits while it lacks the value or was not checked", () => {
429
+ const abundance = abundanceEntry({ type: "notRun" });
430
+ const lacking = pathEntry({ type: "missingValues", values: ["Ty1"] });
431
+ expect(describeMissingValue([lacking, abundance], ty1)?.text).toBe("has no “Ty1” in “Path”.");
432
+ const unchecked = pathEntry({ type: "unreadable" });
433
+ expect(describeMissingValue([unchecked, abundance], ty1)).toBeUndefined();
434
+ });
435
+
436
+ test("does not tell a column waits while every other input is fine", () => {
437
+ const dependencies = [pathEntry({ type: "ok" }), abundanceEntry({ type: "unreadable" })];
438
+ expect(describeMissingValue(dependencies, ty1)).toBeUndefined();
439
+ });
440
+
441
+ test("names a column without a label by its role", () => {
442
+ const cause = describeMissingValue([pathEntry({ type: "pending" }, null)], ty1);
443
+ expect(cause).toEqual({
444
+ type: "source",
445
+ name: "Ty1",
446
+ blockId: "samples",
447
+ text: "is still computing the column.",
448
+ });
449
+ });
450
+
451
+ test("names the block that does not provide a column selected as a whole, by id or ref", () => {
452
+ const deps = [pathEntry({ type: "unavailable" })];
453
+ expect(describeMissingValue(deps, PATH)?.text).toBe("does not provide “Path”.");
454
+ expect(describeMissingValue(deps, PATH)?.name).toBe("Path");
455
+ expect(
456
+ describeMissingValue(deps, { __isRef: true, blockId: "samples", name: "metadata.path" })
457
+ ?.text,
458
+ ).toBe("does not provide “Path”.");
459
+ });
460
+
461
+ test("tells nothing of a column selected as a whole that lacks values picked elsewhere", () => {
462
+ const deps = [pathEntry({ type: "missingValues", values: ["Ty1"] })];
463
+ expect(describeMissingValue(deps, PATH)).toBeUndefined();
464
+ });
465
+
466
+ test("tells nothing of a value that is not a column value id, or of another column", () => {
467
+ const deps = [pathEntry({ type: "unavailable" })];
468
+ expect(describeMissingValue(deps, "Ty1")).toBeUndefined();
469
+ expect(describeMissingValue(deps, { ref: PATH })).toBeUndefined();
470
+ const other = createColumnValueId({
471
+ column: createGlobalPObjectId("samples", "metadata.round"),
472
+ value: "Ty1",
473
+ });
474
+ expect(describeMissingValue(deps, other)).toBeUndefined();
475
+ });
476
+ });
477
+
478
+ function dependent(
479
+ holderBlockId: string,
480
+ output: string,
481
+ values: null | ColumnValue[],
482
+ check: LinkCheck = { type: "ok" },
483
+ columnLabel: null | string = null,
484
+ ): ColumnLink {
485
+ return {
486
+ producer: { blockId: THIS, name: output },
487
+ holderBlockId,
488
+ ref: REF,
489
+ values,
490
+ columnLabel,
491
+ check,
492
+ };
493
+ }
494
+
495
+ function dependency(
496
+ producerBlockId: string,
497
+ output: string,
498
+ values: null | ColumnValue[],
499
+ check: LinkCheck,
500
+ columnLabel: null | string = null,
501
+ ): ColumnLink {
502
+ return {
503
+ producer: { blockId: producerBlockId, name: output },
504
+ holderBlockId: THIS,
505
+ ref: REF,
506
+ values,
507
+ columnLabel,
508
+ check,
509
+ };
510
+ }
511
+
512
+ function missingValues(values: ColumnValue[]): LinkCheck {
513
+ return { type: "missingValues", values };
514
+ }
515
+
516
+ function notExported(): LinkCheck {
517
+ return { type: "unavailable" };
518
+ }
519
+
520
+ function abundanceEntry(check: LinkCheck): ColumnLink {
521
+ return {
522
+ producer: { blockId: "mixcr", name: "abundance" },
523
+ holderBlockId: THIS,
524
+ ref: REF,
525
+ values: null,
526
+ columnLabel: "Abundance",
527
+ check,
528
+ };
529
+ }
530
+
531
+ function pathEntry(check: LinkCheck, columnLabel: null | string = "Path"): ColumnLink {
532
+ return {
533
+ producer: { blockId: "samples", name: "metadata.path" },
534
+ holderBlockId: THIS,
535
+ ref: PATH,
536
+ values: ["Ty1"],
537
+ columnLabel,
538
+ check,
539
+ };
540
+ }