s1seven / schema-tools

Tools to create, validate and render certificates using Material Identity JSON schemas
https://materialidentity.org/
Apache License 2.0
1 stars 1 forks source link

feat: update html and pdf rendering #173

Closed eamon0989 closed 2 years ago

eamon0989 commented 2 years ago

Description

This PR fixes the issue found at https://github.com/thematerials-network/CoA-schemas/issues/57. It updates the functions localizeValue and localizeNumber in generate-html to allow values with trailing zeros to be passed in without any precision being lost by passing the value in as a string. I have also added unit tests to verify that there has been no regression and that the localization happens as expected.

The helper localizeValuein generate-pdf-template-helpers has also been updated to allow values with trailing zeros, and the tests have been updated. Update create-html-certificate.ts to handle partial maps and extra translations. Update create-pdf-certificate.ts to handle extra translations. Add CoA v1.0.0 fixtures and tests. Update schemaTypes.ts to latest version. Update CoA PDF generator to handle the Street property. Update CoA PDF tests to use the latest certificate, update helpers to allow extraTranslations to be loaded for the tests. Update CoA v1.0.0 valid_cert to include properties needed for the CoA PDF tests, update fixtures. Update README to make it clearer how to handle schemaTypes.ts.

Fixes #174 fixes thematerials-network/CoA-schemas#59

Type of change

Checklist:

Screenshot showing updated rendering for https://github.com/thematerials-network/CoA-schemas/issues/59 image

Screenshot showing a PDF rendered without the Analysis property:

image
getlarge commented 2 years ago

@eamon0989 The tests for for CoA v1.0.0 should be disabled (as the release v1.0.0 will not land right away) except the one using local resources, then for the latter you should update the PDF fixtures to make the test pass.

eamon0989 commented 2 years ago

@eamon0989 The tests for for CoA v1.0.0 should be disabled (as the release v1.0.0 will not land right away) except the one using local resources, then for the latter you should update the PDF fixtures to make the test pass.

I've commented out the PDF test for now, the HTML test is passing so I've left it, if you want it removed let me know. SonarCloud is failing due to 0.0 percent coverage, but the tests are there, it doesn't seem to recognize the lines they cover for some reason.

sonarcloud[bot] commented 2 years ago

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

20.8% 20.8% Coverage
23.9% 23.9% Duplication