@decocms/apps-vtex 7.28.1 → 8.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/apps-vtex",
3
- "version": "7.28.1",
3
+ "version": "8.0.0",
4
4
  "type": "module",
5
5
  "description": "Deco commerce app: VTEX integration",
6
6
  "repository": {
@@ -51,10 +51,10 @@
51
51
  "lint:unused": "knip"
52
52
  },
53
53
  "dependencies": {
54
- "@decocms/blocks": "7.28.1",
55
- "@decocms/apps-commerce": "7.28.1",
56
- "@decocms/apps-website": "7.28.1",
57
- "@decocms/tanstack": "7.28.1"
54
+ "@decocms/blocks": "8.0.0",
55
+ "@decocms/apps-commerce": "8.0.0",
56
+ "@decocms/apps-website": "8.0.0",
57
+ "@decocms/tanstack": "8.0.0"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@tanstack/react-query": ">=5.0.0",
@@ -721,13 +721,11 @@ describe("toProductShelf", () => {
721
721
  },
722
722
  },
723
723
  ],
724
- // Campanha is the VTEX spec MonteCarlo uses to tag launches ("Lançamentos").
725
- variations: [
726
- { name: "Cor", values: ["Preto"] },
727
- { name: "Campanha", values: ["Lançamentos"] },
728
- ],
724
+ variations: [{ name: "Cor", values: ["Preto"] }],
729
725
  }) as any;
730
726
 
727
+ // Campanha is a PRODUCT specification (in specificationGroups), NOT a sku.variation.
728
+ // It is the marker MonteCarlo uses to tag launches ("Lançamentos").
731
729
  const makeProduct = (overrides: Record<string, unknown> = {}) =>
732
730
  ({
733
731
  origin: "intelligent-search",
@@ -740,25 +738,32 @@ describe("toProductShelf", () => {
740
738
  categoryId: "1",
741
739
  productClusters: [{ id: "100", name: "Sale" }],
742
740
  clusterHighlights: [],
741
+ specificationGroups: [
742
+ { name: "Campanha", specifications: [{ name: "Campanha", values: ["Lançamentos"] }] },
743
+ ],
743
744
  items: [makeSku()],
744
745
  ...overrides,
745
746
  }) as any;
746
747
 
747
748
  const options = { baseUrl: "https://example.com", priceCurrency: "BRL" };
748
749
 
749
- it("keeps the Campanha launch spec in product-level additionalProperty", () => {
750
+ it("surfaces the Campanha launch spec in isVariantOf.additionalProperty (ReleaseFlag reads it)", () => {
750
751
  const result = toProductShelf(makeProduct(), makeSku(), 0, options);
751
- expect(result.additionalProperty).toEqual(
752
+ const groupProps = result.isVariantOf?.additionalProperty ?? [];
753
+ expect(groupProps).toEqual(
752
754
  expect.arrayContaining([
753
755
  expect.objectContaining({ name: "Campanha", value: "Lançamentos" }),
754
756
  ]),
755
757
  );
756
758
  });
757
759
 
758
- it("populates isVariantOf.additionalProperty with the launch spec (ReleaseFlag reads it)", () => {
759
- const result = toProductShelf(makeProduct(), makeSku(), 0, options);
760
- const groupProps = result.isVariantOf?.additionalProperty ?? [];
761
- expect(groupProps.length).toBeGreaterThan(0);
762
- expect(groupProps.some((p) => p.value === "Lançamentos")).toBe(true);
760
+ it("leaves isVariantOf.additionalProperty empty when there is no shelf-safe group spec", () => {
761
+ const result = toProductShelf(
762
+ makeProduct({ specificationGroups: [] }),
763
+ makeSku(),
764
+ 0,
765
+ options,
766
+ );
767
+ expect(result.isVariantOf?.additionalProperty).toEqual([]);
763
768
  });
764
769
  });
@@ -635,6 +635,15 @@ export const toProductShelf = <P extends LegacyProductVTEX | ProductVTEX>(
635
635
  ...clusterAdditionalProperties,
636
636
  ].filter((prop) => SHELF_PROPERTY_NAMES.has(prop.name ?? ""));
637
637
 
638
+ // Product-group specs (from specificationGroups) filtered to shelf-safe names.
639
+ // Launch markers like "Campanha" live here, NOT in sku.variations, so they only
640
+ // reach the card through the ProductGroup's additionalProperty (mirrors toProduct).
641
+ const groupAdditionalProperty = (
642
+ isLegacyProduct(product)
643
+ ? legacyToProductGroupAdditionalProperties(product)
644
+ : toProductGroupAdditionalProperties(product)
645
+ ).filter((prop) => SHELF_PROPERTY_NAMES.has(prop.name ?? ""));
646
+
638
647
  // isVariantOf: single in-stock variant at level 0
639
648
  const isVariantOf =
640
649
  level < 1
@@ -647,10 +656,10 @@ export const toProductShelf = <P extends LegacyProductVTEX | ProductVTEX>(
647
656
  hasVariant: singleVariant,
648
657
  url: getProductGroupURL(baseUrl, product).href,
649
658
  name: product.productName,
650
- // Carry the shelf-safe group props (incl. "Campanha") so ProductCard
659
+ // Carry the shelf-safe group specs (incl. "Campanha") so ProductCard
651
660
  // flags that read isVariantOf.additionalProperty (e.g. ReleaseFlag ->
652
661
  // "Lançamento") still fire on shelf/carousel cards.
653
- additionalProperty,
662
+ additionalProperty: groupAdditionalProperty,
654
663
  } satisfies ProductGroup;
655
664
  })()
656
665
  : undefined;