Skip to content

Commit

Permalink
REFACTOR #256 move dialog Portals to top level
Browse files Browse the repository at this point in the history
Reason: the portal results in render to return null . Compare testing-library/react-testing-library#62
  • Loading branch information
mkraenz committed Sep 17, 2020
1 parent 3359c98 commit ff74796
Show file tree
Hide file tree
Showing 7 changed files with 419 additions and 84 deletions.
24 changes: 24 additions & 0 deletions __tests__/components/home/ReportThankYouDialog.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import i18next from "i18next";
import { noop } from "lodash";
import React from "react";
import "react-native";
import renderer, { act } from "react-test-renderer";
import ReportThankYouDialog from "../../../src/components/home/ReportThankYouDialog";
import TestLocalizationProvider from "../../helpers/TestLocalizationProvider";

it("renders correctly", async () => {
const tree = renderer
.create(
<TestLocalizationProvider>
<ReportThankYouDialog onDismiss={noop} />
</TestLocalizationProvider>
)
.toJSON();
await act(async () => {});

const treeStr = JSON.stringify(tree);
expect(treeStr).toContain(i18next.t("reportThankYouTitle"));
expect(treeStr).toContain(i18next.t("reportThankYouText"));
expect(treeStr).toContain(i18next.t("reportThankYouButton"));
expect(tree).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders correctly 1`] = `
<View
accessibilityLiveRegion="polite"
accessibilityViewIsModal={true}
pointerEvents="auto"
style={
Object {
"bottom": 0,
"left": 0,
"position": "absolute",
"right": 0,
"top": 0,
}
}
>
<View
accessible={true}
focusable={true}
onClick={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"backgroundColor": "rgba(0, 0, 0, 0.5)",
"flex": 1,
"opacity": 1,
}
}
/>
<View
forwardedRef={[Function]}
onLayout={[Function]}
pointerEvents="box-none"
style={
Object {
"bottom": 0,
"justifyContent": "center",
"left": 0,
"paddingBottom": 0,
"paddingLeft": 0,
"paddingRight": 0,
"paddingTop": 20,
"position": "absolute",
"right": 0,
"top": 0,
}
}
>
<View
style={
Object {
"backgroundColor": "#ffffff",
"borderRadius": 4,
"elevation": 24,
"justifyContent": "flex-start",
"marginHorizontal": 26,
"marginVertical": 0,
"opacity": 1,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 23,
"width": 0,
},
"shadowOpacity": 0.24,
"shadowRadius": 24,
}
}
>
<Text
accessibilityRole="header"
accessibilityStates={Object {}}
accessibilityTraits="header"
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
"textAlign": "left",
},
Array [
Object {
"color": "rgba(0, 0, 0, 0.87)",
"fontFamily": "System",
"fontWeight": "500",
"textAlign": "left",
"writingDirection": "ltr",
},
Array [
Object {
"fontSize": 20,
"letterSpacing": 0.15,
"lineHeight": 30,
"marginVertical": 2,
},
Array [
Object {
"marginBottom": 18,
"marginHorizontal": 24,
"marginTop": 22,
},
Object {
"color": "#000000",
},
undefined,
],
],
Array [
Object {
"fontSize": 20,
"letterSpacing": 0.15,
"lineHeight": 30,
"marginVertical": 2,
},
Array [
Object {
"marginBottom": 18,
"marginHorizontal": 24,
"marginTop": 22,
},
Object {
"color": "#000000",
},
undefined,
],
],
],
]
}
>
Thanks for Reporting
</Text>
<View
style={
Array [
Object {
"paddingBottom": 24,
"paddingHorizontal": 24,
},
undefined,
]
}
>
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
"textAlign": "left",
},
Array [
Object {
"color": "rgba(0, 0, 0, 0.87)",
"fontFamily": "System",
"fontWeight": "400",
"textAlign": "left",
"writingDirection": "ltr",
},
Array [
Object {
"fontSize": 14,
"letterSpacing": 0.25,
"lineHeight": 20,
"marginVertical": 2,
},
undefined,
],
Array [
Object {
"fontSize": 14,
"letterSpacing": 0.25,
"lineHeight": 20,
"marginVertical": 2,
},
undefined,
],
],
]
}
>
We are committed to protecting our users and others as well as their rights. We will check your report as soon as possible and take appropriate action.
</Text>
</View>
<View
style={
Array [
Object {
"alignItems": "center",
"flexDirection": "row",
"justifyContent": "flex-end",
"padding": 8,
},
undefined,
]
}
>
<View
accessibilityStates={Object {}}
style={
Object {
"backgroundColor": "transparent",
"borderColor": "transparent",
"borderRadius": 4,
"borderStyle": "solid",
"borderWidth": 0,
"elevation": 0,
"minWidth": "auto",
}
}
>
<View
accessibilityRole="button"
accessible={true}
focusable={true}
onClick={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Array [
Object {
"overflow": "hidden",
},
Object {
"borderRadius": 4,
},
]
}
>
<View
style={
Array [
Object {
"alignItems": "center",
"flexDirection": "row",
"justifyContent": "center",
},
undefined,
]
}
>
<Text
numberOfLines={1}
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
"textAlign": "left",
},
Array [
Object {
"letterSpacing": 1,
"marginHorizontal": 16,
"marginVertical": 9,
"textAlign": "center",
},
Object {
"marginHorizontal": 8,
},
Object {
"textTransform": "uppercase",
},
Object {
"color": "#6200ee",
"fontFamily": "System",
"fontWeight": "500",
},
Object {
"fontFamily": "System",
"fontWeight": "500",
},
undefined,
],
]
}
>
Close
</Text>
</View>
</View>
</View>
</View>
</View>
</View>
</View>
`;
6 changes: 6 additions & 0 deletions src/api/reportInappropriateContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ export const reportInappropriateContent = async (report: {
reason: string;
comment: string;
}) => {
if (
CONFIG.disableApiCall.all ||
CONFIG.disableApiCall.reportInappropriateContent
) {
return;
}
const result = await Axios.post(
CONFIG.uri.reportInappropriateContent,
pick(report, ["messageId", "reason", "comment"]),
Expand Down
Loading

0 comments on commit ff74796

Please sign in to comment.