Skip to content

Add complex Shopify template rendering tests - #13

Merged
benfaerber merged 1 commit into
masterfrom
test/complex-shopify-templates
May 29, 2026
Merged

benfaerber merged 1 commit into
masterfrom
test/complex-shopify-templates

Conversation

@benfaerber

Copy link
Copy Markdown
Owner

Summary

Adds end-to-end rendering tests built from 6 real-world templates taken from Shopify's own Ruby Liquid benchmark suite (performance/tests/{tribble,vogue,dropify,ripen}). These give the renderer a comprehensive, real-world workout beyond the existing focused unit tests.

Templates added under test/templates/complex/:

File Source theme Exercises
theme.liquid vogue layout, menus, blog list (limit/offset), featured products, pluralize, date
minicart_theme.liquid dropify minicart loop, pluralize, money, linklists
index.liquid tribble product grid, variant loops, price logic
product.liquid tribble tags loop, variant <select>, image loops
product_variants.liquid ripen options, vendor/type, price_varies
cart.liquid tribble nested loops, cycle, money_with_currency, forloop.first, limit

How it works

  • A single shared, representative data context (shop, cart, product, collections, linklists, pages, blogs, …) is built with small helper constructors.
  • A universal passthrough filter stub covers the Shopify-specific filters liquid-ml doesn't implement (asset_url, product_img_url, link_to, within, stylesheet_tag, …). The standard library is consulted first, so real filters (money, pluralize, truncate, …) keep their behavior.
  • Each template is rendered and asserted to be non-empty and contain stable marker substrings.

Notes / findings

  • The renderer handled all 6 templates end-to-end: nested for-loops, cycle, forloop.first/last, hyphenated keys (linklists.main-menu), list .size/.first, and nested conditionals.
  • One correctness behavior is encoded in the assertions: {% for article in blogs.news.articles limit: 6 offset: 1 %} correctly skips the first article, so the test asserts News Two rather than News One.

Testing

dune test — 268 tests run, all passing (was 262; +6).

Wire 6 real-world templates from Shopify's Ruby Liquid benchmark suite
(performance/tests/{tribble,vogue,dropify,ripen}) into the test runner as
end-to-end rendering tests.

These exercise the renderer comprehensively: nested for-loops, cycle,
forloop.first/last, nested object access, hyphenated keys
(linklists.main-menu), list .size/.first, money/pluralize/truncate filters,
and nested conditionals.

A universal passthrough filter stub stands in for the Shopify-specific
filters liquid-ml does not implement (asset_url, product_img_url, link_to,
within, stylesheet_tag, ...); the standard library is consulted first so
real filters keep their behavior. Each template is rendered against a shared
representative context and asserted to contain stable marker substrings.

Adds 6 tests (262 -> 268), all passing.
@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.94595% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
test/test_complex_templates.ml 95.94% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@benfaerber
benfaerber merged commit b899e4d into master May 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant