-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: 💍 Add test coverage with mocked GraphQL layer (pt2) (#4)
* chore: 🤖 initial test structure with msw * chore: 🤖 start application tests * test: 💍 add get applications * test: 💍 add create application * test: 💍 add update application * test: 💍 add delete application * test: 💍 add get domains * chore: 🤖 delete unused, create alias * chore: 🤖 update mocks * chore: 🤖 update gitignore * chore: 🤖 update applications test * chore: 🤖 format * chore: 🤖 update Domains handler * test: 💍 extend domains test by id and hostname * test: 💍 test domains by zone id * test: 💍 create domain * test: 💍 delete domain * test: 💍 verify domain * test: 💍 list zones * test: 💍 get zone * test: 💍 create zone for private gateway * test: 💍 delete zone * test: 💍 create ens record * test: 💍 get ens record * test: 💍 get ens record by name * test: 💍 verify ens record * test: 💍 delete ens record * test: 💍 list ens records * test: 💍 list by ipns record id * test: 💍 get fleek functions by name * test: 💍 get fleek functions * test: 💍 create fleek functions * test: 💍 delete fleek function * test: 💍 add file to ipfs * test: 💍 add files to ipfs * test: 💍 todo should add files by path * chore: 🤖 format * fix: 🐛 conflict amend * refactor: 💡 generate cids texts * chore: 🤖 remove graphql schema * chore: 🤖 add TODO * chore: 🤖 remove tester package * test: 💍 add publish ipns name * test: 💍 publish ipns record * test: 💍 create ipns record * test: 💍 create ipns record for site * test: 💍 delete ipns record * test: 💍 list ipns record * test: 💍 get ipns record by name * test: 💍 get private gateway * test: 💍 get private gatewa by slug * test: 💍 get private gateways * test: 💍 create private gateways * test: 💍 delete private gateway * test: 💍 update private gateway * test: 💍 create project * test: 💍 get project * test: 💍 get projects * test: 💍 get site by id * test: 💍 get site by slug * test: 💍 list sites * test: 💍 create site * test: 💍 delete site * test: 💍 create custom ipfs deployment * test: 💍 get deployment by id * test: 💍 get personal access tokens * test: 💍 delete personal access tokens * fix: 🐛 conflict amend
- Loading branch information
Showing
17 changed files
with
2,207 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
import { describe, expect, it, afterAll, afterEach, beforeAll } from 'vitest'; | ||
import { server } from '../mocks/graphql/node'; | ||
import { mockGraphqlServiceApiUrl as graphqlServiceApiUrl } from '../mocks/graphql/handlers'; | ||
import { FleekSdk } from '../FleekSdk'; | ||
import state from '../mocks/state'; | ||
|
||
const TEST_KEY = | ||
'k51qzi5uqu5djd7wik4gj3evcbnx2okerdrh0swusu07mu2ak1v1r3y70e7k8o'; | ||
const TEST_INPUT = | ||
'CjQvaXBmcy9RbVBxckVISlRleDJDUGJxTlVMQ21iU0ZKVDNib0J3QUFmTWI1VWp2WHRLakVlEkB/s3F4iHVMyA9LOFizt5N4PHiI2APD15wsMa1RXGwmugThVpUjTw+5HHwFt16TI/8AKk/1p8+26hylxMxd3wAIGAAiHjIwMjMtMDgtMDVUMDk6NDk6MjguNDk5MDAwMDAwWigNMODyh77rhc0FQkCdgM1u1AAUsdf4pE7/kNYjl438/g6Ja48Tr2evFSRc6YSMgljaKX8PpQC0JDlZqF2jiKdHRUOaxLHArPo9MW0PSosBpWNUVEwbAAs0LrfB+WBlVmFsdWVYNC9pcGZzL1FtUHFyRUhKVGV4MkNQYnFOVUxDbWJTRkpUM2JvQndBQWZNYjVVanZYdEtqRWVoU2VxdWVuY2UNaFZhbGlkaXR5WB4yMDIzLTA4LTA1VDA5OjQ5OjI4LjQ5OTAwMDAwMFpsVmFsaWRpdHlUeXBlAA=='; | ||
|
||
describe('IPNS', () => { | ||
const sdk = new FleekSdk({ | ||
graphqlServiceApiUrl, | ||
accessTokenService: {} as any, | ||
}); | ||
|
||
beforeAll(() => server.listen()); | ||
afterEach(() => server.resetHandlers()); | ||
afterAll(() => server.close()); | ||
|
||
it('should publish IPNS name', async () => { | ||
const response = await sdk.ipns().publishSignedName({ | ||
input: TEST_INPUT, | ||
key: TEST_KEY, | ||
}); | ||
|
||
expect(response).toMatchInlineSnapshot( | ||
'"k51qzi5uqu5dgsc1bvsuk1x84bptdvp8cupbnnbqxpxzd629gadpci3kpcm311"', | ||
); | ||
}); | ||
|
||
// TODO: Mocking is failing for w3name | ||
// for some reason | ||
it.todo('should get resolved IPNS name', async (context) => { | ||
const response = await sdk.ipns().resolveName({ name: TEST_KEY }); | ||
|
||
expect(response).toMatchInlineSnapshot( | ||
'"/ipfs/QmRG4xcsmoZuXqKuPz3uVBgvo3GZ6k1kLZWhmvzuKtDr9s"', | ||
); | ||
}); | ||
|
||
it('should publish IPNS record', async () => { | ||
const response = await sdk.ipns().publishRecord({ | ||
id: state.ipns.ipnsRecord.electronicCoEshop.id, | ||
hash: 'QmRG4xcsmoZuXqKuPz3uVBgvo3GZ6k1kLZWhmvzuKtDr9s', | ||
}); | ||
|
||
expect(response).toMatchInlineSnapshot(` | ||
Object { | ||
"ensRecords": Array [ | ||
Object { | ||
"id": "8d3ad502-ec4d-489e-858e-d112656f3511", | ||
}, | ||
Object { | ||
"id": "clm0mhccs000108ma34jn6ed3", | ||
}, | ||
], | ||
"hash": "QmRG4xcsmoZuXqKuPz3uVBgvo3GZ6k1kLZWhmvzuKtDr9s", | ||
"id": "clgkj995t000108med7gb2w4v", | ||
"name": "k51qzi5uqu5dhrupvn0ru1c6el43rhimh95cuiwqy0ofo8bgomvq296b49v9r7", | ||
} | ||
`); | ||
}); | ||
|
||
it('should create IPNS record', async () => { | ||
const response = await sdk.ipns().createRecord(); | ||
|
||
expect(response).toMatchInlineSnapshot( | ||
{ id: expect.any(String) }, | ||
` | ||
Object { | ||
"ensRecords": Array [], | ||
"hash": null, | ||
"id": Any<String>, | ||
"name": "test-name", | ||
} | ||
`, | ||
); | ||
}); | ||
|
||
it('should create IPNS record for site', async () => { | ||
const response = await sdk | ||
.ipns() | ||
.createRecordForSite({ siteId: state.sites.site.electronicCoEshop.id }); | ||
|
||
// TODO: Investigate why the hash changed here | ||
expect(response).toMatchInlineSnapshot( | ||
{ id: expect.any(String) }, | ||
` | ||
Object { | ||
"ensRecords": Array [], | ||
"hash": "bafybeibtme5hmkjxsryerf6pihhfbhifwnsz7gmhnfqglg2r326m4glzva", | ||
"id": Any<String>, | ||
"name": "test-name", | ||
} | ||
`, | ||
); | ||
}); | ||
|
||
it('should delete IPNS record', async () => { | ||
const response = await sdk | ||
.ipns() | ||
.deleteRecord({ id: state.ipns.ipnsRecord.electronicCoEshop.id }); | ||
|
||
expect(response).toMatchInlineSnapshot(` | ||
Object { | ||
"ensRecords": Array [], | ||
"hash": "QmcvfRw5WDutRzvRNq2matcJWW2nKWFGDbqxaaTxnWksME", | ||
"id": "clgkj995t000108med7gb2w4v", | ||
"name": "k51qzi5uqu5dhrupvn0ru1c6el43rhimh95cuiwqy0ofo8bgomvq296b49v9r7", | ||
} | ||
`); | ||
}); | ||
|
||
it('should list IPNS records', async () => { | ||
const response = await sdk.ipns().listRecords(); | ||
|
||
expect(response).toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"ensRecords": Array [ | ||
Object { | ||
"id": "8d3ad502-ec4d-489e-858e-d112656f3511", | ||
}, | ||
Object { | ||
"id": "clm0mhccs000108ma34jn6ed3", | ||
}, | ||
], | ||
"hash": "QmcvfRw5WDutRzvRNq2matcJWW2nKWFGDbqxaaTxnWksME", | ||
"id": "clgkj995t000108med7gb2w4v", | ||
"name": "k51qzi5uqu5dhrupvn0ru1c6el43rhimh95cuiwqy0ofo8bgomvq296b49v9r7", | ||
}, | ||
Object { | ||
"ensRecords": Array [ | ||
Object { | ||
"id": "40767ba9-eb85-439b-9369-489459a9376b", | ||
}, | ||
], | ||
"hash": "QmX7WyiLtbvmfbUzN2eJuvmDuGZSDjavuauwaJL4bFC5SJ", | ||
"id": "clgkj9ipf000208me9yzre1cn", | ||
"name": "k51qzi5uqu5dh2c8ec00yowiapopchxdvnwh6iy2xoxc51inldruqh4yvzgez5", | ||
}, | ||
Object { | ||
"ensRecords": Array [ | ||
Object { | ||
"id": "af470cc1-08d8-4d39-be6f-b0eebc0a6480", | ||
}, | ||
], | ||
"hash": "QmW73w6jvat7zDpFkYHft8eB88LiU6fPyV9LUX9et7XRUy", | ||
"id": "clgkj9pfa000308meh73d8nff", | ||
"name": "k51qzi5uqu5dipwqop5kj5na30qlwqbyyn54g8y3jcm3sdc02t9tjlec2a46ci", | ||
}, | ||
] | ||
`); | ||
}); | ||
|
||
it('should get IPNS record by name', async () => { | ||
const response = await sdk | ||
.ipns() | ||
.getRecord({ name: state.ipns.ipnsRecord.electronicCoEshop.name }); | ||
|
||
expect(response).toMatchInlineSnapshot(` | ||
Object { | ||
"ensRecords": Array [ | ||
Object { | ||
"id": "8d3ad502-ec4d-489e-858e-d112656f3511", | ||
}, | ||
Object { | ||
"id": "clm0mhccs000108ma34jn6ed3", | ||
}, | ||
], | ||
"hash": "QmcvfRw5WDutRzvRNq2matcJWW2nKWFGDbqxaaTxnWksME", | ||
"id": "clgkj995t000108med7gb2w4v", | ||
"name": "k51qzi5uqu5dhrupvn0ru1c6el43rhimh95cuiwqy0ofo8bgomvq296b49v9r7", | ||
} | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.