codeforpdx / PASS

PASS project - with HMIS module integration
MIT License
35 stars 27 forks source link

Improve testing mocks to mock network calls #248

Open timbot1789 opened 1 year ago

timbot1789 commented 1 year ago

Is your feature request related to a problem? Please describe. Currently, our unit tests are based around mocking Inrupt's solid-client library. However, this means that the unit tests have a dependency on solid-client. If we ever update the library, and that update includes breaking changes, our unit tests won't be able to detect them.

Describe the solution you'd like A better way would be to mock responses to the network calls inrupt itself makes. Most of these are REST calls to prescribed endpoints, based on the linked data platform. Vitest suggests using Mock service worker to do this.

Additional context The main goal of this issue is to remove the test cases' dependency on any specific implementation of Inrupt's libraries. Even if we remove Inrupt's library entirely, and replace it with something else, our tests should still work.

Another goal is to give me an excuse to learn how the Linked Data Platform works.

timbot1789 commented 1 year ago

This is internal work, not needed for MVP. Should be fixed sooner rather than later though.

leekahung commented 1 year ago

Hey @timbot1789, I saw there's been work made in the mock directory for the project. Would that be related to this issue or does it have something more to do with mocking the session.fetch from Inrupt?

timbot1789 commented 1 year ago

Hey @timbot1789, I saw there's been work made in the mock directory for the project. Would that be related to this issue or does it have something more to do with mocking the session.fetch from Inrupt?

No the goal here is to mock the solid pod itself (or it's network responses) rather than inrupt's solid client module. That way the tests arent dependent on us using inrupt's libraries. Just the solid protocol.

This issue isnt very important. More a note about a better design.