Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 46bd770

Browse files
author
scottbommarito
committed
fixes issue
1 parent 9eefb21 commit 46bd770

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

RestartManager.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const log = require("./logging");
22
const NativeCodePush = require("react-native").NativeModules.CodePush;
33

44
const RestartManager = (() => {
5+
let _in_progress = false;
56
let _allowed = true;
67
let _restartPending = false;
78

@@ -25,6 +26,11 @@ const RestartManager = (() => {
2526
}
2627

2728
function restartApp(onlyIfUpdateIsPending = false) {
29+
if (_in_progress) {
30+
log("A restart request is already in progress or queued");
31+
return;
32+
}
33+
_in_progress = true;
2834
if (_allowed) {
2935
NativeCodePush.restartApp(onlyIfUpdateIsPending);
3036
log("Restarting app");
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var CodePushWrapper = require("../codePushWrapper.js");
2+
import CodePush from "react-native-code-push";
3+
4+
module.exports = {
5+
startTest: function(testApp) {
6+
CodePushWrapper.checkAndInstall(testApp,
7+
() => {
8+
CodePush.restartApp();
9+
CodePush.restartApp();
10+
}
11+
);
12+
},
13+
14+
getScenarioName: function() {
15+
return "Install and Restart 2x";
16+
}
17+
};

test/test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ const ScenarioInstall = "scenarioInstall.js";
465465
const ScenarioInstallOnResumeWithRevert = "scenarioInstallOnResumeWithRevert.js";
466466
const ScenarioInstallOnRestartWithRevert = "scenarioInstallOnRestartWithRevert.js";
467467
const ScenarioInstallWithRevert = "scenarioInstallWithRevert.js";
468+
const ScenarioInstallRestart2x = "scenarioInstallRestart2x.js";
468469
const ScenarioSync1x = "scenarioSync.js";
469470
const ScenarioSyncResume = "scenarioSyncResume.js";
470471
const ScenarioSyncResumeDelay = "scenarioSyncResumeDelay.js";
@@ -986,6 +987,26 @@ PluginTestingFramework.initializeTests(new RNProjectManager(), supportedTargetPl
986987
});
987988
}, ScenarioRestart);
988989

990+
TestBuilder.describe("#codePush.restartApplication.2x",
991+
() => {
992+
TestBuilder.it("with pending update", false,
993+
(done: MochaDone) => {
994+
ServerUtil.updateResponse = { updateInfo: ServerUtil.createUpdateResponse(false, targetPlatform) };
995+
996+
setupUpdateScenario(projectManager, targetPlatform, UpdateDeviceReady, "Update 1")
997+
.then<void>((updatePath: string) => {
998+
ServerUtil.updatePackagePath = updatePath;
999+
projectManager.runApplication(TestConfig.testRunDirectory, targetPlatform);
1000+
return ServerUtil.expectTestMessages([
1001+
ServerUtil.TestMessage.CHECK_UPDATE_AVAILABLE,
1002+
ServerUtil.TestMessage.DOWNLOAD_SUCCEEDED,
1003+
ServerUtil.TestMessage.UPDATE_INSTALLED,
1004+
ServerUtil.TestMessage.DEVICE_READY_AFTER_UPDATE]);
1005+
})
1006+
.done(() => { done(); }, (e) => { done(e); });
1007+
});
1008+
}, ScenarioInstallRestart2x);
1009+
9891010
TestBuilder.describe("#window.codePush.sync",
9901011
() => {
9911012
// We test the functionality with sync twice--first, with sync only called once,

0 commit comments

Comments
 (0)