-
Notifications
You must be signed in to change notification settings - Fork 639
fix: Merge manifest validation reports to include latest validation errors and warnings #3567
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
Conversation
| jest.mock('fs'); | ||
| jest.mock('../fs', () => ({ | ||
| ...jest.requireActual('../fs'), | ||
| useFileSystemCache: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just disables the file system cache. We mock network requests anyway, and doing this makes testing a bit easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this make easier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't figure out how to test the new invalid platform version warning showing up without changing this. It would always cache the correct version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand how this changes that, the mock returns the platform version from getPlatformVersion anyways 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test replaces the fetch mock.
fetchMock.mockResponseOnce(MOCK_GITHUB_RESPONSE).mockResponseOnce(
JSON.stringify({
dependencies: {
'@metamask/snaps-sdk': '1.0.0',
},
}),
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe try if clearing it out in resetFileSystem fixes it? Otherwise fine to merge as-is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cache seems to be written to the real file system, or at least I can't find where it is in the virtual file system 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect something like this:
await fs.rm('./node_modules/.cache/snaps', { recursive: true, force: true });
Does that not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't, I'm not seeing the node_modules/.cache folder anywhere in the VFS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange 🤔
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3567 +/- ##
=======================================
Coverage 98.28% 98.28%
=======================================
Files 417 417
Lines 11764 11769 +5
Branches 1829 1830 +1
=======================================
+ Hits 11562 11567 +5
Misses 202 202 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
packages/snaps-utils/src/manifest/validators/is-localization-file.ts
Outdated
Show resolved
Hide resolved
packages/snaps-utils/src/manifest/validators/is-package-json.ts
Outdated
Show resolved
Hide resolved
packages/snaps-utils/src/manifest/validators/is-snap-manifest.ts
Outdated
Show resolved
Hide resolved
packages/snaps-utils/src/manifest/validators/package-json-recommended-fields.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Frederik Bolding <[email protected]>
This updates the manifest validation to merge new reports after the initial validation. We run the validation logic in a loop to address any newly found issues, but previously, newly found errors or warnings were never actually surfaced: Only the reports found in the initial validation were used.
After this change, each report has an ID based on the name of the report, and for validators with multiple potential errors (e.g., unused exports/endowments), a different ID is used as well. This ensures we can merge reports without duplicating them (causing two shasum warnings for example).
Closes #3505.