diff --git a/ts/components/WebviewComponent.tsx b/ts/components/WebviewComponent.tsx index 4422a1f6492..094477f727a 100644 --- a/ts/components/WebviewComponent.tsx +++ b/ts/components/WebviewComponent.tsx @@ -42,6 +42,7 @@ const WebviewComponent = (props: Props) => { <> {hasError ? ( { ) : ( { + const globalState = appReducer(undefined, applicationChangeState("active")); + const mockStore = configureMockStore(); + const store: ReturnType = mockStore(globalState); + it("snapshot for component", () => { - const globalState = appReducer(undefined, applicationChangeState("active")); const enrichedState = { ...globalState, persistedPreferences: { @@ -16,13 +19,58 @@ describe("WebviewComponent tests", () => { isDesignSystemEnabled: false } }; - const mockStore = configureMockStore(); - const store: ReturnType = mockStore(enrichedState); + const enrichedStore: ReturnType = + mockStore(enrichedState); const component = render( - + ); expect(component).toMatchSnapshot(); }); + + it("should display error screen on error", () => { + const { getByText, getByTestId } = render( + + + + ); + + fireEvent(getByTestId("webview"), "onError", { + nativeEvent: { description: "Network error" } + }); + + expect(getByText(I18n.t("wallet.errors.GENERIC_ERROR"))).toBeTruthy(); + expect(getByText(I18n.t("global.buttons.retry"))).toBeTruthy(); + }); + + it("should reload on retry", () => { + const { getByText, getByTestId } = render( + + + + ); + + fireEvent(getByTestId("webview"), "onError", { + nativeEvent: { description: "Network error" } + }); + + fireEvent.press(getByText(I18n.t("global.buttons.retry"))); + + expect(getByTestId("webview")).toBeTruthy(); + }); + + it("should call handleError on WebView error", () => { + const { getByTestId } = render( + + + + ); + + fireEvent(getByTestId("webview"), "onError", { + nativeEvent: { description: "Network error" } + }); + + expect(getByTestId("webview-error")).toBeTruthy(); + }); }); diff --git a/ts/components/__tests__/__snapshots__/WebviewComponent.test.tsx.snap b/ts/components/__tests__/__snapshots__/WebviewComponent.test.tsx.snap index f24a780e097..e157e09672d 100644 --- a/ts/components/__tests__/__snapshots__/WebviewComponent.test.tsx.snap +++ b/ts/components/__tests__/__snapshots__/WebviewComponent.test.tsx.snap @@ -322,6 +322,7 @@ exports[`WebviewComponent tests snapshot for component 1`] = ` }, ] } + testID="webview" textInteractionEnabled={true} useSharedProcessPool={true} />