-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: total binding issue by binding initialization (#53)
* fix(FHIRContextBinding): Fixes an issue when elements are bound to the '%total%' property * test: add OPA5 tests for total binding on tile * fix: enablement of refresh of total value * docs: updating the lint
- Loading branch information
Showing
12 changed files
with
172 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
sap.ui.define(["../utils/TestUtilsIntegration", "../utils/TestUtils"], function (TestUtilsIntegration, TestUtils) { | ||
"use strict"; | ||
|
||
var oModel, oContextBinding; | ||
|
||
function createModel(mParameters) { | ||
oModel = TestUtils.createFHIRModel("http://localhost:8080/fhir/R4/", mParameters); | ||
} | ||
|
||
function createContextBinding(sPath, oContext, mParameters) { | ||
oContextBinding = oModel.bindContext(sPath, oContext, mParameters).initialize(); | ||
} | ||
|
||
QUnit.module("Integration-Tests: FHIRContextBinding", { | ||
beforeEach: function () { | ||
createModel(); | ||
} | ||
}); | ||
|
||
QUnit.test("Check if contextbinding is initialized correctly", function (assert) { | ||
var done = assert.async(); | ||
var fnChangeHandler1 = function(oEvent){ | ||
oContextBinding.detachChange(fnChangeHandler1); | ||
var aPatientKeys = Object.keys(oModel.oData.Patient); | ||
assert.strictEqual(oContextBinding.isInitial(), false); | ||
assert.strictEqual(oContextBinding.bPendingRequest, false); | ||
assert.strictEqual(oContextBinding.bUnique, undefined); | ||
assert.strictEqual(aPatientKeys.length, 4); | ||
assert.strictEqual(oContextBinding.getBoundContext().iTotal, 4); | ||
assert.strictEqual(oContextBinding.getContext(), undefined); | ||
assert.strictEqual(oContextBinding.getPath(), "/Patient"); | ||
done(); | ||
}; | ||
createContextBinding("/Patient", undefined, undefined); | ||
oContextBinding.attachChange(fnChangeHandler1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
sap.ui.define(["../utils/TestUtilsIntegration", "../utils/TestUtils"], function (TestUtilsIntegration, TestUtils) { | ||
"use strict"; | ||
|
||
var oModel, oContextBinding, oPropertyBinding; | ||
|
||
function createModel(mParameters) { | ||
oModel = TestUtils.createFHIRModel("http://localhost:8080/fhir/R4/", mParameters); | ||
} | ||
|
||
function createContextBinding(sPath, oContext, mParameters) { | ||
oContextBinding = oModel.bindContext(sPath, oContext, mParameters).initialize(); | ||
} | ||
|
||
function createPropertyBinding(sPath, oContext, mParameters) { | ||
oPropertyBinding = oModel.bindProperty(sPath, oContext, mParameters).initialize(); | ||
} | ||
|
||
QUnit.module("Integration-Tests: FHIRPropertyBinding", { | ||
beforeEach: function () { | ||
createModel(); | ||
} | ||
}); | ||
|
||
QUnit.test("Check if propertybinding is initialized correctly if context is a aggregation of resources", function (assert) { | ||
var done = assert.async(); | ||
var fnChangeHandler1 = function(oEvent){ | ||
oContextBinding.detachChange(fnChangeHandler1); | ||
createPropertyBinding("%total%", oContextBinding.getBoundContext()); | ||
assert.strictEqual(oPropertyBinding.getValue(), 4, "The value of the propertybinding contains the correct 'total' value."); | ||
done(); | ||
}; | ||
createContextBinding("/Patient", undefined, undefined); | ||
oContextBinding.attachChange(fnChangeHandler1); | ||
}); | ||
|
||
QUnit.test("Check if propertybinding is initialized correctly if context is a single resource", function (assert) { | ||
var done = assert.async(); | ||
var fnChangeHandler1 = function(oEvent){ | ||
oContextBinding.detachChange(fnChangeHandler1); | ||
createPropertyBinding("name/0/given/0", oContextBinding.getBoundContext()); | ||
assert.strictEqual(oPropertyBinding.getValue(), "Hans", "The value of the propertybinding contains the correct given name."); | ||
done(); | ||
}; | ||
createContextBinding("/Patient/a2519", undefined, undefined); | ||
oContextBinding.attachChange(fnChangeHandler1); | ||
}); | ||
|
||
QUnit.test("Check if propertybinding is initialized correctly if propertybinding is created before context is loaded", function (assert) { | ||
var done = assert.async(); | ||
createContextBinding("/Patient", undefined, undefined); | ||
createPropertyBinding("%total%", undefined); | ||
var fnChangeHandler1 = function(oEvent){ | ||
var fnChangeHandler2 = function(oEvent){ | ||
oPropertyBinding.detachChange(fnChangeHandler2); | ||
assert.strictEqual(oPropertyBinding.getValue(), 4, "The value of the propertybinding contains the correct 'total' value."); | ||
done(); | ||
}; | ||
oContextBinding.detachChange(fnChangeHandler1); | ||
oPropertyBinding.attachChange(fnChangeHandler2); | ||
oPropertyBinding.setContext(oContextBinding.getBoundContext()); | ||
}; | ||
oContextBinding.attachChange(fnChangeHandler1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
sap.ui.define(["../utils/TestUtils"], function (TestUtils) { | ||
"use strict"; | ||
|
||
var oModel, oPropertyBinding; | ||
|
||
function createModel(mParameters) { | ||
oModel = TestUtils.createFHIRModel("https://example.com/fhir", mParameters); | ||
} | ||
|
||
function createPropertyBinding(sPath, oContext, mParameters) { | ||
oPropertyBinding = oModel.bindProperty(sPath, oContext, mParameters); | ||
} | ||
|
||
QUnit.module("Unit-Tests: FHIRPropertyBinding", { | ||
beforeEach: function () { | ||
createModel(); | ||
} | ||
}); | ||
|
||
QUnit.test("create and initialize", function (assert) { | ||
var sPath = "/Patient/123/name/0/given"; | ||
createPropertyBinding(sPath, undefined); | ||
assert.strictEqual(oPropertyBinding.isInitial(), false, "The binding is after creation not in 'initial' mode."); | ||
assert.deepEqual(oPropertyBinding.initialize(), oPropertyBinding, "The initialize method returns the binding itself."); | ||
assert.strictEqual(oPropertyBinding.isInitial(), false, "The binding is after initialization not in 'initial' mode."); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
test/sap-fhir-test-app/webapp/test/opa5/journeys/other/NavigationJourney.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
sap.ui.require(["sap/ui/test/opaQunit"], function(opaTest) { | ||
"use strict"; | ||
|
||
var sHash = ""; | ||
var sPatientTableHash = "patients"; | ||
var sView = "sap-fhir-test-app.view.Home"; | ||
var sPatientTableViewName = "sap-fhir-test-app.view.patient.PatientTable"; | ||
|
||
QUnit.module("Navigation Example"); | ||
|
||
opaTest("Check total binding on start screen", function(Given, When, Then) { | ||
Given.iStartMyApp(sHash); | ||
Then.theGenericTileBindingShouldDeliver(sView, "allPatients", {value : "4"}); | ||
}); | ||
|
||
opaTest("Check total binding after navigation", function(Given, When, Then) { | ||
Given.iStartMyApp(sPatientTableHash); | ||
When.iPressNavBackButton(sPatientTableViewName, "patientPage"); | ||
Then.theGenericTileBindingShouldDeliver(sView, "allPatients", {value : "4"}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters