Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test/template/scenarios/scenarioSyncRestart2x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var CodePushWrapper = require("../codePushWrapper.js");
import CodePush from "@bitrise/code-push-sdk";

module.exports = {
startTest: function (testApp) {
testApp.sendCurrentAndPendingPackage()
.then(() => {
CodePushWrapper.sync(testApp, (status) => {
if (status === CodePush.SyncStatus.UPDATE_INSTALLED) {
testApp.sendCurrentAndPendingPackage().then(() => {
// Call sync() again without restarting: the update from the first call is still pending.
CodePushWrapper.sync(testApp, () => {}, undefined, { installMode: CodePush.InstallMode.ON_NEXT_RESTART });
});
}
}, undefined, { installMode: CodePush.InstallMode.ON_NEXT_RESTART });
});
},

getScenarioName: function () {
return "Sync Restart 2x (no restart in between)";
}
};
26 changes: 26 additions & 0 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ const ScenarioSyncResumeDelay = "scenarioSyncResumeDelay.js";
const ScenarioSyncRestartDelay = "scenarioSyncRestartDelay.js";
const ScenarioSyncSuspendDelay = "scenarioSyncSuspendDelay.js";
const ScenarioSync2x = "scenarioSync2x.js";
const ScenarioSyncRestart2x = "scenarioSyncRestart2x.js";
const ScenarioRestart = "scenarioRestart.js";
const ScenarioRestart2x = "scenarioRestart2x.js";
const ScenarioSyncMandatoryDefault = "scenarioSyncMandatoryDefault.js";
Expand Down Expand Up @@ -1538,6 +1539,31 @@ PluginTestingFramework.initializeTests(new RNProjectManager(), supportedTargetPl
}, ScenarioSync2x);
});

TestBuilder.describe("#window.codePush.sync restart 2x",
() => {
// Regression test: a sync() called again while a previous ON_NEXT_RESTART install is
// still pending (i.e. no actual restart happened in between) must report UPDATE_INSTALLED,
// not UP_TO_DATE. getCurrentPackage().isPending must reflect that pending state.
TestBuilder.it("window.codePush.sync.restart2x.stillpending", false,
(done: Mocha.Done) => {
ServerUtil.updateResponse = { update_info: ServerUtil.createUpdateResponse(false, targetPlatform) };

setupUpdateScenario(projectManager, targetPlatform, UpdateDeviceReady, "Update 1 (good update)")
.then<void>((updatePath: string) => {
ServerUtil.updatePackagePath = updatePath;
projectManager.runApplication(TestConfig.testRunDirectory, targetPlatform);
return ServerUtil.expectTestMessages([
new ServerUtil.AppMessage(ServerUtil.TestMessage.PENDING_PACKAGE, [null]),
new ServerUtil.AppMessage(ServerUtil.TestMessage.CURRENT_PACKAGE, [null]),
new ServerUtil.AppMessage(ServerUtil.TestMessage.SYNC_STATUS, [ServerUtil.TestMessage.SYNC_UPDATE_INSTALLED]),
new ServerUtil.AppMessage(ServerUtil.TestMessage.PENDING_PACKAGE, [ServerUtil.updateResponse.update_info.package_hash]),
new ServerUtil.AppMessage(ServerUtil.TestMessage.CURRENT_PACKAGE, [null]),
new ServerUtil.AppMessage(ServerUtil.TestMessage.SYNC_STATUS, [ServerUtil.TestMessage.SYNC_UPDATE_INSTALLED])]);
})
.done(() => { done(); }, (e) => { done(e); });
});
}, ScenarioSyncRestart2x);

TestBuilder.describe("#window.codePush.sync minimum background duration tests",
() => {
TestBuilder.it("defaults to no minimum for Resume mode", false,
Expand Down