Skip to content

Commit 3e30c3d

Browse files
Fix BugReporting.setVideoRecordingFloatingButtonPosition
1 parent d0baaeb commit 3e30c3d

File tree

8 files changed

+51
-26
lines changed

8 files changed

+51
-26
lines changed

__tests__/bugReporting.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ describe('Testing BugReporting Module', () => {
3535
const didSelectPromptOptionHandler = sinon.spy(NativeModules.IBGBugReporting, 'setDidSelectPromptOptionHandler');
3636
const setFloatingButtonEdge = sinon.spy(NativeModules.IBGBugReporting, 'setFloatingButtonEdge');
3737
const setEnabledAttachmentTypes = sinon.spy(NativeModules.IBGBugReporting, 'setEnabledAttachmentTypes');
38+
const setVideoRecordingFloatingButtonPosition = sinon.spy(NativeModules.IBGBugReporting, 'setVideoRecordingFloatingButtonPosition');
3839

3940

4041
beforeEach(() => {
@@ -265,4 +266,12 @@ describe('Testing BugReporting Module', () => {
265266

266267
});
267268

269+
it('should call the native method setVideoRecordingFloatingButtonPosition', () => {
270+
271+
const position = 30;
272+
BugReporting.setVideoRecordingFloatingButtonPosition(position);
273+
274+
expect(setVideoRecordingFloatingButtonPosition.calledOnceWithExactly(position)).toBe(true);
275+
276+
});
268277
});

__tests__/index.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('Instabug Module', () => {
5656
const enable = sinon.spy(NativeModules.Instabug, 'enable');
5757
const disable = sinon.spy(NativeModules.Instabug, 'disable');
5858
const isRunningLive = sinon.spy(NativeModules.Instabug, 'isRunningLive');
59-
const setVideoRecordingFloatingButtonPosition = sinon.spy(NativeModules.Instabug, 'setVideoRecordingFloatingButtonPosition');
59+
const setVideoRecordingFloatingButtonPosition = sinon.spy(NativeModules.IBGBugReporting, 'setVideoRecordingFloatingButtonPosition');
6060
const showWelcomeMessageWithMode = sinon.spy(NativeModules.Instabug, 'showWelcomeMessageWithMode');
6161
const setWelcomeMessageMode = sinon.spy(NativeModules.Instabug, 'setWelcomeMessageMode');
6262
const setFileAttachment = sinon.spy(NativeModules.Instabug, 'setFileAttachment');

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -418,25 +418,6 @@ public void run() {
418418
});
419419
}
420420

421-
/**
422-
* Sets the default corner at which the video recording floating button will be shown
423-
*
424-
* @param corner corner to stick the video recording floating button to
425-
*/
426-
@ReactMethod
427-
public void setVideoRecordingFloatingButtonPosition(final String corner) {
428-
MainThreadHandler.runOnMainThread(new Runnable() {
429-
@Override
430-
public void run() {
431-
try {
432-
BugReporting.setVideoRecordingFloatingButtonPosition(getVideoRecordingButtonCorner(corner));
433-
} catch (Exception e) {
434-
e.printStackTrace();
435-
}
436-
}
437-
});
438-
}
439-
440421
/**
441422
* The file at filePath will be uploaded along upcoming reports with the name
442423
* fileNameWithExtension

index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export namespace BugReporting {
3939
autoScreenRecordingMaxDuration: number
4040
): void;
4141
function setViewHierarchyEnabled(viewHierarchyEnabled: boolean): void;
42+
function setVideoRecordingFloatingButtonPosition(
43+
position: BugReporting.position
44+
): void;
4245
enum invocationEvent {
4346
none,
4447
shake,
@@ -68,6 +71,12 @@ export namespace BugReporting {
6871
commentFieldRequired,
6972
disablePostSendingDialog
7073
}
74+
enum position {
75+
bottomRight,
76+
topRight,
77+
bottomLeft,
78+
topLeft
79+
}
7180
}
7281
export namespace Chats {
7382
function setEnabled(isEnabled: boolean): void;

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,9 @@ const InstabugModule = {
666666
}
667667
},
668668

669+
/* istanbul ignore next */
669670
/**
671+
* @deprecated use {@link BugReporting.setVideoRecordingFloatingButtonPosition}
670672
* Sets the default position at which the Instabug screen recording button will be shown.
671673
* Different orientations are already handled.
672674
* (Default for `position` is `bottomRight`)
@@ -675,7 +677,7 @@ const InstabugModule = {
675677
* or `bottomRight` to show on the bottom right of scrren.
676678
*/
677679
setVideoRecordingFloatingButtonPosition(position) {
678-
Instabug.setVideoRecordingFloatingButtonPosition(position);
680+
BugReporting.setVideoRecordingFloatingButtonPosition(position);
679681
},
680682

681683
/* istanbul ignore next */

jest/mockBugReporting.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ jest.mock('NativeModules', () => {
1818
setAutoScreenRecordingMaxDuration: jest.fn(),
1919
setViewHierarchyEnabled: jest.fn(),
2020
setEnabledAttachmentTypes: jest.fn(),
21-
setDidSelectPromptOptionHandler: jest.fn()
21+
setDidSelectPromptOptionHandler: jest.fn(),
22+
setVideoRecordingFloatingButtonPosition: jest.fn(),
2223
},
2324
Instabug: {}
2425
};

jest/mockInstabug.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,14 @@ jest.mock('NativeModules', () => {
4848
getReport: jest.fn(),
4949
sendHandledJSCrash: jest.fn(),
5050
sendJSCrash: jest.fn(),
51-
reportScreenChange: jest.fn()
52-
51+
reportScreenChange: jest.fn(),
5352
},
5453
IBGBugReporting: {
5554
setFloatingButtonEdge: jest.fn(),
5655
setEnabledAttachmentTypes: jest.fn(),
5756
},
5857
IBGReplies: {
5958
setPushNotificationsEnabled: jest.fn(),
60-
}
59+
},
6160
};
6261
});

modules/BugReporting.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ export default {
168168
IBGBugReporting.setAutoScreenRecordingMaxDuration(autoScreenRecordingMaxDuration);
169169
},
170170

171+
/**
172+
* Sets the default position at which the Instabug screen recording button will be shown.
173+
* Different orientations are already handled.
174+
* (Default for `position` is `bottomRight`)
175+
*
176+
* @param position is of type position `topLeft` to show on the top left of screen,
177+
* or `bottomRight` to show on the bottom right of scrren.
178+
*/
179+
setVideoRecordingFloatingButtonPosition(position) {
180+
IBGBugReporting.setVideoRecordingFloatingButtonPosition(position);
181+
},
182+
171183
/**
172184
* @summary Enables/disables inspect view hierarchy when reporting a bug/feedback.
173185
* @param {boolean} viewHierarchyEnabled A boolean to set whether view hierarchy are enabled
@@ -287,5 +299,17 @@ export default {
287299
emailFieldOptional: Instabug.optionEmailFieldOptional,
288300
commentFieldRequired: Instabug.optionCommentFieldRequired,
289301
disablePostSendingDialog: Instabug.optionDisablePostSendingDialog
290-
}
302+
},
303+
304+
/**
305+
* Instabug floating buttons positions.
306+
* @readonly
307+
* @enum {number}
308+
*/
309+
position: {
310+
bottomRight: Instabug.bottomRight,
311+
topRight: Instabug.topRight,
312+
bottomLeft: Instabug.bottomLeft,
313+
topLeft: Instabug.topLeft
314+
},
291315
};

0 commit comments

Comments
 (0)