@jobber/components-native 0.46.10 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,6 +55,10 @@ interface CommonButtonProps {
55
55
  * `accessibilityLabel`. **Don't use this for testing purposes.**
56
56
  */
57
57
  readonly accessibilityLabel?: string;
58
+ /**
59
+ * Used to locate this view in end-to-end tests.
60
+ */
61
+ readonly testID?: string;
58
62
  }
59
63
  interface LabelButton extends CommonButtonProps {
60
64
  /**
@@ -67,5 +71,5 @@ interface IconButton extends CommonButtonProps {
67
71
  readonly accessibilityLabel: string;
68
72
  }
69
73
  export type ButtonProps = XOR<LabelButton, IconButton>;
70
- export declare function Button({ label, onPress, variation, type, fullHeight, fullWidth, disabled, loading, size, accessibilityLabel, accessibilityHint, icon, }: ButtonProps): JSX.Element;
74
+ export declare function Button({ label, onPress, variation, type, fullHeight, fullWidth, disabled, loading, size, accessibilityLabel, accessibilityHint, icon, testID, }: ButtonProps): JSX.Element;
71
75
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components-native",
3
- "version": "0.46.10",
3
+ "version": "0.47.0",
4
4
  "license": "MIT",
5
5
  "description": "React Native implementation of Atlantis",
6
6
  "repository": {
@@ -84,5 +84,5 @@
84
84
  "react-native-reanimated": "^2.17.0",
85
85
  "react-native-safe-area-context": "^4.5.2"
86
86
  },
87
- "gitHead": "5668739977ce8c578ac682452ea31261d423bf10"
87
+ "gitHead": "a4a664e49538a432df03a593c100ab6055adeca4"
88
88
  }
@@ -72,6 +72,11 @@ interface CommonButtonProps {
72
72
  * `accessibilityLabel`. **Don't use this for testing purposes.**
73
73
  */
74
74
  readonly accessibilityLabel?: string;
75
+
76
+ /**
77
+ * Used to locate this view in end-to-end tests.
78
+ */
79
+ readonly testID?: string;
75
80
  }
76
81
 
77
82
  interface LabelButton extends CommonButtonProps {
@@ -87,6 +92,7 @@ interface IconButton extends CommonButtonProps {
87
92
  }
88
93
 
89
94
  export type ButtonProps = XOR<LabelButton, IconButton>;
95
+
90
96
  export function Button({
91
97
  label,
92
98
  onPress,
@@ -100,6 +106,7 @@ export function Button({
100
106
  accessibilityLabel,
101
107
  accessibilityHint,
102
108
  icon,
109
+ testID,
103
110
  }: ButtonProps): JSX.Element {
104
111
  const buttonStyle = [
105
112
  styles.button,
@@ -119,7 +126,7 @@ export function Button({
119
126
  return (
120
127
  <TouchableHighlight
121
128
  onPress={onPress}
122
- testID={accessibilityLabel || label}
129
+ testID={buildTestID(testID, label, accessibilityLabel)}
123
130
  accessibilityLabel={accessibilityLabel || label}
124
131
  accessibilityHint={accessibilityHint}
125
132
  accessibilityRole="button"
@@ -220,3 +227,15 @@ function getContentStyles(
220
227
  !!label && styles.contentWithLabel,
221
228
  ];
222
229
  }
230
+
231
+ function buildTestID(
232
+ testID: string | undefined,
233
+ label: string | undefined,
234
+ accessibilityLabel: string | undefined,
235
+ ): string | undefined {
236
+ if (testID) {
237
+ return `ATL-${testID}-Button`;
238
+ }
239
+
240
+ return accessibilityLabel || label;
241
+ }
@@ -50,6 +50,7 @@ export function ButtonGroup({
50
50
  const { handlePress } = usePreventTapWhenOffline();
51
51
  const secondaryActionsRef = useRef<BottomSheetRef>();
52
52
  const { primaryActions, secondaryActions } = getActions(children);
53
+
53
54
  return (
54
55
  <View style={styles.buttonGroup}>
55
56
  {primaryActions.map((action, index) => {
@@ -75,6 +76,7 @@ export function ButtonGroup({
75
76
  fullHeight={true}
76
77
  icon={icon}
77
78
  loading={loading}
79
+ testID={`ATL-ButtonGroup-Primary-Action-${index}`}
78
80
  />
79
81
  )}
80
82
  </View>
@@ -88,6 +90,7 @@ export function ButtonGroup({
88
90
  accessibilityLabel={t("more")}
89
91
  onPress={handlePress(openBottomSheet)}
90
92
  fullHeight={true}
93
+ testID="ATL-ButtonGroup-Secondary-Action"
91
94
  />
92
95
  </View>
93
96
  )}
@@ -21,36 +21,34 @@ export function FormSaveButton({
21
21
  const buttonActions = useButtonGroupAction(secondaryActions);
22
22
 
23
23
  return (
24
- <>
25
- <ButtonGroup
26
- onOpenBottomSheet={onOpenBottomSheet}
27
- onCloseBottomSheet={onCloseBottomSheet}
28
- allowTapWhenOffline={true}
29
- >
30
- {buttonActions.map((action, index) => {
31
- if (index === 0) {
32
- return (
33
- <ButtonGroup.PrimaryAction
34
- key={index}
35
- onPress={primaryAction}
36
- label={label ?? t("save")}
37
- loading={loading}
38
- />
39
- );
40
- } else {
41
- return (
42
- <ButtonGroup.SecondaryAction
43
- key={index}
44
- label={action.label}
45
- icon={action.icon}
46
- onPress={action.onPress}
47
- destructive={action.destructive}
48
- />
49
- );
50
- }
51
- })}
52
- </ButtonGroup>
53
- </>
24
+ <ButtonGroup
25
+ onOpenBottomSheet={onOpenBottomSheet}
26
+ onCloseBottomSheet={onCloseBottomSheet}
27
+ allowTapWhenOffline={true}
28
+ >
29
+ {buttonActions.map((action, index) => {
30
+ if (index === 0) {
31
+ return (
32
+ <ButtonGroup.PrimaryAction
33
+ key={index}
34
+ onPress={primaryAction}
35
+ label={label ?? t("save")}
36
+ loading={loading}
37
+ />
38
+ );
39
+ } else {
40
+ return (
41
+ <ButtonGroup.SecondaryAction
42
+ key={index}
43
+ label={action.label}
44
+ icon={action.icon}
45
+ onPress={action.onPress}
46
+ destructive={action.destructive}
47
+ />
48
+ );
49
+ }
50
+ })}
51
+ </ButtonGroup>
54
52
  );
55
53
 
56
54
  function useButtonGroupAction(
@@ -81,6 +79,7 @@ export function FormSaveButton({
81
79
  handleAction: SecondaryActionProp["handleAction"],
82
80
  ) {
83
81
  let performSubmit = true;
82
+
84
83
  if (handleAction.onBeforeSubmit) {
85
84
  performSubmit = await handleAction.onBeforeSubmit();
86
85
  }