Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
fix(settings): show Merchant Center as coming soon while the server has no setup for it, and claim its checks only for brands it reads (#1618)
Cihan5986fd678c5b
diff --git a/web/messages/en.json b/web/messages/en.jsonindex a78cc324b..39d28f109 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -4460,7 +4460,7 @@},"shopping": {"title": "Shopping path",- "description": "Where this page sends readers. Picked by topic, stock and Merchant Center status. Prices and specs come from the catalog only.",+ "description": "Where this page sends readers. Picked by topic and stock, and by Merchant Center status once it's connected. Prices and specs come from the catalog only.","empty": "Pick the category page and the products in stock this page links, from your catalog.","build": "Pick from the catalog","rebuild": "Pick again",@@ -4475,7 +4475,7 @@"noPath": {"not_a_shop": "Shopping paths are for brands that sell online. Set the site type to E-commerce in Brand settings.","page_type": "This page type doesn't link products. Buying guides, best-of lists, comparisons, guides and blog posts do.",- "no_catalog": "There's no catalog to pick from yet. Connect Google Merchant Center or a product feed in Settings › Integrations.",+ "no_catalog": "There's no catalog to pick from yet. Add a product feed URL or upload a file in Settings › Integrations › Product catalog.","no_match": "Nothing in your catalog matches this page's topic. Name what you sell in the title or the brief's keywords, then pick again.","other": "No shopping path fits this page right now. Try again later."},@@ -5075,7 +5075,7 @@"reading": "Reading your catalog for the linked products' stock…","failed": "Couldn't read your catalog: check the products the page links are in stock before you publish.","ok": "Shopping links work",- "okDetail": "{count, plural, =0 {{category, select, yes {No product linked yet; the category page is.} other {No product linked yet.}}} one {# product linked, in stock and accepted by Merchant Center.} other {# products linked, in stock and accepted by Merchant Center.}}",+ "okDetail": "{count, plural, =0 {{category, select, yes {No product linked yet; the category page is.} other {No product linked yet.}}} one {# product linked, {merchantCenter, select, yes {in stock and accepted by Merchant Center} other {in stock}}.} other {# products linked, {merchantCenter, select, yes {in stock and accepted by Merchant Center} other {in stock}}.}}","bad": "{count, plural, one {# product link to remove or replace} other {# product links to remove or replace}}","badDetail": "{list}{more, plural, =0 {} other { +# more}}. Remove or replace these links on the page: Brief › Shopping path lists products that sell.","item": "{title} ({state, select, sold_out {not in stock} refused {Merchant Center refuses it} gone {no longer in the catalog} other {check it}})",@@ -5182,7 +5182,7 @@"confirmCaseFull": "This page keeps 50 confirmations already.","feed": {"none": "Price and stock aren't checked: no product feed is connected for this brand yet.",- "connect": "Connect a feed",+ "connect": "Add a feed URL or a file","notFound": "Price and stock aren't checked: no product in your feed has this page's URL or title."},"weightsFor": {@@ -5582,8 +5582,8 @@"first40Words": "ChatGPT reads about the first 50 tokens (~40 words) of a product description. The rest is ignored.","feedMatch": "Checked against the product in your product feed with this page's URL, or else its name: the price, any GTIN the page gives, and the stock, where both say them.","shopCategoryLink": "A link to the category page in Brief › Shopping path, so readers and AI answers reach the products.",- "shopProductLinks": "Links to the products in Brief › Shopping path that are in stock and accepted by Merchant Center: this many, or all of them when fewer are. A product card or grid counts.",- "shopLinksLive": "Every product the page links from its shopping path, or removed from it, is in stock, accepted by Merchant Center for free listings, and still in the catalog. Remove or replace a link to one that isn't, on the page.",+ "shopProductLinks": "Links to the products in Brief › Shopping path that are {merchantCenter, select, yes {in stock and accepted by Merchant Center} other {in stock}}: this many, or all of them when fewer are. A product card or grid counts.",+ "shopLinksLive": "Every product the page links from its shopping path, or removed from it, is in stock{merchantCenter, select, yes {, accepted by Merchant Center for free listings,} other {}} and still in the catalog. Remove or replace a link to one that isn't, on the page.","definitionFirst": "The paragraph under the H1 says what the term is (\"X is …\") in a few words: what answer engines quote for \"what is\" prompts.","measureSteps": "The longest numbered list on the page counts as the steps."},@@ -7480,7 +7480,7 @@"lockedDescription": "Free and Starter plans see the shopping card rate. Growth unlocks the My Products tab, competitor breakdown, card-eligible prompts, and merchant analytics.","tabOverview": "Overview","tabMyProducts": "My Products",- "connectCatalog": "These are your products as AI shopping cards showed them. Connect your product catalog (Google Merchant Center or a product feed) in <link>Settings › Integrations</link>, and the Content Editor checks your product pages' price, GTIN and stock against it.",+ "connectCatalog": "These are your products as AI shopping cards showed them. Add your product catalog (a product feed URL or a file you upload) in <link>Settings › Integrations</link>, and the Content Editor checks your product pages' price, GTIN and stock against it.","tabCompetitors": "Competitors","colProductTitle": "Product Title","colPlatforms": "Platforms",@@ -8159,6 +8159,7 @@},"merchantCenter": {"description": "Your products and the problems Merchant Center reports for them. Google AI Overviews and AI Mode show products from it.",+ "comingSoon": "Until it's available, add your products with a feed URL or a file upload in Product catalog below.","title": "Merchant Center account for {brand}","hint": "Pick the account that sells this brand's products. They're read every day into the brand's product catalog below, with their issues.","noBrand": "Pick a brand to add its Merchant Center account.",@@ -8261,6 +8262,7 @@},"integrations_connected": "Connected","integrations_notConfigured": "Not configured",+ "integrations_comingSoon": "Coming soon","integrations_disconnect": "Disconnect","integrations_disconnectDescription": "The stored connection is removed for the whole organization. You can reconnect at any time.","removeMember": "Remove team member",diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.test.tsxindex c7a50e51b..d5c688275 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.test.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.test.tsx@@ -203,6 +203,7 @@ describe('BeforePublish', () => {products: 4,want: 0,categories: 1,+ merchantCenter: true,...over,});const shoppingRow = () => rows().find((r) => r?.startsWith('Shopping links'));@@ -273,6 +274,26 @@ describe('BeforePublish', () => {expect(none).not.toContain('category page');});+ it('says the products are accepted by Merchant Center only when the brand has it', async () => {+ const summit = [product('Summit', 'ok')];+ await render(quality(), {+ shopping: links({ linked: summit, want: 1, merchantCenter: false }),+ });+ const one = rows().find((r) => r?.startsWith('Shopping links work'));+ expect(one).toContain('1 product linked, in stock.');+ expect(one).not.toContain('Merchant Center');++ const two = [...summit, product('Ridge', 'ok')];+ await render(quality(), { shopping: links({ linked: two, want: 2, merchantCenter: false }) });+ expect(rows().find((r) => r?.startsWith('Shopping links work'))).toContain(+ '2 products linked, in stock.',+ );+ await render(quality(), { shopping: links({ linked: two, want: 2 }) });+ expect(rows().find((r) => r?.startsWith('Shopping links work'))).toContain(+ '2 products linked, in stock and accepted by Merchant Center.',+ );+ });+it('says the catalog is being read, or couldn’t be, and shows no row without a path', async () => {await render(quality(), { shopping: 'reading' });expect(shoppingRow()).toBe(diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.tsxindex b5d76ac5e..7cfba8416 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.tsx@@ -713,6 +713,8 @@ function shoppingRow(t: T, shopping: ShoppingLinks | 'reading' | 'failed'): Rowdetail: t('shopping.okDetail', {count: shopping.linked.length,category: shopping.categoryLinked ? 'yes' : 'no',+ // Accepted by Merchant Center is said only where it was read.+ merchantCenter: shopping.merchantCenter ? 'yes' : 'no',}),};}diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.test.tsxindex d4c85e2ac..886c3b858 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.test.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.test.tsx@@ -192,7 +192,7 @@ describe('QualityTab', () => {expect(container.querySelector<HTMLAnchorElement>('a[href="/dashboard/settings/integrations"]')?.textContent,- ).toBe('Connect a feed');+ ).toBe('Add a feed URL or a file');await render({ ...read(result), feed: 'notFound' });expect(container.textContent).toContain("no product in your feed has this page's URL or title");await render(read(result));diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.test.tsxindex 9ff09bc0f..4e9845b12 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.test.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.test.tsx@@ -508,6 +508,7 @@ describe('the Rules tab', () => {const shopping = {categories: [],site: null,+ merchantCenter: true,products: titles.map((t, i) => ({key: `shop.example/products/${t}`,title: t.toUpperCase(),@@ -540,6 +541,31 @@ describe('the Rules tab', () => {);});+ it('explains the Shopping rules on hover, accepted by Merchant Center only when the brand has it', async () => {+ const checked = activeRules(ruleSet('buying_guide', { shopping: true }), {+ overrides: {},+ }).map((rule) => ({ rule, status: { state: 'ok' as const } }));+ const hint = (name: string) =>+ [...container.querySelectorAll('span')].find((s) => s.textContent === name)?.title;++ await render(state(undefined, { rules: checked, ...rulesMet(checked) }));+ expect(hint('Links its category page')).toContain('A link to the category page');+ expect(hint("Links the shopping path's products")).toBe(+ 'Links to the products in Brief › Shopping path that are in stock: this many, or all of them when fewer are. A product card or grid counts.',+ );+ expect(hint('No out-of-stock or refused product linked')).toBe(+ "Every product the page links from its shopping path, or removed from it, is in stock and still in the catalog. Remove or replace a link to one that isn't, on the page.",+ );++ await render(state(undefined, { rules: checked, ...rulesMet(checked), merchantCenter: true }));+ expect(hint("Links the shopping path's products")).toContain(+ 'that are in stock and accepted by Merchant Center: this many',+ );+ expect(hint('No out-of-stock or refused product linked')).toContain(+ 'is in stock, accepted by Merchant Center for free listings, and still in the catalog.',+ );+ });+it('shows Ansvisor’s set when a draft on My rules has none for its type', async () => {await render(state(undefined, { source: 'mine', mineTypes: [] }));const trigger = container.querySelector('[aria-label="Rule set"]')!;diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.tsxindex b8412aa20..4fe8463bf 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.tsx@@ -66,6 +66,9 @@ const HINTED = new Set(['whoFor','first40Words','feedMatch',+ 'shopCategoryLink',+ 'shopProductLinks',+ 'shopLinksLive',]);/**@@ -458,6 +461,7 @@ export function RulesTab({onChange={(change) => state.change(rule.key, change)}agentFix={rule.key === 'aiTraces' ? agentFix : undefined}onOpenSources={onOpenSources}+ merchantCenter={state.merchantCenter ?? false}note={rule.key === 'length' && state.lengthConflict? t('lengthConflict', state.lengthConflict)@@ -661,6 +665,7 @@ function RuleRow({onChange,agentFix,onOpenSources,+ merchantCenter,note,}: {rule: ActiveRule;@@ -669,6 +674,8 @@ function RuleRow({/** "Remove AI traces" offers Fix: the agent rewrites only those phrases. */agentFix?: AgentFix;onOpenSources?: () => void;+ /** The brand has a Merchant Center account: the Shopping hints say it's checked. */+ merchantCenter: boolean;/** A warning under the rule: Length, when the other rules can't fit in it. */note?: string;}) {@@ -689,7 +696,11 @@ function RuleRow({)}<spanclassName="min-w-0 flex-1 text-xs"- title={HINTED.has(rule.key) ? t(`hints.${rule.key}`) : undefined}+ title={+ HINTED.has(rule.key)+ ? t(`hints.${rule.key}`, { merchantCenter: merchantCenter ? 'yes' : 'no' })+ : undefined+ }>{name}</span>diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_use-draft-rules.ts b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_use-draft-rules.tsindex d2699a4e2..bef5b618a 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_use-draft-rules.ts+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_use-draft-rules.ts@@ -57,6 +57,11 @@ export interface DraftRulesState {settled?: boolean;/** The sections and questions the rules ask for take more than Length allows. */lengthConflict: { need: number; max: number } | null;+ /**+ * The draft's brand reads a Google Merchant Center account into its+ * catalog (the shopping check's): the Shopping hints say what it accepts.+ */+ merchantCenter?: boolean;/*** The rules checked against another page (an agent's change applied to a* copy): what it would meet and break (editor test 2026-10-25).@@ -278,6 +283,7 @@ export function useDraftRules({total,length: ruleLength(rules, setType),lengthConflict: conflict,+ merchantCenter: typeof shopping === 'object' && shopping !== null && shopping.merchantCenter,checkHtml,change: (key, change) =>edited({diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_use-shopping-check.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_use-shopping-check.test.tsxindex d46ea30d7..f56302f0b 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_use-shopping-check.test.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_use-shopping-check.test.tsx@@ -23,6 +23,7 @@ const check = (title: string): ShoppingCheck => ({categories: [],products: [{ key: `shop.example/products/${title}`, title, state: 'ok', inPath: true }],site: null,+ merchantCenter: false,});let container: HTMLDivElement;diff --git a/web/src/components/settings/integrations-section.test.tsx b/web/src/components/settings/integrations-section.test.tsxindex 7f8a55700..5681c1a40 100644--- a/web/src/components/settings/integrations-section.test.tsx+++ b/web/src/components/settings/integrations-section.test.tsx@@ -92,6 +92,11 @@ function groupOf(element: Element | null) {}const byText = (text: string) =>[...container.querySelectorAll('p')].find((p) => p.textContent === text) ?? null;+/** Merchant Center's card: its row and the lines under it. */+const merchantCenter = () => byText('Google Merchant Center')?.closest('.space-y-4') ?? null;+/** The badges a card shows, by their words. */+const badges = (card: Element) =>+ [...card.querySelectorAll('[class*="group/badge"]')].map((b) => b.textContent);describe('IntegrationsSection', () => {it('names its groups with headings, each group labelled by its own', async () => {@@ -130,16 +135,59 @@ describe('IntegrationsSection', () => {expect(container.querySelector('[data-card="catalog"]')).not.toBeNull();});- it('keeps it hidden on the cloud while it is not set up there; a self-hosted server shows it', async () => {+ it('says Coming soon on the cloud while it is not set up there, with nothing to connect', async () => {statuses['google-merchant-center'] = 'not_configured';cloud.on = true;await render();- expect(byText('Google Merchant Center')).toBeNull();+ const card = merchantCenter()!;+ expect(card).not.toBeNull();+ expect(badges(card)).toEqual(['Coming soon']);+ expect(card.textContent).toContain(+ "Until it's available, add your products with a feed URL or a file upload in Product catalog below.",+ );+ expect(card.querySelector('button')).toBeNull();+ // Not the self-hosted set-up line, nor its badge.+ expect(card.textContent).not.toContain('Not configured');+ expect(card.textContent).not.toContain('COMPOSIO_GMC_AUTH_CONFIG_ID');+ });++ it('keeps the set-up line on a self-hosted server that is not set up for it', async () => {+ statuses['google-merchant-center'] = 'not_configured';+ cloud.on = false;+ await render();+ const card = merchantCenter()!;+ expect(card).not.toBeNull();+ expect(badges(card)).toEqual(['Not configured']);+ expect(card.textContent).toContain('COMPOSIO_GMC_AUTH_CONFIG_ID');+ expect(card.textContent).not.toContain('Coming soon');+ expect(card.textContent).not.toContain('Until it');++ // A provider without it keeps the set-up line.+ statuses['google-search-console'] = 'not_configured';act(() => root.unmount());root = createRoot(container);- cloud.on = false;await render();- expect(byText('Google Merchant Center')).not.toBeNull();+ const gsc = byText('Google Search Console')!.closest('.space-y-4')!;+ expect(gsc.textContent).toContain('Not configured');+ expect(gsc.textContent).toContain('COMPOSIO_GSC_AUTH_CONFIG_ID');+ expect(gsc.textContent).not.toContain('Coming soon');+ });++ it('connects Merchant Center as before once the server is set up for it', async () => {+ statuses['google-merchant-center'] = 'not_connected';+ await render();+ const card = merchantCenter()!;+ expect(badges(card)).toEqual([]);+ expect([...card.querySelectorAll('button')].map((b) => b.textContent)).toEqual(['Connect']);+ expect(card.textContent).not.toContain('Coming soon');+ expect(card.textContent).not.toContain('Until it');++ act(() => root.unmount());+ root = createRoot(container);+ statuses['google-merchant-center'] = 'connected';+ await render();+ expect(badges(merchantCenter()!)).toEqual(['Connected']);+ expect(merchantCenter()!.textContent).toContain('Disconnect');});it("reads the category pages again on each read of a brand's sources after its first", async () => {diff --git a/web/src/components/settings/integrations-section.tsx b/web/src/components/settings/integrations-section.tsxindex 8b74cd573..9773fca3b 100644--- a/web/src/components/settings/integrations-section.tsx+++ b/web/src/components/settings/integrations-section.tsx@@ -112,6 +112,7 @@ export function IntegrationsSection() {icon={<ShoppingBag className="h-5 w-5 text-muted-foreground" />}authConfigEnv="COMPOSIO_GMC_AUTH_CONFIG_ID"hideUnavailable+ comingSoon={t('merchantCenter.comingSoon')}><MerchantCenterAccountssources={catalogSources}@@ -156,6 +157,12 @@ function IntegrationGroup({ title, children }: { title: string; children: ReactN* `hideUnavailable`: a newer integration's card isn't shown while its status* can't be read (an API older than the web), nor on the cloud while it isn't* set up there; a self-hosted server keeps the set-up line.+ *+ * `comingSoon`: while the cloud isn't set up for it, the card says Coming+ * soon and this line instead, with nothing to connect (Google Merchant+ * Center, until Google approves the connection); a self-hosted server keeps+ * the set-up line. Sources a brand added before stay in Product catalog,+ * where they're removed.*/function IntegrationCard({provider,@@ -164,6 +171,7 @@ function IntegrationCard({icon,authConfigEnv,hideUnavailable = false,+ comingSoon,children,}: {provider: IntegrationProvider;@@ -172,6 +180,7 @@ function IntegrationCard({icon: ReactNode;authConfigEnv: string;hideUnavailable?: boolean;+ comingSoon?: string;children?: ReactNode;}) {const t = useTranslations('settings');@@ -216,7 +225,10 @@ function IntegrationCard({}};- if (hideUnavailable && (unreadable || (status === 'not_configured' && isCloud()))) return null;+ const soon = comingSoon !== undefined && status === 'not_configured' && isCloud();+ if (hideUnavailable && (unreadable || (status === 'not_configured' && isCloud() && !soon))) {+ return null;+ }return (<div className="space-y-4">@@ -236,12 +248,17 @@ function IntegrationCard({{t('integrations_connected')}</Badge>)}+ {soon && (+ <Badge variant="secondary" className="bg-muted text-muted-foreground">+ {t('integrations_comingSoon')}+ </Badge>+ )}</div><p className="text-xs text-muted-foreground truncate">{description}</p></div></div>- {status === null ? (+ {soon ? null : status === null ? (<Skeleton className="h-8 w-24" />) : status === 'not_configured' ? (<Badge variant="outline" className="text-muted-foreground shrink-0">@@ -293,7 +310,9 @@ function IntegrationCard({)}</div>- {status === 'not_configured' && (+ {soon && <p className="text-xs text-muted-foreground">{comingSoon}</p>}++ {status === 'not_configured' && !soon && (<p className="text-xs text-muted-foreground">This server has no Composio credentials for {label}. Set{' '}<code className="rounded bg-muted px-1">COMPOSIO_API_KEY</code> and{' '}diff --git a/web/src/lib/actions/shopping-path.test.ts b/web/src/lib/actions/shopping-path.test.tsindex 741e8e4ed..f93eb60ad 100644--- a/web/src/lib/actions/shopping-path.test.ts+++ b/web/src/lib/actions/shopping-path.test.ts@@ -535,6 +535,7 @@ describe('getShoppingCheck', () => {catalog_products: [],catalog_variants: [],catalog_item_issues: [],+ catalog_sources: [],};answer = (call) => {if (down[call.table]) return { data: null, error: { message: down[call.table] } };@@ -633,6 +634,7 @@ describe('getShoppingCheck', () => {price: null,})),site: 'https://www.shop.example/',+ merchantCenter: false,});// The refusals of the variants in stock alone.expect(of('catalog_item_issues').flatMap(inList).sort()).toEqual(@@ -718,6 +720,43 @@ describe('getShoppingCheck', () => {expect(of('catalog_item_issues').map((c) => inList(c).length)).toEqual([100, 100, 100]);});+ it('says whether the brand has a Merchant Center account it read, none when it can’t be read', async () => {+ draftRow().shopping_path = pathOf({ products: [inPath(1)] });+ db.catalog_sources = [+ { id: 's1', brand_id: SHOP, kind: 'feed_url', last_status: 'ok' },+ { id: 's2', brand_id: BRAND, kind: 'merchant_center', last_status: 'ok' },+ { id: 's3', brand_id: SHOP, kind: 'merchant_center', last_status: 'auth_failed' },+ { id: 's4', brand_id: SHOP, kind: 'merchant_center', last_status: null },+ ];+ // A feed, another brand's Merchant Center, and this brand's never read+ // (its syncs failed, or none ran yet): none to claim it for.+ expect((await getShoppingCheck(DRAFT))!.merchantCenter).toBe(false);+ expect(of('catalog_sources').at(-1)!.filters).toEqual([+ ['eq', 'brand_id', SHOP],+ ['eq', 'kind', 'merchant_center'],+ ['eq', 'last_status', 'ok'],+ ]);+ db.catalog_sources.push({+ id: 's5',+ brand_id: SHOP,+ kind: 'merchant_center',+ last_status: 'ok',+ });+ expect((await getShoppingCheck(DRAFT))!.merchantCenter).toBe(true);++ // Unread: none said, and the rest of the check stands.+ const error = vi.spyOn(console, 'error').mockImplementation(() => {});+ try {+ down = { catalog_sources: 'down' };+ expect(await getShoppingCheck(DRAFT)).toMatchObject({+ products: [{ key: 'shop.example/products/1' }],+ merchantCenter: false,+ });+ } finally {+ error.mockRestore();+ }+ });+it('reads a relative link against the live page, the page it optimizes, else the brand’s site', async () => {draftRow().published_url = 'https://shop.example/blog/boots';draftRow().source_url = 'https://shop.example/old';@@ -745,7 +784,7 @@ describe('getShoppingCheck', () => {draftRow().shopping_path = null;expect(await getShoppingCheck(DRAFT)).toBeNull();draftRow().shopping_path = pathOf();- expect(await getShoppingCheck(DRAFT)).toMatchObject({ products: [] });+ expect(await getShoppingCheck(DRAFT)).toMatchObject({ products: [], merchantCenter: false });expect(calls.some((c) => c.table.startsWith('catalog_'))).toBe(false);await expect(getShoppingCheck('nope')).rejects.toThrow('invalid');diff --git a/web/src/lib/actions/shopping-path.ts b/web/src/lib/actions/shopping-path.tsindex 0605cbf2b..bba625c1f 100644--- a/web/src/lib/actions/shopping-path.ts+++ b/web/src/lib/actions/shopping-path.ts@@ -2,6 +2,7 @@import { z } from 'zod';import { API_BASE_URL } from '@/config/api';+import { MERCHANT_CENTER_KIND } from '@/lib/catalog';import { createClient } from '@/lib/supabase/server';import { jsonbBytes } from '@/lib/content/draft-inputs';import { variantStock } from '@/lib/content/feed-match';@@ -361,11 +362,33 @@ async function pageSite(return host ? `https://${host}/` : null;}+/**+ * Whether the brand reads a Google Merchant Center account into its catalog,+ * its last sync read: only then does the check say a product is accepted by+ * Merchant Center. None when it can't be read: the check then says less,+ * never more.+ */+async function hasMerchantCenter(supabase: Client, brandId: string): Promise<boolean> {+ const { data, error } = await supabase+ .from('catalog_sources')+ .select('id')+ .eq('brand_id', brandId)+ .eq('kind', MERCHANT_CENTER_KIND)+ .eq('last_status', 'ok')+ .limit(1);+ if (error) {+ console.error('Failed to read the brand’s catalog sources:', error.message);+ return false;+ }+ return (data ?? []).length > 0;+}+/*** The draft's shopping path read against the catalog now (shopping path,* part 6): each of its products sold out, refused by Merchant Center, gone,* or fine; the ones removed from it or left out that no longer sell, in- * case the page still links them; and the category pages. Read for the+ * case the page still links them; the category pages; and whether the+ * brand has a Merchant Center account to say they're accepted. Read for the* draft's own brand, whatever brand the tab has open. Null without a path;* throws when the draft or the catalog can't be read.*/@@ -388,7 +411,7 @@ export async function getShoppingCheck(draftId: string): Promise<ShoppingCheck |(id) => !inPath.has(id),);const ids = [...inPath, ...others].filter((id) => guid.safeParse(id).success);- const [products, variants, site] = await Promise.all([+ const [products, variants, site, merchantCenter] = await Promise.all([readByIds(ids, (chunk, from, to) =>supabase.from('catalog_products')@@ -409,6 +432,8 @@ export async function getShoppingCheck(draftId: string): Promise<ShoppingCheck |.range(from, to),),pageSite(supabase, draft),+ // Nothing to check, nothing to say about it: no catalog read.+ ids.length ? hasMerchantCenter(supabase, brandId) : false,]);// A refusal matters only for a variant in stock: the others are sold out anyway.const inStock = variants.filter((v) => variantStock(v.availability) === 'in');@@ -489,6 +514,7 @@ export async function getShoppingCheck(draftId: string): Promise<ShoppingCheck |.filter((k): k is string => !!k),products: [...pathProducts, ...otherProducts],site,+ merchantCenter,};}diff --git a/web/src/lib/content/rules.test.ts b/web/src/lib/content/rules.test.tsindex fbc54bf87..1205905af 100644--- a/web/src/lib/content/rules.test.ts+++ b/web/src/lib/content/rules.test.ts@@ -473,6 +473,7 @@ describe('shopping path rules (shopping path, part 6)', () => {item(4, 'Alpine', 'ok'),],site: 'https://shop.example/blog/boots',+ merchantCenter: true,};const shopRule = (key: string, value?: string) => {const found = activeRules(diff --git a/web/src/lib/content/shopping-check.test.ts b/web/src/lib/content/shopping-check.test.tsindex 40bb2c9e3..cc2cf2efc 100644--- a/web/src/lib/content/shopping-check.test.ts+++ b/web/src/lib/content/shopping-check.test.ts@@ -26,6 +26,7 @@ const CHECK: ShoppingCheck = {product('r', 'sold_out', false),],site: 'https://www.shop.example/blog/boots',+ merchantCenter: false,};describe('shoppingLinks, with the page’s product cards (#1610)', () => {@@ -119,6 +120,11 @@ describe('shoppingLinks', () => {expect(shoppingLinks(['/products/a'], { ...CHECK, site: null }, 3).linked).toEqual([]);});+ it("passes on whether the brand has a Merchant Center account, for what's said", () => {+ expect(shoppingLinks([], CHECK).merchantCenter).toBe(false);+ expect(shoppingLinks([], { ...CHECK, merchantCenter: true }).merchantCenter).toBe(true);+ });+it('asks for the number given, or all that sell when fewer do; none for 0', () => {expect(shoppingLinks([], CHECK, 1).want).toBe(1);expect(shoppingLinks([], CHECK, 0).want).toBe(0);diff --git a/web/src/lib/content/shopping-check.ts b/web/src/lib/content/shopping-check.tsindex 09c913183..81616afc5 100644--- a/web/src/lib/content/shopping-check.ts+++ b/web/src/lib/content/shopping-check.ts@@ -60,6 +60,11 @@ export interface ShoppingCheck {* page's address, else the brand's site; null when neither is known.*/site: string | null;+ /**+ * The brand reads a Google Merchant Center account into its catalog: only+ * then is a product said to be accepted by Merchant Center.+ */+ merchantCenter: boolean;}/** What a page's links do with its shopping path. */@@ -77,6 +82,8 @@ export interface ShoppingLinks {categories: number;/** The cards of products that sell whose price changed since they went in, each product once. */prices?: CardPrice[];+ /** The check's `merchantCenter`: whether "accepted by Merchant Center" is said. */+ merchantCenter: boolean;}/** A link's key, a relative one read against `site`; null when it leads to no page. */@@ -137,6 +144,7 @@ export function shoppingLinks(want: Math.min(Math.max(0, n), selling.length),categories: check.categories.length,prices: [...prices.values()],+ merchantCenter: check.merchantCenter,};}