diff --git a/packages/snaps-cli/src/commands/build/implementation.test.ts b/packages/snaps-cli/src/commands/build/implementation.test.ts index 40e6246cc8..79ff01c15a 100644 --- a/packages/snaps-cli/src/commands/build/implementation.test.ts +++ b/packages/snaps-cli/src/commands/build/implementation.test.ts @@ -1,5 +1,8 @@ +import { getPlatformVersion } from '@metamask/snaps-utils'; import { DEFAULT_SNAP_BUNDLE, + DEFAULT_SNAP_ICON, + getMockSnapFilesWithUpdatedChecksum, getPackageJson, getSnapManifest, } from '@metamask/snaps-utils/test-utils'; @@ -61,15 +64,21 @@ jest.mock('../../webpack/utils', () => ({ describe('build', () => { beforeEach(async () => { + const { manifest } = await getMockSnapFilesWithUpdatedChecksum({ + manifest: getSnapManifest({ + platformVersion: getPlatformVersion(), + }), + }); + await fs.mkdir('/snap'); await fs.writeFile('/snap/input.js', DEFAULT_SNAP_BUNDLE); await fs.writeFile( '/snap/snap.manifest.json', - JSON.stringify(getSnapManifest()), + JSON.stringify(manifest.result), ); await fs.writeFile('/snap/package.json', JSON.stringify(getPackageJson())); await fs.mkdir('/snap/images'); - await fs.writeFile('/snap/images/icon.svg', ''); + await fs.writeFile('/snap/images/icon.svg', DEFAULT_SNAP_ICON); await fs.mkdir(dirname(BROWSERSLIST_FILE), { recursive: true }); await fs.writeFile( BROWSERSLIST_FILE, diff --git a/packages/snaps-cli/src/commands/manifest/implementation.test.ts b/packages/snaps-cli/src/commands/manifest/implementation.test.ts index 792e100dc1..83acf966a2 100644 --- a/packages/snaps-cli/src/commands/manifest/implementation.test.ts +++ b/packages/snaps-cli/src/commands/manifest/implementation.test.ts @@ -1,5 +1,8 @@ +import { getPlatformVersion } from '@metamask/snaps-utils'; import { DEFAULT_SNAP_BUNDLE, + DEFAULT_SNAP_ICON, + getMockSnapFilesWithUpdatedChecksum, getPackageJson, getSnapManifest, } from '@metamask/snaps-utils/test-utils'; @@ -32,19 +35,23 @@ jest.mock('../../webpack', () => ({ describe('manifest', () => { beforeEach(async () => { + const { manifest: newManifest } = await getMockSnapFilesWithUpdatedChecksum( + { + manifest: getSnapManifest({ + platformVersion: getPlatformVersion(), + }), + }, + ); + await fs.mkdir('/snap/dist', { recursive: true }); await fs.writeFile('/snap/dist/bundle.js', DEFAULT_SNAP_BUNDLE); await fs.writeFile( '/snap/snap.manifest.json', - JSON.stringify( - getSnapManifest({ - shasum: 'G/W5b2JZVv+epgNX9pkN63X6Lye9EJVJ4NLSgAw/afc=', - }), - ), + JSON.stringify(newManifest.result), ); await fs.writeFile('/snap/package.json', JSON.stringify(getPackageJson())); await fs.mkdir('/snap/images'); - await fs.writeFile('/snap/images/icon.svg', ''); + await fs.writeFile('/snap/images/icon.svg', DEFAULT_SNAP_ICON); }); afterEach(async () => { @@ -52,9 +59,9 @@ describe('manifest', () => { }); it('validates a snap manifest', async () => { - const error = jest.spyOn(console, 'error').mockImplementation(); + const error = jest.spyOn(console, 'error'); const warn = jest.spyOn(console, 'warn').mockImplementation(); - const log = jest.spyOn(console, 'log').mockImplementation(); + const log = jest.spyOn(console, 'log'); const spinner = ora(); const result = await manifest('/snap/snap.manifest.json', false, spinner); @@ -157,7 +164,7 @@ describe('manifest', () => { "url": "https://github.com/MetaMask/example-snap.git" }, "source": { - "shasum": "d4W7f1lzpVGMj8jjCn1lYhhHmKc/9TSk5QLH5ldKQoI=", + "shasum": "c3Dn62ZSKu7fATN+40MhI9UqEInE9qE7u5tDjb7ylyk=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -172,6 +179,7 @@ describe('manifest', () => { "chains": ["eip155:1", "eip155:2", "eip155:3"] } }, + "platformVersion": "6.7.0", "manifestVersion": "0.1" } " diff --git a/packages/snaps-webpack-plugin/src/manifest.test.ts b/packages/snaps-webpack-plugin/src/manifest.test.ts index 163fb71551..451ccb5701 100644 --- a/packages/snaps-webpack-plugin/src/manifest.test.ts +++ b/packages/snaps-webpack-plugin/src/manifest.test.ts @@ -26,7 +26,7 @@ describe('writeManifest', () => { "url": "https://github.com/MetaMask/example-snap.git" }, "source": { - "shasum": "rNyfINgNh161cBmUop+F7xlE+GSEDZH53Y/HDpGLGGg=", + "shasum": "/17SwI03+Cn9sk45Z6Czp+Sktru1oLzOmkJW+YbP9WE=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -40,6 +40,7 @@ describe('writeManifest', () => { "snap_dialog": {}, "endowment:rpc": { "snaps": true, "dapps": false } }, + "platformVersion": "1.0.0", "manifestVersion": "0.1" } " @@ -63,7 +64,7 @@ describe('writeManifest', () => { "url": "https://github.com/MetaMask/example-snap.git" }, "source": { - "shasum": "rNyfINgNh161cBmUop+F7xlE+GSEDZH53Y/HDpGLGGg=", + "shasum": "/17SwI03+Cn9sk45Z6Czp+Sktru1oLzOmkJW+YbP9WE=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -77,6 +78,7 @@ describe('writeManifest', () => { "snap_dialog": {}, "endowment:rpc": { "snaps": true, "dapps": false } }, + "platformVersion": "1.0.0", "manifestVersion": "0.1" } " @@ -99,7 +101,7 @@ describe('writeManifest', () => { "url": "https://github.com/MetaMask/example-snap.git" }, "source": { - "shasum": "rNyfINgNh161cBmUop+F7xlE+GSEDZH53Y/HDpGLGGg=", + "shasum": "/17SwI03+Cn9sk45Z6Czp+Sktru1oLzOmkJW+YbP9WE=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -113,6 +115,7 @@ describe('writeManifest', () => { "snap_dialog": {}, "endowment:rpc": { "snaps": true, "dapps": false } }, + "platformVersion": "1.0.0", "manifestVersion": "0.1" } "