Automatically generate theme preview links

Short description of issue

Lighthouse CI fails due to redirects from the theme_preview parameter in the URL

Reproduction steps

  • Develop Feature
  • Push to CI and create new unpublished Theme in the online store
  • Let CI run Lighthouse on newly created Theme
  • Lighthouse fails

Additional info

When running Shopify Lighthouse CI on a store with preview themes deployed via GitHub Actions, the preview_theme_id parameter gets stripped from URLs, causing redirects. This makes Lighthouse fail:

“The page may not be loading as expected because your test URL (https://xxx.myshopify.com/collections/shop?preview_theme_id=177624383864&_fd=0&pb=0) was redirected to https://xxx.myshopify.com/collections/shop?_fd=0&pb=0. Try testing the second URL directly.”

The workaround is using http://shopifypreview.com URLs which don’t redirect, but these require extracting the unique preview hash from the theme’s prefix like https://{preview-hash}-{shop-id}.shopifypreview.com. Is there any way to get the preview-hash automatically?
I can only seem to get it while previewing a theme in the store admin and then pressing share and copy the link

What type of topic is this

Feature request