@airalogy/aimd-recorder 1.17.0 → 1.19.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 +42 -10
- package/README.zh-CN.md +42 -10
- package/dist/AimdCodeField-BQUuM-EF.js +182 -0
- package/dist/{AimdDnaSequenceField-D6ZgCDpp.js → AimdDnaSequenceField-TBKunqU_.js} +2 -2
- package/dist/{AimdEditor.vue_vue_type_style_index_0_lang-B5Tq4zPV.js → AimdEditor.vue_vue_type_style_index_0_lang-tdh0dJNa.js} +3922 -3829
- package/dist/AimdMarkdownField-DmNX2g4j.js +254 -0
- package/dist/AimdMarkdownNoteField-B5ruzmwS.js +259 -0
- package/dist/{_commonjsHelpers-CZXJ37nu.js → _commonjsHelpers-B5RozER-.js} +2 -2
- package/dist/aimd-recorder.css +1 -1
- package/dist/arc-B-vsgEXF.js +83 -0
- package/dist/architectureDiagram-3BPJPVTR-BwPNOtNH.js +4692 -0
- package/dist/blockDiagram-GPEHLZMM-CMUI4kKc.js +2425 -0
- package/dist/c4Diagram-AAUBKEIU-Cpmfsy_s.js +1577 -0
- package/dist/channel-DlMAXHQK.js +5 -0
- package/dist/chunk-2J33WTMH-DP9BS2ux.js +19 -0
- package/dist/chunk-4BX2VUAB-ncsOeLMb.js +8 -0
- package/dist/chunk-55IACEB6-C7wHk4B7.js +8 -0
- package/dist/chunk-727SXJPM-Caa5aVUO.js +1528 -0
- package/dist/chunk-AQP2D5EJ-CL8egKqD.js +1387 -0
- package/dist/chunk-FMBD7UC4-heVR6BSA.js +19 -0
- package/dist/chunk-ND2GUHAM-BYH-wC2J.js +68 -0
- package/dist/chunk-QZHKN3VN-Bx2K7vkq.js +15 -0
- package/dist/classDiagram-4FO5ZUOK-BLLfLYy0.js +16 -0
- package/dist/classDiagram-v2-Q7XG4LA2-BLLfLYy0.js +16 -0
- package/dist/components.js +3776 -2247
- package/dist/composables.js +96 -70
- package/dist/cose-bilkent-S5V4N54A-E1YmM_xr.js +2609 -0
- package/dist/cytoscape.esm-r59gEWFs.js +18710 -0
- package/dist/dagre-BM42HDAG-BsXpQirH.js +445 -0
- package/dist/defaultLocale-BgPVtth8.js +171 -0
- package/dist/diagram-2AECGRRQ-CamqbWlY.js +217 -0
- package/dist/diagram-5GNKFQAL-DZyRFcOC.js +123 -0
- package/dist/diagram-KO2AKTUF-CmkGcy7R.js +461 -0
- package/dist/diagram-LMA3HP47-IdDwQPZ-.js +142 -0
- package/dist/diagram-OG6HWLK6-t0LBcUIU.js +528 -0
- package/dist/erDiagram-TEJ5UH35-DJBY2iZG.js +899 -0
- package/dist/flowDiagram-I6XJVG4X-DE4MzPPk.js +1628 -0
- package/dist/ganttDiagram-6RSMTGT7-CmAc35Yw.js +2707 -0
- package/dist/gitGraphDiagram-PVQCEYII-DDQZ5flw.js +815 -0
- package/dist/graph-BsJ8-1Pq.js +1510 -0
- package/dist/index.js +110 -83
- package/dist/infoDiagram-5YYISTIA-DSZjFR5g.js +24 -0
- package/dist/init-DjUOC4st.js +16 -0
- package/dist/ishikawaDiagram-YF4QCWOH-DCO9dx2L.js +621 -0
- package/dist/journeyDiagram-JHISSGLW-b-PpuBqg.js +834 -0
- package/dist/kanban-definition-UN3LZRKU-BjclDuJZ.js +724 -0
- package/dist/katex-DNob3HGn.js +11690 -0
- package/dist/layout-D4wqKu72.js +1703 -0
- package/dist/linear-Voc3BJib.js +259 -0
- package/dist/mermaid.core-Dt_VbeGP.js +15940 -0
- package/dist/mindmap-definition-RKZ34NQL-B3vrXRVY.js +827 -0
- package/dist/ordinal-B6-f3MAq.js +61 -0
- package/dist/pieDiagram-4H26LBE5-DFpWxSxk.js +163 -0
- package/dist/quadrantDiagram-W4KKPZXB-BYHcrGoB.js +1024 -0
- package/dist/record.js +1199 -0
- package/dist/requirementDiagram-4Y6WPE33-C-FgWrRz.js +882 -0
- package/dist/sankeyDiagram-5OEKKPKP-IwN0Evji.js +847 -0
- package/dist/sequenceDiagram-3UESZ5HK-_OnqhBO2.js +2891 -0
- package/dist/stateDiagram-AJRCARHV-BRLv0Zcw.js +263 -0
- package/dist/stateDiagram-v2-BHNVJYJU-BofX0AdS.js +16 -0
- package/dist/timeline-definition-PNZ67QCA-C-DpPLpw.js +1055 -0
- package/dist/{useFieldRendering-xLajJhyA.js → useCodeBlockRendering-DoTZaJTW.js} +1528 -1725
- package/dist/useMonacoAutoHeight-D4T-El3J.js +66 -0
- package/dist/vennDiagram-CIIHVFJN-zTHQR9Oq.js +1557 -0
- package/dist/wardley-L42UT6IY-D7b2ujEZ.js +22512 -0
- package/dist/wardleyDiagram-YWT4CUSO-au5koizO.js +675 -0
- package/dist/xychartDiagram-2RQKCTM6-BNf12P8z.js +1342 -0
- package/package.json +13 -8
- package/src/__tests__/assigner-graph.test.ts +82 -0
- package/src/__tests__/assigner-runner-dependent-data.test.ts +32 -0
- package/src/__tests__/markdown-field.test.ts +150 -1
- package/src/__tests__/markdown-note-field.test.ts +86 -3
- package/src/__tests__/recorder-assigner-control.test.ts +993 -0
- package/src/__tests__/recorder-editor.test.ts +17 -0
- package/src/__tests__/recorder-markdown-assigner-integration.test.ts +49 -0
- package/src/__tests__/step-field.test.ts +47 -1
- package/src/__tests__/type-plugins.test.ts +1 -0
- package/src/__tests__/var-field-render.test.ts +806 -1
- package/src/components/AimdAssignerGraph.vue +816 -0
- package/src/components/AimdCodeField.vue +24 -5
- package/src/components/AimdMarkdownField.vue +556 -11
- package/src/components/AimdMarkdownNoteField.vue +241 -30
- package/src/components/AimdRecorder.vue +1619 -99
- package/src/components/AimdRecorderEditor.vue +276 -8
- package/src/components/AimdRecorderWysiwygFieldHost.vue +6 -0
- package/src/components/AimdRecorderWysiwygSurface.vue +32 -0
- package/src/components/AimdStepCheckField.vue +82 -18
- package/src/components/AimdVarField.vue +694 -25
- package/src/components/AimdVarTableField.vue +325 -138
- package/src/components/icons/AimdAssignerCalculatorIcon.vue +18 -0
- package/src/components/icons/AimdAssignerCloudStatusIcon.vue +22 -0
- package/src/components/index.ts +9 -1
- package/src/components/recorderMilkdownPlugin.ts +14 -0
- package/src/composables/__tests__/useRecordState.test.ts +86 -0
- package/src/composables/__tests__/useVarHelpers.test.ts +175 -0
- package/src/composables/index.ts +28 -1
- package/src/composables/useAssignerRunner.ts +376 -0
- package/src/composables/useCodeBlockRendering.ts +51 -0
- package/src/composables/useFieldRendering.ts +32 -4
- package/src/composables/useMonacoAutoHeight.ts +127 -0
- package/src/composables/useRecordState.ts +22 -3
- package/src/composables/useVarHelpers.ts +237 -32
- package/src/index.ts +20 -1
- package/src/locales.ts +45 -0
- package/src/record/index.ts +120 -0
- package/src/styles/aimd.css +216 -1
- package/src/type-plugins.ts +7 -0
- package/src/type-utils.ts +1 -3
- package/src/types.ts +130 -2
- package/dist/AimdCodeField-DC3DPvgc.js +0 -172
- package/dist/AimdMarkdownField-BJ20QtO8.js +0 -67
- package/dist/AimdMarkdownNoteField-DwAQhoyk.js +0 -186
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs'
|
|
2
2
|
import { dirname, resolve } from 'node:path'
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
|
-
import {
|
|
4
|
+
import { h } from 'vue'
|
|
5
|
+
import { flushPromises, mount } from '@vue/test-utils'
|
|
6
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
7
|
+
import type { AimdVarNode, AimdVarTableNode } from '@airalogy/aimd-core/types'
|
|
8
|
+
|
|
9
|
+
import AimdRecorder from '../components/AimdRecorder.vue'
|
|
10
|
+
import AimdVarField from '../components/AimdVarField.vue'
|
|
11
|
+
import AimdVarTableField from '../components/AimdVarTableField.vue'
|
|
12
|
+
import { createAimdRecorderMessages } from '../locales'
|
|
5
13
|
|
|
6
14
|
const __filename = fileURLToPath(import.meta.url)
|
|
7
15
|
const __dirname = dirname(__filename)
|
|
8
16
|
const source = readFileSync(resolve(__dirname, '../components/AimdVarField.vue'), 'utf8')
|
|
17
|
+
const codeFieldSource = readFileSync(resolve(__dirname, '../components/AimdCodeField.vue'), 'utf8')
|
|
18
|
+
const varTableSource = readFileSync(resolve(__dirname, '../components/AimdVarTableField.vue'), 'utf8')
|
|
19
|
+
const recorderSource = readFileSync(resolve(__dirname, '../components/AimdRecorder.vue'), 'utf8')
|
|
20
|
+
const varHelpersSource = readFileSync(resolve(__dirname, '../composables/useVarHelpers.ts'), 'utf8')
|
|
21
|
+
const styles = readFileSync(resolve(__dirname, '../styles/aimd.css'), 'utf8')
|
|
9
22
|
|
|
10
23
|
describe('AimdVarField render behavior', () => {
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
vi.unstubAllGlobals()
|
|
26
|
+
})
|
|
27
|
+
|
|
11
28
|
it('shares compact layout syncing between textareas and single-line inputs', () => {
|
|
12
29
|
expect(source).toMatch(/function syncCompactControlLayout\(control: HTMLInputElement \| HTMLTextAreaElement\)/)
|
|
13
30
|
expect(source).toMatch(/if \(typeof HTMLTextAreaElement !== "undefined" && control instanceof HTMLTextAreaElement\) \{\s*syncAutoWrapTextareaHeight\(control\)\s*\}/)
|
|
@@ -29,4 +46,792 @@ describe('AimdVarField render behavior', () => {
|
|
|
29
46
|
expect(source).toMatch(/language: codeLanguage/)
|
|
30
47
|
expect(source).toMatch(/"aimd-rec-inline--var-stacked--code"/)
|
|
31
48
|
})
|
|
49
|
+
|
|
50
|
+
it('starts CodeStr and PyStr editors at a compact content-driven height', () => {
|
|
51
|
+
expect(codeFieldSource).toContain('createMonacoAutoHeight')
|
|
52
|
+
expect(codeFieldSource).toMatch(/const editorHeight = codeAutoHeight\.editorHeight/)
|
|
53
|
+
expect(codeFieldSource).toMatch(/codeAutoHeight\.attachEditor\(monacoEditor\)/)
|
|
54
|
+
expect(codeFieldSource).toContain('--aimd-code-field-editor-height')
|
|
55
|
+
expect(codeFieldSource).not.toContain('min-height: 240px;')
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('keeps table metadata popovers from being clipped by table bounds', () => {
|
|
59
|
+
expect(styles).toMatch(/\.aimd-field--var-table \.aimd-field__table-preview \{[\s\S]*?overflow: visible;/)
|
|
60
|
+
expect(styles).toMatch(/\.aimd-field--var-table \.aimd-field__table-preview th \{[\s\S]*?overflow: visible;/)
|
|
61
|
+
expect(styles).toContain('.aimd-field--var-table .aimd-field__table-preview th:has(.aimd-field__metadata-host:hover)')
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('renders editable table cell values without inherited italic preview styling', () => {
|
|
65
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-table-cell-input\) \{[\s\S]*?font-style: normal;/)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('keeps card-style table rows compact in dense recorder layouts', () => {
|
|
69
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-card-list\) \{[\s\S]*?gap: 8px;/)
|
|
70
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-card\) \{[\s\S]*?padding: 7px 10px 9px;/)
|
|
71
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-card__field\) \{[\s\S]*?padding-top: 6px;[\s\S]*?margin-top: 6px;/)
|
|
72
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-card__input\) \{[\s\S]*?height: 30px;/)
|
|
73
|
+
expect(recorderSource).toContain('.aimd-rec-card .aimd-rec-inline-table__drag-handle')
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('shows visible row numbers for table and card var_table layouts', () => {
|
|
77
|
+
expect(varTableSource).toContain('function renderRowNumber')
|
|
78
|
+
expect(varTableSource).toContain('aimd-rec-inline-table__row-control')
|
|
79
|
+
expect(varTableSource).toContain('aimd-rec-card__row-meta')
|
|
80
|
+
expect(varTableSource).toContain('aimd-rec-inline-table__row-head-label')
|
|
81
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-inline-table__row-number\) \{[\s\S]*?font-variant-numeric: tabular-nums;/)
|
|
82
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-inline-table__row-number\) \{[\s\S]*?background: transparent;[\s\S]*?font-style: normal;/)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it('clips plain stacked var controls so rounded corners render cleanly', () => {
|
|
86
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-inline--var-stacked\) \{[\s\S]*?overflow: hidden;/)
|
|
87
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-inline--var-stacked:has\(\.aimd-field__metadata-host\)\) \{[\s\S]*?overflow: visible;/)
|
|
88
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-inline--has-assigner-control\) \{[\s\S]*?overflow: hidden;/)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('normalizes stacked var value typography across native control types', () => {
|
|
92
|
+
expect(recorderSource).toContain('--rec-body-font-size: 14px;')
|
|
93
|
+
expect(recorderSource).toContain('--rec-var-value-font-size: var(--rec-body-font-size);')
|
|
94
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content \{[\s\S]*?font-size: var\(--rec-body-font-size\);/)
|
|
95
|
+
expect(source).toContain('aimd-rec-inline__value-control aimd-rec-inline__input aimd-rec-inline__input--stacked')
|
|
96
|
+
expect(source).toContain('aimd-rec-inline__value-control aimd-rec-inline__textarea aimd-rec-inline__textarea--stacked')
|
|
97
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-inline--var-stacked \.aimd-rec-inline__value-control\) \{[\s\S]*?font: inherit;[\s\S]*?font-size: var\(--rec-var-value-font-size\);/)
|
|
98
|
+
expect(recorderSource).toContain('.aimd-rec-inline__value-control::-webkit-datetime-edit')
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('uses wrapped line-numbered code blocks in recorder markdown output', () => {
|
|
102
|
+
expect(recorderSource).toContain('useCodeBlockRendering')
|
|
103
|
+
expect(recorderSource).toMatch(/elementRenderers:\s*\{\s*pre: codeBlockPreRenderer/)
|
|
104
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-code-block\) \{[\s\S]*?overflow: hidden;/)
|
|
105
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-code-block__line\) \{[\s\S]*?grid-template-columns: max-content minmax\(0, 1fr\);/)
|
|
106
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-code-block__line-code\) \{[\s\S]*?white-space: pre-wrap;[\s\S]*?overflow-wrap: anywhere;/)
|
|
107
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-code-block--wrap \.aimd-code-block__line-code\) \{[\s\S]*?text-indent: calc\(-1 \* var\(--aimd-code-wrap-indent, 0ch\)\);/)
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('lets block recorder fields fill the available panel width', () => {
|
|
111
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-inline--var-markdown\) \{[\s\S]*?width: 100%;[\s\S]*?box-sizing: border-box;/)
|
|
112
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-inline--step\) \{[\s\S]*?width: 100%;[\s\S]*?box-sizing: border-box;/)
|
|
113
|
+
expect(recorderSource).toMatch(/\.aimd-protocol-recorder__content :deep\(\.aimd-rec-inline--check\) \{[\s\S]*?width: 100%;/)
|
|
114
|
+
expect(recorderSource).not.toContain('width: min(100%, 1040px);')
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('renders file-like vars with a native file picker control', async () => {
|
|
118
|
+
const node: AimdVarNode = {
|
|
119
|
+
type: 'aimd',
|
|
120
|
+
fieldType: 'var',
|
|
121
|
+
scope: 'var',
|
|
122
|
+
id: 'dose_response_file',
|
|
123
|
+
raw: '{{var|dose_response_file}}',
|
|
124
|
+
definition: {
|
|
125
|
+
id: 'dose_response_file',
|
|
126
|
+
type: 'FileIdCSV',
|
|
127
|
+
kwargs: {
|
|
128
|
+
title: 'Dose response file',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
}
|
|
132
|
+
const uploadFile = vi.fn(() => 'uploaded-file-id')
|
|
133
|
+
|
|
134
|
+
const wrapper = mount(AimdVarField, {
|
|
135
|
+
props: {
|
|
136
|
+
node,
|
|
137
|
+
disabled: false,
|
|
138
|
+
extraClasses: [],
|
|
139
|
+
messages: createAimdRecorderMessages('en-US'),
|
|
140
|
+
displayValue: '',
|
|
141
|
+
inputKind: 'file',
|
|
142
|
+
initialized: true,
|
|
143
|
+
uploadFile,
|
|
144
|
+
},
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
const input = wrapper.find('input[type="file"]')
|
|
148
|
+
expect(input.exists()).toBe(true)
|
|
149
|
+
expect(input.attributes('accept')).toBe('.csv,text/csv')
|
|
150
|
+
expect(wrapper.find('.aimd-rec-file-field__badge').text()).toBe('CSV')
|
|
151
|
+
expect(wrapper.find('.aimd-rec-file-field__name').text()).toBe('Choose file')
|
|
152
|
+
|
|
153
|
+
const file = new File(['a,b\n1,2'], 'dose.csv', { type: 'text/csv' })
|
|
154
|
+
Object.defineProperty(input.element, 'files', {
|
|
155
|
+
value: [file],
|
|
156
|
+
configurable: true,
|
|
157
|
+
})
|
|
158
|
+
await input.trigger('change')
|
|
159
|
+
await Promise.resolve()
|
|
160
|
+
|
|
161
|
+
expect(uploadFile).toHaveBeenCalledWith(file, expect.objectContaining({
|
|
162
|
+
fieldKey: 'var:dose_response_file',
|
|
163
|
+
type: 'FileIdCSV',
|
|
164
|
+
normalizedType: 'fileidcsv',
|
|
165
|
+
accept: '.csv,text/csv',
|
|
166
|
+
}))
|
|
167
|
+
expect(wrapper.emitted('change')?.[0]?.[0]).toMatchObject({
|
|
168
|
+
id: 'dose_response_file',
|
|
169
|
+
value: 'uploaded-file-id',
|
|
170
|
+
type: 'FileIdCSV',
|
|
171
|
+
inputKind: 'file',
|
|
172
|
+
})
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
it('places file assigner actions in the field header instead of the file card body', () => {
|
|
176
|
+
const node: AimdVarNode = {
|
|
177
|
+
type: 'aimd',
|
|
178
|
+
fieldType: 'var',
|
|
179
|
+
scope: 'var',
|
|
180
|
+
id: 'dose_response_file',
|
|
181
|
+
raw: '{{var|dose_response_file}}',
|
|
182
|
+
definition: {
|
|
183
|
+
id: 'dose_response_file',
|
|
184
|
+
type: 'FileIdCSV',
|
|
185
|
+
},
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const wrapper = mount(AimdVarField, {
|
|
189
|
+
props: {
|
|
190
|
+
node,
|
|
191
|
+
disabled: false,
|
|
192
|
+
extraClasses: [],
|
|
193
|
+
messages: createAimdRecorderMessages('en-US'),
|
|
194
|
+
displayValue: '',
|
|
195
|
+
inputKind: 'file',
|
|
196
|
+
initialized: true,
|
|
197
|
+
assignerControl: h('button', { class: 'assigner-test-button', type: 'button' }, 'run'),
|
|
198
|
+
assignerStatus: h('span', { class: 'assigner-test-status' }, 'idle'),
|
|
199
|
+
},
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
expect(wrapper.find('.aimd-rec-inline__header-assigner-actions').exists()).toBe(true)
|
|
203
|
+
expect(wrapper.find('.aimd-rec-inline__header-assigner-action .assigner-test-button').exists()).toBe(true)
|
|
204
|
+
expect(wrapper.find('.aimd-rec-inline__header-assigner-state .assigner-test-status').exists()).toBe(true)
|
|
205
|
+
expect(wrapper.find('.aimd-rec-inline__control-row').exists()).toBe(false)
|
|
206
|
+
expect(recorderSource).toContain('.aimd-rec-inline__header-assigner-actions')
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
it('places code assigner actions in the field header instead of a side prefix', () => {
|
|
210
|
+
expect(source).toContain('["file", "code"].includes(inputKind)')
|
|
211
|
+
expect(source).toMatch(/if \(inputKind === "code"\) \{[\s\S]*?"aimd-rec-inline--var-stacked--code",[\s\S]*?\{ controlRow: false \}/)
|
|
212
|
+
expect(recorderSource).toContain('["number", "date", "datetime", "time", "text", "textarea", "checkbox", "file", "code"].includes(inputKind)')
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
it('shows file ids as user-facing file cards instead of raw ids', async () => {
|
|
216
|
+
const fileId = 'airalogy.id.file.11111111-1111-1111-1111-111111111111'
|
|
217
|
+
vi.stubGlobal('fetch', vi.fn(async () => ({
|
|
218
|
+
ok: true,
|
|
219
|
+
text: async () => 't_min,area_a,area_p\n0,1000,0\n5,800,200\n',
|
|
220
|
+
})))
|
|
221
|
+
const node: AimdVarNode = {
|
|
222
|
+
type: 'aimd',
|
|
223
|
+
fieldType: 'var',
|
|
224
|
+
scope: 'var',
|
|
225
|
+
id: 'dose_response_file',
|
|
226
|
+
raw: '{{var|dose_response_file}}',
|
|
227
|
+
definition: {
|
|
228
|
+
id: 'dose_response_file',
|
|
229
|
+
type: 'FileIdCSV',
|
|
230
|
+
},
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const wrapper = mount(AimdVarField, {
|
|
234
|
+
props: {
|
|
235
|
+
node,
|
|
236
|
+
value: fileId as any,
|
|
237
|
+
disabled: false,
|
|
238
|
+
extraClasses: [],
|
|
239
|
+
messages: createAimdRecorderMessages('en-US'),
|
|
240
|
+
displayValue: '',
|
|
241
|
+
inputKind: 'file',
|
|
242
|
+
initialized: true,
|
|
243
|
+
resolveFile: (src: string) => `/api/files/${src}`,
|
|
244
|
+
},
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
expect(wrapper.text()).not.toContain(fileId)
|
|
248
|
+
expect(wrapper.find('.aimd-rec-file-field__name').text()).toBe('Selected file')
|
|
249
|
+
expect(wrapper.find('.aimd-rec-file-card__action[href]').attributes('href')).toBe(`/api/files/${fileId}`)
|
|
250
|
+
expect(wrapper.find('.aimd-rec-file-card__action--danger').exists()).toBe(true)
|
|
251
|
+
await flushPromises()
|
|
252
|
+
expect(wrapper.find('.aimd-rec-file-field__csv-preview').text()).toContain('t_min')
|
|
253
|
+
expect(wrapper.find('.aimd-rec-file-field__csv-preview').text()).toContain('1000')
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
it('renders image file ids with an inline preview when a resolver is available', () => {
|
|
257
|
+
const fileId = 'airalogy.id.file.22222222-2222-2222-2222-222222222222'
|
|
258
|
+
const node: AimdVarNode = {
|
|
259
|
+
type: 'aimd',
|
|
260
|
+
fieldType: 'var',
|
|
261
|
+
scope: 'var',
|
|
262
|
+
id: 'chart',
|
|
263
|
+
raw: '{{var|chart}}',
|
|
264
|
+
definition: {
|
|
265
|
+
id: 'chart',
|
|
266
|
+
type: 'FileIdPNG',
|
|
267
|
+
},
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const wrapper = mount(AimdVarField, {
|
|
271
|
+
props: {
|
|
272
|
+
node,
|
|
273
|
+
value: fileId as any,
|
|
274
|
+
disabled: false,
|
|
275
|
+
extraClasses: [],
|
|
276
|
+
messages: createAimdRecorderMessages('en-US'),
|
|
277
|
+
displayValue: '',
|
|
278
|
+
inputKind: 'file',
|
|
279
|
+
initialized: true,
|
|
280
|
+
resolveFile: (src: string) => `/api/files/${src}`,
|
|
281
|
+
},
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
const preview = wrapper.find('.aimd-rec-file-field__preview img')
|
|
285
|
+
expect(preview.exists()).toBe(true)
|
|
286
|
+
expect(preview.attributes('src')).toBe(`/api/files/${fileId}`)
|
|
287
|
+
expect(wrapper.text()).not.toContain(fileId)
|
|
288
|
+
expect((wrapper.find('.aimd-rec-inline--var-stacked').element as HTMLElement).style.width).toBe('360px')
|
|
289
|
+
expect(varHelpersSource).toContain('case "image":')
|
|
290
|
+
expect(varHelpersSource).toContain('return 360')
|
|
291
|
+
expect(recorderSource).toContain('.aimd-rec-inline__file-control[data-file-kind="image"] .aimd-rec-file-field__preview')
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
it('uses host-resolved file metadata for file cards', async () => {
|
|
295
|
+
const fileId = 'airalogy.id.file.33333333-3333-3333-3333-333333333333'
|
|
296
|
+
const node: AimdVarNode = {
|
|
297
|
+
type: 'aimd',
|
|
298
|
+
fieldType: 'var',
|
|
299
|
+
scope: 'var',
|
|
300
|
+
id: 'chart',
|
|
301
|
+
raw: '{{var|chart}}',
|
|
302
|
+
definition: {
|
|
303
|
+
id: 'chart',
|
|
304
|
+
type: 'FileIdSVG',
|
|
305
|
+
},
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const wrapper = mount(AimdVarField, {
|
|
309
|
+
props: {
|
|
310
|
+
node,
|
|
311
|
+
value: fileId as any,
|
|
312
|
+
disabled: false,
|
|
313
|
+
extraClasses: [],
|
|
314
|
+
messages: createAimdRecorderMessages('en-US'),
|
|
315
|
+
displayValue: '',
|
|
316
|
+
inputKind: 'file',
|
|
317
|
+
initialized: true,
|
|
318
|
+
resolveFile: (src: string) => `/api/files/${src}`,
|
|
319
|
+
resolveFileInfo: async (src: string) => ({
|
|
320
|
+
id: src,
|
|
321
|
+
name: 'conversion_curve.svg',
|
|
322
|
+
url: `/signed/${src}`,
|
|
323
|
+
content_type: 'image/svg+xml',
|
|
324
|
+
size: 2048,
|
|
325
|
+
}),
|
|
326
|
+
},
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
await flushPromises()
|
|
330
|
+
|
|
331
|
+
expect(wrapper.find('.aimd-rec-file-field__name').text()).toBe('conversion_curve.svg')
|
|
332
|
+
expect(wrapper.find('.aimd-rec-file-card__meta').text()).toContain('IMG')
|
|
333
|
+
expect(wrapper.find('.aimd-rec-file-card__meta').text()).toContain('2.0 KB')
|
|
334
|
+
expect(wrapper.find('.aimd-rec-file-field__preview img').attributes('src')).toBe(`/signed/${fileId}`)
|
|
335
|
+
})
|
|
336
|
+
|
|
337
|
+
it('falls back to serializable selected-file metadata without an upload handler', async () => {
|
|
338
|
+
const node: AimdVarNode = {
|
|
339
|
+
type: 'aimd',
|
|
340
|
+
fieldType: 'var',
|
|
341
|
+
scope: 'var',
|
|
342
|
+
id: 'image_file',
|
|
343
|
+
raw: '{{var|image_file}}',
|
|
344
|
+
definition: {
|
|
345
|
+
id: 'image_file',
|
|
346
|
+
type: 'image',
|
|
347
|
+
},
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const wrapper = mount(AimdVarField, {
|
|
351
|
+
props: {
|
|
352
|
+
node,
|
|
353
|
+
disabled: false,
|
|
354
|
+
extraClasses: [],
|
|
355
|
+
messages: createAimdRecorderMessages('en-US'),
|
|
356
|
+
displayValue: '',
|
|
357
|
+
inputKind: 'file',
|
|
358
|
+
initialized: true,
|
|
359
|
+
},
|
|
360
|
+
})
|
|
361
|
+
|
|
362
|
+
const input = wrapper.find('input[type="file"]')
|
|
363
|
+
expect(input.attributes('accept')).toBe('image/*')
|
|
364
|
+
const file = new File(['png'], 'chart.png', {
|
|
365
|
+
type: 'image/png',
|
|
366
|
+
lastModified: 456,
|
|
367
|
+
})
|
|
368
|
+
Object.defineProperty(input.element, 'files', {
|
|
369
|
+
value: [file],
|
|
370
|
+
configurable: true,
|
|
371
|
+
})
|
|
372
|
+
await input.trigger('change')
|
|
373
|
+
await Promise.resolve()
|
|
374
|
+
|
|
375
|
+
expect(wrapper.emitted('change')?.[0]?.[0]).toMatchObject({
|
|
376
|
+
id: 'image_file',
|
|
377
|
+
value: {
|
|
378
|
+
format: 'airalogy_selected_file_v1',
|
|
379
|
+
name: 'chart.png',
|
|
380
|
+
type: 'image/png',
|
|
381
|
+
size: 3,
|
|
382
|
+
lastModified: 456,
|
|
383
|
+
},
|
|
384
|
+
inputKind: 'file',
|
|
385
|
+
})
|
|
386
|
+
})
|
|
387
|
+
|
|
388
|
+
it('styles metadata examples as distinct chips', () => {
|
|
389
|
+
expect(styles).toContain('.aimd-field__metadata-examples')
|
|
390
|
+
expect(styles).toContain('.aimd-field__metadata-example')
|
|
391
|
+
expect(styles).toMatch(/\.aimd-field__metadata-example \{[\s\S]*?border: 1px solid rgba\(248, 250, 252, 0\.18\);/)
|
|
392
|
+
})
|
|
393
|
+
|
|
394
|
+
it('renders AIMD var metadata and uses examples as placeholders', () => {
|
|
395
|
+
const node: AimdVarNode = {
|
|
396
|
+
type: 'aimd',
|
|
397
|
+
fieldType: 'var',
|
|
398
|
+
scope: 'var',
|
|
399
|
+
id: 'record_date',
|
|
400
|
+
raw: '{{var|record_date}}',
|
|
401
|
+
definition: {
|
|
402
|
+
id: 'record_date',
|
|
403
|
+
type: 'str',
|
|
404
|
+
kwargs: {
|
|
405
|
+
title: 'Record date',
|
|
406
|
+
description: 'ISO date',
|
|
407
|
+
examples: ['2026-05-26', '2026-05-27'],
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
const wrapper = mount(AimdVarField, {
|
|
413
|
+
props: {
|
|
414
|
+
node,
|
|
415
|
+
disabled: false,
|
|
416
|
+
extraClasses: [],
|
|
417
|
+
messages: createAimdRecorderMessages('en-US'),
|
|
418
|
+
displayValue: '',
|
|
419
|
+
inputKind: 'text',
|
|
420
|
+
initialized: true,
|
|
421
|
+
},
|
|
422
|
+
})
|
|
423
|
+
|
|
424
|
+
expect(wrapper.find('.aimd-field__title').text()).toBe('Record date')
|
|
425
|
+
expect(wrapper.find('.aimd-field__key').text()).toBe('record_date')
|
|
426
|
+
expect(wrapper.find('.aimd-field__description').exists()).toBe(false)
|
|
427
|
+
expect(wrapper.find('.aimd-field__metadata-popover').text()).toContain('ISO date')
|
|
428
|
+
expect(wrapper.find('.aimd-field__metadata-examples-label').text()).toBe('e.g.')
|
|
429
|
+
expect(wrapper.findAll('.aimd-field__metadata-example').map(example => example.text())).toEqual(['2026-05-26', '2026-05-27'])
|
|
430
|
+
expect(wrapper.find('.aimd-field__metadata-host').attributes('tabindex')).toBe('0')
|
|
431
|
+
expect(wrapper.find('.aimd-field__metadata-host').attributes('title')).toBeUndefined()
|
|
432
|
+
expect(wrapper.find('.aimd-field__metadata-host').attributes('aria-label')).toContain('ISO date')
|
|
433
|
+
expect(wrapper.find('.aimd-field__label').attributes('title')).toBeUndefined()
|
|
434
|
+
expect(wrapper.find('.aimd-field__label').classes()).toContain('aimd-field__label--has-metadata')
|
|
435
|
+
expect((wrapper.find('input, textarea').element as HTMLInputElement | HTMLTextAreaElement).placeholder).toBe('2026-05-26')
|
|
436
|
+
})
|
|
437
|
+
|
|
438
|
+
it('does not use AIMD var titles as placeholders', () => {
|
|
439
|
+
const node: AimdVarNode = {
|
|
440
|
+
type: 'aimd',
|
|
441
|
+
fieldType: 'var',
|
|
442
|
+
scope: 'var',
|
|
443
|
+
id: 'operator',
|
|
444
|
+
raw: '{{var|operator}}',
|
|
445
|
+
definition: {
|
|
446
|
+
id: 'operator',
|
|
447
|
+
type: 'str',
|
|
448
|
+
kwargs: {
|
|
449
|
+
title: 'Operator',
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
const wrapper = mount(AimdVarField, {
|
|
455
|
+
props: {
|
|
456
|
+
node,
|
|
457
|
+
disabled: false,
|
|
458
|
+
extraClasses: [],
|
|
459
|
+
messages: createAimdRecorderMessages('en-US'),
|
|
460
|
+
displayValue: '',
|
|
461
|
+
inputKind: 'text',
|
|
462
|
+
initialized: true,
|
|
463
|
+
},
|
|
464
|
+
})
|
|
465
|
+
|
|
466
|
+
expect(wrapper.find('.aimd-field__title').text()).toBe('Operator')
|
|
467
|
+
expect((wrapper.find('input, textarea').element as HTMLInputElement | HTMLTextAreaElement).placeholder).toBe('')
|
|
468
|
+
})
|
|
469
|
+
|
|
470
|
+
it('lets fieldMeta override AIMD var display metadata', () => {
|
|
471
|
+
const node: AimdVarNode = {
|
|
472
|
+
type: 'aimd',
|
|
473
|
+
fieldType: 'var',
|
|
474
|
+
scope: 'var',
|
|
475
|
+
id: 'record_date',
|
|
476
|
+
raw: '{{var|record_date}}',
|
|
477
|
+
definition: {
|
|
478
|
+
id: 'record_date',
|
|
479
|
+
type: 'str',
|
|
480
|
+
kwargs: {
|
|
481
|
+
title: 'AIMD title',
|
|
482
|
+
description: 'AIMD description',
|
|
483
|
+
examples: ['aimd-example'],
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
const wrapper = mount(AimdVarField, {
|
|
489
|
+
props: {
|
|
490
|
+
node,
|
|
491
|
+
disabled: false,
|
|
492
|
+
extraClasses: [],
|
|
493
|
+
messages: createAimdRecorderMessages('en-US'),
|
|
494
|
+
fieldMeta: {
|
|
495
|
+
title: 'Runtime title',
|
|
496
|
+
description: 'Runtime description',
|
|
497
|
+
examples: ['runtime-example'],
|
|
498
|
+
},
|
|
499
|
+
displayValue: '',
|
|
500
|
+
inputKind: 'text',
|
|
501
|
+
initialized: true,
|
|
502
|
+
},
|
|
503
|
+
})
|
|
504
|
+
|
|
505
|
+
expect(wrapper.find('.aimd-field__title').text()).toBe('Runtime title')
|
|
506
|
+
expect(wrapper.find('.aimd-field__description').exists()).toBe(false)
|
|
507
|
+
expect(wrapper.find('.aimd-field__metadata-popover').text()).toContain('Runtime description')
|
|
508
|
+
expect(wrapper.find('.aimd-field__metadata-example').text()).toBe('runtime-example')
|
|
509
|
+
expect(wrapper.find('.aimd-field__metadata-host').attributes('title')).toBeUndefined()
|
|
510
|
+
expect(wrapper.find('.aimd-field__metadata-host').attributes('aria-label')).toContain('Runtime description')
|
|
511
|
+
expect((wrapper.find('input, textarea').element as HTMLInputElement | HTMLTextAreaElement).placeholder).toBe('runtime-example')
|
|
512
|
+
})
|
|
513
|
+
|
|
514
|
+
it('renders parsed Literal vars as select fields in AimdRecorder', async () => {
|
|
515
|
+
const wrapper = mount(AimdRecorder, {
|
|
516
|
+
props: {
|
|
517
|
+
content: 'Review type: {{var|review_type: Literal["quick", "scoping"] = "scoping", title = "Review type"}}',
|
|
518
|
+
locale: 'en-US',
|
|
519
|
+
modelValue: { var: {}, step: {}, check: {}, quiz: {} },
|
|
520
|
+
},
|
|
521
|
+
})
|
|
522
|
+
|
|
523
|
+
await flushPromises()
|
|
524
|
+
await wrapper.vm.$nextTick()
|
|
525
|
+
await vi.dynamicImportSettled()
|
|
526
|
+
await wrapper.vm.$nextTick()
|
|
527
|
+
|
|
528
|
+
const select = wrapper.find('select[data-rec-focus-key="var:review_type"]')
|
|
529
|
+
expect(select.exists()).toBe(true)
|
|
530
|
+
expect(select.findAll('option').map(option => option.text())).toEqual(['quick', 'scoping'])
|
|
531
|
+
expect((select.element as HTMLSelectElement).value).toBe('1')
|
|
532
|
+
|
|
533
|
+
await select.setValue('0')
|
|
534
|
+
await flushPromises()
|
|
535
|
+
|
|
536
|
+
const updates = wrapper.emitted('update:modelValue') ?? []
|
|
537
|
+
const latest = updates[updates.length - 1]?.[0] as { var?: Record<string, unknown> } | undefined
|
|
538
|
+
expect(latest?.var?.review_type).toBe('quick')
|
|
539
|
+
})
|
|
540
|
+
|
|
541
|
+
it('renders AIMD var_table and column metadata', () => {
|
|
542
|
+
vi.stubGlobal('ResizeObserver', class {
|
|
543
|
+
observe() {}
|
|
544
|
+
unobserve() {}
|
|
545
|
+
disconnect() {}
|
|
546
|
+
})
|
|
547
|
+
vi.stubGlobal('requestAnimationFrame', (callback: FrameRequestCallback) => {
|
|
548
|
+
callback(0)
|
|
549
|
+
return 1
|
|
550
|
+
})
|
|
551
|
+
vi.stubGlobal('cancelAnimationFrame', () => {})
|
|
552
|
+
|
|
553
|
+
const node: AimdVarTableNode = {
|
|
554
|
+
type: 'aimd',
|
|
555
|
+
fieldType: 'var_table',
|
|
556
|
+
scope: 'var_table',
|
|
557
|
+
id: 'samples',
|
|
558
|
+
raw: '{{var_table|samples}}',
|
|
559
|
+
columns: ['sample_id'],
|
|
560
|
+
definition: {
|
|
561
|
+
id: 'samples',
|
|
562
|
+
kwargs: {
|
|
563
|
+
title: 'Samples',
|
|
564
|
+
description: 'Measured rows',
|
|
565
|
+
examples: ['S-001 row'],
|
|
566
|
+
},
|
|
567
|
+
subvars: {
|
|
568
|
+
sample_id: {
|
|
569
|
+
id: 'sample_id',
|
|
570
|
+
type: 'str',
|
|
571
|
+
kwargs: {
|
|
572
|
+
title: 'Sample ID',
|
|
573
|
+
description: 'Tube identifier',
|
|
574
|
+
examples: ['S-001'],
|
|
575
|
+
},
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
},
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
const wrapper = mount(AimdVarTableField, {
|
|
582
|
+
props: {
|
|
583
|
+
node,
|
|
584
|
+
rows: [{ sample_id: '' }],
|
|
585
|
+
columns: ['sample_id'],
|
|
586
|
+
disabled: false,
|
|
587
|
+
readonly: false,
|
|
588
|
+
settlingRowKey: null,
|
|
589
|
+
messages: createAimdRecorderMessages('en-US'),
|
|
590
|
+
},
|
|
591
|
+
})
|
|
592
|
+
|
|
593
|
+
expect(wrapper.text()).toContain('Samples')
|
|
594
|
+
expect(wrapper.text()).toContain('samples')
|
|
595
|
+
expect(wrapper.text()).toContain('Measured rows')
|
|
596
|
+
expect(wrapper.text()).toContain('S-001 row')
|
|
597
|
+
expect(wrapper.text()).toContain('Sample ID')
|
|
598
|
+
expect(wrapper.text()).toContain('sample_id')
|
|
599
|
+
expect(wrapper.findAll('.aimd-field__description')).toHaveLength(0)
|
|
600
|
+
expect(wrapper.findAll('.aimd-field__metadata-popover').some(popover => popover.text().includes('Tube identifier'))).toBe(true)
|
|
601
|
+
expect(wrapper.findAll('.aimd-field__metadata-popover').some(popover => popover.text().includes('S-001'))).toBe(true)
|
|
602
|
+
expect(wrapper.find('.aimd-field__metadata-popover').exists()).toBe(true)
|
|
603
|
+
expect((wrapper.find('input').element as HTMLInputElement).placeholder).toBe('S-001')
|
|
604
|
+
})
|
|
605
|
+
|
|
606
|
+
it('renders table row numbers without adding data columns', () => {
|
|
607
|
+
vi.stubGlobal('ResizeObserver', class {
|
|
608
|
+
observe() {}
|
|
609
|
+
unobserve() {}
|
|
610
|
+
disconnect() {}
|
|
611
|
+
})
|
|
612
|
+
vi.stubGlobal('requestAnimationFrame', (callback: FrameRequestCallback) => {
|
|
613
|
+
callback(0)
|
|
614
|
+
return 1
|
|
615
|
+
})
|
|
616
|
+
vi.stubGlobal('cancelAnimationFrame', () => {})
|
|
617
|
+
|
|
618
|
+
const node: AimdVarTableNode = {
|
|
619
|
+
type: 'aimd',
|
|
620
|
+
fieldType: 'var_table',
|
|
621
|
+
scope: 'var_table',
|
|
622
|
+
id: 'samples',
|
|
623
|
+
raw: '{{var_table|samples}}',
|
|
624
|
+
columns: ['sample_id'],
|
|
625
|
+
definition: {
|
|
626
|
+
id: 'samples',
|
|
627
|
+
subvars: {
|
|
628
|
+
sample_id: {
|
|
629
|
+
id: 'sample_id',
|
|
630
|
+
type: 'str',
|
|
631
|
+
},
|
|
632
|
+
},
|
|
633
|
+
},
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
const wrapper = mount(AimdVarTableField, {
|
|
637
|
+
props: {
|
|
638
|
+
node,
|
|
639
|
+
rows: [{ sample_id: 'A' }, { sample_id: 'B' }],
|
|
640
|
+
columns: ['sample_id'],
|
|
641
|
+
disabled: false,
|
|
642
|
+
readonly: false,
|
|
643
|
+
settlingRowKey: null,
|
|
644
|
+
messages: createAimdRecorderMessages('en-US'),
|
|
645
|
+
},
|
|
646
|
+
})
|
|
647
|
+
|
|
648
|
+
expect(wrapper.find('.aimd-rec-inline-table__row-head-label').text()).toBe('#')
|
|
649
|
+
expect(wrapper.findAll('.aimd-rec-inline-table__row-number').map(number => number.text())).toEqual(['1', '2'])
|
|
650
|
+
expect(wrapper.findAll('.aimd-rec-inline-table__value-cell')).toHaveLength(2)
|
|
651
|
+
})
|
|
652
|
+
|
|
653
|
+
it('places table assigner actions in the table header', () => {
|
|
654
|
+
vi.stubGlobal('ResizeObserver', class {
|
|
655
|
+
observe() {}
|
|
656
|
+
unobserve() {}
|
|
657
|
+
disconnect() {}
|
|
658
|
+
})
|
|
659
|
+
vi.stubGlobal('requestAnimationFrame', (callback: FrameRequestCallback) => {
|
|
660
|
+
callback(0)
|
|
661
|
+
return 1
|
|
662
|
+
})
|
|
663
|
+
vi.stubGlobal('cancelAnimationFrame', () => {})
|
|
664
|
+
|
|
665
|
+
const node: AimdVarTableNode = {
|
|
666
|
+
type: 'aimd',
|
|
667
|
+
fieldType: 'var_table',
|
|
668
|
+
scope: 'var_table',
|
|
669
|
+
id: 'samples',
|
|
670
|
+
raw: '{{var_table|samples}}',
|
|
671
|
+
columns: ['sample_id'],
|
|
672
|
+
definition: {
|
|
673
|
+
id: 'samples',
|
|
674
|
+
subvars: {
|
|
675
|
+
sample_id: {
|
|
676
|
+
id: 'sample_id',
|
|
677
|
+
type: 'str',
|
|
678
|
+
},
|
|
679
|
+
},
|
|
680
|
+
},
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
const wrapper = mount(AimdVarTableField, {
|
|
684
|
+
props: {
|
|
685
|
+
node,
|
|
686
|
+
rows: [{ sample_id: '' }],
|
|
687
|
+
columns: ['sample_id'],
|
|
688
|
+
disabled: false,
|
|
689
|
+
readonly: false,
|
|
690
|
+
settlingRowKey: null,
|
|
691
|
+
messages: createAimdRecorderMessages('en-US'),
|
|
692
|
+
assignerControl: h('button', { class: 'assigner-test-button', type: 'button' }, 'run'),
|
|
693
|
+
assignerStatus: h('span', { class: 'assigner-test-status' }, 'idle'),
|
|
694
|
+
assignerError: 'Missing source data',
|
|
695
|
+
},
|
|
696
|
+
})
|
|
697
|
+
|
|
698
|
+
expect(wrapper.find('.aimd-rec-inline-table__header-actions').exists()).toBe(true)
|
|
699
|
+
expect(wrapper.find('.aimd-rec-inline-table__header-action .assigner-test-button').exists()).toBe(true)
|
|
700
|
+
expect(wrapper.find('.aimd-rec-inline-table__header-state .assigner-test-status').exists()).toBe(true)
|
|
701
|
+
expect(wrapper.find('.aimd-rec-inline-table__assigner-error').text()).toBe('Missing source data')
|
|
702
|
+
expect(recorderSource).toContain('.aimd-rec-inline-table__header-actions')
|
|
703
|
+
})
|
|
704
|
+
|
|
705
|
+
it('does not use AIMD var_table titles as cell placeholders and honors explicit column placeholders', () => {
|
|
706
|
+
vi.stubGlobal('ResizeObserver', class {
|
|
707
|
+
observe() {}
|
|
708
|
+
unobserve() {}
|
|
709
|
+
disconnect() {}
|
|
710
|
+
})
|
|
711
|
+
vi.stubGlobal('requestAnimationFrame', (callback: FrameRequestCallback) => {
|
|
712
|
+
callback(0)
|
|
713
|
+
return 1
|
|
714
|
+
})
|
|
715
|
+
vi.stubGlobal('cancelAnimationFrame', () => {})
|
|
716
|
+
|
|
717
|
+
const node: AimdVarTableNode = {
|
|
718
|
+
type: 'aimd',
|
|
719
|
+
fieldType: 'var_table',
|
|
720
|
+
scope: 'var_table',
|
|
721
|
+
id: 'samples',
|
|
722
|
+
raw: '{{var_table|samples}}',
|
|
723
|
+
columns: ['sample_id'],
|
|
724
|
+
definition: {
|
|
725
|
+
id: 'samples',
|
|
726
|
+
kwargs: {
|
|
727
|
+
title: 'Samples',
|
|
728
|
+
},
|
|
729
|
+
subvars: {
|
|
730
|
+
sample_id: {
|
|
731
|
+
id: 'sample_id',
|
|
732
|
+
type: 'str',
|
|
733
|
+
kwargs: {
|
|
734
|
+
title: 'Sample ID',
|
|
735
|
+
},
|
|
736
|
+
},
|
|
737
|
+
},
|
|
738
|
+
},
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
const wrapper = mount(AimdVarTableField, {
|
|
742
|
+
props: {
|
|
743
|
+
node,
|
|
744
|
+
rows: [{ sample_id: '' }],
|
|
745
|
+
columns: ['sample_id'],
|
|
746
|
+
disabled: false,
|
|
747
|
+
readonly: false,
|
|
748
|
+
settlingRowKey: null,
|
|
749
|
+
messages: createAimdRecorderMessages('en-US'),
|
|
750
|
+
},
|
|
751
|
+
})
|
|
752
|
+
|
|
753
|
+
expect(wrapper.text()).toContain('Samples')
|
|
754
|
+
expect(wrapper.text()).toContain('Sample ID')
|
|
755
|
+
expect((wrapper.find('input').element as HTMLInputElement).placeholder).toBe('')
|
|
756
|
+
|
|
757
|
+
const wrapperWithPlaceholder = mount(AimdVarTableField, {
|
|
758
|
+
props: {
|
|
759
|
+
node,
|
|
760
|
+
rows: [{ sample_id: '' }],
|
|
761
|
+
columns: ['sample_id'],
|
|
762
|
+
disabled: false,
|
|
763
|
+
readonly: false,
|
|
764
|
+
settlingRowKey: null,
|
|
765
|
+
messages: createAimdRecorderMessages('en-US'),
|
|
766
|
+
fieldMeta: {
|
|
767
|
+
'var_table:samples:sample_id': {
|
|
768
|
+
placeholder: 'Runtime sample',
|
|
769
|
+
},
|
|
770
|
+
},
|
|
771
|
+
},
|
|
772
|
+
})
|
|
773
|
+
|
|
774
|
+
expect((wrapperWithPlaceholder.find('input').element as HTMLInputElement).placeholder).toBe('Runtime sample')
|
|
775
|
+
})
|
|
776
|
+
|
|
777
|
+
it('renders var_table enum metadata as select cells', async () => {
|
|
778
|
+
vi.stubGlobal('ResizeObserver', class {
|
|
779
|
+
observe() {}
|
|
780
|
+
unobserve() {}
|
|
781
|
+
disconnect() {}
|
|
782
|
+
})
|
|
783
|
+
vi.stubGlobal('requestAnimationFrame', (callback: FrameRequestCallback) => {
|
|
784
|
+
callback(0)
|
|
785
|
+
return 1
|
|
786
|
+
})
|
|
787
|
+
vi.stubGlobal('cancelAnimationFrame', () => {})
|
|
788
|
+
|
|
789
|
+
const node: AimdVarTableNode = {
|
|
790
|
+
type: 'aimd',
|
|
791
|
+
fieldType: 'var_table',
|
|
792
|
+
scope: 'var_table',
|
|
793
|
+
id: 'screening',
|
|
794
|
+
raw: '{{var_table|screening}}',
|
|
795
|
+
columns: ['decision'],
|
|
796
|
+
definition: {
|
|
797
|
+
id: 'screening',
|
|
798
|
+
subvars: {
|
|
799
|
+
decision: {
|
|
800
|
+
id: 'decision',
|
|
801
|
+
type: 'Literal["include", "exclude"]',
|
|
802
|
+
enum: ['include', 'exclude'],
|
|
803
|
+
kwargs: {
|
|
804
|
+
title: 'Decision',
|
|
805
|
+
},
|
|
806
|
+
},
|
|
807
|
+
},
|
|
808
|
+
},
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
const wrapper = mount(AimdVarTableField, {
|
|
812
|
+
props: {
|
|
813
|
+
node,
|
|
814
|
+
rows: [{ decision: 'exclude' }],
|
|
815
|
+
columns: ['decision'],
|
|
816
|
+
disabled: false,
|
|
817
|
+
readonly: false,
|
|
818
|
+
settlingRowKey: null,
|
|
819
|
+
messages: createAimdRecorderMessages('en-US'),
|
|
820
|
+
},
|
|
821
|
+
})
|
|
822
|
+
|
|
823
|
+
const select = wrapper.find('select[data-rec-focus-key="var_table:screening:0:decision"]')
|
|
824
|
+
expect(select.exists()).toBe(true)
|
|
825
|
+
expect((select.element as HTMLSelectElement).value).toBe('1')
|
|
826
|
+
|
|
827
|
+
await select.setValue('0')
|
|
828
|
+
|
|
829
|
+
const cellUpdates = wrapper.emitted('cell-input') ?? []
|
|
830
|
+
expect(cellUpdates[cellUpdates.length - 1]?.[0]).toMatchObject({
|
|
831
|
+
tableName: 'screening',
|
|
832
|
+
column: 'decision',
|
|
833
|
+
rowIndex: 0,
|
|
834
|
+
value: 'include',
|
|
835
|
+
})
|
|
836
|
+
})
|
|
32
837
|
})
|