@powerhousedao/vetra 4.1.0-dev.81 → 4.1.0-dev.83
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/dist/document-models/app-module/src/reducers/base-operations.d.ts.map +1 -1
- package/dist/document-models/app-module/src/reducers/base-operations.js +5 -1
- package/dist/document-models/app-module/src/tests/base-operations.test.js +157 -30
- package/dist/document-models/app-module/src/tests/dnd-operations.test.js +38 -7
- package/dist/document-models/app-module/src/tests/document-model.test.js +80 -8
- package/dist/document-models/document-editor/src/reducers/base-operations.d.ts.map +1 -1
- package/dist/document-models/document-editor/src/reducers/base-operations.js +10 -1
- package/dist/document-models/document-editor/src/tests/base-operations.test.js +137 -23
- package/dist/document-models/document-editor/src/tests/document-model.test.js +91 -8
- package/dist/document-models/processor-module/src/reducers/base-operations.d.ts.map +1 -1
- package/dist/document-models/processor-module/src/reducers/base-operations.js +15 -2
- package/dist/document-models/processor-module/src/tests/base-operations.test.js +153 -33
- package/dist/document-models/processor-module/src/tests/document-model.test.js +96 -8
- package/dist/document-models/subgraph-module/src/reducers/base-operations.d.ts.map +1 -1
- package/dist/document-models/subgraph-module/src/reducers/base-operations.js +5 -1
- package/dist/document-models/subgraph-module/src/tests/base-operations.test.js +33 -12
- package/dist/document-models/subgraph-module/src/tests/document-model.test.js +25 -8
- package/dist/document-models/vetra-package/src/reducers/base-operations.d.ts.map +1 -1
- package/dist/document-models/vetra-package/src/reducers/base-operations.js +5 -0
- package/dist/document-models/vetra-package/src/tests/base-operations.test.js +171 -75
- package/dist/document-models/vetra-package/src/tests/document-model.test.js +101 -8
- package/dist/editors/app-editor/components/AppEditorForm.d.ts.map +1 -1
- package/dist/editors/app-editor/components/AppEditorForm.js +2 -2
- package/dist/editors/app-editor/editor.test.d.ts +2 -0
- package/dist/editors/app-editor/editor.test.d.ts.map +1 -0
- package/dist/editors/app-editor/editor.test.js +422 -0
- package/dist/editors/document-editor/components/DocumentEditorForm.d.ts.map +1 -1
- package/dist/editors/document-editor/components/DocumentEditorForm.js +1 -1
- package/dist/editors/document-editor/editor.test.d.ts +2 -0
- package/dist/editors/document-editor/editor.test.d.ts.map +1 -0
- package/dist/editors/document-editor/editor.test.js +374 -0
- package/dist/editors/processor-editor/components/ProcessorEditorForm.d.ts.map +1 -1
- package/dist/editors/processor-editor/components/ProcessorEditorForm.js +1 -1
- package/dist/editors/processor-editor/editor.test.d.ts +2 -0
- package/dist/editors/processor-editor/editor.test.d.ts.map +1 -0
- package/dist/editors/processor-editor/editor.test.js +459 -0
- package/dist/editors/subgraph-editor/components/SubgraphEditorForm.d.ts.map +1 -1
- package/dist/editors/subgraph-editor/components/SubgraphEditorForm.js +3 -3
- package/dist/editors/subgraph-editor/editor.test.d.ts +2 -0
- package/dist/editors/subgraph-editor/editor.test.d.ts.map +1 -0
- package/dist/editors/subgraph-editor/editor.test.js +201 -0
- package/dist/editors/vetra-package/components/MetaForm.d.ts.map +1 -1
- package/dist/editors/vetra-package/components/MetaForm.js +3 -3
- package/dist/editors/vetra-package/editor.test.d.ts +2 -0
- package/dist/editors/vetra-package/editor.test.d.ts.map +1 -0
- package/dist/editors/vetra-package/editor.test.js +330 -0
- package/dist/processors/codegen/__tests__/codegen-processor-e2e.test.d.ts +2 -0
- package/dist/processors/codegen/__tests__/codegen-processor-e2e.test.d.ts.map +1 -0
- package/dist/processors/codegen/__tests__/codegen-processor-e2e.test.js +615 -0
- package/dist/processors/codegen/__tests__/factory.test.d.ts +2 -0
- package/dist/processors/codegen/__tests__/factory.test.d.ts.map +1 -0
- package/dist/processors/codegen/__tests__/factory.test.js +190 -0
- package/dist/setupTests.d.ts +2 -0
- package/dist/setupTests.d.ts.map +1 -0
- package/dist/setupTests.js +1 -0
- package/dist/style.css +9 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/vitest.config.d.ts.map +1 -1
- package/dist/vitest.config.js +9 -0
- package/package.json +19 -14
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen, waitFor } from "@testing-library/react";
|
|
3
|
+
import { userEvent } from "@testing-library/user-event";
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { useSelectedAppModuleDocument } from "../hooks/useVetraDocument.js";
|
|
6
|
+
import { Editor } from "./editor.js";
|
|
7
|
+
vi.mock("../hooks/useVetraDocument.js", () => ({
|
|
8
|
+
useSelectedAppModuleDocument: vi.fn(),
|
|
9
|
+
}));
|
|
10
|
+
vi.mock("@powerhousedao/reactor-browser", () => ({
|
|
11
|
+
useDocumentTypesInSelectedDrive: vi.fn(() => [
|
|
12
|
+
"powerhouse/document-model",
|
|
13
|
+
"powerhouse/budget-statement",
|
|
14
|
+
"powerhouse/project-tracker",
|
|
15
|
+
]),
|
|
16
|
+
useSupportedDocumentTypesInReactor: vi.fn(() => []),
|
|
17
|
+
useSetPHDocumentEditorConfig: vi.fn(),
|
|
18
|
+
}));
|
|
19
|
+
describe("AppModule Editor", () => {
|
|
20
|
+
let mockDispatch;
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
mockDispatch = vi.fn();
|
|
23
|
+
vi.mocked(useSelectedAppModuleDocument).mockReturnValue([
|
|
24
|
+
{
|
|
25
|
+
state: {
|
|
26
|
+
global: {
|
|
27
|
+
name: "",
|
|
28
|
+
status: "DRAFT",
|
|
29
|
+
allowedDocumentTypes: null,
|
|
30
|
+
isDragAndDropEnabled: true,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
mockDispatch,
|
|
35
|
+
]);
|
|
36
|
+
});
|
|
37
|
+
describe("Core Rendering", () => {
|
|
38
|
+
it("should render all main form sections and labels", () => {
|
|
39
|
+
render(_jsx(Editor, {}));
|
|
40
|
+
expect(screen.getByText("App Configuration")).toBeInTheDocument();
|
|
41
|
+
expect(screen.getByText("App Name")).toBeInTheDocument();
|
|
42
|
+
expect(screen.getByText("Document Types")).toBeInTheDocument();
|
|
43
|
+
expect(screen.getByText("Drag and Drop Settings")).toBeInTheDocument();
|
|
44
|
+
expect(screen.getByText("Enable drag and drop")).toBeInTheDocument();
|
|
45
|
+
expect(screen.getByText("Confirm")).toBeInTheDocument();
|
|
46
|
+
});
|
|
47
|
+
it("should display existing app data when document has values", () => {
|
|
48
|
+
vi.mocked(useSelectedAppModuleDocument).mockReturnValue([
|
|
49
|
+
{
|
|
50
|
+
state: {
|
|
51
|
+
global: {
|
|
52
|
+
name: "test-app",
|
|
53
|
+
status: "DRAFT",
|
|
54
|
+
allowedDocumentTypes: [
|
|
55
|
+
"powerhouse/document-model",
|
|
56
|
+
"powerhouse/budget-statement",
|
|
57
|
+
],
|
|
58
|
+
isDragAndDropEnabled: true,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
mockDispatch,
|
|
63
|
+
]);
|
|
64
|
+
render(_jsx(Editor, {}));
|
|
65
|
+
expect(screen.getByDisplayValue("test-app")).toBeInTheDocument();
|
|
66
|
+
expect(screen.getByText("powerhouse/document-model")).toBeInTheDocument();
|
|
67
|
+
expect(screen.getByText("powerhouse/budget-statement")).toBeInTheDocument();
|
|
68
|
+
const checkbox = screen.getByLabelText("Enable drag and drop");
|
|
69
|
+
expect(checkbox).toBeChecked();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
describe("App Name Input", () => {
|
|
73
|
+
it("should dispatch setAppName when name changes (debounced)", async () => {
|
|
74
|
+
const user = userEvent.setup();
|
|
75
|
+
render(_jsx(Editor, {}));
|
|
76
|
+
const nameInput = screen.getByLabelText("App Name");
|
|
77
|
+
await user.type(nameInput, "new-app");
|
|
78
|
+
await waitFor(() => {
|
|
79
|
+
expect(mockDispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
80
|
+
type: "SET_APP_NAME",
|
|
81
|
+
input: { name: "new-app" },
|
|
82
|
+
}));
|
|
83
|
+
}, { timeout: 500 });
|
|
84
|
+
});
|
|
85
|
+
it("should dispatch when clearing a non-empty field", async () => {
|
|
86
|
+
vi.mocked(useSelectedAppModuleDocument).mockReturnValue([
|
|
87
|
+
{
|
|
88
|
+
state: {
|
|
89
|
+
global: {
|
|
90
|
+
name: "existing-app",
|
|
91
|
+
status: "DRAFT",
|
|
92
|
+
allowedDocumentTypes: null,
|
|
93
|
+
isDragAndDropEnabled: true,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
mockDispatch,
|
|
98
|
+
]);
|
|
99
|
+
const user = userEvent.setup();
|
|
100
|
+
render(_jsx(Editor, {}));
|
|
101
|
+
const nameInput = screen.getByLabelText("App Name");
|
|
102
|
+
await user.clear(nameInput);
|
|
103
|
+
await waitFor(() => {
|
|
104
|
+
expect(mockDispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
105
|
+
type: "SET_APP_NAME",
|
|
106
|
+
input: { name: "" },
|
|
107
|
+
}));
|
|
108
|
+
}, { timeout: 500 });
|
|
109
|
+
});
|
|
110
|
+
it("should NOT dispatch when typing identical value without clearing", async () => {
|
|
111
|
+
vi.mocked(useSelectedAppModuleDocument).mockReturnValue([
|
|
112
|
+
{
|
|
113
|
+
state: {
|
|
114
|
+
global: {
|
|
115
|
+
name: "test",
|
|
116
|
+
status: "DRAFT",
|
|
117
|
+
allowedDocumentTypes: null,
|
|
118
|
+
isDragAndDropEnabled: true,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
mockDispatch,
|
|
123
|
+
]);
|
|
124
|
+
const user = userEvent.setup();
|
|
125
|
+
render(_jsx(Editor, {}));
|
|
126
|
+
const nameInput = screen.getByLabelText("App Name");
|
|
127
|
+
// Simulate user selecting all text and typing the same value
|
|
128
|
+
await user.tripleClick(nameInput); // Select all
|
|
129
|
+
await user.type(nameInput, "test");
|
|
130
|
+
await waitFor(() => {
|
|
131
|
+
expect(mockDispatch).not.toHaveBeenCalled();
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
it("should NOT dispatch when both old and new values are empty", async () => {
|
|
135
|
+
const user = userEvent.setup();
|
|
136
|
+
render(_jsx(Editor, {}));
|
|
137
|
+
const nameInput = screen.getByLabelText("App Name");
|
|
138
|
+
await user.click(nameInput);
|
|
139
|
+
await user.tab();
|
|
140
|
+
await waitFor(() => {
|
|
141
|
+
expect(mockDispatch).not.toHaveBeenCalled();
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
describe("Document Types Management", () => {
|
|
146
|
+
it("should add regular document type from dropdown", async () => {
|
|
147
|
+
const user = userEvent.setup();
|
|
148
|
+
render(_jsx(Editor, {}));
|
|
149
|
+
const select = screen.getByRole("combobox");
|
|
150
|
+
await user.selectOptions(select, "powerhouse/document-model");
|
|
151
|
+
expect(mockDispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
152
|
+
type: "ADD_DOCUMENT_TYPE",
|
|
153
|
+
input: {
|
|
154
|
+
documentType: "powerhouse/document-model",
|
|
155
|
+
},
|
|
156
|
+
}));
|
|
157
|
+
});
|
|
158
|
+
it("should add all document types when selecting 'all-in-drive'", async () => {
|
|
159
|
+
const user = userEvent.setup();
|
|
160
|
+
render(_jsx(Editor, {}));
|
|
161
|
+
const select = screen.getByRole("combobox");
|
|
162
|
+
await user.selectOptions(select, "all-in-drive");
|
|
163
|
+
expect(mockDispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
164
|
+
type: "SET_DOCUMENT_TYPES",
|
|
165
|
+
input: {
|
|
166
|
+
documentTypes: [
|
|
167
|
+
"powerhouse/document-model",
|
|
168
|
+
"powerhouse/budget-statement",
|
|
169
|
+
"powerhouse/project-tracker",
|
|
170
|
+
],
|
|
171
|
+
},
|
|
172
|
+
}));
|
|
173
|
+
});
|
|
174
|
+
it("should remove document type", async () => {
|
|
175
|
+
vi.mocked(useSelectedAppModuleDocument).mockReturnValue([
|
|
176
|
+
{
|
|
177
|
+
state: {
|
|
178
|
+
global: {
|
|
179
|
+
name: "test-app",
|
|
180
|
+
status: "DRAFT",
|
|
181
|
+
allowedDocumentTypes: [
|
|
182
|
+
"powerhouse/document-model",
|
|
183
|
+
"powerhouse/budget-statement",
|
|
184
|
+
],
|
|
185
|
+
isDragAndDropEnabled: true,
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
mockDispatch,
|
|
190
|
+
]);
|
|
191
|
+
const user = userEvent.setup();
|
|
192
|
+
render(_jsx(Editor, {}));
|
|
193
|
+
// Find the remove button for the first document type
|
|
194
|
+
const documentModelText = screen.getByText("powerhouse/document-model");
|
|
195
|
+
const removeButton = documentModelText.parentElement?.querySelector("button");
|
|
196
|
+
if (removeButton) {
|
|
197
|
+
await user.click(removeButton);
|
|
198
|
+
}
|
|
199
|
+
expect(mockDispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
200
|
+
type: "REMOVE_DOCUMENT_TYPE",
|
|
201
|
+
input: { documentType: "powerhouse/document-model" },
|
|
202
|
+
}));
|
|
203
|
+
});
|
|
204
|
+
it("should NOT show duplicate document type in dropdown", () => {
|
|
205
|
+
vi.mocked(useSelectedAppModuleDocument).mockReturnValue([
|
|
206
|
+
{
|
|
207
|
+
state: {
|
|
208
|
+
global: {
|
|
209
|
+
name: "test-app",
|
|
210
|
+
status: "DRAFT",
|
|
211
|
+
allowedDocumentTypes: ["powerhouse/document-model"],
|
|
212
|
+
isDragAndDropEnabled: true,
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
mockDispatch,
|
|
217
|
+
]);
|
|
218
|
+
render(_jsx(Editor, {}));
|
|
219
|
+
const select = screen.getByRole("combobox");
|
|
220
|
+
// Document type should not be in the options since it's already selected
|
|
221
|
+
const options = Array.from(select.querySelectorAll("option")).map((opt) => opt.value);
|
|
222
|
+
expect(options).not.toContain("powerhouse/document-model");
|
|
223
|
+
// But other document types should still be available
|
|
224
|
+
expect(options).toContain("powerhouse/budget-statement");
|
|
225
|
+
expect(options).toContain("powerhouse/project-tracker");
|
|
226
|
+
});
|
|
227
|
+
it("should display existing document types list", () => {
|
|
228
|
+
vi.mocked(useSelectedAppModuleDocument).mockReturnValue([
|
|
229
|
+
{
|
|
230
|
+
state: {
|
|
231
|
+
global: {
|
|
232
|
+
name: "test-app",
|
|
233
|
+
status: "DRAFT",
|
|
234
|
+
allowedDocumentTypes: [
|
|
235
|
+
"powerhouse/document-model",
|
|
236
|
+
"powerhouse/budget-statement",
|
|
237
|
+
],
|
|
238
|
+
isDragAndDropEnabled: true,
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
mockDispatch,
|
|
243
|
+
]);
|
|
244
|
+
render(_jsx(Editor, {}));
|
|
245
|
+
expect(screen.getByText("powerhouse/document-model")).toBeInTheDocument();
|
|
246
|
+
expect(screen.getByText("powerhouse/budget-statement")).toBeInTheDocument();
|
|
247
|
+
});
|
|
248
|
+
it("should show 'All documents (*)' when allowedDocumentTypes is empty", () => {
|
|
249
|
+
vi.mocked(useSelectedAppModuleDocument).mockReturnValue([
|
|
250
|
+
{
|
|
251
|
+
state: {
|
|
252
|
+
global: {
|
|
253
|
+
name: "test-app",
|
|
254
|
+
status: "DRAFT",
|
|
255
|
+
allowedDocumentTypes: [],
|
|
256
|
+
isDragAndDropEnabled: true,
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
mockDispatch,
|
|
261
|
+
]);
|
|
262
|
+
render(_jsx(Editor, {}));
|
|
263
|
+
expect(screen.getByText("All documents (*)")).toBeInTheDocument();
|
|
264
|
+
});
|
|
265
|
+
it("should show 'All documents (*)' when allowedDocumentTypes is null", () => {
|
|
266
|
+
vi.mocked(useSelectedAppModuleDocument).mockReturnValue([
|
|
267
|
+
{
|
|
268
|
+
state: {
|
|
269
|
+
global: {
|
|
270
|
+
name: "test-app",
|
|
271
|
+
status: "DRAFT",
|
|
272
|
+
allowedDocumentTypes: null,
|
|
273
|
+
isDragAndDropEnabled: true,
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
mockDispatch,
|
|
278
|
+
]);
|
|
279
|
+
render(_jsx(Editor, {}));
|
|
280
|
+
expect(screen.getByText("All documents (*)")).toBeInTheDocument();
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
describe("Drag and Drop Toggle", () => {
|
|
284
|
+
it("should dispatch setDragAndDropEnabled when checkbox toggled", async () => {
|
|
285
|
+
const user = userEvent.setup();
|
|
286
|
+
render(_jsx(Editor, {}));
|
|
287
|
+
const checkbox = screen.getByLabelText("Enable drag and drop");
|
|
288
|
+
await user.click(checkbox);
|
|
289
|
+
expect(mockDispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
290
|
+
type: "SET_DRAG_AND_DROP_ENABLED",
|
|
291
|
+
input: { enabled: false },
|
|
292
|
+
}));
|
|
293
|
+
});
|
|
294
|
+
it("should NOT dispatch when value equals current value", async () => {
|
|
295
|
+
vi.mocked(useSelectedAppModuleDocument).mockReturnValue([
|
|
296
|
+
{
|
|
297
|
+
state: {
|
|
298
|
+
global: {
|
|
299
|
+
name: "test-app",
|
|
300
|
+
status: "DRAFT",
|
|
301
|
+
allowedDocumentTypes: null,
|
|
302
|
+
isDragAndDropEnabled: true,
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
mockDispatch,
|
|
307
|
+
]);
|
|
308
|
+
const user = userEvent.setup();
|
|
309
|
+
render(_jsx(Editor, {}));
|
|
310
|
+
const checkbox = screen.getByLabelText("Enable drag and drop");
|
|
311
|
+
// Checkbox is already checked, so clicking it would toggle to false
|
|
312
|
+
await user.click(checkbox);
|
|
313
|
+
// The dispatch should be called with enabled: false
|
|
314
|
+
expect(mockDispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
315
|
+
type: "SET_DRAG_AND_DROP_ENABLED",
|
|
316
|
+
input: { enabled: false },
|
|
317
|
+
}));
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
describe("Confirm Button", () => {
|
|
321
|
+
it("should dispatch setAppStatus when confirm clicked", async () => {
|
|
322
|
+
vi.mocked(useSelectedAppModuleDocument).mockReturnValue([
|
|
323
|
+
{
|
|
324
|
+
state: {
|
|
325
|
+
global: {
|
|
326
|
+
name: "test-app",
|
|
327
|
+
status: "DRAFT",
|
|
328
|
+
allowedDocumentTypes: null,
|
|
329
|
+
isDragAndDropEnabled: true,
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
mockDispatch,
|
|
334
|
+
]);
|
|
335
|
+
const user = userEvent.setup();
|
|
336
|
+
render(_jsx(Editor, {}));
|
|
337
|
+
const confirmButton = screen.getByText("Confirm");
|
|
338
|
+
await user.click(confirmButton);
|
|
339
|
+
expect(mockDispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
340
|
+
type: "SET_APP_STATUS",
|
|
341
|
+
input: { status: "CONFIRMED" },
|
|
342
|
+
}));
|
|
343
|
+
});
|
|
344
|
+
it("should be disabled when app name is empty", () => {
|
|
345
|
+
render(_jsx(Editor, {}));
|
|
346
|
+
const confirmButton = screen.getByText("Confirm");
|
|
347
|
+
expect(confirmButton).toBeDisabled();
|
|
348
|
+
});
|
|
349
|
+
it("should be hidden when status is CONFIRMED", () => {
|
|
350
|
+
vi.mocked(useSelectedAppModuleDocument).mockReturnValue([
|
|
351
|
+
{
|
|
352
|
+
state: {
|
|
353
|
+
global: {
|
|
354
|
+
name: "test-app",
|
|
355
|
+
status: "CONFIRMED",
|
|
356
|
+
allowedDocumentTypes: null,
|
|
357
|
+
isDragAndDropEnabled: true,
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
mockDispatch,
|
|
362
|
+
]);
|
|
363
|
+
render(_jsx(Editor, {}));
|
|
364
|
+
const confirmButton = screen.queryByText("Confirm");
|
|
365
|
+
expect(confirmButton).not.toBeInTheDocument();
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
describe("Read-only Mode", () => {
|
|
369
|
+
it("should disable form fields when status is CONFIRMED", () => {
|
|
370
|
+
vi.mocked(useSelectedAppModuleDocument).mockReturnValue([
|
|
371
|
+
{
|
|
372
|
+
state: {
|
|
373
|
+
global: {
|
|
374
|
+
name: "test-app",
|
|
375
|
+
status: "CONFIRMED",
|
|
376
|
+
allowedDocumentTypes: ["powerhouse/document-model"],
|
|
377
|
+
isDragAndDropEnabled: true,
|
|
378
|
+
},
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
mockDispatch,
|
|
382
|
+
]);
|
|
383
|
+
render(_jsx(Editor, {}));
|
|
384
|
+
const nameInput = screen.getByLabelText("App Name");
|
|
385
|
+
const checkbox = screen.getByLabelText("Enable drag and drop");
|
|
386
|
+
expect(nameInput).toBeDisabled();
|
|
387
|
+
expect(checkbox).toBeDisabled();
|
|
388
|
+
// Document types dropdown should not be visible in read-only mode
|
|
389
|
+
const select = screen.queryByRole("combobox");
|
|
390
|
+
expect(select).not.toBeInTheDocument();
|
|
391
|
+
// Remove buttons should not be visible
|
|
392
|
+
const removeButtons = screen.queryAllByText("×");
|
|
393
|
+
expect(removeButtons).toHaveLength(0);
|
|
394
|
+
});
|
|
395
|
+
it("should enable form fields when status is DRAFT", () => {
|
|
396
|
+
vi.mocked(useSelectedAppModuleDocument).mockReturnValue([
|
|
397
|
+
{
|
|
398
|
+
state: {
|
|
399
|
+
global: {
|
|
400
|
+
name: "test-app",
|
|
401
|
+
status: "DRAFT",
|
|
402
|
+
allowedDocumentTypes: ["powerhouse/document-model"],
|
|
403
|
+
isDragAndDropEnabled: false,
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
mockDispatch,
|
|
408
|
+
]);
|
|
409
|
+
render(_jsx(Editor, {}));
|
|
410
|
+
const nameInput = screen.getByLabelText("App Name");
|
|
411
|
+
const checkbox = screen.getByLabelText("Enable drag and drop");
|
|
412
|
+
expect(nameInput).not.toBeDisabled();
|
|
413
|
+
expect(checkbox).not.toBeDisabled();
|
|
414
|
+
// Document types dropdown should be visible
|
|
415
|
+
const select = screen.getByRole("combobox");
|
|
416
|
+
expect(select).toBeInTheDocument();
|
|
417
|
+
// Remove button should be visible
|
|
418
|
+
const removeButtons = screen.queryAllByText("×");
|
|
419
|
+
expect(removeButtons.length).toBeGreaterThan(0);
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentEditorForm.d.ts","sourceRoot":"","sources":["../../../../editors/document-editor/components/DocumentEditorForm.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,mDAAmD,CAAC;AAI3D,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC1D,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAChE,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,
|
|
1
|
+
{"version":3,"file":"DocumentEditorForm.d.ts","sourceRoot":"","sources":["../../../../editors/document-editor/components/DocumentEditorForm.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,mDAAmD,CAAC;AAI3D,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC1D,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAChE,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAmKhE,CAAC"}
|
|
@@ -32,7 +32,7 @@ export const DocumentEditorForm = ({ editorName: initialEditorName = "", documen
|
|
|
32
32
|
onConfirm?.();
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
return (_jsxs("div", { className: "space-y-6 bg-white p-6", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("h2", { className: "text-lg font-medium text-gray-900", children: "Editor Configuration" }), _jsx(StatusPill, { status: status === "CONFIRMED" ? "confirmed" : "draft", label: status === "CONFIRMED" ? "Confirmed" : "Draft" })] }), _jsxs("div", { children: [_jsx("label", { className: "mb-2 block text-sm font-medium text-gray-700", children: "Editor Name" }), _jsx("input", { type: "text", value: editorName, onChange: (e) => setEditorName(e.target.value), disabled: isReadOnly, className: `w-full rounded-md border border-gray-300 px-3 py-2 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500 ${isReadOnly ? "cursor-not-allowed bg-gray-100" : ""}` })] }), _jsxs("div", { children: [_jsx("label", { className: "mb-2 block text-sm font-medium text-gray-700", children: "Supported Document Types" }), _jsxs("div", { className: "space-y-2", children: [!isReadOnly && availableDocumentTypes.length > 0 && (_jsxs("select", { value: selectedDocumentType, onChange: (e) => {
|
|
35
|
+
return (_jsxs("div", { className: "space-y-6 bg-white p-6", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("h2", { className: "text-lg font-medium text-gray-900", children: "Editor Configuration" }), _jsx(StatusPill, { status: status === "CONFIRMED" ? "confirmed" : "draft", label: status === "CONFIRMED" ? "Confirmed" : "Draft" })] }), _jsxs("div", { children: [_jsx("label", { htmlFor: "editor-name", className: "mb-2 block text-sm font-medium text-gray-700", children: "Editor Name" }), _jsx("input", { id: "editor-name", type: "text", value: editorName, onChange: (e) => setEditorName(e.target.value), disabled: isReadOnly, className: `w-full rounded-md border border-gray-300 px-3 py-2 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500 ${isReadOnly ? "cursor-not-allowed bg-gray-100" : ""}` })] }), _jsxs("div", { children: [_jsx("label", { htmlFor: "supported-document-types", className: "mb-2 block text-sm font-medium text-gray-700", children: "Supported Document Types" }), _jsxs("div", { className: "space-y-2", children: [!isReadOnly && availableDocumentTypes.length > 0 && (_jsxs("select", { id: "supported-document-types", value: selectedDocumentType, onChange: (e) => {
|
|
36
36
|
const selectedValue = e.target.value;
|
|
37
37
|
if (selectedValue) {
|
|
38
38
|
// Remove existing document type if any
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.test.d.ts","sourceRoot":"","sources":["../../../editors/document-editor/editor.test.tsx"],"names":[],"mappings":""}
|