Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion apps/storefront/scripts/optional-graphql.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,26 @@ test("recognizes only the requested optional field and parent type", () => {
});

test("recognizes errors caused only by unavailable optional GraphQL types", () => {
const commerceTypes = ["Product", "ProductBrand", "ProductCategory", "ProductTag"];
const commerceTypes = [
"ExternalProduct",
"GroupProduct",
"Product",
"ProductBrand",
"ProductCategory",
"ProductTag",
"SimpleProduct",
"VariableProduct",
];

assert.equal(
hasOnlyUnknownTypes(
[
{ message: 'Unknown type "Product".' },
{ message: 'Unknown type "ProductCategory". Did you mean "Category"?' },
{ message: 'Unknown type "ExternalProduct".' },
{ message: 'Unknown type "GroupProduct".' },
{ message: 'Unknown type "SimpleProduct".' },
{ message: 'Unknown type "VariableProduct".' },
],
commerceTypes,
),
Expand Down
4 changes: 4 additions & 0 deletions apps/storefront/scripts/prerender-language-fallback.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ test("prerender uses the WordPress site language when Polylang is unavailable",
});

test("prerender retries commerce route discovery without multilingual WooCommerce metadata", () => {
assert.match(
prerenderSource,
/const COMMERCE_ROUTE_TYPES = \[[\s\S]*?"ExternalProduct"[\s\S]*?"GroupProduct"[\s\S]*?"SimpleProduct"[\s\S]*?"VariableProduct"/,
);
assert.match(
prerenderSource,
/!backendLanguageFieldsAvailable[\s\S]*?error instanceof GraphqlHttpError[\s\S]*?error\.status >= 500/,
Expand Down
11 changes: 10 additions & 1 deletion apps/storefront/scripts/prerender.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,16 @@ const backendProfile = ["shell", "blog", "shop", "full"].includes(configuredBack
? configuredBackendProfile
: "full";
const commerceRoutesAvailable = backendProfile === "shop" || backendProfile === "full";
const COMMERCE_ROUTE_TYPES = ["Product", "ProductBrand", "ProductCategory", "ProductTag"];
const COMMERCE_ROUTE_TYPES = [
"ExternalProduct",
"GroupProduct",
"Product",
"ProductBrand",
"ProductCategory",
"ProductTag",
"SimpleProduct",
"VariableProduct",
];
const expectedLanguages = (process.env.STOREFRONT_EXPECTED_LOCALES || "")
.split(",")
.map((locale) => locale.trim().toLowerCase())
Expand Down
Loading