react-native-insider 8.1.0 → 9.0.0-nh
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.
- package/README.md +89 -660
- package/RNInsider.podspec +33 -12
- package/android/build.gradle +16 -7
- package/android/src/main/java/com/useinsider/react/RNInsiderAppFrameViewManager.java +253 -0
- package/android/src/main/java/com/useinsider/react/RNInsiderModule.java +238 -178
- package/android/src/main/java/com/useinsider/react/RNInsiderPackage.java +5 -1
- package/android/src/main/java/com/useinsider/react/RNUtils.java +111 -0
- package/babel.config.js +4 -1
- package/index.d.ts +196 -161
- package/index.js +60 -11
- package/ios/RNInsider/RNInsider.m +245 -341
- package/ios/RNInsider/RNInsiderAppFrameView.h +33 -0
- package/ios/RNInsider/RNInsiderAppFrameView.mm +315 -0
- package/ios/RNInsider/RNNotificationHandler.h +4 -1
- package/ios/RNInsider/RNNotificationHandler.m +16 -18
- package/ios/RNInsider/RNUtils.h +2 -0
- package/ios/RNInsider/RNUtils.m +79 -0
- package/package.json +43 -12
- package/src/EventHandler.js +17 -0
- package/src/InsiderAppFrame.d.ts +45 -0
- package/src/InsiderAppFrame.js +265 -0
- package/src/InsiderAppFrameLogic.d.ts +35 -0
- package/src/InsiderAppFrameLogic.js +192 -0
- package/src/InsiderAppFrameStatus.d.ts +22 -0
- package/src/InsiderAppFrameStatus.js +35 -0
- package/src/InsiderAppFramesError.d.ts +25 -0
- package/src/InsiderAppFramesError.js +77 -0
- package/src/InsiderEvent.js +1 -0
- package/src/InsiderEvents.d.ts +93 -0
- package/src/InsiderEvents.js +124 -0
- package/src/InsiderIdentifier.js +1 -1
- package/src/InsiderUser.d.ts +3 -2
- package/src/InsiderUser.js +27 -0
- package/src/Util.js +2 -1
- package/src/specs/InsiderAppFrameNativeComponent.ts +54 -0
- package/.orbit-output/config/MASTER.md +0 -129
- package/.orbit-output/config/architecture/API_DOCS.md +0 -342
- package/.orbit-output/config/architecture/ARCHITECTURE.md +0 -209
- package/.orbit-output/config/architecture/CODE-CATALOG.md +0 -172
- package/.orbit-output/config/architecture/project.yaml +0 -138
- package/.orbit-output/config/automation/AUTOMATION-SETUP.md +0 -50
- package/.orbit-output/config/enforcement/ENFORCEMENT-RULES.md +0 -41
- package/.orbit-output/config/enforcement/validate.sh +0 -49
- package/.orbit-output/skills/custom/academy-doc-generator.md +0 -598
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
- package/android/src/test/java/com/useinsider/react/RNInsiderModuleTest.java +0 -169
- package/docs/app-cards/app-cards_new.md +0 -569
- package/ios/RNInsiderTests/RNInsiderTriggerPushProcessTests.m +0 -91
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
package com.useinsider.react;
|
|
2
|
-
|
|
3
|
-
import static org.junit.Assert.assertEquals;
|
|
4
|
-
import static org.junit.Assert.assertTrue;
|
|
5
|
-
import static org.mockito.ArgumentMatchers.any;
|
|
6
|
-
import static org.mockito.ArgumentMatchers.eq;
|
|
7
|
-
import static org.mockito.Mockito.never;
|
|
8
|
-
import static org.mockito.Mockito.times;
|
|
9
|
-
import static org.mockito.Mockito.verify;
|
|
10
|
-
import static org.mockito.Mockito.when;
|
|
11
|
-
|
|
12
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
13
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
14
|
-
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
15
|
-
import com.facebook.react.bridge.ReadableType;
|
|
16
|
-
import com.useinsider.insider.Insider;
|
|
17
|
-
|
|
18
|
-
import org.junit.After;
|
|
19
|
-
import org.junit.Before;
|
|
20
|
-
import org.junit.Test;
|
|
21
|
-
import org.mockito.ArgumentCaptor;
|
|
22
|
-
|
|
23
|
-
import java.lang.reflect.Field;
|
|
24
|
-
import java.util.HashMap;
|
|
25
|
-
import java.util.Map;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Unit tests for {@link RNInsiderModule#triggerPushProcessWithNotificationData(ReadableMap)}.
|
|
29
|
-
*
|
|
30
|
-
* MOB-26455: New bridge method that converts the JS notification payload to a
|
|
31
|
-
* String map and forwards it to {@code Insider.Instance.triggerPushProcessWithNotificationData}.
|
|
32
|
-
* The bridge must:
|
|
33
|
-
* - Treat a null payload as a no-op (early return, no native call).
|
|
34
|
-
* - Convert ReadableMap entries to String values via {@link String#valueOf(Object)}.
|
|
35
|
-
* - Pass the supplied {@link ReactApplicationContext} to the native SDK.
|
|
36
|
-
* - Route any thrown exception through {@code Insider.Instance.putException}
|
|
37
|
-
* instead of propagating it to the JS caller.
|
|
38
|
-
*/
|
|
39
|
-
public class RNInsiderModuleTest {
|
|
40
|
-
|
|
41
|
-
private RNInsiderModule module;
|
|
42
|
-
private ReactApplicationContext reactContext;
|
|
43
|
-
private Insider insiderMock;
|
|
44
|
-
private Insider originalInstance;
|
|
45
|
-
|
|
46
|
-
@Before
|
|
47
|
-
public void setUp() throws Exception {
|
|
48
|
-
reactContext = org.mockito.Mockito.mock(ReactApplicationContext.class);
|
|
49
|
-
insiderMock = org.mockito.Mockito.mock(Insider.class);
|
|
50
|
-
|
|
51
|
-
Field instanceField = Insider.class.getDeclaredField("Instance");
|
|
52
|
-
instanceField.setAccessible(true);
|
|
53
|
-
originalInstance = (Insider) instanceField.get(null);
|
|
54
|
-
instanceField.set(null, insiderMock);
|
|
55
|
-
|
|
56
|
-
module = new RNInsiderModule(reactContext);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@After
|
|
60
|
-
public void tearDown() throws Exception {
|
|
61
|
-
Field instanceField = Insider.class.getDeclaredField("Instance");
|
|
62
|
-
instanceField.setAccessible(true);
|
|
63
|
-
instanceField.set(null, originalInstance);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
@Test
|
|
67
|
-
public void triggerPushProcessWithNotificationData_nullPayload_doesNotInvokeNativeSdk() {
|
|
68
|
-
module.triggerPushProcessWithNotificationData(null);
|
|
69
|
-
|
|
70
|
-
verify(insiderMock, never())
|
|
71
|
-
.triggerPushProcessWithNotificationData(any(), any());
|
|
72
|
-
verify(insiderMock, never()).putException(any(Exception.class));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@Test
|
|
76
|
-
public void triggerPushProcessWithNotificationData_emptyMap_forwardsEmptyStringMap() {
|
|
77
|
-
ReadableMap empty = readableMapOf(new HashMap<String, Object>());
|
|
78
|
-
|
|
79
|
-
module.triggerPushProcessWithNotificationData(empty);
|
|
80
|
-
|
|
81
|
-
@SuppressWarnings("unchecked")
|
|
82
|
-
ArgumentCaptor<Map<String, String>> captor = ArgumentCaptor.forClass(Map.class);
|
|
83
|
-
verify(insiderMock, times(1))
|
|
84
|
-
.triggerPushProcessWithNotificationData(eq(reactContext), captor.capture());
|
|
85
|
-
assertTrue("Empty payload should produce empty String map", captor.getValue().isEmpty());
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
@Test
|
|
89
|
-
public void triggerPushProcessWithNotificationData_stringValues_passedThroughVerbatim() {
|
|
90
|
-
Map<String, Object> entries = new HashMap<>();
|
|
91
|
-
entries.put("title", "Welcome");
|
|
92
|
-
entries.put("body", "Hello there");
|
|
93
|
-
ReadableMap payload = readableMapOf(entries);
|
|
94
|
-
|
|
95
|
-
module.triggerPushProcessWithNotificationData(payload);
|
|
96
|
-
|
|
97
|
-
@SuppressWarnings("unchecked")
|
|
98
|
-
ArgumentCaptor<Map<String, String>> captor = ArgumentCaptor.forClass(Map.class);
|
|
99
|
-
verify(insiderMock, times(1))
|
|
100
|
-
.triggerPushProcessWithNotificationData(eq(reactContext), captor.capture());
|
|
101
|
-
Map<String, String> forwarded = captor.getValue();
|
|
102
|
-
assertEquals("Welcome", forwarded.get("title"));
|
|
103
|
-
assertEquals("Hello there", forwarded.get("body"));
|
|
104
|
-
assertEquals(2, forwarded.size());
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
@Test
|
|
108
|
-
public void triggerPushProcessWithNotificationData_numericValues_stringifiedViaStringValueOf() {
|
|
109
|
-
Map<String, Object> entries = new HashMap<>();
|
|
110
|
-
entries.put("priority", 5.0);
|
|
111
|
-
entries.put("retry", true);
|
|
112
|
-
ReadableMap payload = readableMapOf(entries);
|
|
113
|
-
|
|
114
|
-
module.triggerPushProcessWithNotificationData(payload);
|
|
115
|
-
|
|
116
|
-
@SuppressWarnings("unchecked")
|
|
117
|
-
ArgumentCaptor<Map<String, String>> captor = ArgumentCaptor.forClass(Map.class);
|
|
118
|
-
verify(insiderMock, times(1))
|
|
119
|
-
.triggerPushProcessWithNotificationData(eq(reactContext), captor.capture());
|
|
120
|
-
Map<String, String> forwarded = captor.getValue();
|
|
121
|
-
assertEquals(String.valueOf(5.0), forwarded.get("priority"));
|
|
122
|
-
assertEquals("true", forwarded.get("retry"));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
@Test
|
|
126
|
-
public void triggerPushProcessWithNotificationData_nativeSdkThrows_swallowedViaPutException() {
|
|
127
|
-
ReadableMap payload = readableMapOf(new HashMap<String, Object>());
|
|
128
|
-
RuntimeException boom = new RuntimeException("native failure");
|
|
129
|
-
org.mockito.Mockito.doThrow(boom)
|
|
130
|
-
.when(insiderMock)
|
|
131
|
-
.triggerPushProcessWithNotificationData(any(), any());
|
|
132
|
-
|
|
133
|
-
module.triggerPushProcessWithNotificationData(payload);
|
|
134
|
-
|
|
135
|
-
verify(insiderMock, times(1)).putException(boom);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Builds a {@link ReadableMap} stub backed by a plain Java map. The bridge
|
|
140
|
-
* only walks the iterator and asks for {@code getType}/{@code getString}/
|
|
141
|
-
* {@code getDouble}/{@code getBoolean}, so we mirror that minimal contract
|
|
142
|
-
* instead of pulling in {@code JavaOnlyMap} (which requires the React Native
|
|
143
|
-
* AAR at test time).
|
|
144
|
-
*/
|
|
145
|
-
private static ReadableMap readableMapOf(Map<String, Object> entries) {
|
|
146
|
-
ReadableMap map = org.mockito.Mockito.mock(ReadableMap.class);
|
|
147
|
-
ReadableMapKeySetIterator iterator = org.mockito.Mockito.mock(ReadableMapKeySetIterator.class);
|
|
148
|
-
Iterable<String> keys = new java.util.ArrayList<>(entries.keySet());
|
|
149
|
-
java.util.Iterator<String> keyIter = keys.iterator();
|
|
150
|
-
when(iterator.hasNextKey()).thenAnswer(invocation -> keyIter.hasNext());
|
|
151
|
-
when(iterator.nextKey()).thenAnswer(invocation -> keyIter.next());
|
|
152
|
-
when(map.keySetIterator()).thenReturn(iterator);
|
|
153
|
-
for (Map.Entry<String, Object> entry : entries.entrySet()) {
|
|
154
|
-
String key = entry.getKey();
|
|
155
|
-
Object value = entry.getValue();
|
|
156
|
-
if (value instanceof String) {
|
|
157
|
-
when(map.getType(key)).thenReturn(ReadableType.String);
|
|
158
|
-
when(map.getString(key)).thenReturn((String) value);
|
|
159
|
-
} else if (value instanceof Boolean) {
|
|
160
|
-
when(map.getType(key)).thenReturn(ReadableType.Boolean);
|
|
161
|
-
when(map.getBoolean(key)).thenReturn((Boolean) value);
|
|
162
|
-
} else if (value instanceof Number) {
|
|
163
|
-
when(map.getType(key)).thenReturn(ReadableType.Number);
|
|
164
|
-
when(map.getDouble(key)).thenReturn(((Number) value).doubleValue());
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return map;
|
|
168
|
-
}
|
|
169
|
-
}
|