Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate fixtures.json files for components on build:package #1925

Merged
merged 3 commits into from
Sep 2, 2020

Conversation

vanitabarrett
Copy link
Contributor

Resolves #1895

What

Adds steps to the build:package task to generate fixtures.json files for each component in the following format:

{
  "component": "button",
  "examples": [
      {
        "name": "default-example",
        "options": {
           "text": "Save and continue"
         },
         "html": "<button class=\"govuk-button\" data-module=\"govuk-button\">\n  Save and continue\n</button>"
      }
   ]
}

Fixtures files contain the component name and all examples with the output html to allow maintainers to test their own HTML against ours

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1925 August 21, 2020 10:58 Inactive
@vanitabarrett vanitabarrett linked an issue Aug 21, 2020 that may be closed by this pull request
Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really good – great to have tests that cover this as well.

tasks/gulp/__tests__/after-build-package.test.js Outdated Show resolved Hide resolved
tasks/gulp/__tests__/after-build-package.test.js Outdated Show resolved Hide resolved
tasks/gulp/__tests__/after-build-package.test.js Outdated Show resolved Hide resolved
fixtures.examples.push(fixture)
})

fs.writeFileSync(fixturesPath, JSON.stringify(fixtures, null, 2))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit strange to write the file out from the task, rather than passing it out and letting gulp handle it. It's definitely strange that we write the two files in two different ways.

I think there's probably a more 'gulp-like' way of doing this, but my gulp knowledge is lacking…

If not, and we stick with using fs.writeFileSync here I think we should write both files from within the task?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separately, we use 4 space indentation for params.json, so we should probably be consistent and use the same here.

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1925 August 24, 2020 10:09 Inactive
Copy link
Member

@hannalaakso hannalaakso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good to me 👍 Agree with @36degrees that it would be good to generate the two files in a similar manner.

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1925 August 24, 2020 14:26 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1925 August 24, 2020 14:28 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1925 August 25, 2020 09:34 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1925 August 25, 2020 09:46 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1925 August 25, 2020 10:00 Inactive
@vanitabarrett
Copy link
Contributor Author

@hannalaakso @36degrees Thanks both - I think I've addressed those comments now. I've also added a second commit to create separate functions for the fixtures and macro-options gulp tasks - I think it makes it a bit easier to quickly scan the gulp task and see what's happening, but happy to leave that change out if people don't find it helpful!

Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, with a couple of minor comments 👍🏻

I think it might be revisiting this task some point soon as it feels like it's becoming a bit of a 'monolith' task with too many responsibilities – the two JSON-generating functions could be separate dependent tasks?

That would also make it possible to update just the JSON files without having to run all of the other changes, which feels like it might be useful.

tasks/gulp/copy-to-destination.js Outdated Show resolved Hide resolved
tasks/gulp/copy-to-destination.js Outdated Show resolved Hide resolved
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1925 August 25, 2020 13:03 Inactive
@vanitabarrett vanitabarrett force-pushed the component-test-files-use-examples branch 6 times, most recently from d2234cd to 0bd7652 Compare August 27, 2020 14:32
Copy link
Member

@hannalaakso hannalaakso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 👍

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1925 September 2, 2020 10:08 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1925 September 2, 2020 10:35 Inactive
@vanitabarrett
Copy link
Contributor Author

Needs rebasing against master once #1924 has been merged

@vanitabarrett vanitabarrett modified the milestone: v3.9.0 Sep 2, 2020
Base automatically changed from component-test-files-use-examples to master September 2, 2020 13:35
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1925 September 2, 2020 13:52 Inactive
Vanita Barrett added 2 commits September 2, 2020 14:53
Fixtures files contain the component name  and all examples with the output html to allow maintainers to test their own HTML against ours
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1925 September 2, 2020 13:53 Inactive
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.

Generate test fixtures for components
4 participants