Skip to content

Commit e1912ba

Browse files
test(e2e): Skip shopify image cache test when shopify is unconfigured (#1068)
The shopify-image-cache e2e test depends on real products rendering on /store, which requires SHOPIFY_STORE_DOMAIN and SHOPIFY_STOREFRONT_ACCESS_TOKEN. CI does not set these, so the store page falls back to a "Store Configuration Required" panel and the test fails on a missing img[src*="cdn.shopify.com"] locator. Fixes: - Detect the fallback panel at runtime and call test.skip with a clear message pointing at the env vars required to run the test meaningfully. - Forward SHOPIFY_STORE_DOMAIN and SHOPIFY_STOREFRONT_ACCESS_TOKEN from the parent environment to the spawned web server in playwright.config.ts when available, so future CI runs (with secrets set) or local runs without reuseExistingServer actually exercise the Shopify path. Note: a separate service-worker timing bug exists on the offline-reload step (page.reload after setOffline returns ERR_INTERNET_DISCONNECTED when the SW has not finished caching the HTML). That is unrelated to Shopify config and will be filed as a follow-up.
1 parent 0e67ad7 commit e1912ba

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

playwright.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ export default defineConfig({
7070
timeout: process.env.CI ? 30000 : 120000,
7171
env: {
7272
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET || "test-secret-for-playwright",
73+
// Forward Shopify creds when present so /store can render real
74+
// products for e2e tests that depend on them. When unset (most CI
75+
// runs), the Shopify-dependent specs skip themselves at runtime.
76+
...(process.env.SHOPIFY_STORE_DOMAIN && {
77+
SHOPIFY_STORE_DOMAIN: process.env.SHOPIFY_STORE_DOMAIN,
78+
}),
79+
...(process.env.SHOPIFY_STOREFRONT_ACCESS_TOKEN && {
80+
SHOPIFY_STOREFRONT_ACCESS_TOKEN:
81+
process.env.SHOPIFY_STOREFRONT_ACCESS_TOKEN,
82+
}),
7383
},
7484
},
7585
});

tests/e2e/shopify-image-cache.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ test.describe("Shopify Image Caching", () => {
1515
// Wait for the page to be fully loaded
1616
await page.waitForLoadState("networkidle");
1717

18+
// When SHOPIFY_STORE_DOMAIN / SHOPIFY_STOREFRONT_ACCESS_TOKEN aren't set,
19+
// /store renders a "Store Configuration Required" fallback with no
20+
// products. Skip the test at runtime rather than fail — this test
21+
// requires a live Shopify connection to be meaningful.
22+
const storeUnconfigured = await page
23+
.getByText("Store Configuration Required")
24+
.isVisible()
25+
.catch(() => false);
26+
test.skip(
27+
storeUnconfigured,
28+
"Shopify not configured — set SHOPIFY_STORE_DOMAIN + SHOPIFY_STOREFRONT_ACCESS_TOKEN to run this test"
29+
);
30+
1831
// Find the first product image from Shopify
1932
const productImage = page.locator('img[src*="cdn.shopify.com"]').first();
2033
await expect(productImage).toBeVisible();

0 commit comments

Comments
 (0)