@airalogy/aimd-recorder 1.22.0 → 1.24.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.
- package/README.md +80 -0
- package/README.zh-CN.md +80 -0
- package/dist/{AimdCodeField-BN_0UQMx.js → AimdCodeField-CPjcXY4D.js} +1 -1
- package/dist/{AimdDnaSequenceField-Bhj28fP8.js → AimdDnaSequenceField-Dz-IONoA.js} +5 -4
- package/dist/{AimdEditor.vue_vue_type_style_index_0_lang-D7c01UqN.js → AimdEditor.vue_vue_type_style_index_0_lang-JAD--qFs.js} +1999 -1900
- package/dist/AimdEntityRefField-BE0s2o5T.js +229 -0
- package/dist/{AimdMarkdownField-GS15pv4z.js → AimdMarkdownField-BeD2t9JY.js} +5 -5
- package/dist/{AimdMarkdownNoteField-H9WP8tR6.js → AimdMarkdownNoteField-DIgGEYpj.js} +16 -16
- package/dist/{_commonjsHelpers-B5RozER-.js → _commonjsHelpers-ByX85dGu.js} +12 -19
- package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
- package/dist/aimd-recorder.css +1 -1
- package/dist/{arc-B50G9-kH.js → arc-CLJJdrm0.js} +1 -1
- package/dist/{architectureDiagram-3BPJPVTR-D9mBEbpY.js → architectureDiagram-3BPJPVTR-BizrFPnS.js} +3 -3
- package/dist/{blockDiagram-GPEHLZMM-Cs4swgto.js → blockDiagram-GPEHLZMM-IHDih8JW.js} +4 -4
- package/dist/{c4Diagram-AAUBKEIU-C12HKS3r.js → c4Diagram-AAUBKEIU-BQtg8m_M.js} +2 -2
- package/dist/{channel-D69VnjVz.js → channel-D8q7AX1Z.js} +1 -1
- package/dist/{chunk-2J33WTMH-oc-89G5c.js → chunk-2J33WTMH-C24lbKon.js} +1 -1
- package/dist/{chunk-4BX2VUAB-BDJS9G3r.js → chunk-4BX2VUAB-1m_lB_xe.js} +1 -1
- package/dist/{chunk-55IACEB6-BPl3uHcA.js → chunk-55IACEB6-BE5Nj-sd.js} +1 -1
- package/dist/{chunk-727SXJPM-pWe-vDGf.js → chunk-727SXJPM-Cg-Xw_d_.js} +5 -5
- package/dist/{chunk-AQP2D5EJ-D-R5sIr1.js → chunk-AQP2D5EJ-BvRpPCiY.js} +3 -3
- package/dist/{chunk-FMBD7UC4-bo6Qyom1.js → chunk-FMBD7UC4-D_44MTsg.js} +1 -1
- package/dist/{chunk-ND2GUHAM-DQMvtYV7.js → chunk-ND2GUHAM-tVBIo4LA.js} +1 -1
- package/dist/{chunk-QZHKN3VN-DlCn3HON.js → chunk-QZHKN3VN-B91HYLks.js} +1 -1
- package/dist/{classDiagram-v2-Q7XG4LA2-DzUwWFwr.js → classDiagram-4FO5ZUOK-CkejvTAN.js} +2 -2
- package/dist/{classDiagram-4FO5ZUOK-DzUwWFwr.js → classDiagram-v2-Q7XG4LA2-CkejvTAN.js} +2 -2
- package/dist/components.js +3869 -3359
- package/dist/composables.js +98 -93
- package/dist/{cose-bilkent-S5V4N54A-BXLMzfpO.js → cose-bilkent-S5V4N54A-CNcuriOF.js} +2 -2
- package/dist/{dagre-BM42HDAG-DHnofIh9.js → dagre-BM42HDAG-DMqFGafq.js} +3 -3
- package/dist/{diagram-2AECGRRQ-BqTTVPsm.js → diagram-2AECGRRQ-Cksd3pP3.js} +2 -2
- package/dist/{diagram-5GNKFQAL-D5p1UVbw.js → diagram-5GNKFQAL-SVjLnDJG.js} +3 -3
- package/dist/{diagram-KO2AKTUF-Uuoz9cFn.js → diagram-KO2AKTUF-DfNIAG6w.js} +2 -2
- package/dist/{diagram-LMA3HP47-W001U31X.js → diagram-LMA3HP47-DPOyCMGB.js} +2 -2
- package/dist/{diagram-OG6HWLK6-DL516LDr.js → diagram-OG6HWLK6-BDURmT37.js} +3 -3
- package/dist/{erDiagram-TEJ5UH35-CCxgMb67.js → erDiagram-TEJ5UH35-N991qII9.js} +4 -4
- package/dist/{flowDiagram-I6XJVG4X-nXGdmC0O.js → flowDiagram-I6XJVG4X-BABRFuk-.js} +6 -6
- package/dist/{ganttDiagram-6RSMTGT7-Bi9Ro7_Z.js → ganttDiagram-6RSMTGT7-BMDnK96S.js} +3 -3
- package/dist/{gitGraphDiagram-PVQCEYII-w1kNAy4E.js → gitGraphDiagram-PVQCEYII-cEvL7Dss.js} +3 -3
- package/dist/{graph-CpOkL_eZ.js → graph-BA09aCvZ.js} +1 -1
- package/dist/index.js +125 -113
- package/dist/{infoDiagram-5YYISTIA-Bde_w9T1.js → infoDiagram-5YYISTIA-DpC1Zthd.js} +1 -1
- package/dist/{ishikawaDiagram-YF4QCWOH-x5M1KR0l.js → ishikawaDiagram-YF4QCWOH-CMEt_f-x.js} +1 -1
- package/dist/{journeyDiagram-JHISSGLW-CIDQP8Zm.js → journeyDiagram-JHISSGLW-C0Qw169C.js} +4 -4
- package/dist/{kanban-definition-UN3LZRKU-CKgO7sG8.js → kanban-definition-UN3LZRKU-caROmSUy.js} +2 -2
- package/dist/{layout-BZYprqYR.js → layout-CH65__O4.js} +2 -2
- package/dist/{linear-ClSH2F_v.js → linear-B1VXpcsy.js} +1 -1
- package/dist/{mermaid.core-CcRV6K2R.js → mermaid.core-Cbmwvfvk.js} +35 -35
- package/dist/{mindmap-definition-RKZ34NQL-s3h6uszV.js → mindmap-definition-RKZ34NQL-DpTR5ilS.js} +3 -3
- package/dist/{pieDiagram-4H26LBE5-CgiazyWv.js → pieDiagram-4H26LBE5-Cb_KrmWC.js} +3 -3
- package/dist/{quadrantDiagram-W4KKPZXB-DCPVgHoW.js → quadrantDiagram-W4KKPZXB-B5_NswmK.js} +2 -2
- package/dist/record.js +77 -72
- package/dist/{requirementDiagram-4Y6WPE33-DE6F9oSB.js → requirementDiagram-4Y6WPE33-OFwfat5D.js} +3 -3
- package/dist/{sankeyDiagram-5OEKKPKP-DZZoFFr-.js → sankeyDiagram-5OEKKPKP-BaawdZEE.js} +1 -1
- package/dist/{sequenceDiagram-3UESZ5HK-DaYEOl60.js → sequenceDiagram-3UESZ5HK-DLv8X8ef.js} +3 -3
- package/dist/{stateDiagram-AJRCARHV-BmgpHJlH.js → stateDiagram-AJRCARHV-B6F3wrsd.js} +4 -4
- package/dist/{stateDiagram-v2-BHNVJYJU-D49CHQD6.js → stateDiagram-v2-BHNVJYJU-BcNEoshv.js} +2 -2
- package/dist/{timeline-definition-PNZ67QCA-DdVLoCkC.js → timeline-definition-PNZ67QCA-CvdHJ4eQ.js} +2 -2
- package/dist/useCodeBlockRendering-D2viVPtA.js +3158 -0
- package/dist/useFieldRendering-Co4DOOvL.js +1120 -0
- package/dist/useVarHelpers-Du2obGza.js +3474 -0
- package/dist/validation-oyqyD7Jp.js +5601 -0
- package/dist/{vennDiagram-CIIHVFJN-CCcMKcd7.js → vennDiagram-CIIHVFJN-U0GlQDjX.js} +1 -1
- package/dist/{wardleyDiagram-YWT4CUSO-R4UGgGWY.js → wardleyDiagram-YWT4CUSO-CzF_KMcn.js} +2 -2
- package/dist/{xychartDiagram-2RQKCTM6-DyFhCubk.js → xychartDiagram-2RQKCTM6-Cljki2Vk.js} +2 -2
- package/package.json +6 -4
- package/src/__tests__/collector-field.test.ts +269 -0
- package/src/__tests__/record-search-render.test.ts +1 -0
- package/src/__tests__/record-validation.test.ts +378 -0
- package/src/__tests__/recorder-wysiwyg-field-host.test.ts +26 -0
- package/src/__tests__/var-field-render.test.ts +64 -2
- package/src/components/AimdCollectorField.vue +233 -0
- package/src/components/AimdEntityRefField.vue +314 -0
- package/src/components/AimdRecorder.vue +285 -7
- package/src/components/AimdRecorderEditor.vue +51 -1
- package/src/components/AimdRecorderWysiwygFieldHost.vue +10 -0
- package/src/components/AimdRecorderWysiwygSurface.vue +166 -4
- package/src/components/AimdVarField.vue +39 -2
- package/src/components/AimdVarTableField.vue +38 -21
- package/src/components/index.ts +4 -0
- package/src/components/recorderMilkdownPlugin.ts +16 -0
- package/src/composables/__tests__/useVarHelpers.test.ts +32 -0
- package/src/composables/index.ts +12 -0
- package/src/composables/useCollectors.ts +399 -0
- package/src/composables/useVarHelpers.ts +130 -2
- package/src/index.ts +32 -2
- package/src/locales.ts +140 -2
- package/src/record/index.ts +14 -0
- package/src/record/validation.ts +772 -0
- package/src/styles/collector-field.css +281 -0
- package/src/styles/recorder-surface.css +163 -0
- package/src/styles/recorder.css +33 -0
- package/src/types.ts +168 -1
- package/dist/index-Dkrf2LJl.js +0 -1308
- package/dist/useCodeBlockRendering-CCuoP52e.js +0 -6103
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aU as Gt, s as Wt, g as Kt, t as Ht, q as Yt, a as Xt, b as Zt, _ as w, F as wt, L as Jt, d as ot, al as Qt, ac as $t, ad as te, ae as ee, e as ne, A as se, H as ie, I as oe } from "./mermaid.core-
|
|
1
|
+
import { aU as Gt, s as Wt, g as Kt, t as Ht, q as Yt, a as Xt, b as Zt, _ as w, F as wt, L as Jt, d as ot, al as Qt, ac as $t, ad as te, ae as ee, e as ne, A as se, H as ie, I as oe } from "./mermaid.core-Cbmwvfvk.js";
|
|
2
2
|
const kt = (t, n) => Gt(t, "a", -n), _t = 1e-10;
|
|
3
3
|
function st(t, n) {
|
|
4
4
|
const s = ae(t), e = s.filter((c) => re(c, t));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { s as Mt, g as Nt, t as Lt, q as zt, a as Tt, b as At, _ as u, a1 as Xt, F as Et, H as J, l as Q, L as Yt, e as It, A as Ft, c as V } from "./mermaid.core-
|
|
2
|
-
import { p as Bt } from "./chunk-4BX2VUAB-
|
|
1
|
+
import { s as Mt, g as Nt, t as Lt, q as zt, a as Tt, b as At, _ as u, a1 as Xt, F as Et, H as J, l as Q, L as Yt, e as It, A as Ft, c as V } from "./mermaid.core-Cbmwvfvk.js";
|
|
2
|
+
import { p as Bt } from "./chunk-4BX2VUAB-1m_lB_xe.js";
|
|
3
3
|
import { p as Rt } from "./wardley-L42UT6IY-D7b2ujEZ.js";
|
|
4
4
|
var G = /* @__PURE__ */ u((o, r) => {
|
|
5
5
|
const e = o <= 1 ? o * 100 : o;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { s as gi, g as xi, t as Xt, q as di, a as fi, b as pi, _ as a, l as Yt, L as mi, e as yi, A as bi, F as _t, i as Ai, H as Nt, I as wi, a1 as Ci, am as Si, a9 as Wt } from "./mermaid.core-
|
|
1
|
+
import { s as gi, g as xi, t as Xt, q as di, a as fi, b as pi, _ as a, l as Yt, L as mi, e as yi, A as bi, F as _t, i as Ai, H as Nt, I as wi, a1 as Ci, am as Si, a9 as Wt } from "./mermaid.core-Cbmwvfvk.js";
|
|
2
2
|
import { i as _i } from "./init-DjUOC4st.js";
|
|
3
3
|
import { o as ki } from "./ordinal-B6-f3MAq.js";
|
|
4
|
-
import { l as zt } from "./linear-
|
|
4
|
+
import { l as zt } from "./linear-B1VXpcsy.js";
|
|
5
5
|
function Ri(e, t, i) {
|
|
6
6
|
e = +e, t = +t, i = (n = arguments.length) < 2 ? (t = e, e = 0, 1) : n < 3 ? 1 : +i;
|
|
7
7
|
for (var s = -1, n = Math.max(0, Math.ceil((t - e) / i)) | 0, o = new Array(n); ++s < n; )
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airalogy/aimd-recorder",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.24.0",
|
|
5
5
|
"description": "AIMD (Airalogy Markdown) recorder Vue components and UI",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -58,14 +58,16 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@milkdown/kit": "^7.18.0",
|
|
61
|
+
"ajv": "^8.12.0",
|
|
62
|
+
"ajv-formats": "^2.1.1",
|
|
61
63
|
"mermaid": "^11.15.0",
|
|
62
64
|
"monaco-editor": "^0.52.2",
|
|
63
65
|
"react": "^19.2.4",
|
|
64
66
|
"react-dom": "^19.2.4",
|
|
65
67
|
"seqviz": "^3.10.18",
|
|
66
|
-
"@airalogy/aimd-core": "^2.
|
|
67
|
-
"@airalogy/aimd-
|
|
68
|
-
"@airalogy/aimd-
|
|
68
|
+
"@airalogy/aimd-core": "^2.14.0",
|
|
69
|
+
"@airalogy/aimd-editor": "^1.11.0",
|
|
70
|
+
"@airalogy/aimd-renderer": "^2.11.1"
|
|
69
71
|
},
|
|
70
72
|
"devDependencies": {
|
|
71
73
|
"@types/node": "^24.3.0",
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { flushPromises, mount } from "@vue/test-utils"
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from "vitest"
|
|
3
|
+
import AimdRecorder from "../components/AimdRecorder.vue"
|
|
4
|
+
|
|
5
|
+
vi.mock("../components/AimdCodeField.vue", () => ({
|
|
6
|
+
__esModule: true,
|
|
7
|
+
default: {
|
|
8
|
+
name: "AimdCodeField",
|
|
9
|
+
props: ["modelValue", "language", "disabled", "compact"],
|
|
10
|
+
emits: ["update:modelValue", "blur"],
|
|
11
|
+
template: "<textarea />",
|
|
12
|
+
},
|
|
13
|
+
}))
|
|
14
|
+
|
|
15
|
+
function protocol(options: {
|
|
16
|
+
mode?: "snapshot" | "polling" | "stream"
|
|
17
|
+
interval?: string
|
|
18
|
+
manualFallback?: boolean
|
|
19
|
+
type?: string
|
|
20
|
+
} = {}): string {
|
|
21
|
+
const mode = options.mode ?? "snapshot"
|
|
22
|
+
const type = options.type ?? (mode === "snapshot" ? "Observation[float] | None" : "list[Observation[float]] | None")
|
|
23
|
+
return `
|
|
24
|
+
\`\`\`connectors
|
|
25
|
+
sensor_gateway:
|
|
26
|
+
kind: data_source
|
|
27
|
+
descriptor: ./sensor.yaml
|
|
28
|
+
\`\`\`
|
|
29
|
+
|
|
30
|
+
\`\`\`collectors
|
|
31
|
+
temperature_sensor:
|
|
32
|
+
connector: sensor_gateway
|
|
33
|
+
channel: room.temperature
|
|
34
|
+
mode: ${mode}
|
|
35
|
+
${mode === "polling" ? ` interval: ${options.interval ?? "10ms"}\n` : ""} manual_fallback: ${options.manualFallback ?? false}
|
|
36
|
+
\`\`\`
|
|
37
|
+
|
|
38
|
+
Temperature: {{var|temperature: ${type}, title="Temperature", unit="Cel", collector="temperature_sensor"}}
|
|
39
|
+
`
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function settle(wrapper: ReturnType<typeof mount>): Promise<void> {
|
|
43
|
+
await flushPromises()
|
|
44
|
+
await wrapper.vm.$nextTick()
|
|
45
|
+
await vi.dynamicImportSettled()
|
|
46
|
+
await wrapper.vm.$nextTick()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function latestRecord(wrapper: ReturnType<typeof mount>) {
|
|
50
|
+
const updates = wrapper.emitted("update:modelValue") ?? []
|
|
51
|
+
return updates[updates.length - 1]?.[0] as { var: Record<string, unknown> } | undefined
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
describe("AimdRecorder Collector fields", () => {
|
|
55
|
+
afterEach(() => {
|
|
56
|
+
vi.useRealTimers()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it("reads a snapshot through an injected provider and stores a normalized Observation", async () => {
|
|
60
|
+
const read = vi.fn().mockResolvedValue({
|
|
61
|
+
value: 23.4,
|
|
62
|
+
observed_at: "2026-07-19T08:00:00+08:00",
|
|
63
|
+
device_id: "thermometer-01",
|
|
64
|
+
quality: "measured",
|
|
65
|
+
})
|
|
66
|
+
const requestCollectorPermission = vi.fn().mockResolvedValue("record")
|
|
67
|
+
const wrapper = mount(AimdRecorder, {
|
|
68
|
+
props: {
|
|
69
|
+
content: protocol(),
|
|
70
|
+
locale: "en-US",
|
|
71
|
+
modelValue: { var: {}, step: {}, check: {}, quiz: {} },
|
|
72
|
+
collectorProviders: { sensor_gateway: { read } },
|
|
73
|
+
requestCollectorPermission,
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
await settle(wrapper)
|
|
77
|
+
|
|
78
|
+
expect(wrapper.find("textarea[data-rec-focus-key='var:temperature']").exists()).toBe(false)
|
|
79
|
+
const button = wrapper.find(".aimd-rec-collector__button--primary")
|
|
80
|
+
expect(button.text()).toBe("Read now")
|
|
81
|
+
await button.trigger("click")
|
|
82
|
+
await settle(wrapper)
|
|
83
|
+
|
|
84
|
+
expect(read).toHaveBeenCalledTimes(1)
|
|
85
|
+
expect(requestCollectorPermission).toHaveBeenCalledTimes(1)
|
|
86
|
+
const observation = latestRecord(wrapper)?.var.temperature as Record<string, any>
|
|
87
|
+
expect(observation).toMatchObject({
|
|
88
|
+
value: 23.4,
|
|
89
|
+
observed_at: "2026-07-19T00:00:00.000Z",
|
|
90
|
+
unit: "Cel",
|
|
91
|
+
quality: "measured",
|
|
92
|
+
source: {
|
|
93
|
+
kind: "collector",
|
|
94
|
+
connector: "sensor_gateway",
|
|
95
|
+
collector: "temperature_sensor",
|
|
96
|
+
device_id: "thermometer-01",
|
|
97
|
+
},
|
|
98
|
+
})
|
|
99
|
+
expect(observation.received_at).toMatch(/^\d{4}-\d{2}-\d{2}T/)
|
|
100
|
+
expect(wrapper.text()).toContain("23.4")
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it("polls without overlapping reads and stops through the field control", async () => {
|
|
104
|
+
vi.useFakeTimers()
|
|
105
|
+
let value = 20
|
|
106
|
+
const read = vi.fn(async () => ({ value: value += 1 }))
|
|
107
|
+
const wrapper = mount(AimdRecorder, {
|
|
108
|
+
props: {
|
|
109
|
+
content: protocol({ mode: "polling", interval: "10ms" }),
|
|
110
|
+
locale: "en-US",
|
|
111
|
+
modelValue: { var: {}, step: {}, check: {}, quiz: {} },
|
|
112
|
+
collectorProviders: { sensor_gateway: { read } },
|
|
113
|
+
},
|
|
114
|
+
})
|
|
115
|
+
await settle(wrapper)
|
|
116
|
+
|
|
117
|
+
await wrapper.find(".aimd-rec-collector__button--primary").trigger("click")
|
|
118
|
+
await flushPromises()
|
|
119
|
+
await vi.advanceTimersByTimeAsync(25)
|
|
120
|
+
await settle(wrapper)
|
|
121
|
+
|
|
122
|
+
expect(read.mock.calls.length).toBeGreaterThanOrEqual(3)
|
|
123
|
+
const observations = latestRecord(wrapper)?.var.temperature as Array<Record<string, unknown>>
|
|
124
|
+
expect(observations.length).toBe(read.mock.calls.length)
|
|
125
|
+
expect(observations.map(item => item.value)).toEqual(
|
|
126
|
+
Array.from({ length: observations.length }, (_, index) => 21 + index),
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
const stop = wrapper.findAll("button").find(button => button.text() === "Stop")
|
|
130
|
+
expect(stop).toBeTruthy()
|
|
131
|
+
await stop!.trigger("click")
|
|
132
|
+
await flushPromises()
|
|
133
|
+
const callsAfterStop = read.mock.calls.length
|
|
134
|
+
await vi.advanceTimersByTimeAsync(30)
|
|
135
|
+
expect(read).toHaveBeenCalledTimes(callsAfterStop)
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
it("records an explicit manual fallback with provenance when no provider is available", async () => {
|
|
139
|
+
const wrapper = mount(AimdRecorder, {
|
|
140
|
+
props: {
|
|
141
|
+
content: protocol({ manualFallback: true }),
|
|
142
|
+
locale: "en-US",
|
|
143
|
+
collectorActorId: "operator-17",
|
|
144
|
+
modelValue: { var: {}, step: {}, check: {}, quiz: {} },
|
|
145
|
+
},
|
|
146
|
+
})
|
|
147
|
+
await settle(wrapper)
|
|
148
|
+
|
|
149
|
+
expect(wrapper.text()).toContain("This data source is not available")
|
|
150
|
+
const manual = wrapper.findAll("button").find(button => button.text() === "Enter manually")
|
|
151
|
+
expect(manual).toBeTruthy()
|
|
152
|
+
await manual!.trigger("click")
|
|
153
|
+
|
|
154
|
+
await wrapper.find(".aimd-rec-collector__manual-value").setValue("21.75")
|
|
155
|
+
await wrapper.find(".aimd-rec-collector__manual-reason").setValue("Device is being calibrated")
|
|
156
|
+
const save = wrapper.findAll("button").find(button => button.text() === "Save observation")
|
|
157
|
+
await save!.trigger("click")
|
|
158
|
+
await settle(wrapper)
|
|
159
|
+
|
|
160
|
+
expect(latestRecord(wrapper)?.var.temperature).toMatchObject({
|
|
161
|
+
value: 21.75,
|
|
162
|
+
unit: "Cel",
|
|
163
|
+
source: {
|
|
164
|
+
kind: "manual",
|
|
165
|
+
collector: "temperature_sensor",
|
|
166
|
+
actor_id: "operator-17",
|
|
167
|
+
reason: "Device is being calibrated",
|
|
168
|
+
},
|
|
169
|
+
})
|
|
170
|
+
expect((latestRecord(wrapper)?.var.temperature as any).source.connector).toBeUndefined()
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
it("does not call the provider when authorization is denied", async () => {
|
|
174
|
+
const read = vi.fn().mockResolvedValue(18)
|
|
175
|
+
const wrapper = mount(AimdRecorder, {
|
|
176
|
+
props: {
|
|
177
|
+
content: protocol(),
|
|
178
|
+
locale: "en-US",
|
|
179
|
+
modelValue: { var: {}, step: {}, check: {}, quiz: {} },
|
|
180
|
+
collectorProviders: { sensor_gateway: { read } },
|
|
181
|
+
requestCollectorPermission: () => false,
|
|
182
|
+
},
|
|
183
|
+
})
|
|
184
|
+
await settle(wrapper)
|
|
185
|
+
|
|
186
|
+
await wrapper.find(".aimd-rec-collector__button--primary").trigger("click")
|
|
187
|
+
await settle(wrapper)
|
|
188
|
+
|
|
189
|
+
expect(read).not.toHaveBeenCalled()
|
|
190
|
+
expect(wrapper.text()).toContain("Collector access was not authorized")
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
it("discards a pending authorization when the protocol context changes", async () => {
|
|
194
|
+
let resolvePermission!: (decision: "record") => void
|
|
195
|
+
const permission = new Promise<"record">((resolve) => {
|
|
196
|
+
resolvePermission = resolve
|
|
197
|
+
})
|
|
198
|
+
const read = vi.fn().mockResolvedValue(18)
|
|
199
|
+
const originalContent = protocol()
|
|
200
|
+
const wrapper = mount(AimdRecorder, {
|
|
201
|
+
props: {
|
|
202
|
+
content: originalContent,
|
|
203
|
+
locale: "en-US",
|
|
204
|
+
modelValue: { var: {}, step: {}, check: {}, quiz: {} },
|
|
205
|
+
collectorProviders: { sensor_gateway: { read } },
|
|
206
|
+
requestCollectorPermission: () => permission,
|
|
207
|
+
},
|
|
208
|
+
})
|
|
209
|
+
await settle(wrapper)
|
|
210
|
+
|
|
211
|
+
await wrapper.find(".aimd-rec-collector__button--primary").trigger("click")
|
|
212
|
+
await flushPromises()
|
|
213
|
+
expect(wrapper.text()).toContain("Waiting for permission")
|
|
214
|
+
|
|
215
|
+
await wrapper.setProps({ content: `${originalContent}\nChanged.` })
|
|
216
|
+
resolvePermission("record")
|
|
217
|
+
await settle(wrapper)
|
|
218
|
+
|
|
219
|
+
expect(read).not.toHaveBeenCalled()
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
it("does not write a snapshot that resolves after the user stops it", async () => {
|
|
223
|
+
let resolveRead!: (value: number) => void
|
|
224
|
+
const readResult = new Promise<number>((resolve) => {
|
|
225
|
+
resolveRead = resolve
|
|
226
|
+
})
|
|
227
|
+
const wrapper = mount(AimdRecorder, {
|
|
228
|
+
props: {
|
|
229
|
+
content: protocol(),
|
|
230
|
+
locale: "en-US",
|
|
231
|
+
modelValue: { var: {}, step: {}, check: {}, quiz: {} },
|
|
232
|
+
collectorProviders: { sensor_gateway: { read: () => readResult } },
|
|
233
|
+
},
|
|
234
|
+
})
|
|
235
|
+
await settle(wrapper)
|
|
236
|
+
|
|
237
|
+
await wrapper.find(".aimd-rec-collector__button--primary").trigger("click")
|
|
238
|
+
await flushPromises()
|
|
239
|
+
const stop = wrapper.findAll("button").find(button => button.text() === "Stop")
|
|
240
|
+
expect(stop).toBeTruthy()
|
|
241
|
+
await stop!.trigger("click")
|
|
242
|
+
resolveRead(99)
|
|
243
|
+
await settle(wrapper)
|
|
244
|
+
|
|
245
|
+
expect(latestRecord(wrapper)?.var.temperature).not.toMatchObject({ value: 99 })
|
|
246
|
+
expect(wrapper.text()).toContain("Completed")
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
it("uses metadata-only protocol context for WYSIWYG single-field hosts", async () => {
|
|
250
|
+
const full = protocol()
|
|
251
|
+
const context = (full.match(/```(?:connectors|collectors)[\s\S]*?```/g) ?? []).join("\n\n")
|
|
252
|
+
const field = 'Temperature: {{var|temperature: Observation[float] | None, unit="Cel", collector="temperature_sensor"}}'
|
|
253
|
+
const wrapper = mount(AimdRecorder, {
|
|
254
|
+
props: {
|
|
255
|
+
content: field,
|
|
256
|
+
protocolContext: context,
|
|
257
|
+
locale: "en-US",
|
|
258
|
+
modelValue: { var: {}, step: {}, check: {}, quiz: {} },
|
|
259
|
+
collectorProviders: { sensor_gateway: { read: () => 17.5 } },
|
|
260
|
+
},
|
|
261
|
+
})
|
|
262
|
+
await settle(wrapper)
|
|
263
|
+
|
|
264
|
+
expect(wrapper.find(".aimd-rec-collector").exists()).toBe(true)
|
|
265
|
+
await wrapper.find(".aimd-rec-collector__button--primary").trigger("click")
|
|
266
|
+
await settle(wrapper)
|
|
267
|
+
expect(latestRecord(wrapper)?.var.temperature).toMatchObject({ value: 17.5 })
|
|
268
|
+
})
|
|
269
|
+
})
|
|
@@ -71,6 +71,7 @@ describe('AimdRecorder record search', () => {
|
|
|
71
71
|
|
|
72
72
|
const toggle = wrapper.find('[data-rec-search-toggle]')
|
|
73
73
|
expect(toggle.exists()).toBe(true)
|
|
74
|
+
expect(toggle.text()).toContain('Search current record')
|
|
74
75
|
await toggle.trigger('click')
|
|
75
76
|
await wrapper.vm.$nextTick()
|
|
76
77
|
|