@powerhousedao/vetra 6.0.0-dev.17 → 6.0.0-dev.18

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.
@@ -1,12 +1,15 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { render, screen, waitFor } from "@testing-library/react";
3
3
  import { userEvent } from "@testing-library/user-event";
4
- import { beforeEach, describe, expect, it, vi } from "vitest";
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
5
  import { useSelectedAppModuleDocument } from "../../document-models/app-module/hooks.js";
6
6
  import Editor from "./editor.js";
7
7
  vi.mock("../../document-models/app-module/hooks.js", () => ({
8
8
  useSelectedAppModuleDocument: vi.fn(),
9
9
  }));
10
+ vi.mock("@powerhousedao/design-system/connect", () => ({
11
+ DocumentToolbar: () => null,
12
+ }));
10
13
  vi.mock("@powerhousedao/reactor-browser", async (importOriginal) => {
11
14
  const actual = await importOriginal();
12
15
  return {
@@ -34,6 +37,7 @@ vi.mock("@powerhousedao/reactor-browser", async (importOriginal) => {
34
37
  describe("AppModule Editor", () => {
35
38
  let mockDispatch;
36
39
  beforeEach(() => {
40
+ window.ph = {};
37
41
  mockDispatch = vi.fn();
38
42
  vi.mocked(useSelectedAppModuleDocument).mockReturnValue([
39
43
  {
@@ -49,6 +53,9 @@ describe("AppModule Editor", () => {
49
53
  mockDispatch,
50
54
  ]);
51
55
  });
56
+ afterEach(() => {
57
+ delete window.ph;
58
+ });
52
59
  describe("Core Rendering", () => {
53
60
  it("should render all main form sections and labels", () => {
54
61
  render(_jsx(Editor, {}));
@@ -108,12 +108,12 @@ describe("CodegenProcessorLegacy E2E Tests", () => {
108
108
  await vi.runAllTimersAsync();
109
109
  const generateEditorArgs = [
110
110
  {
111
- name: "Test Editor",
111
+ ...mockConfig.PH_CONFIG,
112
+ editorName: "Test Editor",
112
113
  documentTypes: [
113
114
  "powerhouse/document-model",
114
115
  "powerhouse/budget-statement",
115
116
  ],
116
- config: mockConfig.PH_CONFIG,
117
117
  editorId: "test-editor",
118
118
  useTsMorph: USE_TS_MORPH,
119
119
  },
@@ -290,7 +290,7 @@ describe("CodegenProcessorLegacy E2E Tests", () => {
290
290
  };
291
291
  await processor.onStrands([strand]);
292
292
  await vi.runAllTimersAsync();
293
- expect(generateProcessor).toHaveBeenCalledWith("Test Processor", "analytics", ["powerhouse/document-model", "powerhouse/budget-statement"], mockConfig.PH_CONFIG);
293
+ expect(generateProcessor).toHaveBeenCalledWith("Test Processor", "analytics", ["powerhouse/document-model", "powerhouse/budget-statement"], mockConfig.PH_CONFIG.skipFormat);
294
294
  });
295
295
  it("should map relational type to relationalDb when processing processor strand", async () => {
296
296
  const { generateProcessor } = await import("@powerhousedao/codegen");
@@ -309,7 +309,7 @@ describe("CodegenProcessorLegacy E2E Tests", () => {
309
309
  };
310
310
  await processor.onStrands([strand]);
311
311
  await vi.runAllTimersAsync();
312
- expect(generateProcessor).toHaveBeenCalledWith("Test Processor", "relationalDb", ["powerhouse/document-model"], mockConfig.PH_CONFIG);
312
+ expect(generateProcessor).toHaveBeenCalledWith("Test Processor", "relationalDb", ["powerhouse/document-model"], mockConfig.PH_CONFIG.skipFormat);
313
313
  });
314
314
  it("should not call generateProcessor for unsupported processor type", async () => {
315
315
  const { generateProcessor } = await import("@powerhousedao/codegen");
@@ -366,10 +366,10 @@ describe("CodegenProcessorLegacy E2E Tests", () => {
366
366
  await vi.runAllTimersAsync();
367
367
  const generateDriveEditorArgs = [
368
368
  {
369
- name: "Test App",
370
- config: mockConfig.PH_CONFIG,
371
- appId: "test-app",
372
- allowedDocumentTypes: "",
369
+ driveEditorName: "Test App",
370
+ ...mockConfig.PH_CONFIG,
371
+ driveEditorId: "test-app",
372
+ allowedDocumentTypes: [],
373
373
  isDragAndDropEnabled: false,
374
374
  useTsMorph: USE_TS_MORPH,
375
375
  },
@@ -404,10 +404,13 @@ describe("CodegenProcessorLegacy E2E Tests", () => {
404
404
  await processor.onStrands([strand]);
405
405
  await vi.runAllTimersAsync();
406
406
  expect(generateDriveEditor).toHaveBeenCalledWith({
407
- name: "Test App",
408
- config: mockConfig.PH_CONFIG,
409
- appId: "test-app",
410
- allowedDocumentTypes: "powerhouse/document-model,powerhouse/budget-statement",
407
+ driveEditorName: "Test App",
408
+ ...mockConfig.PH_CONFIG,
409
+ driveEditorId: "test-app",
410
+ allowedDocumentTypes: [
411
+ "powerhouse/document-model",
412
+ "powerhouse/budget-statement",
413
+ ],
411
414
  isDragAndDropEnabled: true,
412
415
  useTsMorph: USE_TS_MORPH,
413
416
  });
@@ -557,9 +560,9 @@ describe("CodegenProcessorLegacy E2E Tests", () => {
557
560
  await processor.onStrands(strands);
558
561
  await vi.runAllTimersAsync();
559
562
  expect(generateEditor).toHaveBeenCalledWith({
560
- name: "Test Editor",
563
+ editorName: "Test Editor",
561
564
  documentTypes: ["powerhouse/document-model"],
562
- config: mockConfig.PH_CONFIG,
565
+ ...mockConfig.PH_CONFIG,
563
566
  editorId: "test-editor",
564
567
  useTsMorph: USE_TS_MORPH,
565
568
  });
@@ -596,9 +599,9 @@ describe("CodegenProcessorLegacy E2E Tests", () => {
596
599
  await vi.runAllTimersAsync();
597
600
  // Valid strand should be processed
598
601
  expect(generateEditor).toHaveBeenCalledWith({
599
- name: "Test Editor",
602
+ editorName: "Test Editor",
600
603
  documentTypes: ["powerhouse/document-model"],
601
- config: mockConfig.PH_CONFIG,
604
+ ...mockConfig.PH_CONFIG,
602
605
  editorId: "test-editor",
603
606
  useTsMorph: USE_TS_MORPH,
604
607
  });
@@ -43,10 +43,10 @@ export class AppGenerator extends BaseDocumentGen {
43
43
  const appId = kebabCase(state.name);
44
44
  // Generate the drive editor using the codegen function
45
45
  await generateDriveEditor({
46
- name: state.name,
47
- config: this.config.PH_CONFIG,
48
- appId: appId,
49
- allowedDocumentTypes: state.allowedDocumentTypes?.join(","),
46
+ ...this.config.PH_CONFIG,
47
+ driveEditorName: state.name,
48
+ driveEditorId: appId,
49
+ allowedDocumentTypes: state.allowedDocumentTypes ?? [],
50
50
  isDragAndDropEnabled: state.isDragAndDropEnabled,
51
51
  useTsMorph: USE_TS_MORPH,
52
52
  });
@@ -48,9 +48,9 @@ export class DocumentEditorGenerator extends BaseDocumentGen {
48
48
  const editorId = kebabCase(state.name);
49
49
  // Generate the editor using the codegen function
50
50
  await generateEditor({
51
- name: state.name,
51
+ ...this.config.PH_CONFIG,
52
+ editorName: state.name,
52
53
  documentTypes: documentTypes,
53
- config: this.config.PH_CONFIG,
54
54
  editorId: editorId,
55
55
  useTsMorph: USE_TS_MORPH,
56
56
  });
@@ -63,7 +63,7 @@ export class ProcessorGenerator extends BaseDocumentGen {
63
63
  // Extract document types from the state
64
64
  const documentTypes = state.documentTypes.map((dt) => dt.documentType);
65
65
  // Generate the processor using the codegen function
66
- await generateProcessor(state.name, processorType, documentTypes, this.config.PH_CONFIG);
66
+ await generateProcessor(state.name, processorType, documentTypes, this.config.PH_CONFIG.skipFormat);
67
67
  logger.info(`✅ Processor generation completed successfully for: ${state.name}`);
68
68
  // Backup the document
69
69
  await backupDocument(strand.document, this.config.CURRENT_WORKING_DIR, undefined, state.name);