alphagov / govuk-frontend

GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.
https://frontend.design-system.service.gov.uk/
MIT License
1.18k stars 324 forks source link

Allow tests for '{% call %}' use case for components that support it #510

Closed NickColley closed 6 years ago

NickColley commented 6 years ago

Some of our components allow nesting using https://mozilla.github.io/nunjucks/templating.html#call.

We currently can't show this in the guide or tests, so this functionality could break.

For example https://github.com/alphagov/govuk-frontend/pull/509 we do not have coverage for 'caller'

We would need to

NickColley commented 6 years ago

I've spiked this out: https://github.com/alphagov/govuk-frontend/compare/spike-expose-caller-in-review?expand=1

You can see in the current way our application is structure it results in duplication of logic in three places.

I'd recommend we refactor app.js to remove complex data 'setting' in templates, and instead keep data at the top level passed down to templates.

Then share the rendering of components between the HTML Code examples, the iFrame preview and the test render helper.

36degrees commented 6 years ago

As long as we have test coverage, I don't think we need to have examples in the review app, as neither the generated HTML nor the styling should differ from any other example.

So I'd suggest scoping this to just making sure we have tests that cover the {% call %} use case.

NickColley commented 6 years ago

This has been implemented