From 2433cf882c1435ac4d074e33b96bcb72b69d5d97 Mon Sep 17 00:00:00 2001 From: nlicroshan Date: Mon, 16 Oct 2023 18:03:39 +0800 Subject: [PATCH] fix(): also update brick tree before build Closes NEXT_BUILDER-3913 --- .../src/shared/workbench/WorkbenchBackend.spec.ts | 15 +++++++++++---- .../src/shared/workbench/WorkbenchBackend.ts | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/bricks/next-builder/src/shared/workbench/WorkbenchBackend.spec.ts b/bricks/next-builder/src/shared/workbench/WorkbenchBackend.spec.ts index 4ebf4e48d..964052674 100644 --- a/bricks/next-builder/src/shared/workbench/WorkbenchBackend.spec.ts +++ b/bricks/next-builder/src/shared/workbench/WorkbenchBackend.spec.ts @@ -177,7 +177,14 @@ describe("WorkbenchBackend should work", () => { jest.runAllTimers(); await (global as any).flushPromises(); - expect(handleBackendMessage).toHaveBeenNthCalledWith(3, "message", { + expect(handleBackendMessage).toHaveBeenNthCalledWith( + 3, + "message", + expect.objectContaining({ + action: "update-graph-data", + }) + ); + expect(handleBackendMessage).toHaveBeenNthCalledWith(4, "message", { action: "build-start", }); @@ -192,7 +199,7 @@ describe("WorkbenchBackend should work", () => { }, }); - expect(handleBackendMessage).toHaveBeenNthCalledWith(4, "message", { + expect(handleBackendMessage).toHaveBeenNthCalledWith(5, "message", { action: "build-success", data: { storyboard: { @@ -360,7 +367,7 @@ describe("WorkbenchBackend should work", () => { instanceId: "abc", }); - expect(handleBackendMessage).toBeCalledTimes(10); + expect(handleBackendMessage).toBeCalledTimes(11); backendInstance.unsubscribe(listener); backendInstance.push({ @@ -373,7 +380,7 @@ describe("WorkbenchBackend should work", () => { }); await (global as any).flushPromises(); - expect(handleBackendMessage).toBeCalledTimes(10); + expect(handleBackendMessage).toBeCalledTimes(11); // @ts-ignore backendInstance.mockNodeIdCache.set("mock_id_1", "new-id"); diff --git a/bricks/next-builder/src/shared/workbench/WorkbenchBackend.ts b/bricks/next-builder/src/shared/workbench/WorkbenchBackend.ts index ff963a056..39b635451 100644 --- a/bricks/next-builder/src/shared/workbench/WorkbenchBackend.ts +++ b/bricks/next-builder/src/shared/workbench/WorkbenchBackend.ts @@ -470,6 +470,7 @@ export default class WorkbenchBackend { if (this.isBuilding) return; this.isBuilding = true; try { + await this.updateBrickTree(); // eslint-disable-next-line no-console console.log("=== building ==="); this.publish("message", {