Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

fix(core): name the product-delete when block in apply-product-change-actions (#1743)

Viktor Holikfabf4ae7969c
diff --git a/packages/core/src/workflows/__tests__/when-names.unit.spec.ts b/packages/core/src/workflows/__tests__/when-names.unit.spec.ts
new file mode 100644
index 000000000..56b1a70d8
--- /dev/null
+++ b/packages/core/src/workflows/__tests__/when-names.unit.spec.ts
@@ -0,0 +1,16 @@
+describe("workflow definitions", () => {
+ it("give every when-then block that returns a value a stable name", async () => {
+ const warn = jest.spyOn(console, "warn").mockImplementation(() => {})
+
+ await import("..")
+ await new Promise((resolve) => setImmediate(resolve))
+
+ const unnamed = warn.mock.calls
+ .map((args) => args.map(String).join(" "))
+ .filter((message) => message.includes('"when" name should be defined'))
+
+ warn.mockRestore()
+
+ expect(unnamed).toEqual([])
+ })
+})
diff --git a/packages/core/src/workflows/product-edit/workflows/apply-product-change-actions.ts b/packages/core/src/workflows/product-edit/workflows/apply-product-change-actions.ts
index d79616c19..4638c973f 100644
--- a/packages/core/src/workflows/product-edit/workflows/apply-product-change-actions.ts
+++ b/packages/core/src/workflows/product-edit/workflows/apply-product-change-actions.ts
@@ -275,6 +275,7 @@ export const applyProductChangeActionsWorkflow: ReturnWorkflow<
})
const deletedProductOffers = when(
+ "delete-products-and-load-offers",
{ buckets },
({ buckets }) => buckets.productsToDelete.length > 0,
).then(() => {