NnsProposals.spec.ts was mocking several the proposalsStore and the authStore.
Mocking stores is fragile and unnecessary.
Because the test mocked the proposalsStore it completely ignored the fact that the component empties the store and then fills it with the result of queryProposals.
As a result one test was supposed to check that a spinner is shown while proposals are being loaded, but this is not even the case. Skeleton cards are being shown while proposals are loaded. A spinner is shown when additional proposals are loaded into the infinite scroll. Because of the mocked proposals store, the component thought there were already proposals loaded and additional ones were being loaded, showing the spinner instead of the skeleton cards as a result.
Changes
Stop mocking authStore and instead just set the identity using resetIdentity.
Stop mocking proposalsStore and instead mock queryProposals so the NnsProposals can reset and fill the proposalsStore itself.
Use fake timers to work around the debouncing used by NnsProposals.
Fix the test which does the initial load of proposals to expect skeleton cards and check that the skeleton cards go away after loading finishes.
Add a new test which expects a spinner when additional pages of proposals are loaded.
Tests
test only
Todos
[ ] Add entry to changelog (if necessary).
not necessary
Motivation
NnsProposals.spec.ts
was mocking several theproposalsStore
and theauthStore
. Mocking stores is fragile and unnecessary.Because the test mocked the
proposalsStore
it completely ignored the fact that the component empties the store and then fills it with the result ofqueryProposals
.As a result one test was supposed to check that a spinner is shown while proposals are being loaded, but this is not even the case. Skeleton cards are being shown while proposals are loaded. A spinner is shown when additional proposals are loaded into the infinite scroll. Because of the mocked proposals store, the component thought there were already proposals loaded and additional ones were being loaded, showing the spinner instead of the skeleton cards as a result.
Changes
authStore
and instead just set the identity usingresetIdentity
.proposalsStore
and instead mockqueryProposals
so theNnsProposals
can reset and fill theproposalsStore
itself.NnsProposals
.Tests
test only
Todos