Skip to content

Commit

Permalink
fix(Bonus Pagamenti Digitali): [#176143732] refresh wallet informatio…
Browse files Browse the repository at this point in the history
…n before start the bpd onboarding (#2626)

* [#176143732] dispatch fetchWalletsRequest action before start the bpd onboarding

* [#176143732] add test

* [#176143732] fix lint error

Co-authored-by: Matteo Boschi <[email protected]>
Co-authored-by: fabriziofff <[email protected]>
  • Loading branch information
3 people authored Dec 28, 2020
1 parent 1495859 commit 15c074d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { testSaga } from "redux-saga-test-plan";
import { some } from "fp-ts/lib/Option";
import { right } from "fp-ts/lib/Either";
import { navigationCurrentRouteSelector } from "../../../../../../store/reducers/navigation";
import {
bpdStartOnboardingWorker,
isBpdEnabled
} from "../../orchestration/onboarding/startOnboarding";
import {
navigateToBpdOnboardingDeclaration,
navigateToBpdOnboardingInformationTos,
navigateToBpdOnboardingLoadActivationStatus
} from "../../../navigation/actions";
import { navigationHistoryPop } from "../../../../../../store/actions/navigationHistory";
import {
bpdOnboardingAcceptDeclaration,
bpdUserActivate
} from "../../../store/actions/onboarding";
import { fetchWalletsRequest } from "../../../../../../store/actions/wallet/wallets";

jest.mock("react-native-share", () => ({
open: jest.fn()
}));

describe("bpdStartOnboardingWorker", () => {
it("should onboard a user", () => {
const notLoadingScreenRoute = "NotLoadingScreenRoute";

testSaga(bpdStartOnboardingWorker)
.next()
.select(navigationCurrentRouteSelector)
.next(some(notLoadingScreenRoute))
.put(navigateToBpdOnboardingLoadActivationStatus())
.next()
.put(navigationHistoryPop(1))
.next()
.call(isBpdEnabled)
.next(right(true))
.put(fetchWalletsRequest())
.next()
.put(navigateToBpdOnboardingInformationTos())
.next()
.put(navigationHistoryPop(1))
.next()
.take(bpdUserActivate)
.next()
.put(navigateToBpdOnboardingDeclaration())
.next()
.put(navigationHistoryPop(1))
.next()
.take(bpdOnboardingAcceptDeclaration);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { CitizenResource } from "../../../../../../../definitions/bpd/citizen/CitizenResource";
import ROUTES from "../../../../../../navigation/routes";
import { navigationHistoryPop } from "../../../../../../store/actions/navigationHistory";
import { fetchWalletsRequest } from "../../../../../../store/actions/wallet/wallets";
import { navigationCurrentRouteSelector } from "../../../../../../store/reducers/navigation";
import { SagaCallReturnType } from "../../../../../../types/utils";
import { getAsyncResult } from "../../../../../../utils/saga";
Expand Down Expand Up @@ -82,6 +83,9 @@ export function* bpdStartOnboardingWorker() {
);

if (isBpdActive.isRight()) {
// Refresh the wallets to prevent that added cards are not visible
yield put(fetchWalletsRequest());

yield put(navigateToBpdOnboardingInformationTos());
yield put(navigationHistoryPop(1));

Expand Down

0 comments on commit 15c074d

Please sign in to comment.