@davoodmehraban89 / medusa / commits / 49845c7e
Fork 0

test(preview): verify sample catalog market scope, translation coverage and no invented prices

davoodmehraban89 committed Oct 15, 2026 at 01:27 UTC 49845c7e3e26172f5d63e17f44ea723292638a2a
1 file changed +33
commerce/src/preview/products.test.ts new
+33
@@ -0,0 +1,33 @@
1 +import { describe, expect, it } from "vitest"
2 +import { LOCALES, MARKETS } from "../config/markets"
3 +import { PREVIEW_PRODUCTS, previewProductsForMarket } from "./products"
4 +
5 +describe("public storefront demonstration catalogue", () => {
6 + it("provides examples for all five markets", () => {
7 + for (const market of Object.keys(MARKETS) as Array<keyof typeof MARKETS>) {
8 + expect(previewProductsForMarket(market).length).toBeGreaterThan(0)
9 + }
10 + })
11 + it("limits electronics examples to the Iranian market", () => {
12 + expect(previewProductsForMarket("IR").some((p) => p.kind === "electronics")).toBe(true)
13 + for (const market of ["AE", "OM", "IQ", "QA"] as const) {
14 + expect(previewProductsForMarket(market).every((p) => p.kind === "iranian")).toBe(true)
15 + }
16 + })
17 + it("has complete, nonempty translations and unique sample IDs", () => {
18 + expect(new Set(PREVIEW_PRODUCTS.map((p) => p.id)).size).toBe(PREVIEW_PRODUCTS.length)
19 + for (const product of PREVIEW_PRODUCTS) {
20 + for (const locale of Object.keys(LOCALES) as Array<keyof typeof LOCALES>) {
21 + expect(product.name[locale].trim()).not.toBe("")
22 + expect(product.description[locale].trim()).not.toBe("")
23 + }
24 + }
25 + })
26 + it("has no imaginary price or inventory fields", () => {
27 + for (const p of PREVIEW_PRODUCTS) {
28 + expect("price" in p).toBe(false)
29 + expect("inventory" in p).toBe(false)
30 + expect("available" in p).toBe(false)
31 + }
32 + })
33 +})