How to use startWda method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

ClientSideTargetResolution.qunit.js

Source:ClientSideTargetResolution.qunit.js Github

copy

Full Screen

1// Copyright (c) 2009-2017 SAP SE, All Rights Reserved2/**3 * @fileOverview QUnit tests for sap.ushell.services.ClientSideTargetResolution4 */5sap.ui.require([6 "sap/ushell/services/ClientSideTargetResolution",7 "sap/ushell/services/_ClientSideTargetResolution/InboundIndex",8 "sap/ushell/services/_ClientSideTargetResolution/InboundProvider",9 "sap/ushell/services/_ClientSideTargetResolution/VirtualInbounds",10 "sap/ushell/services/_ClientSideTargetResolution/Search",11 "sap/ushell/services/_ClientSideTargetResolution/Utils",12 "sap/ushell/services/AppConfiguration",13 "sap/ushell/test/utils",14 "sap/ushell/utils",15 "sap/ushell/services/URLParsing",16 "sap/ui/thirdparty/URI",17 "sap/base/util/ObjectPath",18 "sap/ushell/TechnicalParameters",19 "sap/ushell/test/services/_ClientSideTargetResolution/ClientSideTargetResolution.resolveHashFragment",20 "sap/ushell/test/services/_ClientSideTargetResolution/TestHelper"21], function (22 ClientSideTargetResolution,23 oInboundIndex,24 InboundProvider,25 VirtualInbounds,26 oSearch,27 oCSTRUtils,28 oAppConfiguration,29 testUtils,30 utils,31 URLParsing,32 URI,33 ObjectPath,34 TechnicalParameters,35 fnExecuteResolveHashFragment,36 oTestHelper37) {38 "use strict";39 /* global QUnit, module, test, ok, equal, deepEqual, strictEqual, sinon, asyncTest, start */40 var oURLParsing = new URLParsing();41 var mkInt = function (sIntent) {42 return oURLParsing.parseShellHash(sIntent);43 };44 jQuery.sap.require("sap.ushell.services.Container");45 /*eslint max-nested-callbacks: [1, 4]*/46 // lookup of all count parameters47 var O_COUNT_PARAMETERS = {48 "countDefaultedParams": true,49 "countFreeInboundParams": true,50 "countMatchingFilterParams": true,51 "countMatchingParams": true,52 "countMatchingRequiredParams": true,53 "countPotentiallyMatchingParams": true54 },55 I_DEBUG = jQuery.sap.log.Level.DEBUG,56 I_TRACE = jQuery.sap.log.Level.TRACE;57 /*58 * Checks whether the expected warnings and errors were logged on the59 * console, taking the expectations from the given test fixture, which60 * should be defined as follows:61 *62 * {63 *64 * ... rest of the fixture...65 *66 * expectedWarningCalls: [67 * [ // arguments of the first call68 * "1stArg",69 * "2ndArg",70 * "3rdArg"71 * ],72 * ... more items if more calls are expected73 * ],74 * expectedErrorCalls: [] // 0 calls to jQuery.sap.log.error expected75 * }76 *77 * NOTE:78 * - If the given fixture does not specify the 'expectedWarningCalls' and79 * 'expectedErrorCalls' keys, no test will be executed.80 * - jQuery.sap.log.error and jQuery.sap.log.warning should have been81 * already stubbed before this function is called.82 */83 function testExpectedErrorAndWarningCalls (oFixture) {84 if (oFixture.hasOwnProperty("expectedErrorCalls")) {85 var aExpectedErrorCalls = (oFixture.expectedErrorCalls || []);86 strictEqual(87 jQuery.sap.log.error.callCount,88 aExpectedErrorCalls.length,89 "jQuery.sap.log.error was called the expected number of times"90 );91 if (aExpectedErrorCalls.length > 0) {92 deepEqual(93 jQuery.sap.log.error.args,94 aExpectedErrorCalls,95 "jQuery.sap.log.error logged the expected errors"96 );97 }98 }99 if (oFixture.hasOwnProperty("expectedWarningCalls")) {100 var aExpectedWarningCalls = (oFixture.expectedWarningCalls || []);101 strictEqual(102 jQuery.sap.log.warning.callCount,103 aExpectedWarningCalls.length,104 "jQuery.sap.log.warning was called the expected number of times"105 );106 if (aExpectedWarningCalls.length > 0) {107 deepEqual(108 jQuery.sap.log.warning.args,109 aExpectedWarningCalls,110 "jQuery.sap.log.warning logged the expected warnings"111 );112 }113 }114 }115 /*116 * Removes the count* parameters from each match result (output of117 * getMatchingInbounds) and the priority string.118 *119 * Returns the filtered result (that may contain shallow copies of120 * objects/arrays).121 */122 function removeCountsAndSortString (vMatchResults) {123 var bIsObject = jQuery.isPlainObject(vMatchResults);124 var aMatchResults = bIsObject ? [vMatchResults] : vMatchResults,125 aMutatedMatchResults = aMatchResults.map(function (oMatchResult) {126 return JSON.parse(JSON.stringify(oMatchResult, function (sKey, vVal) {127 return O_COUNT_PARAMETERS.hasOwnProperty(sKey) || sKey === "priorityString" ? undefined : vVal;128 }));129 });130 return bIsObject ? aMutatedMatchResults[0] : aMutatedMatchResults;131 }132 /*133 * A factory to create a test ClientSideTargetResolution service with134 * inbounds and configuration as needed.135 *136 * Can be called like:137 * createService(); // no inbounds, mocked adapter, undefined configuration138 * createService({139 * inbounds: [ ... ] // arbitrary inbounds140 * });141 * createService({142 * adapter: { ... } // arbitrary fake adapter143 * });144 * createService({145 * configuration: { ... } // arbitrary service configuration146 * });147 */148 function createService (oArgs) {149 var oConfiguration = (oArgs || {}).configuration;150 var aInbounds = (oArgs || {}).inbounds || [];151 var oAdapter = (oArgs || {}).adapter;152 if (!oAdapter) {153 // create fake adapter154 oAdapter = {155 getInbounds: sinon.stub().returns(156 new jQuery.Deferred().resolve(aInbounds).promise()157 )158 };159 }160 var oUshellConfig = testUtils.overrideObject({}, {161 "/services/ClientSideTargetResolution": oConfiguration162 });163 testUtils.resetConfigChannel(oUshellConfig);164 return new ClientSideTargetResolution(165 oAdapter,166 null,167 null,168 oConfiguration169 );170 }171 /*172 * Tests that _getMatchingInbounds was called with the expected173 * bExcludeTileInbounds argument if called at all.174 */175 function testExcludeTileIntentArgument (oCstrService, bExpectedExcludeTileInbounds) {176 var iCalledTimes = oCstrService._getMatchingInbounds.callCount;177 if (iCalledTimes > 0) {178 // getLinks may return preventively in some cases... but if179 // it's called we need to check these:180 strictEqual(iCalledTimes, 1, "_getMatchingInbounds was called 1 time");181 strictEqual(oCstrService._getMatchingInbounds.getCall(0).args.length, 3, "_getMatchingInbounds was called with three arguments");182 deepEqual(183 oCstrService._getMatchingInbounds.getCall(0).args[2],184 { bExcludeTileInbounds: bExpectedExcludeTileInbounds },185 "_getMatchingInbounds was called with a 'true' third argument (bExcludeTileInbounds)"186 );187 }188 }189 module("sap.ushell.services.ClientSideTargetResolution", {190 setup: function () {191 return sap.ushell.bootstrap("local").then(function () {192 // assume there is no open application in tests193 oAppConfiguration.setCurrentApplication(null);194 });195 },196 /**197 * This method is called after each test. Add every restoration code here.198 */199 teardown: function () {200 testUtils.restoreSpies(201 oCSTRUtils.isDebugEnabled,202 oSearch.match,203 oSearch.matchOne,204 oAppConfiguration.getCurrentApplication,205 utils.Error,206 utils.getFormFactor,207 utils.getLocalStorage,208 sap.ushell.Container.getService,209 sap.ushell.Container.getUser,210 sap.ui.getCore,211 jQuery.sap.getObject,212 jQuery.sap.log.warning,213 jQuery.sap.log.error,214 jQuery.sap.log.debug,215 jQuery.sap.log.getLevel,216 InboundProvider.prototype.getInbounds,217 VirtualInbounds.isVirtualInbound218 );219 delete sap.ushell.Container;220 }221 });222 test("getServiceClientSideTargetResolution: returns something different than undefined", function () {223 var oClientSideTargetResolution = sap.ushell.Container.getService("ClientSideTargetResolution");224 ok(oClientSideTargetResolution !== undefined);225 });226 test("getServiceClientSideTargetResolution: returns something different than undefined", function () {227 var oClientSideTargetResolution = sap.ushell.Container.getService("ClientSideTargetResolution");228 ok(oClientSideTargetResolution !== undefined);229 });230 [231 /*232 * Test for _extractInboundFilter233 */234 {235 testDescription: "natural result",236 input: "ABC-def?SO=AA",237 result: [238 {239 semanticObject: "ABC",240 action: "def"241 }242 ]243 },244 {245 testDescription: "flawed input",246 input: "Customer-processReceivablesCollectionSegment=EUR_TOOL&Customer=C0001&IsHeadOfficeView=true#Shell-home",247 result: undefined248 },249 {250 testDescription: "natural result no segmented access",251 noSegment: true,252 input: "ABC-defo?SO=AA",253 result: undefined254 }255 ].forEach(function (oFixture) {256 test("_extractInboundFilter when " + oFixture.testDescription, function () {257 var aRes,258 oSrvc,259 oFakeAdapter;260 if (oFixture.noSegment) {261 oFakeAdapter = null;262 } else {263 oFakeAdapter = {264 getInbounds: function () {},265 hasSegmentedAccess: true266 };267 }268 oSrvc = createService({269 adapter: oFakeAdapter270 });271 aRes = oSrvc._extractInboundFilter(oFixture.input);272 deepEqual(aRes, oFixture.result, "correct result");273 });274 });275 // test the parameter sap-ui-tech-hint=WDA|UI5|GUI which, given276 // an otherwise identical targetmapping, selects the one which has the given technology.277 var iInb = {278 semanticObject: "SO",279 action: "action",280 signature: {281 parameters: {}282 },283 resolutionResult: {}284 };285 var iInbDefault = {286 semanticObject: "SO",287 action: "action",288 signature: {289 parameters: { "sap-ui-tech-hint": { defaultValue: { value: "XXX" }}}290 },291 resolutionResult: {}292 };293 var iInbDefaultOtherPar = {294 semanticObject: "SO",295 action: "action",296 signature: {297 parameters: {298 "sap-ui-tech-hint": { defaultValue: { value: "XXX" }},299 "demo2": { defaultValue: { value: "XXX" }}300 }301 },302 resolutionResult: {}303 };304 function addTech (oObj, sTech) {305 var copy = jQuery.extend(true, {}, oObj);306 copy.resolutionResult["sap.ui"] = {};307 copy.resolutionResult["sap.ui"].technology = sTech;308 return copy;309 }310 [311 {312 testDescription: "all else equal, tech hint is used WDA->WDA",313 aInbounds: ["GUI", "WDA", "UI5", undefined].map(function (el) {314 return addTech(iInb, el);315 }),316 sIntent: "SO-action?sap-ui-tech-hint=WDA",317 expectedResultTech: "WDA"318 },319 {320 testDescription: "all else equal, no tech hint, 'best technology' UI5->WDA->GUI",321 aInbounds: ["GUI", "UI5", "WDA", undefined].map(function (el) { return addTech(iInb, el); }),322 sIntent: "SO-action",323 expectedResultTech: "UI5"324 },325 {326 testDescription: "all else equal, no tech hint, 'best technology' UI5->WDA->GUI , UI5 not present",327 aInbounds: ["GUI", "WDA", undefined].map(function (el) { return addTech(iInb, el); }),328 sIntent: "SO-action",329 expectedResultTech: "WDA"330 },331 {332 testDescription: "all else equal, no tech hint, 'best technology' UI5->WDA->GUI , default on WDA Intent",333 aInbounds: [addTech(iInbDefault, "WDA")].concat(["GUI", "UI5", undefined].map(function (el) { return addTech(iInb, el); })),334 sIntent: "SO-action?sap-ui-tech-hint=GUI",335 expectedResultTech: "GUI"336 },337 {338 testDescription: "all else equal, no tech hint, 'best technology' UI5->WDA->GUI , DefaultInOther",339 aInbounds: [addTech(iInbDefaultOtherPar, "WDA")].concat(["GUI", "WDA", undefined].map(function (el) { return addTech(iInb, el); })),340 sIntent: "SO-action?sap-ui-tech-hint=GUI",341 expectedResultTech: "GUI"342 },343 {344 testDescription: "all else equal, no tech hint, 'best technology' UI5->WDA->GUI , DefaultInOther no hint",345 aInbounds: [addTech(iInbDefaultOtherPar, "WDA")].concat(["GUI", "WDA", undefined].map(function (el) { return addTech(iInb, el); })),346 sIntent: "SO-action",347 expectedResultTech: "WDA"348 }349 ].forEach(function (oFixture) {350 asyncTest("matchingTarget sap-ui-tech-hint " + oFixture.testDescription, function () {351 var oSrvc = createService();352 var oShellHash = mkInt("#" + oFixture.sIntent);353 oShellHash.formFactor = "desktop";354 var oIndex = oInboundIndex.createIndex(oFixture.aInbounds);355 oSrvc._getMatchingInbounds(oShellHash, oIndex)356 .done(function (oMatchingTargets) {357 if (oFixture.expectedResultTech) {358 equal(oMatchingTargets[0].inbound.resolutionResult["sap.ui"].technology, oFixture.expectedResultTech, "correct result technology");359 }360 })361 .fail(function (sError) {362 ok(false, "promise was rejected");363 })364 .always(function () {365 start();366 });367 });368 });369 [370 /*371 * _getMatchingInbounds: checks match results are sorted as expected"372 */373 {374 testDescription: "one inbound matches",375 aFakeMatchResults: [376 // NOTE: not actual Inbound structure. We only use 'matches' and num377 // is random, used only for report purposes.378 { num: 36, matches: true, inbound: { resolutionResult: { applicationType: "Something" }}}379 ],380 expectedInbounds: [0] // zero-based index in aFakeInbounds381 },382 {383 testDescription: "no inbound matches",384 aFakeMatchResults: [385 ],386 expectedInbounds: []387 },388 {389 testDescription: "multiple inbound match, longer names win",390 aFakeMatchResults: [391 // NOTE: applicationType determines the order here392 { num: 33, matches: true, inbound: { resolutionResult: { applicationType: "Something" }}},393 { num: 36, matches: true, inbound: { resolutionResult: { applicationType: "SomethingExt" }}}394 ],395 expectedInbounds: [1, 0]396 },397 {398 testDescription: "multiple inbound match, reverse alphabetical order in tie-breaker",399 aFakeMatchResults: [400 // NOTE: applicationType determines the order here401 { num: 33, matches: true, inbound: { resolutionResult: { applicationType: "A" }}},402 { num: 36, matches: true, inbound: { resolutionResult: { applicationType: "B" }}}403 ],404 expectedInbounds: [1, 0] // -> B then A405 },406 {407 testDescription: "priority is specified",408 aFakeMatchResults: [409 { num: 18, matches: true, priorityString: "B", inbound: { resolutionResult: {} } },410 { num: 31, matches: true, priorityString: "CD", inbound: { resolutionResult: {} } },411 { num: 33, matches: true, priorityString: "CZ", inbound: { resolutionResult: {} } },412 { num: 41, matches: true, priorityString: "A", inbound: { resolutionResult: {} } },413 { num: 44, matches: true, priorityString: "C", inbound: { resolutionResult: {} } },414 { num: 46, matches: true, priorityString: "CE", inbound: { resolutionResult: {} } }415 ],416 expectedInbounds: [2, 5, 1, 4, 0, 3]417 },418 {419 testDescription: "priority is specified",420 aFakeMatchResults: [421 { num: 44, matches: true, priorityString: "C", inbound: { resolutionResult: {} } },422 { num: 31, matches: true, priorityString: "CD", inbound: { resolutionResult: {} } },423 { num: 41, matches: true, priorityString: "A", inbound: { resolutionResult: {} } },424 { num: 46, matches: true, priorityString: "CE", inbound: { resolutionResult: {} } },425 { num: 18, matches: true, priorityString: "B", inbound: { resolutionResult: {} } },426 { num: 33, matches: true, priorityString: "CZ", inbound: { resolutionResult: {} } }427 ],428 expectedInbounds: [5, 3, 1, 0, 4, 2]429 },430 {431 testDescription: "priority is with numbers",432 aFakeMatchResults: [433 { num: 44, matches: true, priorityString: "101", inbound: { resolutionResult: {} } },434 { num: 31, matches: true, priorityString: "000", inbound: { resolutionResult: {} } },435 { num: 41, matches: true, priorityString: "120", inbound: { resolutionResult: {} } },436 { num: 46, matches: true, priorityString: "999", inbound: { resolutionResult: {} } },437 { num: 18, matches: true, priorityString: "010", inbound: { resolutionResult: {} } },438 { num: 33, matches: true, priorityString: "001", inbound: { resolutionResult: {} } }439 ],440 expectedInbounds: [3, 2, 0, 4, 5, 1]441 },442 {443 testDescription: "realistic sort strings sorted with expected priority",444 aFakeMatchResults: [445 { num: 33, matches: true, priorityString: "x MTCH=003 MREQ=003 NFIL=002 NDEF=001 POT=004 RFRE=999", inbound: { resolutionResult: {} } },446 { num: 18, matches: true, priorityString: "x MTCH=003 MREQ=003 NFIL=002 NDEF=001 POT=100 RFRE=999", inbound: { resolutionResult: {} } }447 ],448 expectedInbounds: [1, 0]449 }450 ].forEach(function (oFixture) {451 asyncTest("_getMatchingInbounds: matching inbounds are returned in priority when " + oFixture.testDescription, function () {452 // Return fake adapter with inbounds in the fixture453 var oSrvc = createService(),454 aExpectedMatchingTargets = oFixture.expectedInbounds.map(function (iIdx) {455 return oFixture.aFakeMatchResults[iIdx];456 });457 var oIndex = {458 // values don't matter for this test (match is stubbed anyway)459 getSegment: sinon.stub().returns([]),460 getAllInbounds: sinon.stub().returns([])461 };462 sinon.stub(oSearch, "match").returns(Promise.resolve({463 matchResults: oFixture.aFakeMatchResults,464 missingReferences: {}465 }));466 // Act467 oSrvc._getMatchingInbounds({} /* any parameter ok for the test*/, oIndex).done(function (aMatchingInbounds) {468 // Assert469 strictEqual(Object.prototype.toString.call(aMatchingInbounds), "[object Array]", "an array was returned");470 deepEqual(aMatchingInbounds, aExpectedMatchingTargets,471 "inbounds that matched were returned in the promise");472 }).fail(function () {473 ok(false, "promise was resolved");474 }).always(function () {475 start();476 });477 });478 });479 [480 /*481 * General tests for _getMatchingInbounds482 *483 * testDescription: {string}:484 * describes the test case (not what the test should do!).485 *486 * oParsedShellHash: {object}:487 * the parsed intent488 *489 * aInbounds: {object}490 * inbounds to match against491 *492 * mockedUserDefaultValues: {object}493 * any mocked known user default value494 *495 * expected: {object[]} or {number[]}496 * - when {object[]}:497 * array of *matching results*. This is checked 1:1498 * with deepEqual.499 *500 * - when {number[]}:501 * array of 0-based indices into aInbounds. In this case the502 * test will deepEqual only the "inbound" entry in the503 * matching result object.504 *505 * NOTE: this test does not check for the sort string or count506 * parameters. Use test for sort string instead.507 */508 {509 testDescription: "generic semantic object specified in intent",510 oParsedShellHash: {511 "semanticObject": undefined,512 "action": "action",513 "params": {514 "currency": ["EUR"]515 }516 },517 aInbounds: [518 {519 semanticObject: "ObjectA",520 action: "action",521 signature: { parameters: {522 currency: { required: true, filter: { value: "EUR" } }523 }},524 resolutionResult: { text: "Currency manager", ui5ComponentName: "Currency.ComponentA", url: "/url/to/currency", applicationType: "URL", additionalInformation: "SAPUI5.Component=Currency.Component" }525 },526 {527 semanticObject: "ObjectB",528 action: "action",529 signature: { parameters: {530 currency: { required: true, filter: { value: "EUR" } },531 user: { required: false, defaultValue: { value: "TEST" } }532 }},533 resolutionResult: { text: "Currency manager", ui5ComponentName: "Currency.ComponentB", url: "/url/to/currency", applicationType: "URL", additionalInformation: "SAPUI5.Component=Currency.Component" }534 }535 ],536 mockedUserDefaultValues: {},537 expected: [1, 0]538 },539 {540 testDescription: "generic action specified in intent",541 oParsedShellHash: {542 "semanticObject": "Object",543 "action": undefined,544 "params": {545 "currency": ["EUR"]546 }547 },548 aInbounds: [549 {550 semanticObject: "Object",551 action: "actionA",552 signature: { parameters: {553 currency: { required: true, filter: { value: "EUR" } }554 }},555 resolutionResult: { text: "Currency manager", ui5ComponentName: "Currency.ComponentA", url: "/url/to/currency", applicationType: "URL", additionalInformation: "SAPUI5.Component=Currency.Component" }556 },557 {558 semanticObject: "Object",559 action: "actionB",560 signature: { parameters: {561 currency: { required: true, filter: { value: "EUR" } },562 user: { required: false, defaultValue: { value: "TEST" } }563 }},564 resolutionResult: { text: "Currency manager", ui5ComponentName: "Currency.ComponentB", url: "/url/to/currency", applicationType: "URL", additionalInformation: "SAPUI5.Component=Currency.Component" }565 }566 ],567 mockedUserDefaultValues: {},568 expected: [1, 0]569 },570 {571 testDescription: "* specified in intent semantic object",572 oParsedShellHash: {573 "semanticObject": "*", // treated as a literal "*"574 "action": undefined,575 "params": {576 "currency": ["EUR"]577 }578 },579 aInbounds: [580 {581 semanticObject: "*",582 action: "action",583 signature: { parameters: {584 currency: { required: true, filter: { value: "EUR" } }585 }},586 resolutionResult: { text: "Currency manager", ui5ComponentName: "Currency.ComponentA", url: "/url/to/currency", applicationType: "URL", additionalInformation: "SAPUI5.Component=Currency.Component" }587 },588 {589 semanticObject: "Object",590 action: "action",591 signature: { parameters: {592 currency: { required: true, filter: { value: "EUR" } },593 user: { required: false, defaultValue: { value: "TEST" } }594 }},595 resolutionResult: { text: "Currency manager", ui5ComponentName: "Currency.ComponentB", url: "/url/to/currency", applicationType: "URL", additionalInformation: "SAPUI5.Component=Currency.Component" }596 }597 ],598 mockedUserDefaultValues: {},599 expected: [0]600 },601 {602 testDescription: "* specified in intent action",603 oParsedShellHash: {604 "semanticObject": undefined,605 "action": "*",606 "params": {607 "currency": ["EUR"]608 }609 },610 aInbounds: [611 {612 semanticObject: "Object",613 action: "action",614 signature: { parameters: {615 currency: { required: true, filter: { value: "EUR" } }616 }},617 resolutionResult: { text: "Currency manager", ui5ComponentName: "Currency.ComponentA", url: "/url/to/currency", applicationType: "URL", additionalInformation: "SAPUI5.Component=Currency.Component" }618 },619 {620 semanticObject: "Object",621 action: "*",622 signature: { parameters: {623 currency: { required: true, filter: { value: "EUR" } },624 user: { required: false, defaultValue: { value: "TEST" } }625 }},626 resolutionResult: { text: "Currency manager", ui5ComponentName: "Currency.ComponentB", url: "/url/to/currency", applicationType: "URL", additionalInformation: "SAPUI5.Component=Currency.Component" }627 }628 ],629 mockedUserDefaultValues: {},630 expected: [1]631 },632 {633 testDescription: "a filter reference is specified",634 oParsedShellHash: {635 "semanticObject": "Object",636"action": "action",637 "params": {638 "currency": ["EUR"]639 }640 },641 aInbounds: [642 {643 semanticObject: "Object",644action: "action",645 signature: { parameters: {646 currency: { required: true, filter: { format: "reference", value: "UserDefault.currency" } }647 }},648 title: "Currency manager",649 resolutionResult: { text: "Currency manager", ui5ComponentName: "Currency.Component", url: "/url/to/currency", applicationType: "URL", additionalInformation: "SAPUI5.Component=Currency.Component" }650 }651 ],652 mockedUserDefaultValues: { "currency": "EUR" },653 expected: [{654 "genericSO": false,655 "intentParamsPlusAllDefaults": {656 "currency": [ "EUR" ]657 },658 "defaultedParamNames": [],659 "matches": true,660 "parsedIntent": {661 "semanticObject": "Object",662 "action": "action",663 "params": {664 "currency": ["EUR"]665 }666 },667 "matchesVirtualInbound": false,668 "inbound": {669 "title": "Currency manager",670 "action": "action",671 "semanticObject": "Object",672 "signature": {673 "parameters": {674 currency: { required: true, filter: { format: "reference", value: "UserDefault.currency" } }675 }676 },677 "resolutionResult": { text: "Currency manager", ui5ComponentName: "Currency.Component", url: "/url/to/currency", applicationType: "URL", additionalInformation: "SAPUI5.Component=Currency.Component" }678 },679 "resolutionResult": { } // title not propagated in early resolution result680 }]681 },682 {683 testDescription: "user default service provides non-matching parameter",684 oParsedShellHash: {685 "semanticObject": "Object",686"action": "action",687 "params": {688 "currency": ["EUR"]689 }690 },691 aInbounds: [692 {693 semanticObject: "Object",694action: "action",695 signature: { parameters: {696 currency: { required: true, filter: { format: "reference", value: "UserDefault.currency" } }697 }},698 resolutionResult: { text: "Currency manager", ui5ComponentName: "Currency.Component", url: "/url/to/currency", applicationType: "URL", additionalInformation: "SAPUI5.Component=Currency.Component" }699 }700 ],701 mockedUserDefaultValues: { "currency": "GBP" }, // NOTE: GBP does not match filter702 expected: []703 },704 {705 testDescription: "user default service cannot provide a default value for filter reference",706 oParsedShellHash: {707 "semanticObject": "Object",708"action": "action",709 "params": {710 "currency": ["EUR"]711 }712 },713 aInbounds: [714 {715 semanticObject: "Object",716action: "action",717 signature: { parameters: {718 currency: { required: true, filter: { format: "reference", value: "UserDefault.currency" } }719 }},720 resolutionResult: { text: "Currency manager", ui5ComponentName: "Currency.Component", url: "/url/to/currency", applicationType: "URL", additionalInformation: "SAPUI5.Component=Currency.Component" }721 }722 ],723 mockedUserDefaultValues: { "other": "uselessValue" },724 expected: []725 },726 {727 testDescription: "default reference value is provided by UserDefaultParameters service",728 oParsedShellHash: {729 "semanticObject": "Object",730"action": "action",731 "params": {}732 },733 aInbounds: [734 {735 semanticObject: "Object",736action: "action",737 signature: { parameters: {738 currency: { required: false, defaultValue: { format: "reference", value: "UserDefault.currency" } }739 }},740 resolutionResult: { text: "Currency manager", ui5ComponentName: "Currency.Component", url: "/url/to/currency", applicationType: "URL", additionalInformation: "SAPUI5.Component=Currency.Component" }741 }742 ],743 mockedUserDefaultValues: { "currency": "EUR" },744 expected: [{745 "genericSO": false,746 "intentParamsPlusAllDefaults": {747 currency: ["EUR"]748 },749 "defaultedParamNames": ["currency"],750 "matches": true,751 "parsedIntent": {752 "semanticObject": "Object",753"action": "action",754 "params": {}755 },756 "matchesVirtualInbound": false,757 "resolutionResult": { }, // no title propagated yet in Early resolution result758 "inbound": {759 "action": "action",760 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },761 "semanticObject": "Object",762 "signature": {763 "parameters": {764 "currency": { required: false, defaultValue: { format: "reference", value: "UserDefault.currency" } }765 }766 }767 }768 }]769 },770 {771 testDescription: "unknown default reference",772 oParsedShellHash: {773 "semanticObject": "Object",774"action": "action",775 "params": {} // note, no parameter given776 },777 aInbounds: [778 {779 semanticObject: "Object",780action: "action",781 signature: { parameters: {782 currency: { required: false, defaultValue: { format: "reference", value: "UserDefault.currency" } }783 }},784 resolutionResult: { text: "Currency manager", ui5ComponentName: "Currency.Component", url: "/url/to/currency", applicationType: "URL", additionalInformation: "SAPUI5.Component=Currency.Component" }785 }786 ],787 mockedUserDefaultValues: { /* no known values */ },788 expected: [{789 "genericSO": false,790 "intentParamsPlusAllDefaults": {}, // no default parameter791 "matches": true,792 "matchesVirtualInbound": false,793 "defaultedParamNames": [],794 "resolutionResult": {}, // no title propagated yet in Early resolution result795 "parsedIntent": {796 "semanticObject": "Object",797"action": "action",798 "params": {}799 },800 "inbound": {801 "action": "action",802 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },803 "semanticObject": "Object",804 "signature": {805 "parameters": {806 "currency": { required: false, defaultValue: { format: "reference", value: "UserDefault.currency" } }807 }808 }809 }810 }]811 },812 {813 testDescription: "a default reference and a filter reference are known",814 oParsedShellHash: {815 "semanticObject": "Currency",816"action": "app",817 "params": {}818 },819 aInbounds: [820 {821 semanticObject: "*",822action: "app",823 signature: { parameters: {824 mode: {825 required: false,826 defaultValue: { format: "reference", value: "UserDefault.mode" },827 filter: { format: "reference", value: "UserDefault.currencyAppMode" }828 }829 }},830 resolutionResult: {831 text: "Currency manager",832 ui5ComponentName: "Currency.Component",833 url: "/url/to/currency",834 applicationType: "URL",835 additionalInformation: "SAPUI5.Component=Currency.Component"836 }837 },838 {839 semanticObject: "*",840action: "app",841 signature: { parameters: {842 mode: {843 required: false,844 defaultValue: { format: "reference", value: "UserDefault.mode" },845 filter: { format: "reference", value: "UserDefault.carsAppMode" }846 }847 }},848 resolutionResult: {849 text: "Cars manager",850 ui5ComponentName: "Cars.Component",851 url: "/url/to/cars",852 applicationType: "URL",853 additionalInformation: "SAPUI5.Component=Cars.Component"854 }855 }856 ],857 mockedUserDefaultValues: {858 "mode": "desktop", // user specific preference859 "currencyAppMode": "desktop",860 "carsAppMode": "mobile"861 },862 expected: [{863 "genericSO": true,864 "intentParamsPlusAllDefaults": {865 "mode": ["desktop"]866 },867 "defaultedParamNames": ["mode"],868 "matches": true,869 "matchesVirtualInbound": false,870 "resolutionResult": { },871 "parsedIntent": {872 "semanticObject": "Currency",873"action": "app",874 "params": {}875 },876 "inbound": {877 "action": "app",878 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },879 "semanticObject": "*",880 "signature": {881 "parameters": {882 "mode": {883 "required": false,884 "defaultValue": { format: "reference", value: "UserDefault.mode" },885 "filter": { format: "reference", value: "UserDefault.currencyAppMode" }886 }887 }888 }889 }890 }]891 },892 {893 testDescription: "sap-ushell-defaultedParameterNames is specified",894 oParsedShellHash: {895 "semanticObject": "Currency",896"action": "app",897 "params": {898 "sap-ushell-defaultedParameterNames": ["will", "be", "ignored"]899 }900 },901 aInbounds: [902 {903 semanticObject: "Currency",904action: "app",905 signature: {906 parameters: {},907 additionalParameters: "allowed"908 },909 resolutionResult: {910 text: "Currency manager",911 ui5ComponentName: "Currency.Component",912 url: "/url/to/currency",913 applicationType: "URL",914 additionalInformation: "SAPUI5.Component=Currency.Component"915 }916 }917 ],918 mockedUserDefaultValues: {},919 expected: [{920 "defaultedParamNames": [], // NOTE: no sap- param!921 "genericSO": false,922 "intentParamsPlusAllDefaults": {},923 "matches": true,924 "matchesVirtualInbound": false,925 "resolutionResult": { },926 "parsedIntent": {927 "action": "app",928 "params": {929 "sap-ushell-defaultedParameterNames": [ "will", "be", "ignored" ]930 },931 "semanticObject": "Currency"932 },933 "inbound": {934 "action": "app",935 "resolutionResult": {936 "additionalInformation": "SAPUI5.Component=Currency.Component",937 "applicationType": "URL",938 "text": "Currency manager",939 "ui5ComponentName": "Currency.Component",940 "url": "/url/to/currency"941 },942 "semanticObject": "Currency",943 "signature": {944 "additionalParameters": "allowed",945 "parameters": {}946 }947 }948 }]949 },950 {951 testDescription: "one inbound default parameter is in the intent",952 oParsedShellHash: {953 "semanticObject": "Currency",954"action": "app",955 "params": {956 "intentParam1": ["ipv1"],957 "overlappingParam3": ["ipv2"]958 }959 },960 aInbounds: [961 {962 semanticObject: "Currency",963action: "app",964 signature: {965 parameters: {966 "defaultParam1": { required: false, defaultValue: { value: "dv1" } },967 "defaultParam2": { required: false, defaultValue: { value: "dv2" } },968 "overlappingParam3": { required: false, defaultValue: { value: "dv3" } }969 },970 additionalParameters: "allowed"971 },972 resolutionResult: {973 text: "Currency manager",974 ui5ComponentName: "Currency.Component",975 url: "/url/to/currency",976 applicationType: "URL",977 additionalInformation: "SAPUI5.Component=Currency.Component"978 }979 }980 ],981 mockedUserDefaultValues: {},982 expected: [{983 "defaultedParamNames": [984 "defaultParam1",985 "defaultParam2"986 ],987 "genericSO": false,988 "intentParamsPlusAllDefaults": {989 "defaultParam1": [990 "dv1"991 ],992 "defaultParam2": [993 "dv2"994 ],995 "intentParam1": [996 "ipv1"997 ],998 "overlappingParam3": [999 "ipv2"1000 ]1001 },1002 "matches": true,1003 "matchesVirtualInbound": false,1004 "resolutionResult": { },1005 "parsedIntent": {1006 "action": "app",1007 "params": {1008 "intentParam1": [1009 "ipv1"1010 ],1011 "overlappingParam3": [1012 "ipv2"1013 ]1014 },1015 "semanticObject": "Currency"1016 },1017 "inbound": {1018 "action": "app",1019 "resolutionResult": {1020 "additionalInformation": "SAPUI5.Component=Currency.Component",1021 "applicationType": "URL",1022 "text": "Currency manager",1023 "ui5ComponentName": "Currency.Component",1024 "url": "/url/to/currency"1025 },1026 "semanticObject": "Currency",1027 "signature": {1028 "additionalParameters": "allowed",1029 "parameters": {1030 "defaultParam1": { required: false, defaultValue: { value: "dv1" } },1031 "defaultParam2": { required: false, defaultValue: { value: "dv2" } },1032 "overlappingParam3": { required: false, defaultValue: { value: "dv3" } }1033 }1034 }1035 }1036 }]1037 },1038 {1039 /*1040 * Inbounds with more defaulted parameters are a better fit1041 * if nothing required had matched.1042 */1043 testDescription: "intent matches no filters and multiple inbounds with same SO-action are defined",1044 oParsedShellHash: {1045 "semanticObject": "Object",1046 "action": "action",1047 "params": {1048 "additionalParameter": "hello"1049 }1050 },1051 aInbounds: [1052 { // #0 : this should not match because of the filter on company code1053 semanticObject: "Object",1054action: "action",1055 signature: {1056 additionalParameters: "allowed",1057 parameters: {1058 CompanyCode: {1059 required: true,1060 filter: {1061 format: "plain",1062 value: "1000"1063 }1064 },1065 "sap-app-id": {1066 required: false,1067 defaultValue: {1068 format: "plain",1069 value: "COMPANY1000"1070 }1071 }1072 }1073 },1074 resolutionResult: { } // doesn't really matter1075 },1076 { // Priority: x MTCH=000 MREQ=000 NFIL=000 NDEF=001 POT=001 RFRE=9991077 semanticObject: "Object",1078action: "action",1079 signature: {1080 additionalParameters: "allowed",1081 parameters: {1082 default1: {1083 required: false,1084 defaultValue: { format: "plain", value: "1000" }1085 }1086 }1087 },1088 resolutionResult: { }1089 },1090 { // Priority: x MTCH=000 MREQ=000 NFIL=000 NDEF=002 POT=001 RFRE=9991091 semanticObject: "Object",1092action: "action",1093 signature: {1094 additionalParameters: "allowed",1095 parameters: {1096 default1: {1097 required: false,1098 defaultValue: { format: "plain", value: "1000" }1099 },1100 default2: { // extra default parameter -> more complex1101 required: false,1102 defaultValue: { format: "plain", value: "1000" }1103 }1104 }1105 },1106 resolutionResult: { }1107 },1108 { // Priority: x MTCH=000 MREQ=000 NFIL=000 NDEF=000 POT=001 RFRE=9991109 semanticObject: "Object",1110action: "action",1111 signature: {1112 additionalParameters: "allowed",1113 parameters: { }1114 }, // no signature parameters -> simple.1115 resolutionResult: { }1116 }1117 ],1118 mockedUserDefaultValues: {},1119 expected: [2, 1, 3]1120 },1121 {1122 /*1123 * Test matching with sap-priority1124 */1125 testDescription: "intent matches no filters and multiple inbounds with same SO-action are defined and sap-priority",1126 oParsedShellHash: {1127 "semanticObject": "Object",1128 "action": "action",1129 "params": {1130 "additionalParameter": "hello"1131 }1132 },1133 aInbounds: [1134 { // #0 : this should not match because of the filter on company code1135 semanticObject: "Object",1136action: "action",1137 signature: {1138 additionalParameters: "allowed",1139 parameters: {1140 CompanyCode: {1141 required: true,1142 filter: {1143 format: "plain",1144 value: "1000"1145 }1146 },1147 "sap-app-id": {1148 required: false,1149 defaultValue: {1150 format: "plain",1151 value: "COMPANY1000"1152 }1153 }1154 }1155 },1156 resolutionResult: { } // doesn't really matter1157 },1158 { // #1 : this matches and comes before negative inbounds with negative sap-priority1159 semanticObject: "Object",1160action: "action",1161 signature: {1162 additionalParameters: "allowed",1163 parameters: {1164 default1: {1165 required: false,1166 defaultValue: { format: "plain", value: "1000" }1167 }1168 }1169 },1170 resolutionResult: { }1171 },1172 { // #2 : this matches and should come last, but sap-priority is specified so it comes first1173 semanticObject: "Object",1174action: "action",1175 signature: {1176 additionalParameters: "allowed",1177 parameters: {1178 default1: {1179 required: false,1180 defaultValue: { format: "plain", value: "1000" }1181 },1182 "sap-priority": {1183 defaultValue: { format: "plain", value: "50" }1184 },1185 default2: { // extra default parameter -> more complex1186 required: false,1187 defaultValue: { format: "plain", value: "1000" }1188 }1189 }1190 },1191 resolutionResult: { }1192 },1193 { // #3 : this comes last because of negative sap priority1194 semanticObject: "Object",1195action: "action",1196 signature: {1197 additionalParameters: "allowed",1198 parameters: {1199 "sap-priority": {1200 defaultValue: { format: "plain", value: "-50" }1201 }1202 }1203 }, // no signature parameters -> simple.1204 resolutionResult: { }1205 }1206 ],1207 mockedUserDefaultValues: {},1208 expected: [1209 2, // sap-priority: 501210 1, // no sap priority1211 3 // sap-priority: -501212 ]1213 },1214 {1215 /*1216 * Here we test that the most detailed inbound that suits1217 * the filter is chosen among less detailed/complex ones. In this1218 * case the "sap-app-id" contributes to the complexity of the1219 * inbound which is then prioritized.1220 */1221 testDescription: "intent matches a filter and multiple inbounds with same SO-action are defined",1222 oParsedShellHash: {1223 "semanticObject": "Object",1224 "action": "action",1225 "params": {1226 "CompanyCode": ["1000"]1227 }1228 },1229 aInbounds: [1230 { // #01231 semanticObject: "Object",1232action: "action",1233 signature: {1234 parameters: {1235 CompanyCode: {1236 required: true,1237 filter: {1238 format: "plain",1239 value: "1000" // Company code matches this filter1240 }1241 },1242 "sap-app-id": { // higher complexity, inbound will be prioritized1243 required: false,1244 defaultValue: {1245 format: "plain",1246 value: "COMPANY1000"1247 }1248 }1249 }1250 },1251 resolutionResult: { } // doesn't really matter1252 },1253 { // #11254 semanticObject: "Object",1255action: "action",1256 signature: {1257 parameters: {1258 CompanyCode: {1259 required: true,1260 filter: {1261 format: "plain",1262 value: "1000" // Company code matches this filter, but this inbound is less complex to be prioritized1263 }1264 }1265 }1266 },1267 resolutionResult: { } // doesn't really matter1268 },1269 { // #21270 semanticObject: "Object",1271action: "action",1272 signature: {1273 parameters: {1274 CompanyCode: {1275 required: true,1276 filter: {1277 format: "plain",1278 value: "2000"1279 }1280 },1281 "sap-app-id": {1282 required: false,1283 defaultValue: {1284 format: "plain",1285 value: "COMPANY2000"1286 }1287 }1288 }1289 },1290 resolutionResult: { } // doesn't really matter1291 }1292 ],1293 mockedUserDefaultValues: {},1294 expected: [0, 1]1295 },1296 {1297 testDescription: "required parameter in inbounds without value or defaultValue",1298 oParsedShellHash: {1299 "semanticObject": "Object",1300"action": "action",1301 "params": {1302 "currency": ["EUR"]1303 }1304 },1305 aInbounds: [1306 {1307 semanticObject: "Object",1308action: "action",1309 signature: { parameters: {1310 currency: { required: true }1311 }},1312 resolutionResult: { text: "Currency manager"1313 // ui5ComponentName: "Currency.Component",1314 // url: "/url/to/currency",1315 // applicationType: "URL",1316 // additionalInformation: "SAPUI5.Component=Currency.Component"1317 }1318 }1319 ],1320 mockedUserDefaultValues: {},1321 expected: [0]1322 },1323 {1324 testDescription: "no additional parameters are allowed and inbound signatures indicates non-required parameter",1325 oParsedShellHash: {1326 "semanticObject": "Object",1327"action": "action",1328 "params": {} // no parameter specified1329 },1330 aInbounds: [1331 {1332 semanticObject: "Object",1333action: "action",1334 signature: {1335 parameters: {1336 flag: {} // short notation for required: false1337 },1338 additionalParameters: "notallowed"1339 },1340 resolutionResult: {1341 text: "Currency manager",1342 ui5ComponentName: "Currency.Component",1343 url: "/url/to/currency",1344 applicationType: "URL",1345 additionalInformation: "SAPUI5.Component=Currency.Component"1346 }1347 }1348 ],1349 mockedUserDefaultValues: {},1350 expected: [{1351 "defaultedParamNames": [],1352 "genericSO": false,1353 "intentParamsPlusAllDefaults": {},1354 "matches": true,1355 "matchesVirtualInbound": false,1356 "resolutionResult": { },1357 "parsedIntent": {1358 "action": "action",1359 "params": {},1360 "semanticObject": "Object"1361 },1362 "inbound": {1363 "action": "action",1364 "resolutionResult": {1365 "additionalInformation": "SAPUI5.Component=Currency.Component",1366 "applicationType": "URL",1367 "text": "Currency manager",1368 "ui5ComponentName": "Currency.Component",1369 "url": "/url/to/currency"1370 },1371 "semanticObject": "Object",1372 "signature": {1373 "additionalParameters": "notallowed",1374 "parameters": {1375 "flag": {}1376 }1377 }1378 }1379 }]1380 },1381 {1382 testDescription: " defaulted parameters are mapped to same target A->ANew & B renameTo ANew, both defaulted",1383 oParsedShellHash: {1384 "semanticObject": "Object",1385"action": "action",1386 "params": { }1387 },1388 aInbounds: [1389 {1390 semanticObject: "Object",1391action: "action",1392 signature: {1393 parameters: {1394 "A": { "renameTo": "ANew", "defaultValue": { "value": "ADefaulted" } },1395 "B": { "renameTo": "ANew", "defaultValue": { "value": "BDefaulted" }1396 }1397 },1398 additionalParameters: "allowed"1399 },1400 resolutionResult: {1401 text: "Currency manager",1402 ui5ComponentName: "Currency.Component",1403 url: "/url/to/currency",1404 applicationType: "URL",1405 additionalInformation: "SAPUI5.Component=Currency.Component"1406 }1407 }1408 ],1409 mockedUserDefaultValues: {},1410 expected: [{1411 "defaultedParamNames": [ "A", "B" ],1412 "genericSO": false,1413 "intentParamsPlusAllDefaults": {1414 "A": [1415 "ADefaulted"1416 ],1417 "B": [1418 "BDefaulted"1419 ]1420 },1421 "matches": true,1422 "matchesVirtualInbound": false,1423 "resolutionResult": { },1424 "parsedIntent": {1425 "action": "action",1426 "params": {},1427 "semanticObject": "Object"1428 },1429 "inbound": {1430 "action": "action",1431 "resolutionResult": {1432 "additionalInformation": "SAPUI5.Component=Currency.Component",1433 "applicationType": "URL",1434 "text": "Currency manager",1435 "ui5ComponentName": "Currency.Component",1436 "url": "/url/to/currency"1437 },1438 "semanticObject": "Object",1439 "signature": {1440 parameters: {1441 "A": { "renameTo": "ANew", "defaultValue": { "value": "ADefaulted" } },1442 "B": { "renameTo": "ANew", "defaultValue": { "value": "BDefaulted" }1443 }1444 },1445 additionalParameters: "allowed"1446 }1447 }1448 }]1449 },1450 {1451 testDescription: " defaulted parameters are mapped to same target A->ANew & B renameTo ANew, B defaulted, A supplied",1452 oParsedShellHash: {1453 "semanticObject": "Object",1454"action": "action",1455 "params": { "A": [ "Avalue"] }1456 },1457 aInbounds: [1458 {1459 semanticObject: "Object",1460action: "action",1461 signature: {1462 parameters: {1463 "A": { "renameTo": "ANew"},1464 "B": { "renameTo": "ANew",1465 "defaultValue": { "value": "BDefaulted" }1466 }1467 },1468 additionalParameters: "allowed"1469 },1470 resolutionResult: {1471 text: "Currency manager",1472 ui5ComponentName: "Currency.Component",1473 url: "/url/to/currency",1474 applicationType: "URL",1475 additionalInformation: "SAPUI5.Component=Currency.Component"1476 }1477 }1478 ],1479 mockedUserDefaultValues: {},1480 expected: [{1481 "defaultedParamNames": [],1482 "genericSO": false,1483 "intentParamsPlusAllDefaults": {1484 "A": [1485 "Avalue"1486 ]1487 // B Not present!1488 },1489 "matches": true,1490 "matchesVirtualInbound": false,1491 "resolutionResult": { },1492 "parsedIntent": {1493 "action": "action",1494 "params": {1495 "A": [1496 "Avalue"1497 ]1498 },1499 "semanticObject": "Object"1500 },1501 "inbound": {1502 "action": "action",1503 "resolutionResult": {1504 "additionalInformation": "SAPUI5.Component=Currency.Component",1505 "applicationType": "URL",1506 "text": "Currency manager",1507 "ui5ComponentName": "Currency.Component",1508 "url": "/url/to/currency"1509 },1510 "semanticObject": "Object",1511 "signature": {1512 parameters: {1513 "A": { "renameTo": "ANew"},1514 "B": { "renameTo": "ANew",1515 "defaultValue": { "value": "BDefaulted" }1516 }1517 },1518 additionalParameters: "allowed"1519 }1520 }1521 }]1522 },1523 {1524 testDescription: "matching tile inbound + bExcludeTileInbounds=false parameter is given",1525 oParsedShellHash: { "semanticObject": "Action", "action": "toNewsTile", "params": {} },1526 bExcludeTileInbounds: false,1527 aInbounds: [1528 { // a tile inbound1529 "semanticObject": "Action",1530 "action": "toNewsTile",1531 "title": "News",1532 "resolutionResult": { },1533 "deviceTypes": { "desktop": true, "tablet": true, "phone": true },1534 "signature": {1535 "parameters": {},1536 "additionalParameters": "allowed"1537 },1538 "tileResolutionResult": {1539 "isCustomTile": true // filters out the inbound1540 // ... plus irrelevant data for this test...1541 }1542 }1543 ],1544 mockedUserDefaultValues: {},1545 expected: [1546 { // the same tile inbound1547 "parsedIntent": {1548 "action": "toNewsTile",1549 "params": {},1550 "semanticObject": "Action"1551 },1552 "inbound": {1553 "semanticObject": "Action",1554 "action": "toNewsTile",1555 "title": "News",1556 "resolutionResult": { },1557 "deviceTypes": { "desktop": true, "tablet": true, "phone": true },1558 "signature": {1559 "parameters": {},1560 "additionalParameters": "allowed"1561 },1562 "tileResolutionResult": {1563 "isCustomTile": true // filters out the inbound1564 }1565 },1566 "resolutionResult": {},1567 "defaultedParamNames": [],1568 "genericSO": false,1569 "intentParamsPlusAllDefaults": {},1570 "matches": true,1571 "matchesVirtualInbound": false1572 }1573 ]1574 },1575 {1576 testDescription: "matching tile inbound + bExcludeTileInbounds=true parameter is given",1577 oParsedShellHash: { "semanticObject": "Action", "action": "toNewsTile", "params": {} },1578 bExcludeTileInbounds: true,1579 aInbounds: [1580 { // a tile inbound1581 "semanticObject": "Action",1582 "action": "toNewsTile",1583 "title": "News",1584 "resolutionResult": { },1585 "deviceTypes": { "desktop": true, "tablet": true, "phone": true },1586 "signature": {1587 "parameters": {},1588 "additionalParameters": "allowed"1589 },1590 "tileResolutionResult": {1591 "isCustomTile": true // filters out the inbound1592 // ... plus irrelevant data for this test...1593 }1594 }1595 ],1596 mockedUserDefaultValues: {},1597 expected: []1598 }1599 ].forEach(function (oFixture) {1600 asyncTest("_getMatchingInbounds: works as expected when " + oFixture.testDescription, function () {1601 var oSrvc = createService(),1602 fnRealGetService = sap.ushell.Container.getService;1603 // Mock User Defaults service1604 sinon.stub(sap.ushell.Container, "getService", function (sServiceName) {1605 if (sServiceName === "UserDefaultParameters") {1606 return { // a fake UserDefaultParameters service1607 getValue: function (sValueName) {1608 return new jQuery.Deferred().resolve({1609 value: oFixture.mockedUserDefaultValues[sValueName]1610 }).promise();1611 }1612 };1613 }1614 // else1615 return fnRealGetService(sServiceName);1616 });1617 var oIndex = oInboundIndex.createIndex(oFixture.aInbounds);1618 oSrvc._getMatchingInbounds(oFixture.oParsedShellHash, oIndex, { bExcludeTileInbounds: oFixture.bExcludeTileInbounds })1619 .done(function (aMatchingResults) {1620 ok(true, "promise was resolved");1621 if (!jQuery.isEmptyObject(oFixture.mockedUserDefaultValues)) {1622 ok(sap.ushell.Container.getService.calledWith("UserDefaultParameters"), "the UserDefaultParameters service was invoked");1623 }1624 /*1625 * This test allows to compare inbounds by ids if1626 * integers are specified in the expectation.1627 */1628 if (oFixture.expected.every(function (vArrayItem) {1629 return typeof vArrayItem === "number";1630 })) {1631 // compare only inbound results1632 var aExpectedInbounds = oFixture.expected.map(function (iResultNumber) {1633 return oFixture.aInbounds[iResultNumber];1634 }),1635 aGotInbounds = aMatchingResults.map(function (oMatchResult) {1636 return oMatchResult.inbound;1637 });1638 deepEqual(aGotInbounds, aExpectedInbounds, "match results reference expected inbounds");1639 } else {1640 // compare full result but ignore property originalInbound1641 deepEqual(removeCountsAndSortString(aMatchingResults),1642 oFixture.expected, "got expected matching results");1643 }1644 })1645 .fail(function () {1646 ok(false, "promise was resolved");1647 })1648 .always(function () {1649 start();1650 });1651 });1652 });1653 [1654 {1655 testDescription: "one inbound matches",1656 oIntent: mkInt("#Action-toappnavsample"),1657 aFakeInbounds: [1658 oTestHelper.createInbound("#Action-toappnavsample")1659 ],1660 expectedLogHeader: [1661 /\[REPORT #1\] Matching Intent 'Action-toappnavsample' to inbounds/,1662 /form factor: <any>/1663 ],1664 expectedLogBody: [1665 /#Action-toappnavsample{<no params><\?>}/,1666 /No need to resolve references/,1667 /rematch was skipped/,1668 /Nothing to sort/1669 ]1670 },1671 {1672 testDescription: "no inbounds match",1673 oIntent: mkInt("#Action-toappnavsample"),1674 aFakeInbounds: [1675 // nothing1676 ],1677 expectedLogHeader: [1678 /\[REPORT #1\] Matching Intent 'Action-toappnavsample' to inbounds/,1679 /form factor: <any>/1680 ],1681 expectedLogBody: [1682 /No inbound was matched/,1683 /No need to resolve references/,1684 /rematch was skipped/,1685 /Nothing to sort/1686 ]1687 },1688 {1689 testDescription: "two inbounds with the same name match",1690 oIntent: mkInt("#Action-toappnavsample"),1691 aFakeInbounds: [1692 oTestHelper.createInbound("#Action-toappnavsample{[default1:[value1]]}"),1693 oTestHelper.createInbound("#Action-toappnavsample{[default2:[value2]]}")1694 ],1695 expectedLogHeader: [1696 /\[REPORT #1\] Matching Intent 'Action-toappnavsample' to inbounds/,1697 /form factor: <any>/1698 ],1699 expectedLogBody: [1700 /#Action-toappnavsample{\[default1:\[value1\]\]<o>}\n/,1701 /#Action-toappnavsample{\[default2:\[value2\]\]<o>}\n/,1702 /No need to resolve references/,1703 /rematch was skipped \(no references to resolve\)/,1704 /Sorted inbounds as follows:/,1705 /#Action-toappnavsample{\[default1:\[value1\]\]<o>}.*\n.*#Action-toappnavsample{\[default2:\[value2\]\]<o>}/1706 ]1707 },1708 {1709 testDescription: "inbounds with sap priority are reported",1710 oIntent: mkInt("#Action-toappnavsample"),1711 aFakeInbounds: [1712 oTestHelper.createInbound("#Action-toappnavsample{[default1:[value1]],[sap-priority:[5]]}"),1713 oTestHelper.createInbound("#Action-toappnavsample{[default2:[value2]],[sap-priority:[10]]}")1714 ],1715 expectedLogHeader: [1716 /\[REPORT #1\] Matching Intent 'Action-toappnavsample' to inbounds/,1717 /form factor: <any>/1718 ],1719 expectedLogBody: [1720 /Sorted inbounds as follows:/,1721 /\* 1 \* sap-priority: '10'([\s\S])+\* 1 \* sap-priority: '5'/1722 ]1723 },1724 {1725 testDescription: "an inbound with references is resolved",1726 oIntent: mkInt("#Action-toappnavsample"),1727 aFakeInbounds: [1728 oTestHelper.createInbound("#Action-toappnavsample{[p1:[@paramName@]]}")1729 ],1730 expectedLogHeader: [1731 /\[REPORT #1\] Matching Intent 'Action-toappnavsample' to inbounds/,1732 /form factor: <any>/1733 ],1734 expectedLogBody: [1735 /#Action-toappnavsample{\[p1:\[@paramName@\]\]<o>}\n/,1736 /Must resolve the following references:[\s\S]*paramName/,1737 /resolved references with the following values:[\s\S]*paramName: 'paramNameValue'/1738 ]1739 },1740 {1741 testDescription: "two inbounds with references are matched, but only one is rematched",1742 oIntent: mkInt("#Action-toappnavsample?id=aValue"),1743 aFakeInbounds: [1744 oTestHelper.createInbound("#Action-toappnavsample{id:@a@}"), // id resolves to aValue (see test)1745 oTestHelper.createInbound("#Action-toappnavsample{id:@b@}") // id resolves to bValue (see test)1746 ],1747 expectedLogHeader: [1748 /\[REPORT #1\] Matching Intent 'Action-toappnavsample[?]id=aValue' to inbounds/,1749 /form factor: <any>/1750 ],1751 expectedLogBody: [1752 new RegExp([1753 "STAGE2: Resolve references",1754 "--------------------------",1755 "@ Must resolve the following references:",1756 " . a",1757 " . b",1758 ". resolved references with the following values:",1759 " . a: 'aValue'",1760 " . b: 'bValue'"1761 ].join("\n")),1762 new RegExp([1763 "STAGE3: Rematch with references",1764 "-------------------------------",1765 "The following inbounds re-matched:",1766 " . #Action-toappnavsample{id:@a@<o>}"1767 ].join("\n")),1768 new RegExp([1769 "STAGE4: Sort matched targets",1770 "----------------------------",1771 "Nothing to sort"1772 ].join("\n"))1773 ]1774 },1775 {1776 testDescription: "an inbound with reference is matched, but no inbounds are rematched",1777 oIntent: mkInt("#Action-toappnavsample?id=aValue"),1778 aFakeInbounds: [1779 oTestHelper.createInbound("#Action-toappnavsample{id:@b@}") // id resolves to bValue (see test)1780 ],1781 expectedLogHeader: [1782 /\[REPORT #1\] Matching Intent 'Action-toappnavsample[?]id=aValue' to inbounds/,1783 /form factor: <any>/1784 ],1785 expectedLogBody: [1786 new RegExp([1787 "STAGE2: Resolve references",1788 "--------------------------",1789 "@ Must resolve the following references:",1790 " . b",1791 ". resolved references with the following values:",1792 " . b: 'bValue'"1793 ].join("\n")),1794 new RegExp([1795 "STAGE3: Rematch with references",1796 "-------------------------------",1797 "- No inbounds re-matched"1798 ].join("\n")),1799 new RegExp([1800 "STAGE4: Sort matched targets",1801 "----------------------------",1802 "Nothing to sort"1803 ].join("\n"))1804 ]1805 }1806 ].forEach(function (oFixture) {1807 asyncTest("_getMatchingInbounds: reports inbound search correctly when " + oFixture.testDescription, function () {1808 var oSrvc = createService();1809 // Stub ReferenceResolver1810 var fnGetServiceOrig = sap.ushell.Container.getService;1811 sap.ushell.Container.getService = function (sServiceName) {1812 if (sServiceName === "ReferenceResolver") {1813 return {1814 resolveReferences: function (aRefs) {1815 return new jQuery.Deferred().resolve(aRefs.reduce(function (oResolvedRefs, sNextRef) {1816 oResolvedRefs[sNextRef] = sNextRef + "Value";1817 return oResolvedRefs;1818 }, {})).promise();1819 }1820 };1821 }1822 return fnGetServiceOrig.call(sap.ushell.Container, sServiceName);1823 };1824 // Check logging expectations via LogMock1825 sinon.stub(jQuery.sap.log, "debug");1826 sinon.stub(jQuery.sap.log, "error");1827 sinon.stub(jQuery.sap.log, "warning");1828 // getLevel called by CSTR/Logger to determine logging is enabled1829 var oIndex = oInboundIndex.createIndex(oFixture.aFakeInbounds);1830 sinon.stub(oCSTRUtils, "isDebugEnabled").returns(true);1831 oSrvc._getMatchingInbounds(oFixture.oIntent, oIndex, oFixture.oConstraints)1832 .done(function (aMatchingResults) {1833 ok(true, "_getMatchingInbounds promise was resolved");1834 strictEqual(jQuery.sap.log.error.callCount, 0, "jQuery.sap.log.error was called 0 times");1835 strictEqual(jQuery.sap.log.warning.callCount, 0, "jQuery.sap.log.warning was called 0 times");1836 strictEqual(jQuery.sap.log.debug.callCount, 1, "jQuery.sap.log.debug was called 1 time");1837 // check that each regexp matches the call argument of debug1838 oFixture.expectedLogHeader.forEach(function (rLog) {1839 var sLogHeader = jQuery.sap.log.debug.getCall(0).args[0];1840 var bMatches = !!sLogHeader.match(rLog);1841 ok(bMatches, rLog.toString() + " was found in the log call." + (1842 bMatches ? "" : "Log header was: " + sLogHeader.replace(/\n/g, "\u21a9") // 21a9 enter key symbol1843 ));1844 });1845 oFixture.expectedLogBody.forEach(function (rLog) {1846 var sLogBody = jQuery.sap.log.debug.getCall(0).args[1];1847 var bMatches = !!sLogBody.match(rLog);1848 ok(bMatches, rLog.toString() + " was found in the log call." + (1849 bMatches ? "" : "Log body was: " + sLogBody.replace(/\n/g, "\u21a9") // 21a9 enter key symbol1850 ));1851 });1852 })1853 .fail(function () {1854 ok(false, "_getMatchingInbounds promise was resolved");1855 })1856 .always(function () {1857 start();1858 });1859 });1860 });1861 asyncTest("_resolveHashFragment: promise is rejected when navigation target cannot be resolved client side", function () {1862 sinon.stub(jQuery.sap.log, "error");1863 sinon.stub(jQuery.sap.log, "warning");1864 var oSrvc = createService();1865 // return empty -> cannot resolve matching targets1866 sinon.stub(oSrvc, "_getMatchingInbounds").returns(new jQuery.Deferred().resolve([]).promise());1867 oSrvc._resolveHashFragment("#hash-fragment", function () {} /*fallback*/)1868 .done(function () {1869 ok(false, "Promise was rejected");1870 })1871 .fail(function (sErrorMsg) {1872 ok(true, "Promise was rejected");1873 strictEqual(jQuery.sap.log.warning.getCalls().length, 1, "jQuery.sap.log.warning was called once");1874 strictEqual(jQuery.sap.log.error.getCalls().length, 0, "jQuery.sap.log.error was not called");1875 strictEqual(sErrorMsg, "Could not resolve navigation target", "Rejected with expected message");1876 })1877 .always(function () {1878 start();1879 });1880 });1881 asyncTest("_resolveHashFragment: promise is rejected when _getMatchingInbounds rejects", function () {1882 sinon.stub(jQuery.sap.log, "error");1883 sinon.stub(jQuery.sap.log, "warning");1884 var oSrvc = createService();1885 // rejects1886 sinon.stub(oSrvc, "_getMatchingInbounds").returns(new jQuery.Deferred().reject("Deliberate failure"));1887 oSrvc._resolveHashFragment("#hash-fragment", function () {} /*fallback*/)1888 .done(function () {1889 ok(false, "Promise was rejected");1890 })1891 .fail(function (sErrorMsg) {1892 ok(true, "Promise was rejected");1893 strictEqual(jQuery.sap.log.warning.getCalls().length, 0, "jQuery.sap.log.warning was not called");1894 strictEqual(jQuery.sap.log.error.getCalls().length, 1, "jQuery.sap.log.error was called once");1895 strictEqual(sErrorMsg, "Deliberate failure", "Rejected with expected message");1896 })1897 .always(function () {1898 start();1899 });1900 });1901 [1902 {1903 testDescription: "generic semantic object is passed",1904 sIntent: "#*-action"1905 },1906 {1907 testDescription: "empty semantic object is passed",1908 sIntent: "#-action"1909 },1910 {1911 testDescription: "* is passed in action",1912 sIntent: "#Object-*"1913 },1914 {1915 testDescription: "blank is passed in semantic object",1916 sCurrentFormFactor: "mobile",1917 sIntent: "# -*"1918 },1919 {1920 testDescription: "many blanks are passed in semantic object",1921 sCurrentFormFactor: "mobile",1922 sIntent: "# -*"1923 }1924 ].forEach(function (oFixture) {1925 asyncTest("_resolveHashFragment: rejects promise when " + oFixture.testDescription, function () {1926 var oSrvc = createService();1927 sinon.stub(jQuery.sap.log, "error");1928 // returns the default parameter names after resolution1929 sinon.stub(oSrvc, "_getMatchingInbounds").returns(1930 new jQuery.Deferred().resolve({1931 resolutionResult: {} // causes _resolveHashFragment promise to be resolved (in case test fails)1932 }).promise()1933 );1934 sinon.stub(utils, "getFormFactor").returns("desktop");1935 oSrvc._resolveHashFragment(oFixture.sIntent)1936 .done(function (oResolutionResult) {1937 ok(false, "promise was rejected");1938 })1939 .fail(function () {1940 ok(true, "promise was rejected");1941 strictEqual(jQuery.sap.log.error.getCalls().length, 1, "jQuery.sap.log.error was called once");1942 ok(jQuery.sap.log.error.getCall(0).args[0].indexOf("Could not parse shell hash") === 0,1943 "logged 'Could not parse shell hash ...'");1944 })1945 .always(function () {1946 start();1947 });1948 });1949 });1950 [1951 {1952 testName: "no inbounds are defined",1953 inbounds: [],1954 expectedParameters: { simple: {}, extended: {}}1955 },1956 {1957 testName: "inbounds contain non-overlapping user default placeholders",1958 inbounds: [1959 { semanticObject: "SomeObject",1960action: "action1",1961 signature: {1962 additionalParameters: "allowed",1963 parameters: {1964 "noUserDefault1": { filter: { value: "Some Value1" }, required: false },1965 "withUserDefault1": { filter: { value: "UserDefault.value1", format: "reference" }, required: true },1966 "withUserDefault2": { filter: { value: "UserDefault.value2", format: "reference" }, required: false },1967 "noUserDefault2": { filter: { value: "Some Value2" }, required: false },1968 "withUserDefault3": { filter: { value: "UserDefault.value3", format: "reference" }, required: true }1969 }1970 }1971 },1972 { semanticObject: "SomeObject2",1973action: "action2",1974 signature: {1975 additionalParameters: "allowed",1976 parameters: {1977 "noUserDefault3": { filter: { value: "Another Value1" }, required: false },1978 "withUserDefault4": { filter: { value: "UserDefault.value4", format: "reference" }, required: true },1979 "withUserDefault5": { filter: { value: "UserDefault.value5", format: "reference" }, required: false },1980 "noUserDefault4": { filter: { value: "Another Value2" }, required: false },1981 "withUserDefault6": { filter: { value: "UserDefault.value6", format: "reference" }, required: true }1982 }1983 }1984 }1985 ],1986 expectedParameters: {1987 simple: {"value1": {},1988"value2": {},1989"value3": {},1990"value4": {},1991 "value5": {},1992 "value6": {}},1993 extended: {}1994 }1995 },1996 {1997 testName: "inbounds contain other types of defaults",1998 inbounds: [1999 { semanticObject: "SomeObject",2000action: "action1",2001 signature: {2002 additionalParameters: "allowed",2003 parameters: {2004 "noUserDefault1": { filter: { value: "Some Value1" }, required: false },2005 "withUserDefault1": { filter: { value: "UserDefault.value1", format: "reference" }, required: true },2006 "withUserDefault2": { filter: { value: "MachineDefault.value2", format: "reference" }, required: false },2007 "noUserDefault2": { filter: { value: "Some Value2" }, required: false },2008 "withUserDefault3": { filter: { value: "UserDefault.value3", format: "reference" }, required: true }2009 }2010 }2011 },2012 { semanticObject: "SomeObject2",2013action: "action2",2014 signature: {2015 additionalParameters: "allowed",2016 parameters: {2017 "noUserDefault3": { filter: { value: "Another Value1" }, required: false },2018 "withUserDefault4": { filter: { value: "UserDefault.value4", format: "reference" }, required: true },2019 "withUserDefault5": { filter: { value: "SapDefault.value5", format: "reference" }, required: false },2020 "noUserDefault4": { filter: { value: "Another Value2" }, required: false },2021 "withUserDefault6": { filter: { value: "UserDefault.value6", format: "reference" }, required: true }2022 }2023 }2024 }2025 ],2026 expectedParameters: { simple: {"value1": {}, "value3": {}, "value4": {}, "value6": {}}, extended: {}}2027 },2028 {2029 testName: "inbounds contain overlapping user default placeholders",2030 inbounds: [2031 { semanticObject: "SomeObject",2032action: "action1",2033 signature: {2034 additionalParameters: "allowed",2035 parameters: {2036 "noUserDefault1": { filter: { value: "Some Value1" }, required: false },2037 "withUserDefault1": { filter: { value: "UserDefault.value1", format: "reference" }, required: false },2038 "withUserDefault2": { filter: { value: "UserDefault.value3", format: "reference" }, required: false },2039 "noUserDefault2": { filter: { value: "Some Value2" }, required: false },2040 "withUserDefault3": { filter: { value: "UserDefault.value2", format: "reference" }, required: false }2041 }2042 }2043 },2044 { semanticObject: "SomeObject2",2045action: "action2",2046 signature: {2047 additionalParameters: "allowed",2048 parameters: {2049 "noUserDefault3": { filter: { value: "Another Value1" }, required: false },2050 "withUserDefault4": { filter: { value: "UserDefault.value1", format: "reference" }, required: false },2051 "withUserDefault5": { filter: { value: "UserDefault.value2", format: "reference" }, required: false },2052 "noUserDefault4": { filter: { value: "Another Value2" }, required: false },2053 "withUserDefault6": { filter: { value: "UserDefault.value4", format: "reference" }, required: false }2054 }2055 }2056 }2057 ],2058 expectedParameters: { simple: {"value1": {}, "value2": {}, "value3": {}, "value4": {}}, extended: {}}2059 },2060 {2061 testName: "inbounds contain no user default placeholders",2062 inbounds: [2063 { semanticObject: "SomeObject",2064action: "action1",2065 signature: {2066 additionalParameters: "allowed",2067 parameters: {2068 "noUserDefault1": { filter: { value: "Some Value1" }, required: false },2069 "noUserDefault2": { filter: { value: "Some Value2" }, required: false }2070 }2071 }2072 },2073 { semanticObject: "SomeObject2",2074action: "action2",2075 signature: {2076 additionalParameters: "allowed",2077 parameters: {2078 "noUserDefault3": { filter: { value: "Another Value1" }, required: false },2079 "noUserDefault4": { filter: { value: "Another Value2" }, required: false }2080 }2081 }2082 }2083 ],2084 expectedParameters: { simple: {}, extended: {}}2085 },2086 {2087 testName: "inbounds contain a mix of filter values and user default values",2088 inbounds: [2089 { semanticObject: "SomeObject",2090action: "action1",2091 signature: {2092 additionalParameters: "allowed",2093 parameters: {2094 "noUserDefault1": { defaultValue: { value: "UserDefault.value1", format: "reference" }, required: false },2095 "noUserDefault2": { filter: { value: "UserDefault.value2", format: "reference" }, required: false }2096 }2097 }2098 },2099 { semanticObject: "SomeObject2",2100action: "action2",2101 signature: {2102 additionalParameters: "allowed",2103 parameters: {2104 "noUserDefault3": { filter: { value: "UserDefault.value3", format: "reference" }, required: false },2105 "noUserDefault4": { defaultValue: { value: "UserDefault.value4", format: "reference" }, required: false }2106 }2107 }2108 }2109 ],2110 expectedParameters: { simple: { "value1": {}, "value2": {}, "value3": {}, "value4": {}}, extended: {} }2111 }2112 ].forEach(function (oFixture) {2113 asyncTest("getUserDefaultParameterNames: returns default parameter names when " + oFixture.testName, function () {2114 var oSrvc = createService({2115 inbounds: oFixture.inbounds2116 }),2117 oParameterNamesPromise = oSrvc.getUserDefaultParameterNames();2118 if (typeof oParameterNamesPromise.done !== "function") {2119 ok(false, "getUserDefaultParameterNames returned a promise");2120 start();2121 return;2122 }2123 oParameterNamesPromise.done(function (oGotParameterNames) {2124 deepEqual(oGotParameterNames, oFixture.expectedParameters, "obtained expected parameter names");2125 }).always(function () {2126 start();2127 });2128 });2129 });2130 asyncTest("getUserDefaultParameterNames: rejects promise when private method throws", function () {2131 var oSrvc = createService(),2132 oParameterNamesPromise;2133 sinon.stub(oSrvc, "_getUserDefaultParameterNames").throws("deliberate exception");2134 oParameterNamesPromise = oSrvc.getUserDefaultParameterNames();2135 oParameterNamesPromise2136 .done(function (oGotParameterNames) {2137 ok(false, "promise was rejected");2138 })2139 .fail(function (sErrorMessage) {2140 ok(true, "promise was rejected");2141 strictEqual(sErrorMessage, "Cannot get user default parameters from inbounds: deliberate exception", "obtained expected error message");2142 })2143 .always(function () {2144 start();2145 });2146 });2147 [2148 {2149 testName: "no inbounds are defined",2150 inbounds: [],2151 expectedParameters: { simple: {}, extended: {}}2152 },2153 {2154 testName: "inbounds contain overlapping extended, not extended",2155 inbounds: [2156 { semanticObject: "SomeObject",2157action: "action1",2158 signature: {2159 additionalParameters: "allowed",2160 parameters: {2161 "noUserDefault1": { filter: { value: "Some Value1" }, required: false },2162 "withUserDefault1": { filter: { value: "UserDefault.extended.value1", format: "reference" }, required: true },2163 "withUserDefault2": { filter: { value: "UserDefault.extended.value2", format: "reference" }, required: false },2164 "noUserDefault2": { filter: { value: "Some Value2" }, required: false },2165 "withUserDefault3": { filter: { value: "UserDefault.value3", format: "reference" }, required: true }2166 }2167 }2168 },2169 { semanticObject: "SomeObject2",2170action: "action2",2171 signature: {2172 additionalParameters: "allowed",2173 parameters: {2174 "noUserDefault3": { filter: { value: "Another Value1" }, required: false },2175 "withUserDefault4": { filter: { value: "UserDefault.value1", format: "reference" }, required: true },2176 "withUserDefault5": { filter: { value: "UserDefault.value2", format: "reference" }, required: false },2177 "noUserDefault4": { filter: { value: "Another Value2" }, required: false },2178 "withUserDefault6": { filter: { value: "UserDefault.value6", format: "reference" }, required: true }2179 }2180 }2181 }2182 ],2183 expectedParameters: { simple: {"value1": {}, "value2": {}, "value3": {}, "value6": {}}, extended: {"value1": {}, "value2": {}}}2184 },2185 {2186 testName: "inbounds contain other types of defaults",2187 inbounds: [2188 { semanticObject: "SomeObject",2189action: "action1",2190 signature: {2191 additionalParameters: "allowed",2192 parameters: {2193 "noUserDefault1": { filter: { value: "UserDefault.extended.valuex" }, required: false },2194 "withUserDefault1": { filter: { value: "UserDefault.extended.value1", format: "reference" }, required: true },2195 "withUserDefault2": { filter: { value: "MachineDefault.value2", format: "reference" }, required: false },2196 "noUserDefault2": { filter: { value: "Some Value2" }, required: false },2197 "withUserDefault3": { filter: { value: "UserDefault.value3", format: "reference" }, required: true }2198 }2199 }2200 },2201 { semanticObject: "SomeObject2",2202action: "action2",2203 signature: {2204 additionalParameters: "allowed",2205 parameters: {2206 "noUserDefault3": { filter: { value: "Another Value1" }, required: false },2207 "withUserDefault4": { filter: { value: "UserDefault.value4", format: "reference" }, required: true },2208 "withUserDefault5": { filter: { value: "SapDefault.value5", format: "reference" }, required: false },2209 "noUserDefault4": { filter: { value: "Another Value2" }, required: false },2210 "withUserDefault6": { filter: { value: "UserDefault.value6", format: "reference" }, required: true }2211 }2212 }2213 }2214 ],2215 expectedParameters: { simple: {"value3": {}, "value4": {}, "value6": {}}, extended: {"value1": {}}}2216 },2217 {2218 testName: "inbounds contain overlapping user default placeholders",2219 inbounds: [2220 { semanticObject: "SomeObject",2221action: "action1",2222 signature: {2223 additionalParameters: "allowed",2224 parameters: {2225 "noUserDefault1": { filter: { value: "Some Value1" }, required: false },2226 "withUserDefault1": { filter: { value: "UserDefault.extended.value1", format: "reference" }, required: false },2227 "withUserDefault2": { filter: { value: "UserDefault.extended.value3", format: "reference" }, required: false },2228 "noUserDefault2": { filter: { value: "Some Value2" }, required: false },2229 "withUserDefault3": { filter: { value: "UserDefault.extended.value2", format: "reference" }, required: false }2230 }2231 }2232 },2233 { semanticObject: "SomeObject2",2234action: "action2",2235 signature: {2236 additionalParameters: "allowed",2237 parameters: {2238 "noUserDefault3": { filter: { value: "Another Value1" }, required: false },2239 "withUserDefault4": { filter: { value: "UserDefault.extended.value1", format: "reference" }, required: false },2240 "withUserDefault5": { filter: { value: "UserDefault.extended.value2", format: "reference" }, required: false },2241 "noUserDefault4": { filter: { value: "Another Value2" }, required: false },2242 "withUserDefault6": { filter: { value: "UserDefault.extended.value4", format: "reference" }, required: false }2243 }2244 }2245 }2246 ],2247 expectedParameters: { simple: {}, extended: {"value1": {}, "value2": {}, "value3": {}, "value4": {}}}2248 },2249 {2250 testName: "inbounds contain no user default placeholders",2251 inbounds: [2252 { semanticObject: "SomeObject",2253action: "action1",2254 signature: {2255 additionalParameters: "allowed",2256 parameters: {2257 "noUserDefault1": { filter: { value: "Some Value1" }, required: false },2258 "noUserDefault2": { filter: { value: "Some Value2" }, required: false }2259 }2260 }2261 },2262 { semanticObject: "SomeObject2",2263action: "action2",2264 signature: {2265 additionalParameters: "allowed",2266 parameters: {2267 "noUserDefault3": { filter: { value: "Another Value1" }, required: false },2268 "noUserDefault4": { filter: { value: "Another Value2" }, required: false }2269 }2270 }2271 }2272 ],2273 expectedParameters: {simple: {}, extended: {}}2274 },2275 {2276 testName: "inbounds contain a mix of filter values and user default values",2277 inbounds: [2278 { semanticObject: "SomeObject",2279action: "action1",2280 signature: {2281 additionalParameters: "allowed",2282 parameters: {2283 "noUserDefault1": { defaultValue: { value: "UserDefault.extended.value1", format: "reference" }, required: false },2284 "noUserDefault2": { filter: { value: "UserDefault.value2", format: "reference" }, required: false }2285 }2286 }2287 },2288 { semanticObject: "SomeObject2",2289action: "action2",2290 signature: {2291 additionalParameters: "allowed",2292 parameters: {2293 "noUserDefault3": { filter: { value: "UserDefault.value3", format: "reference" }, required: false },2294 "noUserDefault4": { defaultValue: { value: "UserDefault.extended.value4", format: "reference" }, required: false }2295 }2296 }2297 }2298 ],2299 expectedParameters: {simple: {"value2": {}, "value3": {}}, extended: {"value1": {}, "value4": {}}}2300 }2301 ].forEach(function (oFixture) {2302 asyncTest("getUserDefaultParameterNames: (Extended) returns extended default parameter names when " + oFixture.testName, function () {2303 var oSrvc = createService({2304 inbounds: oFixture.inbounds2305 }),2306 oInboundListPromise = oSrvc.getUserDefaultParameterNames();2307 if (typeof oInboundListPromise.done !== "function") {2308 ok(false, "getUserDefaultParameterNames returned a promise");2309 start();2310 return;2311 }2312 oInboundListPromise.done(function (aObtainedInbounds) {2313 deepEqual(aObtainedInbounds, oFixture.expectedParameters, "obtained expected parameter names");2314 }).always(function () {2315 start();2316 });2317 });2318 });2319 [2320 {2321 testDescription: "legacy parameter is provided",2322 sSemanticObject: "Object",2323 mBusinessParams: { "country": ["IT"] },2324 bIgnoreFormFactor: true,2325 bLegacySortParameter: true, // legacy sort parameter2326 sCurrentFormFactor: "desktop",2327 aMockedResolutionResults: [2328 {2329 "matches": true,2330 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },2331 "inbound": {2332 "title": "Currency manager",2333 "subTitle": "sub Title",2334 "shortTitle": "short Title",2335 "icon": "sap-icon://Fiori2/F0018",2336 "semanticObject": "Object",2337"action": "ZZZ",2338 "resolutionResult": { "_original": { "text": "Currency manager" }, "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },2339 "signature": { "parameters": { }, "additionalParameters": "ignored" }2340 }2341 },2342 { // simulate this result to have higher priority2343 "matches": true,2344 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },2345 "inbound": {2346 "title": "Currency manager",2347 "subTitle": "sub Title",2348 "shortTitle": "short Title",2349 "icon": "sap-icon://Fiori2/F0018",2350 "semanticObject": "Object",2351"action": "bbb",2352 "resolutionResult": { "_original": { "text": "Currency manager" }, "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },2353 "signature": { "parameters": {2354 "country": {2355 required: true2356 }2357 }}2358 }2359 },2360 {2361 "matches": true,2362 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },2363 "inbound": {2364 "title": "Currency manager",2365 "subTitle": "sub Title",2366 "shortTitle": "short Title",2367 "icon": "sap-icon://Fiori2/F0018",2368 "semanticObject": "Object",2369"action": "aaa",2370 "resolutionResult": { "_original": { "text": "Currency manager" }, "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },2371 "signature": { "parameters": { }, "additionalParameters": "ignored" }2372 }2373 }2374 ],2375 expectedSemanticObjectLinks: [2376 { "intent": "#Object-ZZZ",2377 "text": "Currency manager",2378 "icon": "sap-icon://Fiori2/F0018",2379 "subTitle": "sub Title",2380 "shortTitle": "short Title" },2381 { "intent": "#Object-aaa",2382 "text": "Currency manager",2383 "icon": "sap-icon://Fiori2/F0018",2384 "subTitle": "sub Title",2385 "shortTitle": "short Title"},2386 { "intent": "#Object-bbb?country=IT",2387 "text": "Currency manager",2388 "icon": "sap-icon://Fiori2/F0018",2389 "subTitle": "sub Title",2390 "shortTitle": "short Title"}2391 ],2392 expectedWarningCalls: [2393 [2394 "the parameter 'sortResultOnTexts' was experimantal and is no longer supported",2395 "getLinks results will be sorted by 'intent'",2396 "sap.ushell.services.ClientsideTargetResolution"2397 ]2398 ]2399 },2400 {2401 testDescription: "alphabetical order on priority is expected in result",2402 sSemanticObject: "Object",2403 mBusinessParams: { "country": ["IT"] },2404 bIgnoreFormFactor: true,2405 sSortResultsBy: "priority",2406 sCurrentFormFactor: "desktop",2407 aMockedResolutionResults: [2408 { // simulate this result to have higher priority2409 "matches": true,2410 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },2411 "inbound": {2412 "title": "Currency manager",2413 "subTitle": "sub Title",2414 "shortTitle": "short Title",2415 "icon": "sap-icon://Fiori2/F0018",2416 "semanticObject": "Object",2417"action": "bbb",2418 "resolutionResult": { "_original": { "text": "Currency manager" }, "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },2419 "signature": { "parameters": {2420 "country": {2421 required: true2422 }2423 }}2424 }2425 },2426 {2427 "matches": true,2428 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },2429 "inbound": {2430 "title": "Currency manager",2431 "subTitle": "sub Title",2432 "shortTitle": "short Title",2433 "icon": "sap-icon://Fiori2/F0018",2434 "semanticObject": "Object",2435"action": "ccc",2436 "resolutionResult": { "_original": { "text": "Currency manager" }, "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },2437 "signature": { "parameters": { }, "additionalParameters": "ignored" }2438 }2439 },2440 {2441 "matches": true,2442 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },2443 "inbound": {2444 "title": "Currency manager",2445 "subTitle": "sub Title",2446 "shortTitle": "short Title",2447 "icon": "sap-icon://Fiori2/F0018",2448 "semanticObject": "Object",2449"action": "aaa",2450 "resolutionResult": { "_original": { "text": "Currency manager" }, "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },2451 "signature": { "parameters": { }, "additionalParameters": "ignored" }2452 }2453 }2454 ],2455 expectedSemanticObjectLinks: [2456 { "intent": "#Object-bbb?country=IT",2457 "text": "Currency manager",2458 "icon": "sap-icon://Fiori2/F0018",2459 "subTitle": "sub Title",2460 "shortTitle": "short Title"},2461 { "intent": "#Object-ccc",2462 "text": "Currency manager",2463 "icon": "sap-icon://Fiori2/F0018",2464 "subTitle": "sub Title",2465 "shortTitle": "short Title"},2466 { "intent": "#Object-aaa",2467 "text": "Currency manager",2468 "icon": "sap-icon://Fiori2/F0018",2469 "subTitle": "sub Title",2470 "shortTitle": "short Title" }2471 ]2472 },2473 {2474 testDescription: "alphabetical order on intents is expected in result",2475 sSemanticObject: "Object",2476 mBusinessParams: { "country": ["IT"] },2477 bIgnoreFormFactor: true,2478 sCurrentFormFactor: "desktop",2479 aMockedResolutionResults: [2480 { // simulate this result to have higher priority2481 "matches": true,2482 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },2483 "inbound": {2484 "title": "Currency manager",2485 "subTitle": "sub Title",2486 "shortTitle": "short Title",2487 "icon": "sap-icon://Fiori2/F0018",2488 "semanticObject": "Object",2489"action": "bbb",2490 "resolutionResult": { "_original": { "text": "Currency manager" }, "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },2491 "signature": { "parameters": {2492 "country": {2493 required: true2494 }2495 }}2496 }2497 },2498 {2499 "matches": true,2500 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },2501 "inbound": {2502 "title": "Currency manager",2503 "subTitle": "sub Title",2504 "shortTitle": "short Title",2505 "icon": "sap-icon://Fiori2/F0018",2506 "semanticObject": "Object",2507"action": "ccc",2508 "resolutionResult": { "_original": { "text": "Currency manager" }, "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },2509 "signature": { "parameters": { }, "additionalParameters": "ignored" }2510 }2511 },2512 {2513 "matches": true,2514 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },2515 "inbound": {2516 "title": "Currency manager",2517 "subTitle": "sub Title",2518 "shortTitle": "short Title",2519 "icon": "sap-icon://Fiori2/F0018",2520 "semanticObject": "Object",2521"action": "aaa",2522 "resolutionResult": { "_original": { "text": "Currency manager" }, "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },2523 "signature": { "parameters": { }, "additionalParameters": "ignored" }2524 }2525 }2526 ],2527 expectedSemanticObjectLinks: [2528 { "intent": "#Object-aaa",2529 "text": "Currency manager",2530 "icon": "sap-icon://Fiori2/F0018",2531 "subTitle": "sub Title",2532 "shortTitle": "short Title"2533 },2534 { "intent": "#Object-bbb?country=IT",2535 "text": "Currency manager",2536 "icon": "sap-icon://Fiori2/F0018",2537 "subTitle": "sub Title",2538 "shortTitle": "short Title"},2539 { "intent": "#Object-ccc",2540 "text": "Currency manager",2541 "icon": "sap-icon://Fiori2/F0018",2542 "subTitle": "sub Title",2543 "shortTitle": "short Title"}2544 ],2545 expectedWarningCalls: [2546 [2547 "Passing positional arguments to getLinks is deprecated",2548 "Please use nominal arguments instead",2549 "sap.ushell.services.ClientSideTargetResolution"2550 ]2551 ]2552 },2553 {2554 testDescription: "alphabetical order on texts is expected in result",2555 sSemanticObject: "Object",2556 mBusinessParams: { "country": ["IT"] },2557 bIgnoreFormFactor: true,2558 sSortResultsBy: "text",2559 sCurrentFormFactor: "desktop",2560 aMockedResolutionResults: [2561 { // simulate this result to have higher priority2562 "matches": true,2563 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },2564 "inbound": {2565 "title": "Currency managerC",2566 "shortTitle": "short Title",2567 "subTitle": "sub Title",2568 "icon": "sap-icon://Fiori2/F0018",2569 "semanticObject": "Object",2570"action": "aaa",2571 "resolutionResult": { "_original": { "text": "Currency manager" }, "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },2572 "signature": { "parameters": {2573 "country": {2574 required: true2575 }2576 }}2577 }2578 },2579 {2580 "matches": true,2581 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },2582 "inbound": {2583 "title": "Currency managerA",2584 "shortTitle": "short Title",2585 "subTitle": "sub Title",2586 "icon": "sap-icon://Fiori2/F0018",2587 "semanticObject": "Object",2588"action": "bbb",2589 "resolutionResult": { "_original": { "text": "Currency manager" }, "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },2590 "signature": { "parameters": { }, "additionalParameters": "ignored" }2591 }2592 },2593 {2594 "matches": true,2595 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },2596 "inbound": {2597 "title": "Currency managerB",2598 "shortTitle": "short Title",2599 "subTitle": "sub Title",2600 "icon": "sap-icon://Fiori2/F0018",2601 "semanticObject": "Object",2602"action": "ccc",2603 "resolutionResult": { "_original": { "text": "Currency manager" }, "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },2604 "signature": { "parameters": { }, "additionalParameters": "ignored" }2605 }2606 }2607 ],2608 expectedSemanticObjectLinks: [2609 { "intent": "#Object-bbb",2610 "text": "Currency managerA",2611 "icon": "sap-icon://Fiori2/F0018",2612 "subTitle": "sub Title",2613 "shortTitle": "short Title"},2614 { "intent": "#Object-ccc",2615 "text": "Currency managerB",2616 "icon": "sap-icon://Fiori2/F0018",2617 "subTitle": "sub Title",2618 "shortTitle": "short Title" },2619 { "intent": "#Object-aaa?country=IT",2620 "text": "Currency managerC",2621 "icon": "sap-icon://Fiori2/F0018",2622 "subTitle": "sub Title",2623 "shortTitle": "short Title" }2624 ]2625 },2626 {2627 // multiple inbounds are filtered in this case as the URL looks the same2628 testDescription: "multiple inbounds that look identical are matched",2629 sSemanticObject: "Action",2630 mBusinessParams: {},2631 bIgnoreFormFactor: true,2632 sCurrentFormFactor: "desktop",2633 aMockedResolutionResults: [2634 {2635 "matches": true,2636 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },2637 "inbound": {2638 "title": "Currency manager",2639 "shortTitle": "short Title",2640 "subTitle": "sub Title",2641 "icon": "sap-icon://Fiori2/F0018",2642 "semanticObject": "Action",2643"action": "actionX",2644 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },2645 "signature": {2646 "parameters": {2647 "mode": {2648 "required": false,2649 "defaultValue": { value: "DefaultValue1" } // ignored in result2650 }2651 }2652 }2653 }2654 },2655 {2656 "matches": true,2657 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },2658 "inbound": {2659 "title": "Currency manager",2660 "subTitle": "sub Title",2661 "shortTitle": "short Title",2662 "icon": "sap-icon://Fiori2/F0018",2663 "semanticObject": "Action",2664"action": "actionX",2665 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },2666 "signature": {2667 "parameters": { } // this inbound has not parameter2668 }2669 }2670 }2671 ],2672 expectedSemanticObjectLinks: [2673 { "intent": "#Action-actionX", // note "?" removed from parameter2674 "text": "Currency manager",2675 "icon": "sap-icon://Fiori2/F0018",2676 "subTitle": "sub Title",2677 "shortTitle": "short Title"}2678 ],2679 expectedWarningCalls: [2680 [2681 "Passing positional arguments to getLinks is deprecated",2682 "Please use nominal arguments instead",2683 "sap.ushell.services.ClientSideTargetResolution"2684 ]2685 ]2686 },2687 {2688 testDescription: "matching target exists and business parameters are specified",2689 sSemanticObject: "Action",2690 mBusinessParams: { "ParamName1": "value", "ParamName2": ["value1", "value2"] }, // NOTE: parameters provided2691 bIgnoreFormFactor: true,2692 sCurrentFormFactor: "desktop",2693 aMockedResolutionResults: [{2694 // ignore certain fields not needed for the test2695 "matches": true,2696 "resolutionResult": {2697 "additionalInformation": "SAPUI5.Component=Currency.Component",2698 "applicationType": "URL",2699 "text": "Currency manager",2700 "ui5ComponentName": "Currency.Component",2701 "url": "/url/to/currency?mode=desktop"2702 },2703 "inbound": {2704 "title": "Currency manager",2705 "icon": "sap-icon://Fiori2/F0018",2706 "shortTitle": "short Title",2707 "subTitle": "sub Title",2708 "semanticObject": "Action",2709"action": "action1",2710 "resolutionResult": {2711 "additionalInformation": "SAPUI5.Component=Currency.Component",2712 "applicationType": "URL",2713 "text": "Currency manager (ignored text)", // ignored2714 "ui5ComponentName": "Currency.Component",2715 "url": "/url/to/currency"2716 },2717 "signature": {2718 "additionalParameters": "ignored",2719 "parameters": {2720 "mode": {2721 "required": false,2722 "defaultValue": { value: "DefaultValue" } // ignored in result2723 }2724 }2725 }2726 }2727 }],2728 expectedSemanticObjectLinks: [2729 { "intent": "#Action-action1", // only return intent parameters that are mentioned in Inbound2730 "text": "Currency manager",2731 "icon": "sap-icon://Fiori2/F0018",2732 "subTitle": "sub Title",2733 "shortTitle": "short Title"}2734 ],2735 expectedWarningCalls: [2736 [2737 "Passing positional arguments to getLinks is deprecated",2738 "Please use nominal arguments instead",2739 "sap.ushell.services.ClientSideTargetResolution"2740 ]2741 ]2742 },2743 {2744 testDescription: "matching target has default parameter that overlaps with intent parameter",2745 sSemanticObject: "Action",2746 mBusinessParams: { "ParamName1": "value", "ParamName2": ["value1", "value2"] }, // NOTE: parameters provided2747 bIgnoreFormFactor: true,2748 sCurrentFormFactor: "desktop",2749 aMockedResolutionResults: [{2750 // ignore certain fields not needed for the test2751 "matches": true,2752 "resolutionResult": {2753 "additionalInformation": "SAPUI5.Component=Currency.Component",2754 "applicationType": "URL",2755 "text": "Currency manager",2756 "ui5ComponentName": "Currency.Component",2757 "url": "/url/to/currency?mode=desktop"2758 },2759 "inbound": {2760 "title": "Currency manager",2761 "shortTitle": "short Title",2762 "subTitle": "sub Title",2763 "icon": "sap-icon://Fiori2/F0018",2764 "semanticObject": "Action",2765"action": "action1",2766 "resolutionResult": {2767 "additionalInformation": "SAPUI5.Component=Currency.Component",2768 "applicationType": "URL",2769 "text": "Currency manager (ignored text)", // ignored2770 "ui5ComponentName": "Currency.Component",2771 "url": "/url/to/currency"2772 },2773 "signature": {2774 "additionalParameters": "ignored",2775 "parameters": {2776 "ParamName1": {2777 "required": false,2778 "defaultValue": { value: "DefaultValue" }2779 }2780 }2781 }2782 }2783 }],2784 expectedSemanticObjectLinks: [2785 { "intent": "#Action-action1?ParamName1=value", // only ParamName1 is mentioned in Inbound2786 "text": "Currency manager",2787 "icon": "sap-icon://Fiori2/F0018",2788 "subTitle": "sub Title",2789 "shortTitle": "short Title" }2790 ],2791 expectedWarningCalls: [2792 [2793 "Passing positional arguments to getLinks is deprecated",2794 "Please use nominal arguments instead",2795 "sap.ushell.services.ClientSideTargetResolution"2796 ]2797 ]2798 },2799 {2800 testDescription: "sap-system parameter specified in intent",2801 sSemanticObject: "Action",2802 mBusinessParams: { "sap-system": ["CC2"] },2803 bIgnoreFormFactor: true,2804 sCurrentFormFactor: "desktop",2805 aMockedResolutionResults: [{2806 // ignore certain fields not needed for the test2807 "matches": true,2808 "resolutionResult": {2809 "additionalInformation": "SAPUI5.Component=Currency.Component",2810 "applicationType": "URL",2811 "text": "Currency manager",2812 "ui5ComponentName": "Currency.Component",2813 "url": "/url/to/currency?mode=desktop"2814 },2815 "inbound": {2816 "semanticObject": "Action",2817"action": "action1",2818 "title": "Currency manager",2819 "icon": "sap-icon://Fiori2/F0018",2820 "shortTitle": "short Title",2821 "subTitle": "sub Title",2822 "resolutionResult": {2823 "additionalInformation": "SAPUI5.Component=Currency.Component",2824 "applicationType": "URL",2825 "text": "Currency manager (ignored text)", // ignored2826 "ui5ComponentName": "Currency.Component",2827 "url": "/url/to/currency"2828 },2829 "signature": {2830 "additionalParameters": "ignored",2831 "parameters": {2832 "ParamName1": {2833 "required": false,2834 "defaultValue": { value: "DefaultValue" }2835 }2836 }2837 }2838 }2839 }],2840 expectedSemanticObjectLinks: [2841 { "intent": "#Action-action1?sap-system=CC2",2842 "text": "Currency manager",2843 "icon": "sap-icon://Fiori2/F0018",2844 "subTitle": "sub Title",2845 "shortTitle": "short Title" }2846 ],2847 expectedWarningCalls: [2848 [2849 "Passing positional arguments to getLinks is deprecated",2850 "Please use nominal arguments instead",2851 "sap.ushell.services.ClientSideTargetResolution"2852 ]2853 ]2854 },2855 {2856 testDescription: "sap-system and other parameters specified in intent (additionalParameters: allowed)",2857 sSemanticObject: "Action",2858 mBusinessParams: {2859 "sap-system": ["CC2"],2860 "paramName1": ["paramValue1"],2861 "paramName2": ["paramValue2"]2862 },2863 bIgnoreFormFactor: true,2864 sCurrentFormFactor: "desktop",2865 aMockedResolutionResults: [{2866 // ignore certain fields not needed for the test2867 "matches": true,2868 "resolutionResult": {2869 "additionalInformation": "SAPUI5.Component=Currency.Component",2870 "applicationType": "URL",2871 "text": "Currency manager",2872 "ui5ComponentName": "Currency.Component",2873 "url": "/url/to/currency?mode=desktop"2874 },2875 "inbound": {2876 "semanticObject": "Action",2877"action": "action1",2878 "title": "Currency manager",2879 "shortTitle": "short Title",2880 "subTitle": "sub Title",2881 "icon": "sap-icon://Fiori2/F0018",2882 "resolutionResult": {2883 "additionalInformation": "SAPUI5.Component=Currency.Component",2884 "applicationType": "URL",2885 "text": "Currency manager (ignored text)", // ignored2886 "ui5ComponentName": "Currency.Component",2887 "url": "/url/to/currency"2888 },2889 "signature": {2890 "additionalParameters": "allowed", // non overlapping parameters added to result2891 "parameters": {2892 "paramName1": {2893 "required": false,2894 "defaultValue": { value: "DefaultValue" }2895 }2896 }2897 }2898 }2899 }],2900 expectedSemanticObjectLinks: [2901 { "intent": "#Action-action1?paramName1=paramValue1&paramName2=paramValue2&sap-system=CC2",2902 "text": "Currency manager",2903 "icon": "sap-icon://Fiori2/F0018",2904 "subTitle": "sub Title",2905 "shortTitle": "short Title" }2906 ],2907 expectedWarningCalls: [2908 [2909 "Passing positional arguments to getLinks is deprecated",2910 "Please use nominal arguments instead",2911 "sap.ushell.services.ClientSideTargetResolution"2912 ]2913 ]2914 },2915 {2916 testDescription: "sap-system and other parameters specified in intent (additionalParameters: ignored)",2917 sSemanticObject: "Action",2918 mBusinessParams: {2919 "sap-system": ["CC2"],2920 "paramName1": ["paramValue1"],2921 "paramName2": ["paramValue2"]2922 },2923 bIgnoreFormFactor: true,2924 sCurrentFormFactor: "desktop",2925 aMockedResolutionResults: [{2926 // ignore certain fields not needed for the test2927 "matches": true,2928 "resolutionResult": {2929 "additionalInformation": "SAPUI5.Component=Currency.Component",2930 "applicationType": "URL",2931 "text": "Currency manager",2932 "ui5ComponentName": "Currency.Component",2933 "url": "/url/to/currency?mode=desktop"2934 },2935 "inbound": {2936 "title": "Currency manager",2937 "icon": "sap-icon://Fiori2/F0018",2938 "subTitle": "sub Title",2939 "shortTitle": "short Title",2940 "semanticObject": "Action",2941"action": "action1",2942 "resolutionResult": {2943 "additionalInformation": "SAPUI5.Component=Currency.Component",2944 "applicationType": "URL",2945 "text": "Currency manager (ignored text)", // ignored2946 "ui5ComponentName": "Currency.Component",2947 "url": "/url/to/currency"2948 },2949 "signature": {2950 "additionalParameters": "ignored",2951 "parameters": {2952 "paramName1": {2953 "required": false,2954 "defaultValue": { value: "DefaultValue" }2955 }2956 }2957 }2958 }2959 }],2960 expectedSemanticObjectLinks: [2961 { "intent": "#Action-action1?paramName1=paramValue1&sap-system=CC2",2962 "text": "Currency manager",2963 "icon": "sap-icon://Fiori2/F0018",2964 "subTitle": "sub Title",2965 "shortTitle": "short Title" }2966 ],2967 expectedWarningCalls: [2968 [2969 "Passing positional arguments to getLinks is deprecated",2970 "Please use nominal arguments instead",2971 "sap.ushell.services.ClientSideTargetResolution"2972 ]2973 ]2974 },2975 {2976 testDescription: "matching target has required parameter that overlaps with intent parameter",2977 sSemanticObject: "Action",2978 mBusinessParams: { "ParamName1": "value", "ParamName2": ["value1", "value2"] }, // NOTE: parameters provided2979 bIgnoreFormFactor: true,2980 sCurrentFormFactor: "desktop",2981 aMockedResolutionResults: [{2982 // ignore certain fields not needed for the test2983 "matches": true,2984 "resolutionResult": {2985 "additionalInformation": "SAPUI5.Component=Currency.Component",2986 "applicationType": "URL",2987 "text": "Currency manager",2988 "ui5ComponentName": "Currency.Component",2989 "url": "/url/to/currency?mode=desktop"2990 },2991 "inbound": {2992 "title": "Currency manager",2993 "subTitle": "sub Title",2994 "shortTitle": "short Title",2995 "icon": "sap-icon://Fiori2/F0018",2996 "semanticObject": "Action",2997"action": "action1",2998 "resolutionResult": {2999 "additionalInformation": "SAPUI5.Component=Currency.Component",3000 "applicationType": "URL",3001 "text": "Currency manager (ignored text)", // ignored3002 "ui5ComponentName": "Currency.Component",3003 "url": "/url/to/currency"3004 },3005 "signature": {3006 "additionalParameters": "ignored",3007 "parameters": {3008 "ParamName2": {3009 "required": true3010 }3011 }3012 }3013 }3014 }],3015 expectedSemanticObjectLinks: [3016 { "intent": "#Action-action1?ParamName2=value1&ParamName2=value2", // only ParamName2 is mentioned in Inbound3017 "text": "Currency manager",3018 "icon": "sap-icon://Fiori2/F0018",3019 "subTitle": "sub Title",3020 "shortTitle": "short Title" }3021 ],3022 expectedWarningCalls: [3023 [3024 "Passing positional arguments to getLinks is deprecated",3025 "Please use nominal arguments instead",3026 "sap.ushell.services.ClientSideTargetResolution"3027 ]3028 ]3029 },3030 {3031 testDescription: "function called with * semantic object",3032 sSemanticObject: "*",3033 mBusinessParams: { "ParamName1": "value", "ParamName2": ["value1", "value2"] }, // NOTE: parameters provided3034 bIgnoreFormFactor: true,3035 sCurrentFormFactor: "desktop",3036 aMockedResolutionResults: [{ // a inbound with generic semantic object3037 "matches": true,3038 "resolutionResult": {3039 "additionalInformation": "SAPUI5.Component=Currency.Component",3040 "applicationType": "URL",3041 "text": "Currency manager",3042 "ui5ComponentName": "Currency.Component",3043 "url": "/url/to/currency?mode=desktop"3044 },3045 "inbound": {3046 "title": "Currency manager",3047 "subTitle": "sub Title",3048 "shortTitle": "short Title",3049 "icon": "sap-icon://Fiori2/F0018",3050 "semanticObject": "*",3051 "action": "action",3052 "resolutionResult": {3053 "additionalInformation": "SAPUI5.Component=Currency.Component",3054 "applicationType": "URL",3055 "text": "Currency manager (ignored text)", // ignored3056 "ui5ComponentName": "Currency.Component",3057 "url": "/url/to/currency"3058 },3059 "signature": {3060 "parameters": {3061 "mode": {3062 "required": false,3063 "defaultValue": { value: "DefaultValue" } // ignored in result3064 }3065 }3066 }3067 }3068 }],3069 expectedSemanticObjectLinks: [], // Inbound should be filtered out3070 expectedWarningCalls: [3071 [3072 "Passing positional arguments to getLinks is deprecated",3073 "Please use nominal arguments instead",3074 "sap.ushell.services.ClientSideTargetResolution"3075 ]3076 ]3077 },3078 {3079 testDescription: "function called with empty string semantic object",3080 sSemanticObject: "", // should match all3081 mBusinessParams: { "ParamName1": "value", "ParamName2": ["value1", "value2"] }, // NOTE: parameters provided3082 bIgnoreFormFactor: true,3083 sCurrentFormFactor: "desktop",3084 aMockedResolutionResults: [{ // a inbound with generic semantic object3085 "matches": true,3086 "resolutionResult": {3087 "additionalInformation": "SAPUI5.Component=Currency.Component",3088 "applicationType": "URL",3089 "text": "Currency manager",3090 "ui5ComponentName": "Currency.Component",3091 "url": "/url/to/currency?mode=desktop"3092 },3093 "inbound": {3094 "title": "Currency manager",3095 "subTitle": "sub Title",3096 "shortTitle": "short Title",3097 "icon": "sap-icon://Fiori2/F0018",3098 "semanticObject": "*",3099 "action": "action",3100 "resolutionResult": {3101 "additionalInformation": "SAPUI5.Component=Currency.Component",3102 "applicationType": "URL",3103 "text": "Currency manager (ignored text)", // ignored3104 "ui5ComponentName": "Currency.Component",3105 "url": "/url/to/currency"3106 },3107 "signature": {3108 "parameters": {3109 "mode": {3110 "required": false,3111 "defaultValue": { value: "DefaultValue" } // ignored in result3112 }3113 }3114 }3115 }3116 }],3117 expectedSemanticObjectLinks: [], // Inbound should be filtered out3118 expectedWarningCalls: [3119 [3120 "Passing positional arguments to getLinks is deprecated",3121 "Please use nominal arguments instead",3122 "sap.ushell.services.ClientSideTargetResolution"3123 ]3124 ]3125 },3126 {3127 testDescription: "hideIntentLink is set to true",3128 sSemanticObject: "Object",3129 mBusinessParams: {},3130 bIgnoreFormFactor: true,3131 sCurrentFormFactor: "desktop",3132 aMockedResolutionResults: [3133 { // has no hideIntentLink3134 "matches": true,3135 "resolutionResult": {3136 "additionalInformation": "SAPUI5.Component=Currency.Component",3137 "applicationType": "URL",3138 "text": "Currency manager A",3139 "ui5ComponentName": "Currency.Component",3140 "url": "/url/to/currency?mode=desktop"3141 },3142 "inbound": {3143 // NOTE: no hideIntentLink set3144 "title": "Currency manager A",3145 "subTitle": "sub Title",3146 "shortTitle": "short Title",3147 "icon": "sap-icon://Fiori2/F0018",3148 "semanticObject": "Object",3149 "action": "actionA",3150 "resolutionResult": {3151 "additionalInformation": "SAPUI5.Component=Currency.Component",3152 "applicationType": "URL",3153 "text": "Currency manager A",3154 "ui5ComponentName": "Currency.Component",3155 "url": "/url/to/currency"3156 },3157 "signature": { "parameters": { } }3158 }3159 },3160 { // same as the previous inbound but with hideIntentLink set3161 "matches": true,3162 "resolutionResult": {3163 "additionalInformation": "SAPUI5.Component=Currency.Component",3164 "applicationType": "URL",3165 "text": "Currency manager B",3166 "ui5ComponentName": "Currency.Component",3167 "url": "/url/to/currency?mode=desktop"3168 },3169 "inbound": {3170 "hideIntentLink": true, // NOTE: this should be hidden in the result!3171 "title": "Currency manager B",3172 "subTitle": "sub Title",3173 "shortTitle": "short Title",3174 "semanticObject": "Object",3175 "action": "actionB",3176 "resolutionResult": {3177 "additionalInformation": "SAPUI5.Component=Currency.Component",3178 "applicationType": "URL",3179 "text": "Currency manager B",3180 "ui5ComponentName": "Currency.Component",3181 "url": "/url/to/currency"3182 },3183 "signature": { "parameters": { } }3184 }3185 }3186 ],3187 expectedSemanticObjectLinks: [3188 {3189 "intent": "#Object-actionA",3190 "text": "Currency manager A",3191 "icon": "sap-icon://Fiori2/F0018",3192 "subTitle": "sub Title",3193 "shortTitle": "short Title"3194 }3195 ],3196 expectedWarningCalls: [3197 [3198 "Passing positional arguments to getLinks is deprecated",3199 "Please use nominal arguments instead",3200 "sap.ushell.services.ClientSideTargetResolution"3201 ]3202 ]3203 },3204 {3205 testDescription: "app state is provided as member",3206 sSemanticObject: "Object",3207 mBusinessParams: { "ab": 1},3208 sAppStateKey: "AS12345",3209 bIgnoreFormFactor: true,3210 sCurrentFormFactor: "desktop",3211 aMockedResolutionResults: [3212 { // has no hideIntentLink3213 "matches": true,3214 "resolutionResult": {3215 "additionalInformation": "SAPUI5.Component=Currency.Component",3216 "applicationType": "URL",3217 "text": "Currency manager A",3218 "ui5ComponentName": "Currency.Component",3219 "url": "/url/to/currency?mode=desktop"3220 },3221 "inbound": {3222 // NOTE: no hideIntentLink set3223 "title": "Currency manager A",3224 "shortTitle": "short Title",3225 "subTitle": "sub Title",3226 "icon": "sap-icon://Fiori2/F0018",3227 "semanticObject": "Object",3228 "action": "actionA",3229 "resolutionResult": {3230 "additionalInformation": "SAPUI5.Component=Currency.Component",3231 "applicationType": "URL",3232 "text": "Currency manager A",3233 "ui5ComponentName": "Currency.Component",3234 "url": "/url/to/currency"3235 },3236 "signature": { "parameters": { "ab": { required: true } } }3237 }3238 }3239 ],3240 expectedSemanticObjectLinks: [3241 {3242 "intent": "#Object-actionA?ab=1&sap-xapp-state=AS12345",3243 "text": "Currency manager A",3244 "icon": "sap-icon://Fiori2/F0018",3245 "subTitle": "sub Title",3246 "shortTitle": "short Title"3247 }3248 ],3249 expectedWarningCalls: [3250 [3251 "Passing positional arguments to getLinks is deprecated",3252 "Please use nominal arguments instead",3253 "sap.ushell.services.ClientSideTargetResolution"3254 ]3255 ]3256 }3257 ].forEach(function (oFixture) {3258 asyncTest("getLinks: returns expected inbounds when " + oFixture.testDescription, function () {3259 var oSrvc = createService();3260 sinon.stub(jQuery.sap.log, "warning");3261 sinon.stub(jQuery.sap.log, "error");3262 // Mock form factor3263 sinon.stub(utils, "getFormFactor").returns(oFixture.sCurrentFormFactor);3264 // Mock getMatchingInbounds3265 sinon.stub(oSrvc, "_getMatchingInbounds").returns(3266 new jQuery.Deferred().resolve(oFixture.aMockedResolutionResults).promise()3267 );3268 if (oFixture.hasOwnProperty("sAction")) {3269 // test 1.38.0+ behavior3270 oSrvc.getLinks({3271 semanticObject: oFixture.sSemanticObject,3272 action: oFixture.sAction,3273 params: oFixture.mBusinessParams,3274 appStateKey: oFixture.sAppStateKey,3275 ignoreFormFactor: oFixture.bIgnoreFormFactor3276 }).done(function (aResultSemanticObjectLinks) {3277 // Assert3278 ok(true, "promise was resolved");3279 deepEqual(aResultSemanticObjectLinks, oFixture.expectedSemanticObjectLinks, "got expected array of semantic object links");3280 testExcludeTileIntentArgument(oSrvc, true);3281 })3282 .fail(function () {3283 // Assert3284 ok(false, "promise was rejected");3285 })3286 .always(function () {3287 testExpectedErrorAndWarningCalls(oFixture);3288 start();3289 });3290 } else if (oFixture.sSortResultsBy || oFixture.bLegacySortParameter) {3291 // test internal flag for sorting result on texts3292 var oGetLinksCallArgs = {3293 semanticObject: oFixture.sSemanticObject,3294 params: oFixture.mBusinessParams,3295 appStateKey: oFixture.sAppStateKey,3296 ignoreFormFactor: oFixture.bIgnoreFormFactor3297 };3298 if (oFixture.sSortResultsBy) {3299 oGetLinksCallArgs.sortResultsBy = oFixture.sSortResultsBy;3300 }3301 if (oFixture.bLegacySortParameter) {3302 oGetLinksCallArgs.sortResultOnTexts = oFixture.bLegacySortParameter;3303 }3304 oSrvc.getLinks(oGetLinksCallArgs)3305 .done(function (aResultSemanticObjectLinks) {3306 // Assert3307 ok(true, "promise was resolved");3308 deepEqual(aResultSemanticObjectLinks, oFixture.expectedSemanticObjectLinks, "got expected array of semantic object links");3309 testExcludeTileIntentArgument(oSrvc, true);3310 })3311 .fail(function () {3312 // Assert3313 ok(false, "promise was rejected");3314 })3315 .always(function () {3316 testExpectedErrorAndWarningCalls(oFixture);3317 start();3318 });3319 } else {3320 // test old style call and the new style call return the same results3321 var mBusinessParamsAmended = jQuery.extend(true, {}, oFixture.mBusinessParams);3322 if (oFixture.sAppStateKey) {3323 mBusinessParamsAmended["sap-xapp-state"] = [ oFixture.sAppStateKey ];3324 }3325 oSrvc.getLinks(oFixture.sSemanticObject, mBusinessParamsAmended, oFixture.bIgnoreFormFactor)3326 .done(function (aResultSemanticObjectLinksOld) {3327 ok(true, "positional parameters call promise was resolved");3328 testExcludeTileIntentArgument(oSrvc, true);3329 oSrvc._getMatchingInbounds.reset(); // testExcludeTileIntentArgument called later again3330 oSrvc.getLinks({3331 semanticObject: oFixture.sSemanticObject,3332 params: oFixture.mBusinessParams,3333 appStateKey: oFixture.sAppStateKey,3334 ignoreFormFactor: oFixture.bIgnoreFormFactor3335 }).done(function (aResultSemanticObjectLinksNew) {3336 ok(true, "nominal parameters call promise was resolved");3337 testExcludeTileIntentArgument(oSrvc, true);3338 deepEqual(aResultSemanticObjectLinksNew, aResultSemanticObjectLinksOld,3339 "the new call with nominal parameters returns the same result as the call with positional parameters");3340 deepEqual(aResultSemanticObjectLinksNew, oFixture.expectedSemanticObjectLinks,3341 "the new call with positional parameters returns the expected results");3342 deepEqual(aResultSemanticObjectLinksOld, oFixture.expectedSemanticObjectLinks,3343 "the old call with positional parameters returns the expected results");3344 }).fail(function () {3345 ok(false, "nominal parameters call promise was resolved");3346 }).always(function () {3347 testExpectedErrorAndWarningCalls(oFixture);3348 });3349 })3350 .fail(function () {3351 // Assert3352 ok(false, "positional parameters call promise was resolved");3353 })3354 .always(function () {3355 start();3356 });3357 }3358 });3359 });3360 // Test getLinks( ... ) called with 'tags' constraints3361 QUnit.test("getLinks: propagates the tags argument to _getLinks, then to _getMatchingInbounds", function (assert) {3362 var fnDone = assert.async();3363 var oCSTRService = createService();3364 sinon.spy(oCSTRService, "_getLinks");3365 sinon.stub(oCSTRService, "_getMatchingInbounds").returns(jQuery.when([ ]));3366 oCSTRService.getLinks({3367 semanticObject: "Action",3368 tags: [3369 "tag-A",3370 "tag-B",3371 "tag-C"3372 ] })3373 .then(function () {3374 assert.ok(oCSTRService._getLinks.calledOnce, "Calling getLinks consequently calls _getLinks internally");3375 assert.deepEqual(oCSTRService._getLinks.getCall(0).args[0].tags, [3376 "tag-A",3377 "tag-B",3378 "tag-C"3379 ], "_getLinks is called with tags");3380 assert.ok(oCSTRService._getMatchingInbounds.calledOnce, "Calling getLinks consequently calls _getMatchingInbounds internally");3381 assert.deepEqual(oCSTRService._getMatchingInbounds.getCall(0).args[2].tags, [3382 "tag-A",3383 "tag-B",3384 "tag-C"3385 ], "_getMatchingInbounds is called with tags");3386 })3387 .then(function () {3388 oCSTRService._getLinks.restore();3389 oCSTRService._getMatchingInbounds.restore();3390 return;3391 })3392 .then(fnDone, fnDone);3393 });3394 (function () {3395 var oBaseInboundGUI = {3396 "semanticObject": "GUI",3397 "action": "display",3398 "title": "Change Actual Assessment Cycle G/L",3399 "icon": "sap-icon://Fiori2/F0021",3400 "resolutionResult": {3401 "sap.gui": {3402 "_version": "1.2.0",3403 "transaction": "FAGLGA12"3404 },3405 "applicationType": "TR",3406 "systemAlias": "",3407 "text": "Change Actual Assessment Cycle G/L"3408 },3409 "deviceTypes": {3410 "desktop": true,3411 "tablet": false,3412 "phone": false3413 },3414 "signature": {3415 "additionalParameters": "ignored",3416 "parameters": {}3417 },3418 "tileResolutionResult": {3419 "title": "Change Actual Assessment Cycle G/L",3420 "icon": "sap-icon://Fiori2/F0021",3421 "tileComponentLoadInfo": "#Shell-staticTile",3422 "technicalInformation": "FAGLGA12",3423 "isCustomTile": false3424 }3425 };3426 var oBaseInboundWDA = {3427 "semanticObject": "WDA",3428 "action": "display",3429 "title": "Statistical Key Figures",3430 "info": "Accessible",3431 "icon": "sap-icon://Fiori2/F0021",3432 "subTitle": "Actuals",3433 "resolutionResult": {3434 "sap.wda": {3435 "_version": "1.2.0",3436 "applicationId": "FIS_FPM_OVP_STKEYFIGITEMCO",3437 "configId": "FIS_FPM_OVP_STKEYFIGITEMCO"3438 },3439 "applicationType": "WDA",3440 "systemAlias": "",3441 "systemAliasSemantics": "apply",3442 "text": "Statistical Key Figures"3443 },3444 "deviceTypes": { "desktop": true, "tablet": false, "phone": false },3445 "signature": {3446 "additionalParameters": "allowed",3447 "parameters": {}3448 },3449 "tileResolutionResult": {3450 "title": "Statistical Key Figures",3451 "subTitle": "Actuals",3452 "icon": "sap-icon://Fiori2/F0021",3453 "info": "Accessible",3454 "tileComponentLoadInfo": "#Shell-staticTile",3455 "description": "Accessible",3456 "technicalInformation": "FIS_FPM_OVP_STKEYFIGITEMCO",3457 "isCustomTile": false3458 }3459 };3460 var oBaseInboundUI5 = {3461 "semanticObject": "SemanticObject",3462 "action": "action",3463 "title": "Title",3464 "resolutionResult": {3465 "applicationType": "SAPUI5",3466 "additionalInformation": "SAPUI5.Component=sap.ushell.demo.Inbound",3467 "text": "Text",3468 "ui5ComponentName": "sap.ushell.demo.Inbound",3469 "applicationDependencies": {3470 "name": "sap.ushell.demo.Inbound",3471 "self": {3472 "name": "sap.ushell.demo.Inbound"3473 }3474 },3475 "url": "/sap/bc/ui5_demokit/test-resources/sap/ushell/demoapps/AppNavSample",3476 "systemAlias": ""3477 },3478 "deviceTypes": {3479 "desktop": true,3480 "tablet": true,3481 "phone": true3482 },3483 "signature": {3484 "additionalParameters": "allowed",3485 "parameters": {}3486 }3487 };3488 var oTestInbounds = {3489 "wda": jQuery.extend(true, {}, oBaseInboundWDA),3490 "gui": jQuery.extend(true, {}, oBaseInboundGUI),3491 "basic": jQuery.extend(true, {}, oBaseInboundUI5, {3492 semanticObject: "Object",3493 action: "action",3494 tileResolutionResult: {3495 "key": "valueBasic", // any tileResolutionResult3496 navigationMode: "embedded",3497 startupParameters: {}3498 }3499 }),3500 "with_required_parameter_filter_value": jQuery.extend(true, {}, oBaseInboundUI5, {3501 semanticObject: "Object",3502 action: "withParameters",3503 tileResolutionResult: {3504 "key": "valueRequired",3505 navigationMode: "embedded",3506 startupParameters: {3507 "P1": ["V1"]3508 }3509 },3510 signature: {3511 "additionalParameters": "notallowed",3512 "parameters": {3513 "P1": {3514 required: true,3515 filter: { value: "V1" }3516 },3517 "PTOBERENAMED": {3518 renameTo: "IWASRENAMED"3519 }3520 }3521 }3522 }),3523 "with_required_parameter_filter_valueAndRename": jQuery.extend(true, {}, oBaseInboundUI5, {3524 semanticObject: "Object",3525 action: "withParameters",3526 tileResolutionResult: {3527 "key": "valueRequired",3528 navigationMode: "embedded",3529 startupParameters: {3530 "P1": ["V1"],3531 "IWASRENAMED": ["V2"]3532 }3533 },3534 signature: {3535 "additionalParameters": "notallowed",3536 "parameters": {3537 "P1": {3538 required: true,3539 filter: { value: "V1" }3540 },3541 "PTOBERENAMED": {3542 renameTo: "IWASRENAMED"3543 }3544 }3545 }3546 })3547 };3548 [3549 {3550 testType: "success", // the scenario under test3551 testDescription: "no parameters inbound with tileResolutionResult section is provided",3552 sIntent: "#Object-action",3553 aInbounds: [oTestInbounds.basic],3554 expectedResolutionResult: oTestInbounds.basic.tileResolutionResult3555 },3556 {3557 testType: "success",3558 testDescription: "inbound with parameters and tileResolutionResult section is provided",3559 sIntent: "#Object-withParameters?P1=V1",3560 aInbounds: [3561 oTestInbounds.basic,3562 oTestInbounds.with_required_parameter_filter_value3563 ],3564 expectedResolutionResult: oTestInbounds.with_required_parameter_filter_value.tileResolutionResult3565 },3566 {3567 testType: "success",3568 testDescription: "inbound with parameters and tileResolutionResult section is provided an rename to parameter is provided",3569 sIntent: "#Object-withParameters?P1=V1&PTOBERENAMED=V2",3570 aInbounds: [3571 oTestInbounds.basic,3572 oTestInbounds.with_required_parameter_filter_value3573 ],3574 expectedResolutionResult: oTestInbounds.with_required_parameter_filter_valueAndRename.tileResolutionResult3575 },3576 {3577 testType: "success",3578 testDescription: "wda target is provided",3579 sIntent: "#WDA-display",3580 aInbounds: [3581 oTestInbounds.wda3582 ],3583 expectedResolutionResult: jQuery.extend(true, {3584 navigationMode: "newWindowThenEmbedded",3585 startupParameters: undefined3586 }, oTestInbounds.wda.tileResolutionResult)3587 },3588 {3589 testType: "success",3590 testDescription: "gui target is provided",3591 sIntent: "#GUI-display",3592 aInbounds: [3593 oTestInbounds.gui3594 ],3595 expectedResolutionResult: jQuery.extend(true, {3596 navigationMode: "newWindowThenEmbedded",3597 startupParameters: undefined3598 }, oTestInbounds.gui.tileResolutionResult)3599 },3600 {3601 testType: "failure",3602 testDescription: "invalid shell hash passed",3603 sIntent: "#ObjectwithParameters?P1=V1",3604 aInbounds: [],3605 expectedRejectMessage: "Cannot parse shell hash",3606 expectedErrorCallArgs: [3607 "Could not parse shell hash '#ObjectwithParameters?P1=V1'",3608 "please specify a valid shell hash",3609 "sap.ushell.services.ClientSideTargetResolution"3610 ]3611 },3612 {3613 testType: "failure",3614 testDescription: "_getMatchingInbounds fails",3615 testSimulateFailingGetMatchingInbounds: true,3616 sIntent: "#Object-action",3617 aInbounds: [],3618 expectedRejectMessage: "Deliberate failure",3619 expectedErrorCallArgs: [3620 "Could not resolve #Object-action",3621 "_getMatchingInbounds promise rejected with: Deliberate failure",3622 "sap.ushell.services.ClientSideTargetResolution"3623 ]3624 },3625 {3626 testType: "failure",3627 testDescription: "there are no matching targets",3628 sIntent: "#Object-action",3629 aInbounds: [], // deliberately provide empty inbounds here3630 expectedRejectMessage: "No matching targets found",3631 expectedWarningCallArgs: [3632 "Could not resolve #Object-action",3633 "no matching targets were found",3634 "sap.ushell.services.ClientSideTargetResolution"3635 ]3636 }3637 ].forEach(function (oFixture) {3638 asyncTest("resolveTileIntent resolves as expected when " + oFixture.testDescription, function () {3639 var aFixtureInboundsClone = oFixture.aInbounds.map(function (oInbound) {3640 return jQuery.extend(true, {}, oInbound);3641 });3642 var oSrvc = createService({3643 adapter: {3644 hasSegmentedAccess: false,3645 resolveSystemAlias: function (sSystemAlias) {3646 if (sSystemAlias === "") {3647 return new jQuery.Deferred().resolve(oTestHelper.getLocalSystemAlias()).promise();3648 }3649 throw new Error("Test does not mock resolving other system aliases than the local system alias");3650 },3651 getInbounds: sinon.stub().returns(new jQuery.Deferred().resolve(oFixture.aInbounds).promise())3652 }3653 });3654 if (oFixture.testSimulateFailingGetMatchingInbounds) {3655 sinon.stub(oSrvc, "_getMatchingInbounds").returns(3656 new jQuery.Deferred().reject("Deliberate failure").promise()3657 );3658 }3659 var oMockedServices = { // NOTE: any service that is not in this object is not allowed3660 AppState: true,3661 URLParsing: true,3662 ShellNavigation: {3663 compactParams: function () { return new jQuery.Deferred().resolve({}).promise(); }3664 },3665 UserInfo: {3666 getUser: sinon.stub().returns({3667 getLanguage: sinon.stub().returns("DE"),3668 getContentDensity: sinon.stub().returns("cozy")3669 })3670 }3671 };3672 var fnGetServiceOrig = sap.ushell.Container.getService;3673 sinon.stub(sap.ushell.Container, "getService", function (sName) {3674 if (!oMockedServices.hasOwnProperty(sName)) {3675 ok(false, "Test is not accessing " + sName);3676 }3677 // return the result of the real service call3678 if (oMockedServices[sName] === true) {3679 return fnGetServiceOrig.call(sap.ushell.Container, sName);3680 }3681 // return mocked service3682 return oMockedServices[sName];3683 });3684 sinon.stub(jQuery.sap.log, "warning");3685 sinon.stub(jQuery.sap.log, "error");3686 oSrvc.resolveTileIntent(oFixture.sIntent)3687 .done(function (oResolvedTileIntent) {3688 if (oFixture.testType === "failure") {3689 ok(false, "promise was rejected");3690 } else {3691 ok(true, "promise was resolved");3692 deepEqual(oResolvedTileIntent, oFixture.expectedResolutionResult,3693 "obtained the expected resolution result");3694 }3695 })3696 .fail(function (sError) {3697 if (oFixture.testType === "failure") {3698 ok(true, "promise was rejected");3699 strictEqual(sError, oFixture.expectedRejectMessage,3700 "obtained the expected error message");3701 // warnings3702 if (!oFixture.expectedWarningCallArgs) {3703 strictEqual(jQuery.sap.log.warning.getCalls().length, 0,3704 "jQuery.sap.log.warning was not called");3705 } else {3706 strictEqual(jQuery.sap.log.warning.getCalls().length, 1,3707 "jQuery.sap.log.warning was called 1 time");3708 deepEqual(3709 jQuery.sap.log.warning.getCall(0).args,3710 oFixture.expectedWarningCallArgs,3711 "jQuery.sap.log.warning was called with the expected arguments"3712 );3713 }3714 // errors3715 if (!oFixture.expectedErrorCallArgs) {3716 strictEqual(jQuery.sap.log.error.getCalls().length, 0,3717 "jQuery.sap.log.error was not called");3718 } else {3719 strictEqual(jQuery.sap.log.error.getCalls().length, 1,3720 "jQuery.sap.log.error was called 1 time");3721 deepEqual(3722 jQuery.sap.log.error.getCall(0).args,3723 oFixture.expectedErrorCallArgs,3724 "jQuery.sap.log.error was called with the expected arguments"3725 );3726 }3727 } else {3728 ok(false, "promise was resolved without " + sError);3729 }3730 })3731 .always(function () {3732 deepEqual(oFixture.aInbounds, aFixtureInboundsClone,3733 "inbounds provided by getInbounds are not modified by resolveTileIntent");3734 start();3735 });3736 });3737 });3738 })();3739//##3740(function () {3741 /*3742 * Complete test for getLinks3743 */3744 var oTestInbounds = {3745 "ui5InboundWithEmptyURL": {3746 "semanticObject": "Action",3747 "action": "toui5nourl",3748 "id": "Action-toui5nourl~6r8",3749 "title": "UI5 Target without URL",3750 "subTitle": "sub Title",3751 "shortTitle": "short Title",3752 "icon": "sap-icon://Fiori2/F0018",3753 "resolutionResult": {3754 "applicationType": "SAPUI5",3755 "additionalInformation": "SAPUI5.Component=sap.ushell.demo.AppNavSample",3756 "text": "No URL",3757 "ui5ComponentName": "sap.ushell.demo.AppNavSample",3758 "applicationDependencies": {3759 "name": "sap.ushell.demo.AppNavSample",3760 "self": {3761 "name": "sap.ushell.demo.AppNavSample"3762 }3763 },3764 "url": "", // NOTE: no URL!3765 "systemAlias": ""3766 },3767 "deviceTypes": {3768 "desktop": true,3769 "tablet": true,3770 "phone": true3771 },3772 "signature": {3773 "additionalParameters": "allowed",3774 "parameters": {}3775 },3776 "compactSignature": "<no params><+>"3777 },3778 "noParamsNoAdditionalAllowed": {3779 "semanticObject": "Action",3780 "action": "toappnavsample",3781 "id": "Action-toappnavsample~6r8",3782 "title": "App Navigation Sample 1",3783 "subTitle": "sub Title",3784 "shortTitle": "short Title",3785 "icon": "sap-icon://Fiori2/F0018",3786 "resolutionResult": {3787 "applicationType": "SAPUI5",3788 "additionalInformation": "SAPUI5.Component=sap.ushell.demo.AppNavSample",3789 "text": "App Navigation Sample 1",3790 "ui5ComponentName": "sap.ushell.demo.AppNavSample",3791 "applicationDependencies": {3792 "name": "sap.ushell.demo.AppNavSample",3793 "self": {3794 "name": "sap.ushell.demo.AppNavSample"3795 }3796 },3797 "url": "/sap/bc/ui5_demokit/test-resources/sap/ushell/demoapps/AppNavSample",3798 "systemAlias": ""3799 },3800 "deviceTypes": {3801 "desktop": true,3802 "tablet": true,3803 "phone": true3804 },3805 "signature": {3806 "additionalParameters": "ignored",3807 "parameters": {}3808 },3809 "compactSignature": "<no params><+>"3810 },3811 "noParamsAdditionalAllowed": {3812 "semanticObject": "Action",3813 "action": "toappnavsample",3814 "id": "Action-toappnavsample~6r8",3815 "title": "App Navigation Sample 1",3816 "subTitle": "sub Title",3817 "shortTitle": "short Title",3818 "icon": "sap-icon://Fiori2/F0018",3819 "resolutionResult": {3820 "applicationType": "SAPUI5",3821 "additionalInformation": "SAPUI5.Component=sap.ushell.demo.AppNavSample",3822 "text": "App Navigation Sample 1",3823 "ui5ComponentName": "sap.ushell.demo.AppNavSample",3824 "applicationDependencies": {3825 "name": "sap.ushell.demo.AppNavSample",3826 "self": {3827 "name": "sap.ushell.demo.AppNavSample"3828 }3829 },3830 "url": "/sap/bc/ui5_demokit/test-resources/sap/ushell/demoapps/AppNavSample",3831 "systemAlias": ""3832 },3833 "deviceTypes": {3834 "desktop": true,3835 "tablet": true,3836 "phone": true3837 },3838 "signature": {3839 "additionalParameters": "allowed",3840 "parameters": {}3841 },3842 "compactSignature": "<no params><+>"3843 },3844 "requiredParamWithDefaultRenamed": {3845 "semanticObject": "Action",3846 "action": "parameterRename",3847 "id": "Action-parameterRename~67xE",3848 "title": "Parameter Rename",3849 "subTitle": "sub Title",3850 "shortTitle": "short Title",3851 "icon": "Parameter Rename icon",3852 "resolutionResult": {3853 "applicationType": "SAPUI5",3854 "additionalInformation": "SAPUI5.Component=sap.ushell.demo.ReceiveParametersTestApp",3855 "text": "Display received parameters (Case 3, Collision)",3856 "ui5ComponentName": "sap.ushell.demo.ReceiveParametersTestApp",3857 "applicationDependencies": {3858 "name": "sap.ushell.demo.ReceiveParametersTestApp",3859 "self": {3860 "name": "sap.ushell.demo.ReceiveParametersTestApp"3861 }3862 },3863 "url": "/sap/bc/ui5_demokit/test-resources/sap/ushell/demoapps/ReceiveParametersTestApp",3864 "systemAlias": ""3865 },3866 "deviceTypes": {3867 "desktop": true,3868 "tablet": true,3869 "phone": true3870 },3871 "signature": {3872 "additionalParameters": "allowed",3873 "parameters": {3874 "PREQ": {3875 "required": true3876 },3877 "P1": {3878 "renameTo": "P2New",3879 "required": false3880 },3881 "P2": {3882 "renameTo": "P2New",3883 "required": false3884 }3885 }3886 },3887 "compactSignature": "Case:3;[Description:[P1-> P2New; P2-> P2New]];[P1:];[P2:]<+>"3888 },3889 "noParamsAllowed": {3890 "semanticObject": "Action",3891 "action": "noparametersAllowed",3892 "id": "Action-parameterRename~67xE",3893 "title": "No parameters allowed",3894 "subTitle": "sub Title",3895 "shortTitle": "short Title",3896 "icon": "No parameters allowed icon",3897 "resolutionResult": {3898 "applicationType": "SAPUI5",3899 "additionalInformation": "SAPUI5.Component=sap.ushell.demo.ReceiveParametersTestApp",3900 "text": "Display received parameters (Case 3, Collision)",3901 "ui5ComponentName": "sap.ushell.demo.ReceiveParametersTestApp",3902 "applicationDependencies": {3903 "name": "sap.ushell.demo.ReceiveParametersTestApp",3904 "self": {3905 "name": "sap.ushell.demo.ReceiveParametersTestApp"3906 }3907 },3908 "url": "/sap/bc/ui5_demokit/test-resources/sap/ushell/demoapps/ReceiveParametersTestApp",3909 "systemAlias": ""3910 },3911 "deviceTypes": {3912 "desktop": true,3913 "tablet": true,3914 "phone": true3915 },3916 "signature": {3917 "additionalParameters": "notallowed",3918 "parameters": {}3919 },3920 "compactSignature": "Case:3;[Description:[P1-> P2New; P2-> P2New]];[P1:];[P2:]<+>"3921 },3922 "ignoredParamsAndDefaultParameter": {3923 "semanticObject": "Object",3924 "action": "ignoredParameters",3925 "id": "Action-parameterRename~67xE",3926 "title": "No parameters allowed",3927 "subTitle": "sub Title",3928 "shortTitle": "short Title",3929 "icon": "No parameters allowed icon",3930 "resolutionResult": {3931 "applicationType": "SAPUI5",3932 "additionalInformation": "SAPUI5.Component=sap.ushell.demo.ReceiveParametersTestApp",3933 "text": "Ignored parameters",3934 "ui5ComponentName": "sap.ushell.demo.ReceiveParametersTestApp",3935 "applicationDependencies": {3936 "name": "sap.ushell.demo.ReceiveParametersTestApp",3937 "self": {3938 "name": "sap.ushell.demo.ReceiveParametersTestApp"3939 }3940 },3941 "url": "/sap/bc/ui5_demokit/test-resources/sap/ushell/demoapps/ReceiveParametersTestApp",3942 "systemAlias": ""3943 },3944 "deviceTypes": {3945 "desktop": true,3946 "tablet": true,3947 "phone": true3948 },3949 "signature": {3950 "additionalParameters": "ignored",3951 "parameters": {3952 "P1": {3953 "required": false,3954 "defaultValue": {3955 format: "plain",3956 value: "DEFV"3957 }3958 }3959 }3960 },3961 "compactSignature": "Case:3;[Description:[P1-> P2New; P2-> P2New]];[P1:];[P2:]<+>"3962 },3963 "starAction": {3964 "semanticObject": "ActionStar",3965 "action": "*", // <- should be never returned in a getLinks call!3966 "id": "Star-*~683P",3967 "title": "Target Mapping with * as action",3968 "subTitle": "sub Title",3969 "shortTitle": "short Title",3970 "icon": "icon with * as action",3971 "resolutionResult": {3972 "applicationType": "URL",3973 "additionalInformation": "",3974 "text": "StarAction",3975 "url": "http://www.google.com",3976 "systemAlias": ""3977 },3978 "deviceTypes": {3979 "desktop": true,3980 "tablet": true,3981 "phone": true3982 },3983 "signature": {3984 "additionalParameters": "allowed",3985 "parameters": {}3986 },3987 "compactSignature": "<no params><+>"3988 },3989 "starSemanticObject": {3990 "semanticObject": "*", // <- should be never returned in a getLinks call!3991 "action": "starSemanticObject",3992 "id": "Star-*~683P",3993 "title": "Target Mapping with * as semanticObject",3994 "subTitle": "sub Title",3995 "shortTitle": "short Title",3996 "icon": "icon with * as semanticObject",3997 "resolutionResult": {3998 "applicationType": "URL",3999 "additionalInformation": "",4000 "text": "StarAction",4001 "url": "http://www.google.com",4002 "systemAlias": ""4003 },4004 "deviceTypes": {4005 "desktop": true,4006 "tablet": true,4007 "phone": true4008 },4009 "signature": {4010 "additionalParameters": "allowed",4011 "parameters": {}4012 },4013 "compactSignature": "<no params><+>"4014 },4015 "twoDefaultParametersAdditionalAllowed": {4016 "semanticObject": "Object",4017 "action": "twoDefaultParameters",4018 "title": "Two Default Parameters",4019 "subTitle": "sub Title",4020 "shortTitle": "short Title",4021 "icon": "Two Default Parameters icon",4022 "resolutionResult": { /* doesn't matter */ },4023 "deviceTypes": { "desktop": true, "tablet": true, "phone": true },4024 "signature": {4025 "additionalParameters": "allowed",4026 "parameters": {4027 "P1": { defaultValue: { value: "V1" } },4028 "P2": { defaultValue: { value: "V2" } }4029 }4030 }4031 },4032 "threeDefaultParametersAdditionalAllowed": {4033 "semanticObject": "Object",4034 "action": "threeDefaultParameters",4035 "title": "Three Default Parameters",4036 "subTitle": "sub Title",4037 "shortTitle": "short Title",4038 "icon": "Three Default Parameters icon",4039 "resolutionResult": { /* doesn't matter */ },4040 "deviceTypes": { "desktop": true, "tablet": true, "phone": true },4041 "signature": {4042 "additionalParameters": "allowed",4043 "parameters": {4044 "P1": { defaultValue: { value: "V1" } },4045 "P2": { defaultValue: { value: "V2" } },4046 "P3": { defaultValue: { value: "V3" } }4047 }4048 }4049 },4050 "appWithUI5": {4051 "semanticObject": "PickTechnology",4052 "action": "pickTech",4053 "id": "PickTechnology",4054 "title": "Pick Technology (UI5)",4055 "subTitle": "sub Title",4056 "shortTitle": "short Title",4057 "icon": "Pick Technology (UI5) icon",4058 "resolutionResult": {4059 "applicationType": "SAPUI5",4060 "additionalInformation": "SAPUI5.Component=sap.ushell.demo.ReceiveParametersTestApp",4061 "text": "Ignored parameters",4062 "ui5ComponentName": "sap.ushell.demo.ReceiveParametersTestApp",4063 "applicationDependencies": {4064 "name": "sap.ushell.demo.ReceiveParametersTestApp",4065 "self": {4066 "name": "sap.ushell.demo.ReceiveParametersTestApp"4067 }4068 },4069 "url": "/sap/bc/ui5_demokit/test-resources/sap/ushell/demoapps/ReceiveParametersTestApp",4070 "systemAlias": "",4071 "sap.ui": {4072 "technology": "UI5"4073 }4074 },4075 "deviceTypes": {4076 "desktop": true,4077 "tablet": true,4078 "phone": true4079 },4080 "signature": {4081 "additionalParameters": "ignored",4082 "parameters": {4083 "P1": {4084 "required": false,4085 "defaultValue": {4086 format: "plain",4087 value: "DEFV"4088 }4089 }4090 }4091 },4092 "compactSignature": "Case:3;[Description:[P1-> P2New; P2-> P2New]];[P1:];[P2:]<+>"4093 },4094 "appWithWDA": {4095 "semanticObject": "PickTechnology",4096 "action": "pickTech",4097 "id": "PickTechnology",4098 "title": "Pick Technology (WDA)",4099 "subTitle": "sub Title",4100 "shortTitle": "short Title",4101 "icon": "Pick Technology (WDA) icon",4102 "resolutionResult": {4103 "applicationType": "WDA",4104 "additionalInformation": "",4105 "text": "Ignored parameters",4106 "applicationDependencies": {},4107 "url": "/sap/bc/nwbc/somewhereametersTestApp",4108 "systemAlias": "",4109 "sap.ui": {4110 "technology": "WDA"4111 }4112 },4113 "deviceTypes": {4114 "desktop": true,4115 "tablet": true,4116 "phone": true4117 },4118 "signature": {4119 "additionalParameters": "ignored",4120 "parameters": {4121 "P1": {4122 "required": false,4123 "defaultValue": {4124 format: "plain",4125 value: "DEFV"4126 }4127 }4128 }4129 },4130 "compactSignature": "Case:3;[Description:[P1-> P2New; P2-> P2New]];[P1:];[P2:]<+>"4131 }4132 };4133 [4134 { testDescription: "UI5 inbound with empty URL is provided",4135 aInbounds: [4136 oTestInbounds.ui5InboundWithEmptyURL4137 ],4138 aCallArgs: [{4139 semanticObject: "Action",4140 action: "toui5nourl"4141 }],4142 expectedResult: [{4143 "intent": "#Action-toui5nourl",4144 "text": "UI5 Target without URL",4145 "icon": "sap-icon://Fiori2/F0018",4146 "subTitle": "sub Title",4147 "shortTitle": "short Title"4148 }]4149 },4150 {4151 testDescription: "semantic object and action provided",4152 aInbounds: [4153 oTestInbounds.noParamsAdditionalAllowed,4154 oTestInbounds.requiredParamWithDefaultRenamed,4155 oTestInbounds.noParamsAllowed,4156 oTestInbounds.ignoredParamsAndDefaultParameter,4157 oTestInbounds.starAction,4158 oTestInbounds.starSemanticObject4159 ],4160 aCallArgs: [{4161 semanticObject: "Action",4162 action: "toappnavsample"4163 }],4164 expectedResult: [{4165 "intent": "#Action-toappnavsample",4166 "text": "App Navigation Sample 1",4167 "icon": "sap-icon://Fiori2/F0018",4168 "subTitle": "sub Title",4169 "shortTitle": "short Title"4170 }]4171 },4172 {4173 testDescription: "only parameters are provided",4174 aInbounds: [4175 oTestInbounds.noParamsAdditionalAllowed,4176 oTestInbounds.requiredParamWithDefaultRenamed,4177 oTestInbounds.noParamsAllowed,4178 oTestInbounds.ignoredParamsAndDefaultParameter,4179 oTestInbounds.starAction,4180 oTestInbounds.starSemanticObject4181 ],4182 aCallArgs: [{4183 // if CrossApplicationNavigation#getLinks was called, the4184 // presence of action is guaranteed.4185 action: undefined,4186 params: {4187 "PREQ": "valA",4188 "P1": ["val1"],4189 "P2": ["val2"]4190 }4191 }],4192 expectedResult: [{4193 "intent": "#Action-parameterRename?P1=val1&P2=val2&PREQ=valA",4194 "text": "Parameter Rename",4195 "icon": "Parameter Rename icon",4196 "subTitle": "sub Title",4197 "shortTitle": "short Title"4198 }, {4199 "intent": "#Action-toappnavsample?P1=val1&P2=val2&PREQ=valA",4200 "text": "App Navigation Sample 1",4201 "icon": "sap-icon://Fiori2/F0018",4202 "subTitle": "sub Title",4203 "shortTitle": "short Title"4204 }, {4205 "intent": "#Object-ignoredParameters?P1=val1",4206 "text": "No parameters allowed",4207 "icon": "No parameters allowed icon",4208 "subTitle": "sub Title",4209 "shortTitle": "short Title"4210 }]4211 },4212 {4213 testDescription: "no arguments are provided",4214 aInbounds: [4215 oTestInbounds.noParamsAdditionalAllowed,4216 oTestInbounds.requiredParamWithDefaultRenamed,4217 oTestInbounds.noParamsAllowed,4218 oTestInbounds.ignoredParamsAndDefaultParameter,4219 oTestInbounds.starAction,4220 oTestInbounds.starSemanticObject4221 ],4222 aCallArgs: [{4223 // if CrossApplicationNavigation#getLinks was called, the4224 // presence of action is guaranteed.4225 action: undefined4226 }],4227 expectedResult: [{4228 "intent": "#Action-noparametersAllowed",4229 "text": "No parameters allowed",4230 "icon": "No parameters allowed icon",4231 "subTitle": "sub Title",4232 "shortTitle": "short Title"4233 }, {4234 "intent": "#Action-toappnavsample",4235 "text": "App Navigation Sample 1",4236 "icon": "sap-icon://Fiori2/F0018",4237 "subTitle": "sub Title",4238 "shortTitle": "short Title"4239 }, {4240 "intent": "#Object-ignoredParameters",4241 "text": "No parameters allowed",4242 "icon": "No parameters allowed icon",4243 "subTitle": "sub Title",4244 "shortTitle": "short Title"4245 }]4246 },4247 {4248 testDescription: "only semantic object is provided",4249 aInbounds: [4250 oTestInbounds.noParamsAdditionalAllowed,4251 oTestInbounds.requiredParamWithDefaultRenamed,4252 oTestInbounds.noParamsAllowed,4253 oTestInbounds.ignoredParamsAndDefaultParameter,4254 oTestInbounds.starAction,4255 oTestInbounds.starSemanticObject4256 ],4257 aCallArgs: [{4258 // if CrossApplicationNavigation#getLinks was called, the4259 // presence of action is guaranteed.4260 action: undefined,4261 semanticObject: "Object"4262 }],4263 expectedResult: [{4264 "intent": "#Object-ignoredParameters",4265 "text": "No parameters allowed",4266 "icon": "No parameters allowed icon",4267 "subTitle": "sub Title",4268 "shortTitle": "short Title"4269 }, {4270 "intent": "#Object-starSemanticObject",4271 "text": "Target Mapping with * as semanticObject",4272 "icon": "icon with * as semanticObject",4273 "subTitle": "sub Title",4274 "shortTitle": "short Title"4275 }]4276 },4277 {4278 testDescription: "only action is provided",4279 aInbounds: [4280 oTestInbounds.noParamsAdditionalAllowed,4281 oTestInbounds.requiredParamWithDefaultRenamed,4282 oTestInbounds.noParamsAllowed,4283 oTestInbounds.ignoredParamsAndDefaultParameter,4284 oTestInbounds.starAction,4285 oTestInbounds.starSemanticObject4286 ],4287 aCallArgs: [{4288 action: "toappnavsample"4289 }],4290 expectedResult: [{4291 "intent": "#Action-toappnavsample",4292 "text": "App Navigation Sample 1",4293 "icon": "sap-icon://Fiori2/F0018",4294 "subTitle": "sub Title",4295 "shortTitle": "short Title"4296 }]4297 },4298 {4299 testDescription: "semantic object and parameters are provided",4300 aInbounds: [4301 oTestInbounds.noParamsAdditionalAllowed,4302 oTestInbounds.requiredParamWithDefaultRenamed,4303 oTestInbounds.noParamsAllowed,4304 oTestInbounds.ignoredParamsAndDefaultParameter,4305 oTestInbounds.starAction,4306 oTestInbounds.starSemanticObject4307 ],4308 aCallArgs: [{4309 // if CrossApplicationNavigation#getLinks was called, the4310 // presence of action is guaranteed.4311 action: undefined,4312 semanticObject: "Object",4313 params: {4314 "P1": "VDEFINED1"4315 }4316 }],4317 expectedResult: [{4318 "intent": "#Object-ignoredParameters?P1=VDEFINED1",4319 "text": "No parameters allowed",4320 "icon": "No parameters allowed icon",4321 "subTitle": "sub Title",4322 "shortTitle": "short Title"4323 }, {4324 "intent": "#Object-starSemanticObject?P1=VDEFINED1",4325 "text": "Target Mapping with * as semanticObject",4326 "icon": "icon with * as semanticObject",4327 "subTitle": "sub Title",4328 "shortTitle": "short Title"4329 }]4330 },4331 {4332 testDescription: "a '*' semantic object is provided",4333 aInbounds: [4334 oTestInbounds.noParamsAdditionalAllowed,4335 oTestInbounds.requiredParamWithDefaultRenamed,4336 oTestInbounds.noParamsAllowed,4337 oTestInbounds.ignoredParamsAndDefaultParameter,4338 oTestInbounds.starAction,4339 oTestInbounds.starSemanticObject4340 ],4341 aCallArgs: [{4342 // if CrossApplicationNavigation#getLinks was called, the4343 // presence of action is guaranteed.4344 action: undefined,4345 semanticObject: "*"4346 }],4347 expectedResult: []4348 },4349 {4350 testDescription: "a '*' action is provided",4351 aInbounds: [4352 oTestInbounds.noParamsAdditionalAllowed,4353 oTestInbounds.requiredParamWithDefaultRenamed,4354 oTestInbounds.noParamsAllowed,4355 oTestInbounds.ignoredParamsAndDefaultParameter,4356 oTestInbounds.starAction,4357 oTestInbounds.starSemanticObject4358 ],4359 aCallArgs: [{4360 action: "*"4361 }],4362 expectedResult: []4363 },4364 {4365 testDescription: "withAtLeastOneUsedParam enabled, inbounds with default values provided, one common parameter in intent",4366 aInbounds: [4367 oTestInbounds.twoDefaultParametersAdditionalAllowed, // has P1 and P2 params4368 oTestInbounds.threeDefaultParametersAdditionalAllowed // has P1, P2, P3 params4369 ],4370 aCallArgs: [{4371 // if CrossApplicationNavigation#getLinks was called, the4372 // presence of action is guaranteed.4373 action: undefined,4374 withAtLeastOneUsedParam: true,4375 params: {4376 "P2": ["OURV2"]4377 }4378 }],4379 expectedResult: [{ // both are returned because they share P24380 "intent": "#Object-threeDefaultParameters?P2=OURV2",4381 "text": "Three Default Parameters",4382 "icon": "Three Default Parameters icon",4383 "subTitle": "sub Title",4384 "shortTitle": "short Title"4385 }, {4386 "intent": "#Object-twoDefaultParameters?P2=OURV2",4387 "text": "Two Default Parameters",4388 "icon": "Two Default Parameters icon",4389 "subTitle": "sub Title",4390 "shortTitle": "short Title"4391 }]4392 },4393 {4394 testDescription: "withAtLeastOneUsedParam enabled and inbound with no parameters provided",4395 aInbounds: [4396 oTestInbounds.noParamsAdditionalAllowed4397 ],4398 aCallArgs: [{4399 // if CrossApplicationNavigation#getLinks was called, the4400 // presence of action is guaranteed.4401 action: undefined,4402 withAtLeastOneUsedParam: true,4403 params: {4404 "P1": ["OURV1"]4405 }4406 }],4407 expectedResult: [{4408 "intent": "#Action-toappnavsample?P1=OURV1",4409 "text": "App Navigation Sample 1",4410 "icon": "sap-icon://Fiori2/F0018",4411 "subTitle": "sub Title",4412 "shortTitle": "short Title"4413 }]4414 },4415 {4416 testDescription: "withAtLeastOneUsedParam enabled and inbound with no parameters (and ignored additional parameters) provided",4417 aInbounds: [4418 oTestInbounds.noParamsNoAdditionalAllowed4419 ],4420 aCallArgs: [{4421 // if CrossApplicationNavigation#getLinks was called, the4422 // presence of action is guaranteed.4423 action: undefined,4424 withAtLeastOneUsedParam: true,4425 params: {4426 "P1": ["OURV1"]4427 }4428 }],4429 expectedResult: []4430 },4431 {4432 testDescription: "withAtLeastOneUsedParam disabled and inbound with no parameters (and ignored additional parameters) provided",4433 aInbounds: [4434 oTestInbounds.noParamsNoAdditionalAllowed4435 ],4436 aCallArgs: [{4437 // if CrossApplicationNavigation#getLinks was called, the4438 // presence of action is guaranteed.4439 action: undefined,4440 withAtLeastOneUsedParam: false,4441 params: {4442 "P1": ["OURV1"]4443 }4444 }],4445 expectedResult: [{4446 "intent": "#Action-toappnavsample",4447 "text": "App Navigation Sample 1",4448 "icon": "sap-icon://Fiori2/F0018",4449 "subTitle": "sub Title",4450 "shortTitle": "short Title"4451 }]4452 },4453 {4454 testDescription: "withAtLeastOneUsedParam enabled, sap- parameter provided, and inbound with two parameters (others allowed) provided",4455 aInbounds: [4456 oTestInbounds.twoDefaultParametersAdditionalAllowed, // has P1 and P2 params4457 oTestInbounds.threeDefaultParametersAdditionalAllowed // has P1, P2, P3 params4458 ],4459 aCallArgs: [{4460 // if CrossApplicationNavigation#getLinks was called, the4461 // presence of action is guaranteed.4462 action: undefined,4463 withAtLeastOneUsedParam: true,4464 params: {4465 "sap-param": ["OURV1"] // sap- params don't count4466 }4467 }],4468 expectedResult: []4469 },4470 {4471 testDescription: "semantic object and tech hint GUI as filter provided",4472 aInbounds: [4473 oTestInbounds.noParamsAdditionalAllowed,4474 oTestInbounds.requiredParamWithDefaultRenamed,4475 oTestInbounds.appWithUI5,4476 oTestInbounds.appWithWDA4477 ],4478 aCallArgs: [{4479 // if CrossApplicationNavigation#getLinks was called, the4480 // presence of action is guaranteed.4481 action: undefined,4482 semanticObject: "PickTechnology",4483 treatTechHintAsFilter: false,4484 params: {4485 "sap-ui-tech-hint": ["GUI"]4486 }4487 }],4488 expectedResult: [{4489 "intent": "#PickTechnology-pickTech?sap-ui-tech-hint=GUI",4490 "text": "Pick Technology (UI5)",4491 "icon": "Pick Technology (UI5) icon",4492 "subTitle": "sub Title",4493 "shortTitle": "short Title"4494 }]4495 },4496 {4497 testDescription: "semantic object and tech hint as filter WDA provided",4498 aInbounds: [4499 oTestInbounds.noParamsAdditionalAllowed,4500 oTestInbounds.requiredParamWithDefaultRenamed,4501 oTestInbounds.noParamsAllowed,4502 oTestInbounds.ignoredParamsAndDefaultParameter,4503 oTestInbounds.appWithUI5,4504 oTestInbounds.appWithWDA4505 ],4506 aCallArgs: [{4507 // if CrossApplicationNavigation#getLinks was called, the4508 // presence of action is guaranteed.4509 action: undefined,4510 semanticObject: "PickTechnology",4511 treatTechHintAsFilter: true,4512 params: {4513 "sap-ui-tech-hint": ["WDA"]4514 }4515 }],4516 expectedResult: [{4517 "intent": "#PickTechnology-pickTech?sap-ui-tech-hint=WDA",4518 "text": "Pick Technology (WDA)",4519 "icon": "Pick Technology (WDA) icon",4520 "subTitle": "sub Title",4521 "shortTitle": "short Title"4522 }]4523 },4524 {4525 testDescription: "semantic object and tech hint treatTechHintAsFilter GUI (not present)",4526 aInbounds: [4527 oTestInbounds.noParamsAdditionalAllowed,4528 oTestInbounds.requiredParamWithDefaultRenamed,4529 oTestInbounds.noParamsAllowed,4530 oTestInbounds.ignoredParamsAndDefaultParameter,4531 oTestInbounds.appWithUI5,4532 oTestInbounds.appWithWDA4533 ],4534 aCallArgs: [{4535 // if CrossApplicationNavigation#getLinks was called, the4536 // presence of action is guaranteed.4537 action: undefined,4538 semanticObject: "PickTechnology",4539 treatTechHintAsFilter: true,4540 params: {4541 "sap-ui-tech-hint": ["GUI"]4542 }4543 }],4544 expectedResult: [4545 ]4546 },4547 {4548 testDescription: "semantic object and tech hint treatTechHintAsFilter GUI (not present)",4549 aInbounds: [4550 oTestInbounds.noParamsAdditionalAllowed,4551 oTestInbounds.requiredParamWithDefaultRenamed,4552 oTestInbounds.noParamsAllowed,4553 oTestInbounds.ignoredParamsAndDefaultParameter,4554 oTestInbounds.appWithUI5,4555 oTestInbounds.appWithWDA4556 ],4557 aCallArgs: [{4558 // if CrossApplicationNavigation#getLinks was called, the4559 // presence of action is guaranteed.4560 action: undefined,4561 semanticObject: "PickTechnology",4562 params: {4563 "sap-ui-tech-hint": ["GUI"]4564 }4565 }],4566 expectedResult: [{4567 "intent": "#PickTechnology-pickTech?sap-ui-tech-hint=GUI",4568 "text": "Pick Technology (UI5)",4569 "icon": "Pick Technology (UI5) icon",4570 "subTitle": "sub Title",4571 "shortTitle": "short Title"4572 }]4573 },4574 {4575 testDescription: "2 'superior' tags are specified",4576 aInbounds: [4577 oTestHelper.createInbound("#SO-act1{<no params><o>}"),4578 oTestHelper.createInbound("#SO-act2{[sap-tag:[superior]]<o>}"),4579 oTestHelper.createInbound("#SO-act3{[sap-tag:[tag-B]]<o>}"), {4580 "semanticObject": "SO",4581 "action": "act4",4582 "signature": {4583 "parameters": {4584 "sap-tag": {4585 "defaultValue": {4586 "value": "superior"4587 },4588 "required": false4589 }4590 },4591 "additionalParameters": "ignored"4592 }4593 }4594 ],4595 aCallArgs: [ {4596 semanticObject: "SO",4597 params: { },4598 tags: [ "superior" ]4599 } ],4600 expectedResult: [4601 {4602 intent: "#SO-act2",4603 text: undefined,4604 tags: ["superior"]4605 },4606 {4607 intent: "#SO-act4",4608 text: undefined,4609 tags: ["superior"]4610 }4611 ]4612 },4613 {4614 // at the moment we don't support multiple tags, we may do in the future.4615 testDescription: "'superior,something' is specified",4616 aInbounds: [4617 {4618 "semanticObject": "SO",4619 "action": "act4",4620 "signature": {4621 "parameters": {4622 "sap-tag": {4623 "defaultValue": {4624 "value": "superior,superior"4625 },4626 "required": false4627 }4628 },4629 "additionalParameters": "ignored"4630 }4631 }4632 ],4633 aCallArgs: [ {4634 semanticObject: "SO",4635 params: { },4636 tags: [ "superior" ]4637 } ],4638 expectedResult: [ ]4639 },4640 {4641 // at the moment we don't support multiple tags, we may do in the future.4642 testDescription: "'superior,something' is specified",4643 aInbounds: [4644 oTestHelper.createInbound("#SO-act1{<no params><o>}"),4645 oTestHelper.createInbound("#SO-act2{sap-tag:superior<o>}"), {4646 "semanticObject": "SO",4647 "action": "act4",4648 "signature": {4649 "parameters": {4650 "sap-tag": {4651 "filter": {4652 "value": "superior"4653 },4654 "required": false4655 }4656 },4657 "additionalParameters": "ignored"4658 }4659 }4660 ],4661 aCallArgs: [ {4662 semanticObject: "SO",4663 params: { },4664 tags: [ "superior" ]4665 } ],4666 expectedResult: [ ]4667 },4668 {4669 testDescription: "'required' parameter requested",4670 aInbounds: [4671 oTestHelper.createInbound("#Object-action{[p1:v1]<o>}") // p1 is a default parameter.4672 ],4673 aCallArgs: [{4674 semanticObject: "Object",4675 params: {4676 p1: "v1"4677 },4678 paramsOptions: [4679 { name: "p1", options: { required: true } }4680 ]4681 }],4682 expectedResult: [] // ... therefore no results are returned4683 },4684 {4685 testDescription: "'required' parameter requested, but matching target exists",4686 aInbounds: [4687 oTestHelper.createInbound("#Object-action{<no params><+>}", null, { title: "A" }), // matches4688 oTestHelper.createInbound("#Object-action{[p1:[v1]<+>]}", null, { title: "B" }) // matches with higher priority4689 ],4690 aCallArgs: [{4691 semanticObject: "Object",4692 params: {4693 p1: "v1"4694 },4695 paramsOptions: [4696 { name: "p1", options: { required: true } }4697 ]4698 }],4699 // ... B would match if the 'required' option was not4700 // specified, but we expect nothing is returned in this case.4701 //4702 // Explanation: suppose inbound "A" is returned.4703 //4704 // The returned link would look like:4705 // {4706 // text: "A",4707 // intent: "#Object-action?p1=v1"4708 // }4709 //4710 // 1. now user sees a link that has a label "A" on the UI4711 // (e.g., in a smart table control).4712 // 2. User clicks on the "A" link4713 // 3. CSTR#getMatchingTargets matches target "B"4714 // 4. User is navigated to "B" instead of "A" as expected4715 //4716 expectedResult: []4717 }4718 ].forEach(function (oFixture) {4719 asyncTest("getLinks works as expected when " + oFixture.testDescription, function () {4720 var oSrvc = createService({4721 inbounds: oFixture.aInbounds4722 }),4723 oAllowedRequireServices = {4724 URLParsing: true4725 };4726 var fnGetServiceOrig = sap.ushell.Container.getService;4727 sinon.stub(sap.ushell.Container, "getService", function (sName) {4728 if (!oAllowedRequireServices[sName]) {4729 ok(false, "Test is not accessing " + sName);4730 }4731 return fnGetServiceOrig.bind(sap.ushell.Container)(sName);4732 });4733 oSrvc.getLinks.apply(oSrvc, oFixture.aCallArgs)4734 .done(function (aSemanticObjectLinks) {4735 ok(true, "promise is resolved");4736 deepEqual(aSemanticObjectLinks, oFixture.expectedResult,4737 "obtained the expected result");4738 })4739 .fail(function (sErrorMessage) {4740 ok(false, "promise is resolved without " + sErrorMessage);4741 })4742 .always(function () {4743 start();4744 });4745 });4746 });4747})();4748 [4749 {4750 testDescription: "3 Semantic objects in inbounds",4751 aSemanticObjectsInInbounds: [4752 "Action", "Shell", "Object"4753 ],4754 expectedResult: [4755 "Action", "Object", "Shell" // returned in lexicographical order4756 ]4757 },4758 {4759 testDescription: "wildcard semantic object in inbounds",4760 aSemanticObjectsInInbounds: [4761 "Action", "*", "Shell", "Object"4762 ],4763 expectedResult: [4764 "Action", "Object", "Shell" // "*" is ignored4765 ]4766 },4767 {4768 testDescription: "empty list of semantic objects is provided",4769 aSemanticObjectsInInbounds: [],4770 expectedResult: []4771 },4772 {4773 testDescription: "undefined semantic object and empty semantic objects",4774 aSemanticObjectsInInbounds: [undefined, ""],4775 expectedResult: []4776 },4777 {4778 testDescription: "duplicated semantic object in inbounds",4779 aSemanticObjectsInInbounds: ["Shell", "Dup", "action", "Dup"],4780 expectedResult: ["Dup", "Shell", "action"]4781 }4782 ].forEach(function (oFixture) {4783 asyncTest("getDistinctSemanticObjects returns the expected result when " + oFixture.testDescription, function () {4784 // Arrange4785 var aInbounds = oFixture.aSemanticObjectsInInbounds.map(function (sSemanticObject) {4786 return {4787 semanticObject: sSemanticObject,4788 action: "dummyAction"4789 };4790 });4791 var oSrvc = createService({4792 inbounds: aInbounds4793 });4794 // Act4795 oSrvc.getDistinctSemanticObjects()4796 .done(function (aSemanticObjectsGot) {4797 ok(true, "promise was resolved");4798 deepEqual(aSemanticObjectsGot, oFixture.expectedResult,4799 "the expected list of semantic objects was returned");4800 })4801 .fail(function (sMsg) {4802 ok(false, "promise was resolved");4803 })4804 .always(function () {4805 start();4806 });4807 });4808 });4809 asyncTest("getDistinctSemanticObjects behave as expected when getInbounds fails", function () {4810 // Arrange4811 var oFakeAdapter = {4812 getInbounds: function () {4813 return new jQuery.Deferred().reject("Deliberate Error").promise();4814 }4815 },4816 oSrvc = createService({4817 adapter: oFakeAdapter4818 });4819 sinon.stub(jQuery.sap.log, "error");4820 sinon.stub(jQuery.sap.log, "warning");4821 // Act4822 oSrvc.getDistinctSemanticObjects()4823 .done(function () {4824 ok(false, "promise was rejected");4825 })4826 .fail(function (sErrorMessageGot) {4827 ok(true, "promise was rejected");4828 strictEqual(sErrorMessageGot, "Deliberate Error",4829 "expected error message was returned");4830 strictEqual(4831 jQuery.sap.log.error.getCalls().length,4832 0,4833 "jQuery.sap.log.error was called 0 times"4834 );4835 strictEqual(4836 jQuery.sap.log.warning.getCalls().length,4837 0,4838 "jQuery.sap.log.warning was called 0 times"4839 );4840 })4841 .always(function () {4842 start();4843 });4844 });4845 [4846 {4847 testDescription: "matching UI5 url with sap-system and other parameters specified in intent (additionalParameters: ignored)",4848 intent: "Action-action1?sap-system=NOTRELEVANT&paramName1=pv1",4849 sCurrentFormFactor: "desktop",4850 oMockedMatchingTarget: {4851 // ignore certain fields not needed for the test4852 "matches": true,4853 "resolutionResult": { },4854 "defaultedParamNames": ["P2"],4855 "intentParamsPlusAllDefaults": {4856 "P1": ["PV1", "PV2"],4857 "P2": ["1000"],4858 "sap-system": ["AX1"]4859 },4860 "inbound": {4861 "title": "Currency manager (this one)",4862 "semanticObject": "Action",4863 "action": "action1",4864 "permanentKey": "X-SAP-UI2-CATALOGPAGE:Z_UI2_TEST:ET090M0NO76W68G7TEBEFZOSS",4865 "resolutionResult": {4866 "additionalInformation": "SAPUI5.Component=Currency.Component",4867 "applicationType": "SAPUI5",4868 "text": "Currency manager (ignored )", // ignored4869 "ui5ComponentName": "Currency.Component",4870 "url": "/url/to/currency"4871 },4872 "signature": {4873 "additionalParameters": "ignored",4874 "parameters": {4875 "P2": {4876 "required": false,4877 "renameTo": "P3",4878 "defaultValue": { value: "DefaultValue" }4879 }4880 }4881 }4882 }4883 },4884 expectedResolutionResult: {4885 "additionalInformation": "SAPUI5.Component=Currency.Component",4886 "applicationType": "SAPUI5",4887 "text": "Currency manager (this one)",4888 "ui5ComponentName": "Currency.Component",4889 "sap-system": "AX1",4890 "url": "/url/to/currency?P1=PV1&P1=PV2&P3=1000&sap-system=AX1&sap-ushell-defaultedParameterNames=%5B%22P3%22%5D",4891 "reservedParameters": {},4892 "inboundPermanentKey": "X-SAP-UI2-CATALOGPAGE:Z_UI2_TEST:ET090M0NO76W68G7TEBEFZOSS"4893 }4894 },4895 {4896 testDescription: "resolving local WDA url",4897 intent: "Action-action1?paramName1=pv1",4898 bIgnoreFormFactor: true,4899 sCurrentFormFactor: "desktop",4900 oMockedMatchingTarget: {4901 // ignore certain fields not needed for the test4902 "matches": true,4903 "resolutionResult": { },4904 "defaultedParamNames": ["P2"],4905 "intentParamsPlusAllDefaults": {4906 "P1": ["PV1", "PV2"],4907 "P2": ["1000"]4908 },4909 "inbound": {4910 "title": "Currency manager (this one)",4911 "semanticObject": "Action",4912 "action": "action1",4913 "permanentKey": "X-SAP-UI2-CATALOGPAGE:Z_UI2_TEST:ET090M0NO76W68G7TEBEFZOSS",4914 "resolutionResult": {4915 "additionalInformation": "",4916 "applicationType": "WDA",4917 "text": "Currency manager (ignored text)", // ignored4918 "ui5ComponentName": "Currency.Component",4919 "url": "/ui2/nwbc/~canvas;window=app/wda/WD_ANALYZE_CONFIG_USER/?sap-client=120&sap-language=EN"4920 },4921 "signature": {4922 "additionalParameters": "ignored",4923 "parameters": {4924 "P2": {4925 "renameTo": "P3",4926 "required": true4927 }4928 }4929 }4930 }4931 },4932 expectedResolutionResult: {4933 "additionalInformation": "",4934 "applicationType": "NWBC",4935 "reservedParameters": {},4936 "sap-system": undefined,4937 "text": "Currency manager (this one)",4938 "url": "/ui2/nwbc/~canvas;window=app/wda/WD_ANALYZE_CONFIG_USER/?sap-client=120&sap-language=EN&P1=PV1&P1=PV2&P3=1000&sap-ushell-defaultedParameterNames=%5B%22P3%22%5D",4939 "inboundPermanentKey": "X-SAP-UI2-CATALOGPAGE:Z_UI2_TEST:ET090M0NO76W68G7TEBEFZOSS"4940 }4941 },4942 {4943 testDescription: "resolving local WDA url with sap-system",4944 intent: "Action-action1?sap-system=NOTRELEVANT&paramName1=pv1",4945 bIgnoreFormFactor: true,4946 sCurrentFormFactor: "desktop",4947 oMockedMatchingTarget: {4948 // ignore certain fields not needed for the test4949 "matches": true,4950 "resolutionResult": {4951 "text": "Some WDA"4952 },4953 "defaultedParamNames": ["P2"],4954 "intentParamsPlusAllDefaults": {4955 "P1": ["PV1", "PV2"],4956 "P4": { },4957 "P2": ["1000"],4958 "sap-system": ["AX1"]4959 },4960 "inbound": {4961 "semanticObject": "Action",4962 "action": "action1",4963 "permanentKey": "X-SAP-UI2-CATALOGPAGE:Z_UI2_TEST:ET090M0NO76W68G7TEBEFZOSS",4964 "resolutionResult": {4965 "additionalInformation": "",4966 "applicationType": "WDA",4967 "text": "Currency manager (ignored text)", // ignored4968 "ui5ComponentName": "Currency.Component",4969 "url": "/ui2/nwbc/~canvas;window=app/wda/WD_ANALYZE_CONFIG_USER/?sap-client=120&sap-language=EN"4970 },4971 "signature": {4972 "additionalParameters": "ignored",4973 "parameters": {4974 "P2": {4975 "renameTo": "P3",4976 "required": true4977 }4978 }4979 }4980 }4981 },4982 expectedResolutionResult: {4983 "text": "Some WDA",4984 // NOTE: the UNMAPPED paramter list!4985 "url": "fallback :-({P1:[PV1,PV2],P2:[1000],sap-system:[AX1],sap-ushell-defaultedParameterNames:[[P3]]}"4986 }4987 }4988 ].forEach(function (oFixture) {4989 asyncTest("resolveHashFragment postprocessing when " + oFixture.testDescription, function () {4990 var oFakeAdapter = {4991 getInbounds: sinon.stub().returns(4992 new jQuery.Deferred().resolve([]).promise()4993 ),4994 resolveHashFragmentFallback: function (oIntent, oMatchingTarget, oParameters) {4995 return new jQuery.Deferred().resolve({ url: "fallback :-(" + JSON.stringify(oParameters).replace(/["]/g, "").replace(/\\/g, "") }).promise();4996 }4997 };4998 var oSrvc = new ClientSideTargetResolution(oFakeAdapter, null, null, {});4999 // Mock form factor5000 sinon.stub(utils, "getFormFactor").returns(oFixture.sCurrentFormFactor);5001 // Mock getMatchingInbounds5002 sinon.stub(oSrvc, "_getMatchingInbounds").returns(5003 new jQuery.Deferred().resolve([oFixture.oMockedMatchingTarget]).promise()5004 );5005 // Act5006 oSrvc.resolveHashFragment(oFixture.intent)5007 .done(function (oResolutionResult) {5008 // Assert5009 ok(true, "promise was resolved");5010 deepEqual(oResolutionResult, oFixture.expectedResolutionResult, "got expected resolution result");5011 })5012 .fail(function () {5013 // Assert5014 ok(false, "promise was resolved");5015 })5016 .always(function () {5017 start();5018 });5019 });5020 });5021 [5022 {5023 testDescription: "ui5 parameter mapping with appState and defaulting",5024 intent: "Action-action1?sap-system=NOTRELEVANT&paramName1=pv1",5025 sCurrentFormFactor: "desktop",5026 oMockedMatchingTarget: {5027 // ignore certain fields not needed for the test5028 "matches": true,5029 "resolutionResult": { },5030 "defaultedParamNames": ["P2", "P3", "P4", "P5"],5031 "intentParamsPlusAllDefaults": {5032 "P1": ["PV1", "PV2"],5033 "P2": ["1000"],5034 "P3": { "ranges": { option: "EQ", low: "1000" } },5035 "P4": { "ranges": { option: "EQ", low: "notusedbecauseP2" } },5036 "P5": { "ranges": { option: "EQ", low: "1000" } },5037 "P9": ["PV9"],5038 "sap-system": ["AX1"]5039 },5040 "inAppState": {5041 "selectionVariant": {5042 "Parameter": [ { "PropertyName": "P6", "PropertyValue": "0815" },5043 { "PropertyName": "P8", "PropertyValue": "0815" } ],5044 "selectOptions": [5045 {5046 "PropertyName": "P7",5047 "Ranges": [5048 {5049 "Sign": "I",5050 "Option": "EQ",5051 "Low": "INT",5052 "High": null5053 }5054 ]5055 }]5056 }5057 },5058 "inbound": {5059 "title": "Currency manager (this one)",5060 "semanticObject": "Action",5061 "action": "action1",5062 "permanentKey": "X-SAP-UI2-CATALOGPAGE:Z_UI2_TEST:ET090M0NO76W68G7TEBEFZOSS",5063 "resolutionResult": {5064 "additionalInformation": "SAPUI5.Component=Currency.Component",5065 "applicationType": "SAPUI5",5066 "text": "Currency manager (ignored )", // ignored5067 "ui5ComponentName": "Currency.Component",5068 "url": "/url/to/currency"5069 },5070 "signature": {5071 "additionalParameters": "ignored",5072 "parameters": {5073 "P1": { "renameTo": "PX" },5074 "P2": { "renameTo": "P4" },5075 "P5": { "renameTo": "PX"},5076 "P6C": { "renameTo": "PC"},5077 "P6": { "renameTo": "P6New"},5078 "P7": { "renameTo": "P6New"},5079 "P8": { "renameTo": "P8New"},5080 "P9": { "renameTo": "PX"}5081 }5082 }5083 }5084 },5085 expectedResolutionResult: {5086 "additionalInformation": "SAPUI5.Component=Currency.Component",5087 "applicationType": "SAPUI5",5088 "text": "Currency manager (this one)",5089 "ui5ComponentName": "Currency.Component",5090 "sap-system": "AX1",5091 "url": "/url/to/currency?P4=1000&PX=PV1&PX=PV2&sap-system=AX1&sap-ushell-defaultedParameterNames=%5B%22P4%22%5D",5092 "reservedParameters": {},5093 "inboundPermanentKey": "X-SAP-UI2-CATALOGPAGE:Z_UI2_TEST:ET090M0NO76W68G7TEBEFZOSS"5094 }5095 }5096 ].forEach(function (oFixture) {5097 asyncTest("resolveHashFragment with appstate merging " + oFixture.testDescription, function () {5098 var oFakeAdapter = {5099 getInbounds: sinon.stub().returns(5100 new jQuery.Deferred().resolve([]).promise()5101 ),5102 resolveHashFragmentFallback: function (oIntent, oMatchingTarget, oParameters) {5103 return new jQuery.Deferred().resolve({ url: "fallback :-(" + JSON.stringify(oParameters).replace(/["]/g, "").replace(/\\/g, "") }).promise();5104 }5105 };5106 var oSrvc = new ClientSideTargetResolution(oFakeAdapter, null, null, {});5107 // Mock form factor5108 sinon.stub(utils, "getFormFactor").returns(oFixture.sCurrentFormFactor);5109 // Mock getMatchingInbounds5110 sinon.stub(oSrvc, "_getMatchingInbounds").returns(5111 new jQuery.Deferred().resolve([oFixture.oMockedMatchingTarget]).promise()5112 );5113 // Act5114 oSrvc.resolveHashFragment(oFixture.intent)5115 .done(function (oResolutionResult) {5116 // Assert5117 ok(true, "promise was resolved");5118 deepEqual(oResolutionResult, oFixture.expectedResolutionResult, "got expected resolution result");5119 })5120 .fail(function () {5121 // Assert5122 ok(false, "promise was resolved");5123 })5124 .always(function () {5125 start();5126 });5127 });5128 });5129 [5130 {5131 testDescription: "form factor is not ignored",5132 sSemanticObject: "Object",5133 bIgnoreFormFactor: false,5134 mBusinessParams: {},5135 sCurrentFormFactor: "mobile",5136 expectedGetMatchingTargetsIntent: {5137 "action": undefined,5138 "formFactor": "mobile",5139 "params": {},5140 "semanticObject": "Object"5141 }5142 },5143 {5144 testDescription: "form factor is ignored",5145 sSemanticObject: "Object",5146 bIgnoreFormFactor: true,5147 mBusinessParams: {},5148 sCurrentFormFactor: "mobile",5149 expectedGetMatchingTargetsIntent: {5150 "action": undefined,5151 "formFactor": undefined,5152 "params": {},5153 "semanticObject": "Object"5154 }5155 },5156 {5157 testDescription: "parameters are specified",5158 sSemanticObject: "Object",5159 bIgnoreFormFactor: true,5160 mBusinessParams: {5161 "p1": ["v1"],5162 "p2": ["v3", "v2"]5163 },5164 sCurrentFormFactor: "mobile",5165 expectedGetMatchingTargetsIntent: {5166 "action": undefined,5167 "formFactor": undefined,5168 "params": {5169 "p1": ["v1"],5170 "p2": ["v3", "v2"]5171 },5172 "semanticObject": "Object"5173 }5174 },5175 {5176 testDescription: "semantic object is the empty string",5177 sSemanticObject: "",5178 bIgnoreFormFactor: false,5179 mBusinessParams: {},5180 sCurrentFormFactor: "mobile",5181 expectedGetMatchingTargetsIntent: {5182 "action": undefined,5183 "formFactor": "mobile",5184 "semanticObject": undefined,5185 "params": {}5186 }5187 }5188 ].forEach(function (oFixture) {5189 asyncTest("getLinks: calls _getMatchingInbounds with expected shell hash when " + oFixture.testDescription, function () {5190 var oSrvc = createService();5191 // Mock form factor5192 sinon.stub(utils, "getFormFactor").returns(oFixture.sCurrentFormFactor);5193 // Mock getMatchingInbounds5194 sinon.stub(oSrvc, "_getMatchingInbounds").returns(5195 new jQuery.Deferred().resolve([]).promise()5196 );5197 // Act5198 oSrvc.getLinks(oFixture.sSemanticObject, oFixture.mBusinessParams, oFixture.bIgnoreFormFactor)5199 .done(function (aResultSemanticObjectLinks) {5200 // Assert5201 ok(true, "promise was resolved");5202 deepEqual(oSrvc._getMatchingInbounds.getCall(0).args[0], oFixture.expectedGetMatchingTargetsIntent,5203 "_getMatchingInbounds was called with expected intent object");5204 })5205 .fail(function () {5206 // Assert5207 ok(false, "promise was resolved");5208 })5209 .always(function () {5210 start();5211 });5212 });5213 });5214 [5215 {5216 testDescription: "semantic object is a number (nominal parameters)",5217 sSemanticObject: 128,5218 mBusinessParams: {},5219 sCurrentFormFactor: "mobile",5220 bUseNominalParameters: true,5221 sExpectedErrorMessage: "invalid semantic object",5222 sExpectedErrorDetailsPart: "got [object Number] instead"5223 },5224 {5225 testDescription: "semantic object is {} (nominal parameters)",5226 sSemanticObject: {},5227 mBusinessParams: {},5228 sCurrentFormFactor: "mobile",5229 bUseNominalParameters: true,5230 sExpectedErrorMessage: "invalid semantic object",5231 sExpectedErrorDetailsPart: "got [object Object] instead"5232 },5233 {5234 testDescription: "semantic object is [] (nominal parameters)",5235 sSemanticObject: [],5236 mBusinessParams: {},5237 sCurrentFormFactor: "mobile",5238 bUseNominalParameters: true,5239 sExpectedErrorMessage: "invalid semantic object",5240 sExpectedErrorDetailsPart: "got [object Array] instead"5241 },5242 {5243 testDescription: "action is not a string (nominal parameters)",5244 sSemanticObject: "Object",5245 sAction: false,5246 mBusinessParams: {},5247 sCurrentFormFactor: "mobile",5248 bUseNominalParameters: true,5249 sExpectedErrorMessage: "invalid action",5250 sExpectedErrorDetailsPart: "the action must be a string"5251 },5252 {5253 testDescription: "action is not a string (nominal parameters)",5254 sSemanticObject: "Object",5255 sAction: "",5256 mBusinessParams: {},5257 sCurrentFormFactor: "mobile",5258 bUseNominalParameters: true,5259 sExpectedErrorMessage: "invalid action",5260 sExpectedErrorDetailsPart: "the action must not be an empty string"5261 },5262 {5263 testDescription: "semantic object is undefined",5264 sSemanticObject: undefined,5265 mBusinessParams: {},5266 sCurrentFormFactor: "mobile",5267 bUseNominalParameters: false,5268 sExpectedErrorMessage: "invalid semantic object",5269 sExpectedErrorDetailsPart: "got [object Undefined] instead"5270 },5271 {5272 testDescription: "semantic object is a number",5273 sSemanticObject: 128,5274 mBusinessParams: {},5275 sCurrentFormFactor: "mobile",5276 bUseNominalParameters: false,5277 sExpectedErrorMessage: "invalid semantic object",5278 sExpectedErrorDetailsPart: "got [object Number] instead"5279 },5280 {5281 testDescription: "semantic object is {}",5282 sSemanticObject: {},5283 mBusinessParams: {},5284 sCurrentFormFactor: "mobile",5285 bUseNominalParameters: false,5286 sExpectedErrorMessage: "invalid semantic object",5287 sExpectedErrorDetailsPart: "got [object Object] instead"5288 },5289 {5290 testDescription: "semantic object is []",5291 sSemanticObject: [],5292 mBusinessParams: {},5293 sCurrentFormFactor: "mobile",5294 bUseNominalParameters: false,5295 sExpectedErrorMessage: "invalid semantic object",5296 sExpectedErrorDetailsPart: "got [object Array] instead"5297 },5298 {5299 testDescription: "semantic object is blank",5300 sSemanticObject: " ",5301 mBusinessParams: {},5302 sCurrentFormFactor: "mobile",5303 bUseNominalParameters: false,5304 sExpectedErrorMessage: "invalid semantic object",5305 sExpectedErrorDetailsPart: "got ' ' instead"5306 },5307 {5308 testDescription: "semantic object is many blanks",5309 sSemanticObject: " ",5310 mBusinessParams: {},5311 sCurrentFormFactor: "mobile",5312 bUseNominalParameters: false,5313 sExpectedErrorMessage: "invalid semantic object",5314 sExpectedErrorDetailsPart: "got ' ' instead"5315 }5316 ].forEach(function (oFixture) {5317 asyncTest("getLinks: logs an error and rejects promise when " + oFixture.testDescription, function () {5318 var oSrvc = createService();5319 sinon.stub(jQuery.sap.log, "error");5320 // Mock form factor5321 sinon.stub(utils, "getFormFactor").returns(oFixture.sCurrentFormFactor);5322 // Mock getMatchingInbounds5323 sinon.stub(oSrvc, "_getMatchingInbounds").returns(5324 new jQuery.Deferred().resolve([]).promise()5325 );5326 // Act5327 var fnGetSemanticObjectLinksBound = oSrvc.getLinks.bind(oSrvc, oFixture.sSemanticObject, oFixture.mBusinessParams);5328 if (oFixture.bUseNominalParameters) {5329 fnGetSemanticObjectLinksBound = oSrvc.getLinks.bind(oSrvc, {5330 semanticObject: oFixture.sSemanticObject,5331 action: oFixture.sAction,5332 params: oFixture.oParams5333 });5334 }5335 fnGetSemanticObjectLinksBound()5336 .done(function (aResultSemanticObjectLinks) {5337 // Assert5338 ok(false, "promise was rejected");5339 })5340 .fail(function (sErrorMessage) {5341 // Assert5342 ok(true, "promise was rejected");5343 strictEqual(sErrorMessage, oFixture.sExpectedErrorMessage, "rejected with expected error message");5344 strictEqual(jQuery.sap.log.error.getCalls().length, 1, "jQuery.sap.log.error was called once");5345 strictEqual(jQuery.sap.log.error.getCall(0).args[0], "invalid input for _getLinks", "expected error title was logged");5346 ok(jQuery.sap.log.error.getCall(0).args[1].indexOf(oFixture.sExpectedErrorDetailsPart) >= 0, oFixture.sExpectedErrorDetailsPart + " was found in logged error details");5347 strictEqual(jQuery.sap.log.error.getCall(0).args[2], "sap.ushell.services.ClientSideTargetResolution", "error contains sap.ushell.services.ClientSideTargetResolution");5348 })5349 .always(function () {5350 start();5351 });5352 });5353 });5354 [5355 {5356 testLogLevel: [I_DEBUG],5357 sSemanticObject: "Object",5358 mBusinessParams: { "country": ["IT"] },5359 bIgnoreFormFactor: true,5360 sCurrentFormFactor: "desktop",5361 aMockedResolutionResults: [5362 {5363 "matches": true,5364 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },5365 "inbound": {5366 "title": "Currency manager",5367 "icon": "sap-icon://Fiori2/F0018",5368 "subTitle": "sub Title",5369 "shortTitle": "short Title",5370 "semanticObject": "Object",5371"action": "bbb",5372 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },5373 "signature": { "parameters": {5374 "country": {5375 required: true5376 }5377 }}5378 }5379 },5380 {5381 "matches": true,5382 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },5383 "inbound": {5384 "title": "Currency manager",5385 "subTitle": "sub Title",5386 "shortTitle": "short Title",5387 "icon": "sap-icon://Fiori2/F0018",5388 "semanticObject": "Object",5389"action": "ccc",5390 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },5391 "signature": { "parameters": { }, "additionalParameters": "ignored" }5392 }5393 }5394 ],5395 expectedSemanticObjectLinks: [5396 { "intent": "#Object-bbb?country=IT",5397 "text": "Currency manager",5398 "icon": "sap-icon://Fiori2/F0018",5399 "subTitle": "sub Title",5400 "shortTitle": "short Title" },5401 { "intent": "#Object-ccc",5402 "text": "Currency manager",5403 "icon": "sap-icon://Fiori2/F0018",5404 "subTitle": "sub Title",5405 "shortTitle": "short Title" }5406 ],5407 expectedLogArgs: [5408 "_getLinks filtered to unique intents.",5409 /Reporting histogram:(.|\n)*#Object-bbb(.|\n)*#Object-ccc/,5410 "sap.ushell.services.ClientSideTargetResolution"5411 ]5412 },5413 {5414 testLogLevel: [I_TRACE],5415 sSemanticObject: "Object",5416 mBusinessParams: { "country": ["IT"] },5417 bIgnoreFormFactor: true,5418 sCurrentFormFactor: "desktop",5419 aMockedResolutionResults: [5420 {5421 "matches": true,5422 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },5423 "inbound": {5424 "title": "Currency manager",5425 "subTitle": "sub Title",5426 "shortTitle": "short Title",5427 "icon": "sap-icon://Fiori2/F0018",5428 "semanticObject": "Object",5429"action": "bbb",5430 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },5431 "signature": { "parameters": {5432 "country": {5433 required: true5434 }5435 }}5436 }5437 },5438 {5439 "matches": true,5440 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency?mode=desktop" },5441 "inbound": {5442 "title": "Currency manager",5443 "subTitle": "sub Title",5444 "shortTitle": "short Title",5445 "icon": "sap-icon://Fiori2/F0018",5446 "semanticObject": "Object",5447"action": "ccc",5448 "resolutionResult": { "additionalInformation": "SAPUI5.Component=Currency.Component", "applicationType": "URL", "text": "Currency manager (ignored text)", "ui5ComponentName": "Currency.Component", "url": "/url/to/currency" },5449 "signature": { "parameters": { }, "additionalParameters": "ignored" }5450 }5451 }5452 ],5453 expectedSemanticObjectLinks: [5454 { "intent": "#Object-bbb?country=IT",5455 "text": "Currency manager",5456 "icon": "sap-icon://Fiori2/F0018",5457 "subTitle": "sub Title",5458 "shortTitle": "short Title" },5459 { "intent": "#Object-ccc",5460 "text": "Currency manager",5461 "icon": "sap-icon://Fiori2/F0018",5462 "subTitle": "sub Title",5463 "shortTitle": "short Title"}5464 ],5465 expectedLogArgs: [5466 "_getLinks filtered to the following unique intents:",5467 /(.|\n)*#Object-bbb.*country=IT(.|\n)*#Object-ccc.*/,5468 "sap.ushell.services.ClientSideTargetResolution"5469 ]5470 }5471 ].forEach(function (oFixture) {5472 asyncTest("getLinks: correctly logs resulting intents in log level " + oFixture.testLogLevel, function () {5473 var oSrvc = createService(),5474 oLogMock = testUtils.createLogMock().sloppy(true);5475 // Check logging expectations via LogMock5476 oLogMock.debug.apply(oLogMock, oFixture.expectedLogArgs);5477 // LogMock doesn't keep the following original methods5478 jQuery.sap.log.getLevel = sinon.stub().returns(oFixture.testLogLevel);5479 jQuery.sap.log.Level = {5480 DEBUG: I_DEBUG,5481 TRACE: I_TRACE5482 };5483 // Mock form factor5484 sinon.stub(utils, "getFormFactor").returns(oFixture.sCurrentFormFactor);5485 // Mock getMatchingInbounds5486 sinon.stub(oSrvc, "_getMatchingInbounds").returns(5487 new jQuery.Deferred().resolve(oFixture.aMockedResolutionResults).promise()5488 );5489 // Act5490 oSrvc.getLinks(oFixture.sSemanticObject, oFixture.mBusinessParams, oFixture.bIgnoreFormFactor)5491 .done(function (aResultSemanticObjectLinks) {5492 start();5493 // Assert5494 ok(true, "promise was resolved");5495 deepEqual(aResultSemanticObjectLinks, oFixture.expectedSemanticObjectLinks, "got expected array of semantic object links");5496 oLogMock.verify();5497 })5498 .fail(function () {5499 start();5500 // Assert5501 ok(false, "promise was resolved");5502 });5503 });5504 });5505 [5506 {5507 testDescription: "semantic object/actions are both passed",5508 sCurrentFormFactor: "phone",5509 sIntent: "#Object-action",5510 oResolve: [{}],5511 expectedResult: true,5512 expectedGetMatchingTargetsIntent: {5513 "semanticObject": "Object",5514 "action": "action",5515 "formFactor": "phone",5516 "appSpecificRoute": undefined,5517 "contextRaw": undefined,5518 "params": {}5519 }5520 },5521 {5522 testDescription: "Parameters are passed",5523 sCurrentFormFactor: "phone",5524 sIntent: "#Object-action?p1=v1&p2=v2",5525 oResolve: [],5526 expectedResult: false,5527 expectedGetMatchingTargetsIntent: {5528 "semanticObject": "Object",5529 "action": "action",5530 "formFactor": "phone",5531 "params": {5532 "p1": [ "v1" ],5533 "p2": [ "v2" ]5534 },5535 "appSpecificRoute": undefined,5536 "contextRaw": undefined5537 }5538 },5539 {5540 testDescription: " emtpy hash is processed",5541 sCurrentFormFactor: "phone",5542 sIntent: "#",5543 oResolve: [],5544 expectedResult: true,5545 expectedGetMatchingTargetsIntent: undefined5546 }5547 ].forEach(function (oFixture) {5548 function prepareTest () {5549 var oSrvc = createService();5550 sinon.stub(utils, "getFormFactor").returns(oFixture.sCurrentFormFactor);5551 sinon.stub(oSrvc, "_getMatchingInbounds").returns(5552 new jQuery.Deferred().resolve(oFixture.oResolve).promise()5553 );5554 return oSrvc;5555 }5556 asyncTest("_isIntentSupportedOne: calls _getMatchingInbounds with the expected shell hash when " + oFixture.testDescription, function () {5557 var oSrvc = prepareTest();5558 // Act5559 oSrvc._isIntentSupportedOne(oFixture.sIntent).done(function (oResult) {5560 ok(true, "promise was resolved");5561 equal(oResult, oFixture.expectedResult, "result ok");5562 if (oFixture.expectedGetMatchingTargetsIntent) {5563 deepEqual(oSrvc._getMatchingInbounds.getCall(0).args[0], oFixture.expectedGetMatchingTargetsIntent,5564 "_getMatchingInbounds was called with the expected shell hash");5565 } else {5566 equal(oSrvc._getMatchingInbounds.called, false, " _getMatchingInbounds not called!");5567 }5568 }).fail(function () {5569 ok(false, "promise was resolved");5570 }).always(function () {5571 start();5572 });5573 });5574 asyncTest("_isIntentSupportedOne: calls _getMatchingInbounds with the expected bExcludeTileInbounds argument when " + oFixture.testDescription, function () {5575 var oSrvc = prepareTest();5576 // Act5577 oSrvc._isIntentSupportedOne(oFixture.sIntent).done(function (oResult) {5578 ok(true, "promise was resolved");5579 testExcludeTileIntentArgument(oSrvc, true);5580 }).fail(function () {5581 ok(false, "promise was resolved");5582 }).always(function () {5583 start();5584 });5585 });5586 });5587 asyncTest("resolveTileIntentInContext: works as expected when _resolveTileIntent resolves", function () {5588 var oResolvedIntentExpected,5589 oFakeThis,5590 aFakeInbounds;5591 oResolvedIntentExpected = { RESOLVED: "INTENT" };5592 // Arrange5593 aFakeInbounds = [{5594 semanticObject: "Test",5595 action: "inbound"5596 }];5597 oFakeThis = {5598 _resolveTileIntent: sinon.stub().returns(5599 new jQuery.Deferred().resolve(oResolvedIntentExpected).promise()5600 )5601 };5602 // Act5603 ClientSideTargetResolution.prototype.resolveTileIntentInContext.call(5604 oFakeThis, aFakeInbounds, "#Test-inbound"5605 ).done(function (oResolvedIntentGot) {5606 // Assert5607 ok(true, "the promise was resolved");5608 deepEqual(oResolvedIntentGot, oResolvedIntentExpected,5609 "promise resolved with the expected resolved intent");5610 strictEqual(oFakeThis._resolveTileIntent.callCount, 1,5611 "_resolveTileIntent was called once");5612 var oExpectedInboundIndexArg = oFakeThis._resolveTileIntent.getCall(0).args[2];5613 strictEqual(oExpectedInboundIndexArg.hasOwnProperty("index"), true,5614 "third argument of _resolveTileIntent looks like an inbound index"5615 );5616 deepEqual(oExpectedInboundIndexArg.index.all, aFakeInbounds.concat(oTestHelper.getVirtualInbounds()),5617 "the inbound index given to _resolveTileIntent includes both the inbounds in the scope and the virtual inbounds");5618 }).fail(function () {5619 // Assert5620 ok(false, "the promise was resolved");5621 }).always(function () {5622 start();5623 });5624 });5625 asyncTest("resolveTileIntentInContext: works as expected when _resolveTileIntent rejects", function () {5626 var oFakeThis,5627 aFakeInbounds;5628 // Arrange5629 aFakeInbounds = [];5630 oFakeThis = {5631 _resolveTileIntent: sinon.stub().returns(5632 new jQuery.Deferred().reject("Something bad").promise()5633 )5634 };5635 // Act5636 ClientSideTargetResolution.prototype.resolveTileIntentInContext.call(5637 oFakeThis, aFakeInbounds, "#Test-inbound"5638 ).done(function () {5639 ok(false, "the promise was rejected");5640 }).fail(function (sError) {5641 ok(true, "the promise was rejected");5642 strictEqual(sError, "Something bad",5643 "the promise was rejected with the expected error message");5644 }).always(function () {5645 start();5646 });5647 });5648 asyncTest("_resolveTileIntent: calls _getMatchingInbounds with false bExcludeTileInbounds arguments", function () {5649 var oSrvc = createService();5650 sinon.stub(oSrvc, "_getURLParsing").returns({5651 parseShellHash: sinon.stub().returns({ "parsed": "shellHash" })5652 });5653 sinon.stub(oSrvc, "_getMatchingInbounds").returns(5654 new jQuery.Deferred().resolve({}, []).promise()5655 );5656 sinon.stub(oSrvc, "_resolveSingleMatchingTileIntent").returns(5657 new jQuery.Deferred().resolve().promise()5658 );5659 oSrvc._resolveTileIntent("#Sample-hash", null, [])5660 .done(function () {5661 ok(true, "promise was resolved");5662 testExcludeTileIntentArgument(oSrvc, false /* expected bExcludeTileInbounds */);5663 })5664 .fail(function () {5665 ok(false, "promise was resolved");5666 })5667 .always(function () {5668 start();5669 });5670 });5671 [5672 {5673 testDescription: "multiple intents are given",5674 aInbounds: [{5675 "semanticObject": "Action",5676 "action": "toappnavsample",5677 "title": "Title",5678 "resolutionResult": {5679 "applicationType": "SAPUI5",5680 "additionalInformation": "SAPUI5.Component=sap.ushell.demo.Inbound",5681 "text": "Text",5682 "ui5ComponentName": "sap.ushell.demo.Inbound",5683 "applicationDependencies": {5684 "name": "sap.ushell.demo.Inbound",5685 "self": {5686 "name": "sap.ushell.demo.Inbound"5687 }5688 },5689 "url": "/sap/bc/ui5_demokit/test-resources/sap/ushell/demoapps/AppNavSample",5690 "systemAlias": ""5691 },5692 "deviceTypes": {5693 "desktop": true,5694 "tablet": true,5695 "phone": true5696 },5697 "signature": {5698 "additionalParameters": "allowed",5699 "parameters": {}5700 }5701 }, {5702 "semanticObject": "Object",5703 "action": "action",5704 "title": "Object action",5705 "resolutionResult": {5706 "applicationType": "SAPUI5",5707 "additionalInformation": "SAPUI5.Component=sap.ushell.demo.Inbound",5708 "text": "Text",5709 "ui5ComponentName": "sap.ushell.demo.Inbound",5710 "applicationDependencies": {5711 "name": "sap.ushell.demo.Inbound",5712 "self": {5713 "name": "sap.ushell.demo.Inbound"5714 }5715 },5716 "url": "/sap/bc/ui5_demokit/test-resources/sap/ushell/demoapps/AppNavSample",5717 "systemAlias": ""5718 },5719 "deviceTypes": {5720 "desktop": true,5721 "tablet": true,5722 "phone": true5723 },5724 "signature": {5725 "additionalParameters": "notallowed",5726 "parameters": {5727 "P1": {5728 required: true5729 }5730 }5731 }5732 }],5733 sCurrentFormFactor: "desktop",5734 aIsIntentSupportedArg: [5735 "#Action-toappnavsample", "#Object-action?P1=V1", "#Action-nonexisting"5736 ],5737 expectedResult: {5738 "#Action-toappnavsample": {5739 "supported": true5740 },5741 "#Object-action?P1=V1": {5742 "supported": true5743 },5744 "#Action-nonexisting": {5745 "supported": false5746 }5747 }5748 }5749 ].forEach(function (oFixture) {5750 asyncTest("isIntentSupported: works as expected when " + oFixture.testDescription, function () {5751 var oSrvc = createService({5752 inbounds: oFixture.aInbounds5753 });5754 sinon.stub(utils, "getFormFactor").returns(oFixture.sCurrentFormFactor);5755 // Act5756 oSrvc.isIntentSupported(oFixture.aIsIntentSupportedArg).done(function (oResult) {5757 ok(true, "promise was resolved");5758 deepEqual(oResult, oFixture.expectedResult, "result ok");5759 }).fail(function () {5760 ok(false, "promise was resolved");5761 }).always(function () {5762 start();5763 });5764 });5765 });5766 asyncTest("isIntentSupported rejects promise with error message when one intent is not supported", function () {5767 var oSrvc = createService();5768 sinon.stub(oSrvc, "_isIntentSupportedOne", function (sIntent) {5769 return new jQuery.Deferred().reject(sIntent + " was rejected").promise();5770 });5771 oSrvc.isIntentSupported(["#Action-test1", "#Action-test2"]).done(function (oResult) {5772 ok(false, "promise was rejected");5773 }).fail(function (sReason) {5774 ok(true, "promise was rejected");5775 strictEqual(sReason, "One or more input intents contain errors: #Action-test1 was rejected, #Action-test2 was rejected");5776 }).always(function () {5777 start();5778 });5779 });5780 [5781 {5782 testDescription: "Generic semantic object is passed",5783 sCurrentFormFactor: "mobile",5784 sIntent: "#*-action"5785 },5786 {5787 testDescription: "empty semantic object is passed",5788 sCurrentFormFactor: "mobile",5789 sIntent: "#-action"5790 },5791 {5792 testDescription: "* is passed in action",5793 sCurrentFormFactor: "mobile",5794 sIntent: "#Object-*"5795 },5796 {5797 testDescription: "blank is passed in semantic object",5798 sCurrentFormFactor: "mobile",5799 sIntent: "# -*"5800 },5801 {5802 testDescription: "many blanks are passed in semantic object",5803 sCurrentFormFactor: "mobile",5804 sIntent: "# -*"5805 }5806 ].forEach(function (oFixture) {5807 asyncTest("_isIntentSupportedOne: rejects promise when " + oFixture.testDescription, function () {5808 var oSrvc = createService();5809 sinon.stub(utils, "getFormFactor").returns(oFixture.sCurrentFormFactor);5810 sinon.stub(oSrvc, "_getMatchingInbounds").returns(5811 new jQuery.Deferred().resolve([{/*empty tm*/}]).promise()5812 );5813 // Act5814 oSrvc._isIntentSupportedOne(oFixture.sIntent).done(function () {5815 ok(false, "promise was rejected");5816 }).fail(function () {5817 ok(true, "promise was rejected");5818 }).always(function () {5819 start();5820 });5821 });5822 });5823 [5824 {5825 testDescription: "no parameters are specified in URL",5826 oDefaultedParamNames: [],5827 sResolutionResultUrl: "/some/url",5828 expectedResolutionResultUrl: "/some/url" // no parameter is even added5829 },5830 {5831 testDescription: "default parameters specified",5832 oDefaultedParamNames: ["Name1", "Name2"],5833 sResolutionResultUrl: "/some/url",5834 expectedResolutionResultUrl: "/some/url?sap-ushell-defaultedParameterNames=%5B%22Name1%22%2C%22Name2%22%5D"5835 },5836 {5837 testDescription: "url contains a parameter already",5838 oDefaultedParamNames: ["Name2", "Name1"],5839 sResolutionResultUrl: "/some/url?urlparam1=foo",5840 expectedResolutionResultUrl: "/some/url?urlparam1=foo&sap-ushell-defaultedParameterNames=%5B%22Name1%22%2C%22Name2%22%5D"5841 },5842 {5843 testDescription: "parameter names contain '&' and '?'",5844 oDefaultedParamNames: ["Nam&2", "Na?me1"],5845 sResolutionResultUrl: "/some/url?urlparam1=foo",5846 expectedResolutionResultUrl: "/some/url?urlparam1=foo&sap-ushell-defaultedParameterNames=%5B%22Na%3Fme1%22%2C%22Nam%262%22%5D"5847 }5848 ].forEach(function (oFixture) {5849 asyncTest("_resolveHashFragment: correctly adds sap-ushell-defaultedParameterNames when " + oFixture.testDescription, function () {5850 var oSrvc = createService(),5851 aFakeMatchingTargets = [{5852 defaultedParamNames: oFixture.oDefaultedParamNames,5853 resolutionResult: {5854 url: oFixture.sResolutionResultUrl5855 },5856 inbound: {5857 resolutionResult: {5858 applicationType: "SAPUI5",5859 additionalInformation: "SAPUI5.Component=com.sap.cus",5860 url: oFixture.sResolutionResultUrl5861 }5862 },5863 intentParamsPlusAllDefaults: []5864 }];5865 // returns the default parameter names after resolution5866 sinon.stub(oSrvc, "_getMatchingInbounds").returns(5867 new jQuery.Deferred().resolve(aFakeMatchingTargets).promise()5868 );5869 oSrvc._resolveHashFragment("SO-action")5870 .done(function (oResolutionResult) {5871 ok(true, "promise was resolved");5872 strictEqual(oResolutionResult.url, oFixture.expectedResolutionResultUrl,5873 "defaulted parameter names were correctly appended to result url");5874 })5875 .fail(function () {5876 ok(false, "promise was resolved");5877 })5878 .always(function () {5879 start();5880 });5881 });5882 });5883 // parameter mapping5884 asyncTest("_constructFallbackResolutionResult: logs an error when fallback function is passed as undefined", function () {5885 var oSrvc = createService();5886 sinon.stub(jQuery.sap.log, "error");5887 sinon.stub(jQuery.sap.log, "warning");5888 oSrvc._constructFallbackResolutionResult(5889 { /*oMatchingTarget*/5890 intentParamsPlusAllDefaults: {},5891 defaultedParamNames: []5892 },5893 undefined /*fnBoundFallback*/,5894 "#Action-toappnavsample"/*sFixedHashFragment*/5895 )5896 .then(function () {5897 ok(false, "the promise returned by _constructFallbackResolutionResult was rejected");5898 }, function (sErrorMessage) {5899 var iTimesErrorCalled;5900 ok(true, "the promise returned by _constructFallbackResolutionResult was rejected");5901 strictEqual(sErrorMessage, "Cannot resolve hash fragment: no fallback provided.",5902 "the promise was rejected with expected error message");5903 // test warnings5904 strictEqual(jQuery.sap.log.warning.getCalls().length, 0, "jQuery.sap.log.warning was called 0 times");5905 // test error message5906 iTimesErrorCalled = jQuery.sap.log.error.getCalls().length;5907 strictEqual(iTimesErrorCalled, 1, "jQuery.sap.log.warning was called 1 time");5908 if (iTimesErrorCalled) {5909 deepEqual(jQuery.sap.log.error.getCall(0).args, [5910 "Cannot resolve hash fragment",5911 "#Action-toappnavsample has matched an inbound that cannot be resolved client side and no resolveHashFragmentFallback method was implemented in ClientSideTargetResolutionAdapter",5912 "sap.ushell.services.ClientSideTargetResolution"5913 ], "the error was logged as expected");5914 }5915 })5916 .then(start, start);5917 });5918 asyncTest("resolveHashFragment: allows adapter to not implement fallback method", function () {5919 var oFakeAdapter = {5920 getInbounds: sinon.stub().returns(5921 new jQuery.Deferred().resolve([]).promise()5922 )5923 };5924 var oSrvc = new ClientSideTargetResolution(oFakeAdapter, null, null, null);5925 sinon.stub(oSrvc, "_resolveHashFragment").returns(new jQuery.Deferred().resolve({}).promise());5926 try {5927 oSrvc.resolveHashFragment("#Action-toappnavsample")5928 .always(function () {5929 var iResolveHashFragmentCallCount = oSrvc._resolveHashFragment.getCalls().length;5930 strictEqual(iResolveHashFragmentCallCount, 1, "_resolveHashFragment was called 1 time");5931 if (iResolveHashFragmentCallCount === 1) {5932 strictEqual(typeof oSrvc._resolveHashFragment.getCall(0).args[1], "undefined", "_resolveHashFragment was called with undefined fallback function");5933 }5934 start();5935 });5936 } catch (oError) {5937 ok(false, "resolveHashFragment did not throw an exception");5938 start();5939 }5940 });5941 asyncTest("resolveHashFragment calls _getMatchingInbounds with the expected third argument", function () {5942 // Arrange5943 sinon.stub(InboundProvider.prototype, "getInbounds").returns(5944 new Promise(function (fnResolve) { fnResolve(); })5945 );5946 var oSrvc = createService(),5947 sAnyHashFragment = "#Some-hashFragment";5948 sinon.stub(oSrvc, "_getURLParsing").returns({5949 parseShellHash: sinon.stub().returns({ "parsed": "shellHash" })5950 });5951 sinon.stub(oSrvc, "_getMatchingInbounds").returns(5952 new jQuery.Deferred().resolve([{ semanticObject: "Some", action: "hashFragment" }]).promise()5953 );5954 sinon.stub(oSrvc, "_resolveSingleMatchingTarget").returns(5955 new jQuery.Deferred().resolve([]).promise()5956 );5957 // Act5958 oSrvc.resolveHashFragment(sAnyHashFragment)5959 .done(function () {5960 ok(true, "promise was resolved");5961 testExcludeTileIntentArgument(oSrvc, true);5962 })5963 .fail(function () {5964 ok(false, "promise was resolved");5965 })5966 .always(function () {5967 start();5968 });5969 });5970 //Tests for resolveHashFragment are in the _ClientSideTargetResolution/ClientSideTargetResolution.resolveHashFragment.js5971 fnExecuteResolveHashFragment();5972 [5973 {5974 testDescription: "resolveHashFragment, hasSegmentedAccess",5975 // ignore certain fields not needed for the test5976 intent: "Action-aliasToAbsoluteUrl?sap-system=UR3CLNT120",5977 hasSegmentedAccess: true,5978 oInboundFilter: [{5979 semanticObject: "Action",5980 action: "aliasToAbsoluteUrl"5981 }]5982 },5983 {5984 testDescription: "resolveHashFragment, config disabled",5985 intent: "Action-aliasToAbsoluteUrl?sap-system=UR3CLNT120",5986 hasSegmentedAccess: false,5987 oInboundFilter: undefined5988 }5989 ].forEach(function (oFixture) {5990 asyncTest("inbound filter on resolveHashFragment when " + oFixture.testDescription, function () {5991 var oShellNavigationService = sap.ushell.Container.getService("ShellNavigation");5992 sinon.stub(sap.ushell.Container, "getUser").returns({5993 getLanguage: sinon.stub().returns("en")5994 });5995 sinon.spy(oShellNavigationService, "compactParams");5996 var oFakeAdapter = {5997 hasSegmentedAccess: oFixture.hasSegmentedAccess,5998 resolveSystemAlias: function (sSystemAlias) {5999 var oDeferred = new jQuery.Deferred();6000 if (oFixture.oKnownSapSystemData && oFixture.oKnownSapSystemData.hasOwnProperty(sSystemAlias)) {6001 return oDeferred.resolve(oFixture.oKnownSapSystemData[sSystemAlias]).promise();6002 }6003 if (sSystemAlias === "") {6004 return oDeferred.resolve(oTestHelper.getLocalSystemAlias()).promise();6005 }6006 return oDeferred.reject("Cannot resolve system alias").promise();6007 },6008 getInbounds: sinon.stub().returns(6009 new jQuery.Deferred().resolve([oFixture.inbound]).promise()6010 ),6011 resolveHashFragmentFallback: function (oIntent, oMatchingTarget, oParameters) {6012 return new jQuery.Deferred().resolve({ url: "fallback :-(" + JSON.stringify(oParameters).replace(/["]/g, "").replace(/\\/g, "") }).promise();6013 }6014 };6015 var oSrvc = new ClientSideTargetResolution(oFakeAdapter, null, null, oFixture.config);6016 sinon.spy(InboundProvider.prototype, "getInbounds");6017 sinon.stub(oSrvc, "_resolveHashFragment").returns(new jQuery.Deferred().resolve({a: 1}).promise());6018 // Act6019 oSrvc.resolveHashFragment(oFixture.intent, /*fnBoundFallback*/ function () {6020 ok(false, "fallback function is not called");6021 })6022 .done(function (oResolutionResult) {6023 ok(true, "promise was resolved");6024 deepEqual(InboundProvider.prototype.getInbounds.args[0][0], oFixture.oInboundFilter, "inbound reqeust properly filtered");6025 deepEqual(oFakeAdapter.getInbounds.args[0][0], oFixture.oInboundFilter, "inbound reqeust properly filtered");6026 })6027 .fail(function () {6028 // Assert6029 ok(false, "promise was resolved");6030 })6031 .always(function () {6032 start();6033 oShellNavigationService.compactParams.restore();6034 });6035 });6036 });6037// getEasyAccessSystems6038 [6039 {6040 testDescription: "there is no inbound",6041 aInbounds: [],6042 expectedEasyAccessSystems: {6043 userMenu: {},6044 sapMenu: {}6045 }6046 },6047 {6048 testDescription: "empty sap-system",6049 aInbounds: [6050 {6051 id: "Shell-startGUI",6052 semanticObject: "Shell",6053 action: "startGUI",6054 title: "",6055 signature: {6056 parameters: {6057 "sap-system": {6058 required: true6059 }6060 }6061 },6062 deviceTypes: {6063 desktop: true,6064 tablet: true,6065 phone: true6066 }6067 },6068 {6069 id: "Shell-startWDA",6070 semanticObject: "Shell",6071 action: "startWDA",6072 title: "",6073 signature: {6074 parameters: {6075 "sap-system": {6076 required: true6077 }6078 }6079 },6080 deviceTypes: {6081 desktop: true,6082 tablet: true,6083 phone: true6084 }6085 },6086 {6087 id: "Shell-startURL",6088 semanticObject: "Shell",6089 action: "startURL",6090 title: "",6091 signature: {6092 parameters: {6093 "sap-system": {6094 required: true6095 }6096 }6097 },6098 deviceTypes: {6099 desktop: true,6100 tablet: true,6101 phone: true6102 }6103 }6104 ],6105 expectedEasyAccessSystems: {6106 userMenu: {},6107 sapMenu: {}6108 },6109 expectedWarningCalls: {6110 userMenu: [6111 [ // first call args6112 "Cannot extract sap-system from easy access menu inbound: #Shell-startGUI{sap-system:<?>}",6113 "This parameter is supposed to be a string. Got 'undefined' instead.",6114 "sap.ushell.services.ClientSideTargetResolution"6115 ],6116 [ // second call args6117 "Cannot extract sap-system from easy access menu inbound: #Shell-startWDA{sap-system:<?>}",6118 "This parameter is supposed to be a string. Got 'undefined' instead.",6119 "sap.ushell.services.ClientSideTargetResolution"6120 ],6121 [ // third call args6122 "Cannot extract sap-system from easy access menu inbound: #Shell-startURL{sap-system:<?>}",6123 "This parameter is supposed to be a string. Got 'undefined' instead.",6124 "sap.ushell.services.ClientSideTargetResolution"6125 ]6126 ],6127 sapMenu: [6128 [ // first call args6129 "Cannot extract sap-system from easy access menu inbound: #Shell-startGUI{sap-system:<?>}",6130 "This parameter is supposed to be a string. Got 'undefined' instead.",6131 "sap.ushell.services.ClientSideTargetResolution"6132 ],6133 [ // second call args6134 "Cannot extract sap-system from easy access menu inbound: #Shell-startWDA{sap-system:<?>}",6135 "This parameter is supposed to be a string. Got 'undefined' instead.",6136 "sap.ushell.services.ClientSideTargetResolution"6137 ]6138 ]6139 }6140 },6141 {6142 testDescription: "there is no start... inbound",6143 aInbounds: [6144 {6145 id: "Shell-toMyApp~631w",6146 semanticObject: "Shell",6147 action: "toMyApp",6148 title: "My app",6149 signature: {6150 parameters: {6151 "sap-system": {6152 required: true,6153 filter: {6154 value: "AB1CLNT000"6155 }6156 }6157 }6158 },6159 deviceTypes: {6160 desktop: true,6161 tablet: true,6162 phone: true6163 }6164 }6165 ],6166 expectedEasyAccessSystems: {6167 userMenu: {},6168 sapMenu: {}6169 }6170 },6171 {6172 testDescription: "there is one startWDA inbound",6173 aInbounds: [6174 {6175 id: "Shell-startWDA~631w",6176 semanticObject: "Shell",6177 action: "startWDA",6178 title: "CRM Europe",6179 signature: {6180 parameters: {6181 "sap-system": {6182 required: true,6183 filter: {6184 value: "AB1CLNT000"6185 }6186 }6187 }6188 },6189 deviceTypes: {6190 desktop: true,6191 tablet: true,6192 phone: true6193 }6194 }6195 ],6196 expectedEasyAccessSystems: {6197 userMenu: {6198 AB1CLNT000: {6199 text: "CRM Europe",6200 appType: {6201 WDA: true6202 }6203 }6204 },6205 sapMenu: {6206 AB1CLNT000: {6207 text: "CRM Europe",6208 appType: {6209 WDA: true6210 }6211 }6212 }6213 }6214 },6215 {6216 testDescription: "there is one startURL inbound",6217 aInbounds: [6218 {6219 id: "Shell-startURL",6220 semanticObject: "Shell",6221 action: "startURL",6222 title: "BOE Europe",6223 signature: {6224 parameters: {6225 "sap-system": {6226 required: true,6227 filter: {6228 value: "AB1CLNT000"6229 }6230 }6231 }6232 },6233 deviceTypes: {6234 desktop: true,6235 tablet: true,6236 phone: true6237 }6238 }6239 ],6240 expectedEasyAccessSystems: {6241 userMenu: {6242 AB1CLNT000: {6243 text: "BOE Europe",6244 appType: {6245 URL: true6246 }6247 }6248 },6249 sapMenu: { /* URL types ignored in sap menu */ }6250 }6251 },6252 {6253 testDescription: "there are two start... inbounds for two different systems with high and lower priority respectively",6254 aInbounds: [6255 {6256 id: "Shell-startWDA~6311",6257 semanticObject: "Shell",6258 action: "startGUI",6259 title: "GUI Title",6260 signature: {6261 parameters: {6262 "sap-system": {6263 required: true,6264 filter: {6265 value: "SYSTEM1"6266 }6267 }6268 }6269 },6270 deviceTypes: { desktop: true, tablet: true, phone: true }6271 },6272 {6273 id: "Shell-startURL~6312",6274 semanticObject: "Shell",6275 action: "startURL",6276 title: "URL Title",6277 signature: {6278 parameters: {6279 "sap-system": {6280 required: true,6281 filter: {6282 value: "SYSTEM2"6283 }6284 }6285 }6286 },6287 deviceTypes: {6288 desktop: true,6289 tablet: true,6290 phone: true6291 }6292 }6293 ],6294 expectedEasyAccessSystems: {6295 userMenu: {6296 SYSTEM1: {6297 text: "GUI Title",6298 appType: {6299 TR: true6300 }6301 },6302 SYSTEM2: {6303 text: "URL Title",6304 appType: {6305 URL: true6306 }6307 }6308 },6309 sapMenu: {6310 SYSTEM1: {6311 text: "GUI Title",6312 appType: {6313 TR: true6314 }6315 }6316 }6317 }6318 },6319 {6320 testDescription: "there are two different start... inbounds",6321 aInbounds: [6322 {6323 id: "Shell-startWDA~631w",6324 semanticObject: "Shell",6325 action: "startWDA",6326 title: "CRM Europe",6327 signature: {6328 parameters: {6329 "sap-system": {6330 required: true,6331 filter: {6332 value: "AB1CLNT000"6333 }6334 }6335 }6336 },6337 deviceTypes: {6338 desktop: true,6339 tablet: true,6340 phone: true6341 }6342 },6343 {6344 id: "Shell-startGUI~644w",6345 semanticObject: "Shell",6346 action: "startGUI",6347 title: "HR Central",6348 signature: {6349 parameters: {6350 "sap-system": {6351 required: true,6352 filter: {6353 value: "XY1CLNT100"6354 }6355 }6356 }6357 },6358 deviceTypes: {6359 desktop: true,6360 tablet: true,6361 phone: true6362 }6363 }6364 ],6365 expectedEasyAccessSystems: {6366 userMenu: {6367 AB1CLNT000: {6368 text: "CRM Europe",6369 appType: {6370 WDA: true6371 }6372 },6373 XY1CLNT100: {6374 text: "HR Central",6375 appType: {6376 TR: true6377 }6378 }6379 },6380 sapMenu: {6381 AB1CLNT000: {6382 text: "CRM Europe",6383 appType: {6384 WDA: true6385 }6386 },6387 XY1CLNT100: {6388 text: "HR Central",6389 appType: {6390 TR: true6391 }6392 }6393 }6394 }6395 },6396 {6397 testDescription: "there are two start... inbounds one URL and one WDA with the same system alias and same length texts (startWDA is preferred)",6398 aInbounds: [6399 {6400 id: "Shell-startURL~631w",6401 semanticObject: "Shell",6402 action: "startURL",6403 title: "BOE Europe",6404 signature: {6405 parameters: {6406 "sap-system": {6407 required: true,6408 filter: {6409 value: "AB1CLNT000"6410 }6411 }6412 }6413 },6414 deviceTypes: {6415 desktop: true,6416 tablet: true,6417 phone: true6418 }6419 },6420 {6421 id: "Shell-startWDA~631w",6422 semanticObject: "Shell",6423 action: "startWDA",6424 title: "CRM Europe",6425 signature: {6426 parameters: {6427 "sap-system": {6428 required: true,6429 filter: {6430 value: "AB1CLNT000"6431 }6432 }6433 }6434 },6435 deviceTypes: {6436 desktop: true,6437 tablet: true,6438 phone: true6439 }6440 }6441 ],6442 expectedEasyAccessSystems: {6443 userMenu: {6444 AB1CLNT000: {6445 text: "CRM Europe",6446 appType: {6447 URL: true,6448 WDA: true6449 }6450 }6451 },6452 sapMenu: {6453 AB1CLNT000: {6454 text: "CRM Europe",6455 appType: {6456 WDA: true6457 }6458 }6459 }6460 }6461 },6462 {6463 testDescription: "there are three start... inbounds with the same system alias and same length texts (startGUI is preferred)",6464 aInbounds: [6465 {6466 id: "Shell-startGUI~644w",6467 semanticObject: "Shell",6468 action: "startGUI",6469 title: "HCM Europe",6470 signature: {6471 parameters: {6472 "sap-system": {6473 required: true,6474 filter: {6475 value: "AB1CLNT000"6476 }6477 }6478 }6479 },6480 deviceTypes: {6481 desktop: true,6482 tablet: true,6483 phone: true6484 }6485 },6486 {6487 id: "Shell-startURL~631w",6488 semanticObject: "Shell",6489 action: "startURL",6490 title: "BOE Europe",6491 signature: {6492 parameters: {6493 "sap-system": {6494 required: true,6495 filter: {6496 value: "AB1CLNT000"6497 }6498 }6499 }6500 },6501 deviceTypes: {6502 desktop: true,6503 tablet: true,6504 phone: true6505 }6506 },6507 {6508 id: "Shell-startWDA~631w",6509 semanticObject: "Shell",6510 action: "startWDA",6511 title: "CRM Europe",6512 signature: {6513 parameters: {6514 "sap-system": {6515 required: true,6516 filter: {6517 value: "AB1CLNT000"6518 }6519 }6520 }6521 },6522 deviceTypes: {6523 desktop: true,6524 tablet: true,6525 phone: true6526 }6527 }6528 ],6529 expectedEasyAccessSystems: {6530 userMenu: {6531 AB1CLNT000: {6532 text: "HCM Europe",6533 appType: {6534 TR: true,6535 URL: true,6536 WDA: true6537 }6538 }6539 },6540 sapMenu: {6541 AB1CLNT000: {6542 text: "HCM Europe",6543 appType: {6544 TR: true,6545 WDA: true6546 }6547 }6548 }6549 }6550 },6551 {6552 testDescription: "there are three start... inbounds with the same system alias and same length texts (GUI wins over WDA and URL)",6553 aInbounds: [6554 {6555 id: "Shell-startWDA~631w",6556 semanticObject: "Shell",6557 action: "startWDA",6558 title: "HCM Europe",6559 signature: {6560 parameters: {6561 "sap-system": {6562 required: true,6563 filter: {6564 value: "AB1CLNT000"6565 }6566 }6567 }6568 },6569 deviceTypes: {6570 desktop: true,6571 tablet: true,6572 phone: true6573 }6574 },6575 {6576 id: "Shell-startGUI~644w",6577 semanticObject: "Shell",6578 action: "startGUI",6579 title: "CRM Europe",6580 signature: {6581 parameters: {6582 "sap-system": {6583 required: true,6584 filter: {6585 value: "AB1CLNT000"6586 }6587 }6588 }6589 },6590 deviceTypes: {6591 desktop: true,6592 tablet: true,6593 phone: true6594 }6595 },6596 {6597 id: "Shell-startURL~631w",6598 semanticObject: "Shell",6599 action: "startURL",6600 title: "BOE Europe",6601 signature: {6602 parameters: {6603 "sap-system": {6604 required: true,6605 filter: {6606 value: "AB1CLNT000"6607 }6608 }6609 }6610 },6611 deviceTypes: {6612 desktop: true,6613 tablet: true,6614 phone: true6615 }6616 }6617 ],6618 expectedEasyAccessSystems: {6619 userMenu: {6620 AB1CLNT000: {6621 text: "CRM Europe",6622 appType: {6623 TR: true,6624 URL: true,6625 WDA: true6626 }6627 }6628 },6629 sapMenu: {6630 AB1CLNT000: {6631 text: "CRM Europe",6632 appType: {6633 TR: true,6634 WDA: true6635 }6636 }6637 }6638 }6639 },6640 {6641 testDescription: "there are two start... inbounds with the same system alias and same texts",6642 aInbounds: [6643 {6644 id: "Shell-startWDA~631w",6645 semanticObject: "Shell",6646 action: "startWDA",6647 title: "CRM Europe",6648 signature: {6649 parameters: {6650 "sap-system": {6651 required: true,6652 filter: {6653 value: "AB1CLNT000"6654 }6655 }6656 }6657 },6658 deviceTypes: {6659 desktop: true,6660 tablet: true,6661 phone: true6662 }6663 },6664 {6665 id: "Shell-startGUI~644w",6666 semanticObject: "Shell",6667 action: "startGUI",6668 title: "CRM Europe",6669 signature: {6670 parameters: {6671 "sap-system": {6672 required: true,6673 filter: {6674 value: "AB1CLNT000"6675 }6676 }6677 }6678 },6679 deviceTypes: {6680 desktop: true,6681 tablet: true,6682 phone: true6683 }6684 }6685 ],6686 expectedEasyAccessSystems: {6687 userMenu: {6688 AB1CLNT000: {6689 text: "CRM Europe",6690 appType: {6691 TR: true,6692 WDA: true6693 }6694 }6695 },6696 sapMenu: {6697 AB1CLNT000: {6698 text: "CRM Europe",6699 appType: {6700 TR: true,6701 WDA: true6702 }6703 }6704 }6705 }6706 },6707 {6708 testDescription: "the device type of the inbound is not matching for WDA",6709 aInbounds: [6710 {6711 id: "Shell-startWDA~631w",6712 semanticObject: "Shell",6713 action: "startWDA",6714 title: "CRM Europe",6715 signature: {6716 parameters: {6717 "sap-system": {6718 required: true,6719 filter: {6720 value: "AB1CLNT000"6721 }6722 }6723 }6724 },6725 deviceTypes: {6726 desktop: false,6727 tablet: true,6728 phone: true6729 }6730 }6731 ],6732 expectedEasyAccessSystems: {6733 userMenu: { },6734 sapMenu: { }6735 }6736 },6737 {6738 testDescription: "the device type of the inbound is not matching for URL",6739 aInbounds: [6740 {6741 id: "Shell-startURL~631w",6742 semanticObject: "Shell",6743 action: "startURL",6744 title: "POCBOE",6745 signature: {6746 parameters: {6747 "sap-system": {6748 required: true,6749 filter: {6750 value: "FLPINTEGRATION2015_588"6751 }6752 }6753 }6754 },6755 deviceTypes: {6756 desktop: false,6757 tablet: true,6758 phone: true6759 }6760 }6761 ],6762 expectedEasyAccessSystems: {6763 userMenu: { },6764 sapMenu: { }6765 }6766 },6767 {6768 testDescription: "numeric sap-system",6769 aInbounds: [6770 {6771 id: "Shell-startURL~631w",6772 semanticObject: "Shell",6773 action: "startURL",6774 title: "POCBOE",6775 signature: {6776 parameters: {6777 "sap-system": {6778 required: true,6779 filter: {6780 value: "FLPINTEGRATION2015_588"6781 }6782 }6783 }6784 },6785 deviceTypes: {6786 desktop: false,6787 tablet: true,6788 phone: true6789 }6790 }6791 ],6792 expectedEasyAccessSystems: {6793 userMenu: { },6794 sapMenu: { }6795 }6796 }6797 ].forEach(function (oFixture) {6798 ["userMenu", "sapMenu"].forEach(function (sMenuType) {6799 asyncTest("getEasyAccessSystems('" + sMenuType + "') returns the expected list of systems when " + oFixture.testDescription, function () {6800 var oService;6801 sinon.stub(jQuery.sap.log, "warning");6802 // Arrange6803 sinon.stub(utils, "getFormFactor").returns("desktop");6804 oService = createService({6805 inbounds: oFixture.aInbounds6806 });6807 // Act6808 oService.getEasyAccessSystems(sMenuType)6809 .done(function (oActualEasyAccessSystems) {6810 start();6811 // Assert6812 deepEqual(oActualEasyAccessSystems, oFixture.expectedEasyAccessSystems[sMenuType], "Easy Access Systems properly extracted from inbounds");6813 if (oFixture.expectedWarningCalls && oFixture.expectedWarningCalls[sMenuType]) {6814 var aExpectedWarningCalls = oFixture.expectedWarningCalls[sMenuType];6815 strictEqual(6816 jQuery.sap.log.warning.callCount,6817 aExpectedWarningCalls.length,6818 "jQuery.sap.log.warning was called the expected number of times"6819 );6820 if (aExpectedWarningCalls.length === jQuery.sap.log.warning.callCount) {6821 aExpectedWarningCalls.forEach(function (aCallArgs, iCall) {6822 deepEqual(6823 jQuery.sap.log.warning.getCall(iCall).args,6824 aCallArgs,6825 "jQuery.sap.log.warning was called with the expected arguments on call #" + (iCall + 1)6826 );6827 });6828 }6829 } else {6830 strictEqual(jQuery.sap.log.warning.callCount,6831 0, "jQuery.sap.log.warning was not called");6832 }6833 });6834 });6835 });6836 });6837 [6838 {6839 aInbounds: [6840 {6841 id: "Shell-startGUI~644w",6842 semanticObject: "Shell",6843 action: "startGUI",6844 title: "CRM Europe",6845 signature: {6846 parameters: {6847 "sap-system": {6848 required: true,6849 filter: {6850 value: "AB1CLNT000"6851 }6852 }6853 }6854 },6855 deviceTypes: {6856 desktop: true,6857 tablet: true,6858 phone: true6859 }6860 }6861 ],6862 expectedEasyAccessSystems: {6863 AB1CLNT000: {6864 text: "CRM Europe",6865 appType: {6866 TR: true6867 }6868 }6869 }6870 }6871 ].forEach(function (oFixture) {6872 asyncTest("getEasyAccessSystems is calculating the easy access system list only once", 2, function () {6873 var oService,6874 oFakeAdapter;6875 // Arrange6876 sinon.stub(utils, "getFormFactor").returns("desktop");6877 oFakeAdapter = {6878 getInbounds: sinon.stub().returns(6879 new jQuery.Deferred()6880 .resolve(oFixture.aInbounds)6881 .promise()6882 )6883 };6884 oService = new ClientSideTargetResolution(oFakeAdapter, null, null);6885 // Act6886 oService.getEasyAccessSystems()6887 .done(function (oActualEasyAccessSystems1) {6888 oService.getEasyAccessSystems()6889 .done(function (oActualEasyAccessSystems2) {6890 // Assert6891 start();6892 deepEqual(oActualEasyAccessSystems2, oFixture.expectedEasyAccessSystems, "Easy Access Systems properly extracted from inbounds");6893 ok(oFakeAdapter.getInbounds.calledOnce, "getInbounds is only called once");6894 });6895 });6896 });6897 });6898 [{6899 testDescription: "synchronous"6900 }].forEach(function (oFixture) {6901 asyncTest("_getMatchingInboundsSync: " + oFixture.testDescription, 1, function () {6902 var oSrvc = createService();6903 var aFakeMatchResults = [6904 { num: 18, matches: true, priorityString: "B", inbound: { resolutionResult: {} } },6905 { num: 31, matches: true, priorityString: "CD", inbound: { resolutionResult: {} } },6906 { num: 33, matches: true, priorityString: "CZ", inbound: { resolutionResult: {} } },6907 { num: 41, matches: true, priorityString: "A", inbound: { resolutionResult: {} } },6908 { num: 44, matches: true, priorityString: "C", inbound: { resolutionResult: {} } },6909 { num: 46, matches: true, priorityString: "CE", inbound: { resolutionResult: {} } }6910 ];6911 sinon.stub(oSearch, "match").returns(jQuery.Deferred().resolve({6912 missingReferences: {},6913 matchResults: aFakeMatchResults6914 }).promise());6915 var aFakeInbounds = aFakeMatchResults.map(function (oMatchResult) {6916 return oMatchResult.inbound;6917 });6918 var oIndex = oInboundIndex.createIndex(aFakeInbounds);6919 // Act 26920 var i = 2;6921 oSrvc._getMatchingInbounds({}/* any parameter ok for the test*/, oIndex, { }).done(function (aMatchingInbounds) {6922 start();6923 equal(i, 2, "value ok");6924 }).fail(function () {6925 ok(false, "promise was resolved");6926 });6927 i = 3;6928 });6929 });6930 QUnit.module("_getReservedParameters", {6931 beforeEach: function () {6932 this.oMatchingTarget = {6933 "inbound": {6934 "signature": {6935 "parameters": {6936 "sap-navigation-scope": {6937 required: false,6938 "defaultValue": {6939 value: "green",6940 format: "plain"6941 }6942 },6943 "sap-priority": {6944 required: false,6945 "defaultValue": {6946 value: "3",6947 format: "plain"6948 }6949 }6950 }6951 }6952 },6953 "intentParamsPlusAllDefaults": {6954 "sap-navigation-scope": ["green"],6955 "sap-navigation-scope-filter": ["green"],6956 "sap-priority": ["3"]6957 },6958 "defaultedParamNames": ["sap-navigation-scope", "sap-priority"]6959 };6960 this.oGetParametersStub = sinon.stub(TechnicalParameters, "getParameters");6961 this.oGetParametersStub.withArgs({ injectFrom: "startupParameter" }).returns([]);6962 this.oGetParametersStub.withArgs({ injectFrom: "inboundParameter" }).returns([{ name: "sap-navigation-scope" }]);6963 this.oExtractParametersStub = sinon.stub(oCSTRUtils, "extractParameters").returns({"param1": "1"});6964 },6965 afterEach: function () {6966 this.oMatchResult = null;6967 this.oGetParametersStub.restore();6968 this.oExtractParametersStub.restore();6969 }6970 });6971 QUnit.test("Matching reserved parameters are removed from matching target", function (assert) {6972 // Act6973 ClientSideTargetResolution.prototype._getReservedParameters(this.oMatchingTarget);6974 // Assert6975 assert.equal(Object.keys(this.oMatchingTarget.intentParamsPlusAllDefaults).length, 2, "The parameter is removed correctly");6976 assert.equal(this.oMatchingTarget.defaultedParamNames.length, 1, "The parameter is removed correctly");6977 });6978 QUnit.test("Calls getParameters", function (assert) {6979 // Act6980 ClientSideTargetResolution.prototype._getReservedParameters(this.oMatchingTarget);6981 // Assert6982 assert.equal(this.oGetParametersStub.callCount, 2, "getParameters is called returned correctly");6983 assert.deepEqual(this.oGetParametersStub.getCall(0).args, [{"injectFrom": "startupParameter"}], "getParameters is called with correct parameter");6984 assert.deepEqual(this.oGetParametersStub.getCall(1).args, [{"injectFrom": "inboundParameter"}], "getParameters is called with correct parameter");6985 });6986 QUnit.test("Returns an object which contains all reserved parameters", function (assert) {6987 // Act6988 var oResult = ClientSideTargetResolution.prototype._getReservedParameters(this.oMatchingTarget);6989 // Assert6990 assert.deepEqual(oResult, {"param1": "1", "sap-navigation-scope": "green"}, "The parameters are returned correctly");6991 });6992 QUnit.module("_applySapNavigationScope", {6993 beforeEach: function () {6994 this.oSrvc = createService();6995 },6996 afterEach: function () {6997 this.oSrvc = null;6998 }6999 });7000 QUnit.test("Returns the input matching inbounds if the shell hash does not contain sap-navigation-scope-filter", function (assert) {7001 // Arrange7002 var oShellHash = {7003 params: {}7004 };7005 var aMatchingTargets = [{7006 inbound: {7007 signature: {7008 parameters: {}7009 }7010 }7011 },7012 {7013 inbound: {7014 signature: {7015 parameters: {}7016 }7017 }7018 }];7019 // Act7020 var aResult = this.oSrvc._applySapNavigationScopeFilter(aMatchingTargets, oShellHash);7021 // Assert7022 assert.deepEqual(aResult, aMatchingTargets, "Correct matching inbounds are returned");7023 });7024 QUnit.test("Returns the input matching inbounds if there is no inbound containing sap-navigation-scope", function (assert) {7025 // Arrange7026 var oShellHash = {7027 params: {7028 "sap-navigation-scope-filter": ["green"]7029 }7030 };7031 var aMatchingTargets = [{7032 inbound: {7033 signature: {7034 parameters: {}7035 }7036 }7037 },7038 {7039 inbound: {7040 signature: {7041 parameters: {}7042 }7043 }7044 }];7045 // Act7046 var aResult = this.oSrvc._applySapNavigationScopeFilter(aMatchingTargets, oShellHash);7047 // Assert7048 assert.deepEqual(aResult, aMatchingTargets, "Correct matching inbounds are returned");7049 });7050 QUnit.test("Returns the input matching inbounds if there is no matching sap-navigation-scope", function (assert) {7051 // Arrange7052 var oShellHash = {7053 params: {7054 "sap-navigation-scope-filter": ["green"]7055 }7056 };7057 var aMatchingTargets = [{7058 id: "inbound1",7059 inbound: {7060 signature: {7061 parameters: {7062 "sap-navigation-scope": {7063 defaultValue: {7064 value: "pink"7065 }7066 }7067 }7068 }7069 }7070 },7071 {7072 inbound: {7073 id: "inbound2",7074 signature: {7075 parameters: {7076 "sap-navigation-scope": {7077 defaultValue: {7078 value: "pink"7079 }7080 }7081 }7082 }7083 }7084 }];7085 // Act7086 var aResult = this.oSrvc._applySapNavigationScopeFilter(aMatchingTargets, oShellHash);7087 // Assert7088 assert.strictEqual(aResult, aMatchingTargets, "Correct matching inbounds are returned");7089 });7090 QUnit.test("Returns inbounds with matching sap-navigation-scope", function (assert) {7091 // Arrange7092 var oShellHash = {7093 params: {7094 "sap-navigation-scope-filter": ["green"]7095 }7096 };7097 var aMatchingTargets = [{7098 id: "inbound1",7099 inbound: {7100 signature: {7101 parameters: {7102 "sap-navigation-scope": {7103 defaultValue: {7104 value: "pink"7105 }7106 }7107 }7108 }7109 }7110 },7111 {7112 inbound: {7113 id: "inbound2",7114 signature: {7115 parameters: {7116 "sap-navigation-scope": {7117 defaultValue: {7118 value: "green"7119 }7120 }7121 }7122 }7123 }7124 }];7125 // Act7126 var aResult = this.oSrvc._applySapNavigationScopeFilter(aMatchingTargets, oShellHash);7127 // Assert7128 assert.strictEqual(aResult[0].id, aMatchingTargets[1].id, "Correct matching inbound is returned");7129 });7130 QUnit.module("transient state", {7131 beforeEach: function (assert) {7132 var fnDone = assert.async();7133 var testState = {7134 "ABCSTATE": '{"selectionVariant":{"SelectOptions":[{"PropertyName":"P1","Ranges":[{"Sign":"I","Option":"EQ","Low":"INT","High":null}]}]}}'7135 };7136 ObjectPath.set("sap-ushell-config.services.AppState.config.initialAppStates", testState);7137 sap.ushell.bootstrap("local").then(fnDone);7138 },7139 afterEach: function () {7140 delete sap.ushell.Container;7141 delete window["sap-ushell-config"].services.AppState;7142 }7143 });7144 ["SAPUI5", "WDA"].forEach(function (sAppType) {7145 test("transient app state does not persist for applicationType: " + sAppType, function (assert) {7146 var fnDone = assert.async();7147 var oMatchTarget = {7148 "inbound": {7149 "semanticObject": "Action",7150 "action": "testAppStateNotSave",7151 "resolutionResult": {7152 "applicationType": sAppType,7153 "url": "/test/url"7154 },7155 "signature": {7156 "parameters": {7157 "P1": {7158 "renameTo": "P1New",7159 "required": false7160 }7161 },7162 "additionalParameters": "allowed"7163 }7164 },7165 "intentParamsPlusAllDefaults": {7166 "sap-xapp-state": [7167 "ABCSTATE"7168 ]7169 },7170 "defaultedParamNames": [],7171 "resolutionResult": {},7172 "matches": true,7173 "matchesVirtualInbound": false,7174 "parsedIntent": {7175 "semanticObject": "Action",7176 "action": "parameterRename",7177 "params": {7178 "sap-xapp-state": [7179 "ABCSTATE"7180 ]7181 },7182 "formFactor": "desktop"7183 }7184 };7185 var sHash = "#Action-testAppStateNotSave?sap-xapp-state=ABCSTATE";7186 var fnBoundFallback = sinon.spy();7187 var oSrvc = createService();7188 var oAppStateService = sap.ushell.Container.getService("AppState"),7189 oWindowAdapter = oAppStateService._oAdapter,7190 oBackendAdapter = oWindowAdapter._oBackendAdapter,7191 oWindowAdapterSaveSpy = sinon.spy(oWindowAdapter, "saveAppState"),7192 oBackendAdapterSaveSpy = sinon.spy(oBackendAdapter, "saveAppState");7193 oSrvc._resolveSingleMatchingTarget(oMatchTarget, fnBoundFallback, sHash)7194 .done(function (oResolvedTarget) {7195 assert.ok(true, "target was succesfully resolved");7196 assert.ok(fnBoundFallback.notCalled, "fnBoundFallback was not called");7197 assert.ok(oWindowAdapterSaveSpy.calledOnce, "saveAppState of WindowApadter was called");7198 assert.ok(oWindowAdapterSaveSpy.getCall(0).args[0] !== "ABCSTATE", "new state is saved");7199 assert.equal(oResolvedTarget.url.split("=")[1], oWindowAdapterSaveSpy.getCall(0).args[0], "new state is added to url");7200 assert.ok(oWindowAdapterSaveSpy.getCall(0).args[5], "saveAppState of WindowApadter should be called with bTransient=true");7201 assert.ok(oBackendAdapterSaveSpy.notCalled, "saveAppState of oBackendAdapter was not called");7202 })7203 .fail(function () {7204 assert.ok(false, "target should be succesfully resolved");7205 })7206 .always(function () {7207 oWindowAdapterSaveSpy.restore();7208 oBackendAdapterSaveSpy.restore();7209 fnDone();7210 });7211 });7212 });...

Full Screen

Full Screen

driver.js

Source:driver.js Github

copy

Full Screen

...205 }206 if (this.opts.app) {207 await this.installApp();208 }209 await this.startWda(this.opts.sessionId, realDevice);210 await this.setInitialOrientation(this.opts.orientation);211 if (this.isSafari() || this.opts.autoWebview) {212 log.debug('Waiting for initial webview');213 await this.navToInitialWebview();214 }215 }216 async startWda (sessionId, realDevice, tries = 0) {217 tries++;218 this.wda = new WebDriverAgent(this.xcodeVersion, this.opts);219 if (this.opts.useNewWDA) {220 log.debug(`Capability 'useNewWDA' set, so uninstalling WDA before proceeding`);221 await this.wda.uninstall();222 }223 // local helper for the two places we need to uninstall wda and re-start it224 let uninstallAndRestart = async () => {225 log.debug('Quitting and uninstalling WebDriverAgent, then retrying');226 await this.wda.quit();227 await this.wda.uninstall();228 await this.startWda(sessionId, realDevice, tries);229 };230 try {231 await this.wda.launch(sessionId, realDevice);232 } catch (err) {233 if (tries > WDA_STARTUP_RETRIES) throw err;234 log.debug(`Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}`);235 await uninstallAndRestart();236 }237 this.proxyReqRes = this.wda.proxyReqRes.bind(this.wda);238 this.jwpProxyActive = true;239 try {240 await retryInterval(15, 500, async () => {241 log.debug('Sending createSession command to WDA');242 try {...

Full Screen

Full Screen

ApplicationType.qunit.js

Source:ApplicationType.qunit.js Github

copy

Full Screen

1// Copyright (c) 2009-2017 SAP SE, All Rights Reserved2sap.ui.require([3 "sap/ushell/ApplicationType",4 "sap/ushell/services/URLParsing",5 "sap/ushell/_ApplicationType/systemAlias"6], function (oApplicationType, URLParsing, oSystemAlias) {7 "use strict";8 /* global QUnit sinon */9 var O_LOCAL_SYSTEM_ALIAS = { // local system alias (hardcoded in the adapter for now)10 "http": {11 "id": "",12 "host": "",13 "port": 0,14 "pathPrefix": "/sap/bc/"15 },16 "https": {17 "id": "",18 "host": "",19 "port": 0,20 "pathPrefix": "/sap/bc/"21 },22 "rfc": {23 "id": "",24 "systemId": "",25 "host": "",26 "service": 0,27 "loginGroup": "",28 "sncNameR3": "",29 "sncQoPR3": ""30 },31 "id": "",32 "client": "",33 "language": ""34 };3536 var O_KNOWN_SYSTEM_ALIASES = {37 "UR3CLNT120": {38 "http": {39 "id": "UR3CLNT120_HTTP",40 "host": "example.corp.com",41 "port": "50055", // note: string is also valid for the port42 "pathPrefix": ""43 },44 "https": {45 "id": "UR3CLNT120_HTTPS",46 "host": "example.corp.com",47 "port": 44355,48 "pathPrefix": ""49 },50 "rfc": {51 "id": "UR3CLNT120",52 "systemId": "",53 "host": "example.corp.com",54 "service": 3255,55 "loginGroup": "",56 "sncNameR3": "p/secude:CN=UR3, O=SAP-AG, C=DE",57 "sncQoPR3": "8"58 },59 "id": "UR3CLNT120",60 "client": "120",61 "language": ""62 },63 "SYSCONNSTRING": {64 "http": {65 "id": "UR3CLNT120_HTTP",66 "host": "example.corp.com",67 "port": "50055", // note: string is also valid for the port68 "pathPrefix": ""69 },70 "https": {71 "id": "UR3CLNT120_HTTPS",72 "host": "example.corp.com",73 "port": 44355,74 "pathPrefix": ""75 },76 "rfc": {77 "id": "UR3CLNT120",78 "systemId": "",79 "host": "/H/Coffee/S/Decaf/G/Roast",80 "service": 3255,81 "loginGroup": "",82 "sncNameR3": "p/secude:CN=UR3, O=SAP-AG, C=DE",83 "sncQoPR3": "8"84 },85 "id": "UR3CLNT120",86 "client": "120",87 "language": ""88 },89 "ALIASRFC": {90 "http": {91 "id": "ALIASRFC_HTTP",92 "host": "example.corp.com",93 "port": 50055,94 "pathPrefix": "/aliaspath//"95 },96 "https": {97 "id": "ALIASRFC_HTTPS",98 "host": "example.corp.com",99 "port": 1111,100 "pathPrefix": "/path/"101 },102 "rfc": {103 "id": "ALIASRFC",104 "systemId": "UV2",105 "host": "ldcsuv2",106 "service": 32,107 "loginGroup": "SPACE",108 "sncNameR3": "p/secude:CN=UXR, O=SAP-AG, C=DE",109 "sncQoPR3": "9"110 },111 "id": "ALIASRFC",112 "client": "220",113 "language": ""114 },115 "ALIAS111": {116 "http": {117 "id": "ALIAS111",118 "host": "vmw.example.corp.com",119 "port": 44335,120 "pathPrefix": "/go-to/the/moon"121 },122 "https": {123 "id": "ALIAS111_HTTPS",124 "host": "vmw.example.corp.com",125 "port": 44335,126 "pathPrefix": "/go-to/the/moon"127 },128 "rfc": {129 "id": "",130 "systemId": "",131 "host": "",132 "service": 32,133 "loginGroup": "",134 "sncNameR3": "",135 "sncQoPR3": ""136 },137 "id": "ALIAS111",138 "client": "111",139 "language": ""140 },141 "EMPTY_PORT_PREFIX_RFC": {142 // typical system alias defined in HCP143 "id": "ABAP_BACKEND_FOR_DEMO",144 "language": "",145 "client": "",146 "https": {147 "id": "ABAP_BACKEND_FOR_DEMO",148 "host": "system.our.domain.corp",149 "port": 0, // note: null port150 "pathPrefix": "" // note: empty path prefix151 },152 "rfc": {} // note: empty RFC153 },154 "MULTIPLE_INVALID_FIELDS": {155 "http": {156 "id": "SYS",157 "host": 123, // note: should be a string158 "port": "", // note: this is ok: string or number159 "pathPrefix": "/go-to/the/moon" // this is correct160 },161 "https": {162 "id": "SYS",163 // "host": "vmw.example.corp.com", // no host provided164 "port": [44335], // no string or number165 "pathPrefix": 456 // note: should be a string166 },167 "rfc": {168 "id": "",169 "systemId": "",170 "host": "",171 "service": 32,172 "loginGroup": "",173 "sncNameR3": "",174 "sncQoPR3": ""175 },176 "id": "SYS",177 "client": "120",178 "language": ""179 },180 "ONLY_RFC": {181 "rfc": {182 "id": "SYS",183 "systemId": "SYS",184 "host": "ldcisys",185 "service": 32,186 "loginGroup": "SPACE",187 "sncNameR3": "",188 "sncQoPR3": ""189 },190 "id": "SYS",191 "client": "120",192 "language": ""193 }194 };195196 QUnit.module("sap.ushell.ApplicationType", {197 beforeEach: function () { },198 afterEach: function () { }199 });200201 QUnit.test("module exports an object", function (assert) {202 assert.strictEqual(203 Object.prototype.toString.apply(oApplicationType),204 "[object Object]",205 "got an object back"206 );207 });208209 [210 /*211 * Fixture format212 *213 * - expectSuccess: required boolean214 * - expectedWarnings: optional215 * - expectedResolutionResult: to check for the complete resolution result216 */217 {218 testDescription: "a valid (transaction) intent is provided",219 oIntent: {220 semanticObject: "Shell",221 action: "startGUI",222 params: {223 "sap-system": ["ALIASRFC"],224 "sap-ui2-tcode": ["SU01"]225 }226 },227 expectedResolutionResult: {228 url: "https://example.corp.com:1111/path/gui/sap/its/webgui;~sysid=UV2;~loginGroup=SPACE;~messageServer=p%2fsecude%3aCN%3dUXR%2c%20O%3dSAP-AG%2c%20C%3dDE;~sncNameR3=p%2fsecude%3aCN%3dUXR%2c%20O%3dSAP-AG%2c%20C%3dDE;~sncQoPR3=9?%7etransaction=SU01&%7enosplash=1&sap-client=220&sap-language=EN", // see below229 applicationType: "TR", // simply add "TR"230 text: "SU01",231 additionalInformation: "", // leave empty232 "sap-system": "ALIASRFC" // propagate sap-system in here233 }234 }, {235 testDescription: "a valid (transaction) intent is provided with extra parameters",236 oIntent: {237 semanticObject: "Shell",238 action: "startGUI",239 params: {240 "sap-system": ["ALIASRFC"],241 "sap-ui2-tcode": ["*SU01"],242 "sap-theme": ["sap_hcb"],243 "some_parameter": ["some_value"]244 }245 },246 /*247 * Note: do not fail anymore here, we248 * just resolve now because the target mapping is assumed to be there249 * in the correct format250 */251 expectedResolutionResult: {252 "additionalInformation": "",253 "applicationType": "TR",254 "sap-system": "ALIASRFC",255 "text": "*SU01",256 "url": "https://example.corp.com:1111/path/gui/sap/its/webgui;~sysid=UV2;~loginGroup=SPACE;~messageServer=p%2fsecude%3aCN%3dUXR%2c%20O%3dSAP-AG%2c%20C%3dDE;~sncNameR3=p%2fsecude%3aCN%3dUXR%2c%20O%3dSAP-AG%2c%20C%3dDE;~sncQoPR3=9?%7etransaction=*SU01&%7enosplash=1&sap-client=220&sap-language=EN"257 }258 }, {259 testDescription: "a valid (wda) intent is provided",260 oIntent: {261 semanticObject: "Shell",262 action: "startWDA",263 params: {264 "sap-system": ["UR3CLNT120"],265 "sap-ui2-wd-app-id": ["APPID"]266 }267 },268 expectedResolutionResult: {269 url: "https://example.corp.com:44355/sap/bc/ui2/nwbc/~canvas;window=app/wda/APPID/?sap-client=120&sap-language=EN",270 applicationType: "NWBC",271 text: "APPID",272 additionalInformation: "",273 "sap-system": "UR3CLNT120"274 }275 }, {276 testDescription: "a valid (wda) intent with sap-wd-conf-id is provided",277 oIntent: {278 semanticObject: "Shell",279 action: "startWDA",280 params: {281 "sap-system": ["UR3CLNT120"],282 "sap-ui2-wd-app-id": ["APPID"],283 "sap-ui2-wd-conf-id": ["CONFIG_PARAMETER"]284 }285 },286 expectedResolutionResult: {287 url: "https://example.corp.com:44355/sap/bc/ui2/nwbc/~canvas;window=app/wda/APPID/?sap-wd-configId=CONFIG_PARAMETER&sap-client=120&sap-language=EN",288 applicationType: "NWBC",289 text: "APPID",290 additionalInformation: "",291 "sap-system": "UR3CLNT120"292 }293 }, {294 testDescription: "a valid (wda) intent with sap-wd-conf-id with special characters is provided",295 oIntent: {296 semanticObject: "Shell",297 action: "startWDA",298 params: {299 "sap-system": ["UR3CLNT120"],300 "sap-ui2-wd-app-id": ["APPID"],301 "sap-ui2-wd-conf-id": ['CO!@^*()_ ":{}<>NFIG']302 }303 },304 expectedResolutionResult: {305 url: "https://example.corp.com:44355/sap/bc/ui2/nwbc/~canvas;window=app/wda/APPID/?sap-wd-configId=CO!%40%5E*()_%20%22%3A%7B%7D%3C%3ENFIG&sap-client=120&sap-language=EN",306 applicationType: "NWBC",307 text: "APPID",308 additionalInformation: "",309 "sap-system": "UR3CLNT120"310 }311 }, {312 testDescription: "a valid (wda) intent is provided with extra parameters",313 oIntent: {314 semanticObject: "Shell",315 action: "startWDA",316 params: {317 "sap-system": ["UR3CLNT120"],318 "sap-ui2-wd-app-id": ["APPID"],319 "sap-theme": ["sap_hcb"],320 "some_parameter": ["some_value"]321 }322 },323 expectedResolutionResult: {324 url: "https://example.corp.com:44355/sap/bc/ui2/nwbc/~canvas;window=app/wda/APPID/?sap-theme=sap_hcb&some_parameter=some_value&sap-client=120&sap-language=EN",325 applicationType: "NWBC",326 text: "APPID",327 additionalInformation: "",328 "sap-system": "UR3CLNT120"329 }330 }331 ].forEach(function (oFixture) {332333 QUnit.test("resolveEasyAccessMenuIntent returns the correct resolution result when " + oFixture.testDescription, function (assert) {334 var fnDone = assert.async();335336 window.sap = {337 ushell: {338 Container: {339 getUser: sinon.stub().returns({340 getLanguage: sinon.stub().returns("EN")341 }),342 getService: sinon.stub().withArgs("URLParsing").returns(new URLParsing())343 }344 }345 };346347 var fnExternalResolver = function (sSystemAlias) {348 if (sSystemAlias === "") {349 return new jQuery.Deferred().resolve(O_LOCAL_SYSTEM_ALIAS).promise();350 }351 if (O_KNOWN_SYSTEM_ALIASES.hasOwnProperty(sSystemAlias)) {352 return new jQuery.Deferred().resolve(O_KNOWN_SYSTEM_ALIASES[sSystemAlias]).promise();353 }354 return new jQuery.Deferred().reject("Cannot resolve unknown system alias").promise();355 };356357 // Act358 var sIntent = [oFixture.oIntent.semanticObject, oFixture.oIntent.action].join("-");359 var fnResolver = oApplicationType.getEasyAccessMenuResolver(sIntent);360 if (!fnResolver) {361 assert.ok(false, "resolver was not returned");362 fnDone();363 return;364 }365 assert.ok(true, "resolver was returned");366367 fnResolver(oFixture.oIntent, {368 resolutionResult: {},369 intentParamsPlusAllDefaults: {370 "sap-system": [oFixture.oIntent["sap-system"]]371 },372 inbound: {373 "semanticObject": "Shell",374 "action": "startGUI",375 "id": "Shell-startGUI~686q",376 "title": "DUMMY",377 "resolutionResult": {378 "applicationType": "TR",379 "additionalInformation": "",380 "text": "DUMMY",381 "url": "/ui2/nwbc/~canvas;window=app/transaction/DUMMY?sap-client=120&sap-language=EN",382 "systemAlias": ""383 },384 "deviceTypes": {385 "desktop": true,386 "phone": false,387 "tablet": false388 },389 "signature": {390 "additionalParameters": "ignored",391 "parameters": {392 "sap-ui2-tcode": {393 "required": true,394 "filter": {395 "value": ".+",396 "format": "regexp"397 }398 },399 "sap-system": {400 "required": true,401 "filter": {402 "value": ".+",403 "format": "regexp"404 }405 }406 }407 }408 }409 }, fnExternalResolver)410 .then(function (oResolutionResultGot) {411 // Assert412 if (oFixture.expectedError) {413 assert.ok(false, "promise was rejected");414 } else {415 assert.ok(true, "promise was resolved");416 assert.strictEqual(jQuery.isPlainObject(oResolutionResultGot), true, "an object was returned");417418 if (oFixture.expectedResolutionResult) {419 assert.deepEqual(oResolutionResultGot, oFixture.expectedResolutionResult,420 "obtained the expected resolution result");421 }422 }423 }, function (sErrorGot) {424 // Assert425 if (oFixture.expectedError) {426 assert.ok(true, "promise was rejected");427 assert.strictEqual(sErrorGot, oFixture.expectedError, "expected error was returned");428 } else {429 assert.ok(false, "promise was resolved");430 }431 })432 .then(fnDone, fnDone);433 });434 });435436 [{437 testDescription: "return null for Shell-startGUI when resolved application type is SAPUI5",438 sIntent: "Shell-startGUI",439 sResolvedApplicationType: "SAPUI5",440 bReturnResolver: false441 }, {442 testDescription: "return null for Shell-startWDA when resolved application type is SAPUI5",443 sIntent: "Shell-startWDA",444 sResolvedApplicationType: "SAPUI5",445 bReturnResolver: false446 }, {447 testDescription: "return resolver for easyaccess intent when resolved application type is not SAPUI5",448 sIntent: "Shell-startGUI",449 sResolvedApplicationType: "TR",450 bReturnResolver: true451 }, {452 testDescription: "return null for not easyaccess intent",453 sIntent: "Acction-foo",454 sResolvedApplicationType: "TR",455 bReturnResolver: false456 }, {457 testDescription: "return resolver for easyaccess intent when application type is not defined",458 sIntent: "Shell-startGUI",459 sResolvedApplicationType: undefined,460 bReturnResolver: true461 }].forEach(function (oFixture) {462 QUnit.test("resolveEasyAccessMenuIntent: " + oFixture.testDescription, function (assert) {463 var oResolved = oApplicationType.getEasyAccessMenuResolver(oFixture.sIntent, oFixture.sResolvedApplicationType);464 assert.equal(!!oResolved, oFixture.bReturnResolver, "Resolver should be returned: " + oFixture.bReturnResolver);465 });466 });467468469470471 ...

Full Screen

Full Screen

getUrlParamsFiori3.js

Source:getUrlParamsFiori3.js Github

copy

Full Screen

1// Copyright (c) 2009-2017 SAP SE, All Rights Reserved2function getUrlParams() {3 "use strict";4 var vars = {};5 window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {6 vars[key] = value;7 });8 // Change homepage content (fioriDemoConfigCards includes several Cards)9 vars["demoConfig"] = "fioriDemoConfigCards";10 return vars;11}12var configFileUrl = decodeURIComponent(getUrlParams()["configFileUrl"]),13 sapUshellConfig = {14 services: {15 "Container": {16 "adapter": {17 "config": {18 "image": "img/283513_SAP.jpg"19 }20 }21 },22 NavTargetResolution: {23 config: {24 // enable to inject the NavTarget for #Test-url etc. directly via url parameters25 // .../FioriLaunchpad.html?sap-ushell-test-url-url=%2Fushell%2Ftest-resources%2Fsap%2Fushell%2Fdemoapps%2FAppNavSample&sap-ushell-test-url-additionalInformation=SAPUI5.Component%3Dsap.ushell.demo.AppNavSample#Test-url26 allowTestUrlComponentConfig : true27 }28 },29 SupportTicket: {30 // service has to be enabled explicitly for the demo platform31 config: {32 enabled: true33 }34 },35 EndUserFeedback: {36 adapter: {37 config: {38 enabled: true39 }40 }41 },42 UsageAnalytics: {43 config: {44 enabled: true,45 setUsageAnalyticsPermitted : true,46 logClickEvents: false,47 logPageLoadEvents: false,48 pubToken: "f5d00f4d-e968-1649-8285-66ee86ba7845",49 baseUrl: "https://poc.warp.sap.com/tracker/"50 }51 },52 Notifications: {53 config: {54 enabled: true,55 serviceUrl: "/ushell/test-resources/sap/ushell/demoapps/NotificationsSampleData/model",56 //serviceUrl: "/sap/opu/odata4/iwngw/notification/default/iwngw/notification_srv/0001",57 pollingIntervalInSeconds: 30,58 enableNotificationsPreview: true59 }60 },61 AllMyApps: {62 config: {63 enabled: true,64 showHomePageApps: true,65 showCatalogApps: true,66 showExternalProviders: true67 }68 },69 UserInfo: {70 adapter: {71 config: {72 themes: [73 { id: "sap_belize_plus", name: "SAP Belize Plus" },74 { id: "sap_belize", name: "SAP Belize" },75 { id: "theme1_id", name: "Custom Theme" },76 { id: "sap_belize_hcb", name: "SAP Belize HCB"},77 { id: "sap_belize_hcw", name: "SAP Belize HCW"},78 { id: "sap_fiori_3", name: "SAP Fiori 3"}79 ]80 }81 }82 },83 ClientSideTargetResolution: {84 adapter: {85 config: {86 inbounds: {87 startTransactionSample: {88 semanticObject: "Shell",89 action: "startWDA",90 title: "CRM Europe",91 signature: {92 parameters: {93 "sap-system": {94 required: true,95 filter: {96 value: "AB1CLNT000"97 }98 }99 },100 additionalParameters: "allowed"101 },102 deviceTypes: {103 desktop: true,104 tablet: false,105 phone: false106 },107 resolutionResult: {108 applicationType: "SAPUI5",109 additionalInformation: "SAPUI5.Component=sap.ushell.demo.AppNavSample",110 url: "../../../../../test-resources/sap/ushell/demoapps/AppNavSample?array-param1=value1&array-param1=value2"111 }112 },113 startTransactionSample2: {114 semanticObject: "Shell",115 action: "startGUI",116 signature: {117 parameters: {118 "sap-system": {119 required: true,120 filter: {121 value: "U1YCLNT120"122 }123 }124 },125 additionalParameters: "allowed"126 },127 deviceTypes: {128 desktop: true,129 tablet: false,130 phone: false131 },132 resolutionResult: {133 applicationType: "SAPUI5",134 additionalInformation: "SAPUI5.Component=sap.ushell.demo.AppNavSample",135 url: "../../../../../test-resources/sap/ushell/demoapps/AppNavSample?array-param1=value1&array-param1=value2"136 }137 },138 "startTransactionSample3": {139 semanticObject: "Shell",140 action: "startWDA",141 title: "U1Y client 000",142 signature: {143 parameters: {144 "sap-system": {145 required: true,146 filter: {147 value: "LOCAL"148 }149 }150 },151 additionalParameters: "allowed"152 },153 deviceTypes: {154 desktop: true,155 tablet: false,156 phone: false157 },158 resolutionResult: {159 applicationType: "SAPUI5",160 additionalInformation: "SAPUI5.Component=sap.ushell.demo.AppNavSample",161 url: "../../../../../test-resources/sap/ushell/demoapps/AppNavSample?array-param1=value1&array-param1=value2"162 }163 }164 }165 }166 }167 }168 },169 // Enable feature switch for fiori 3170 ushell: {171 home: {172 featuredGroup: {173 enable: true174 },175 gridContainer: true176 }177 },178 renderers: {179 fiori2 : {180 componentData: {181 config: {182 animationMode: 'full',183 enableNotificationsUI: true,184 enableSetTheme: true,185 enableSetLanguage: true,186 enableHelp: true,187 enablePersonalization: true,188 preloadLibrariesForRootIntent: false,189 enableRecentActivity: true,190 enableRecentActivityLogging: true,191 enableContentDensity: true,192 enableUserDefaultParameters: true,193 enableBackGroundShapes: true,194 disableAppFinder: false,195 moveGiveFeedbackActionToShellHeader: true,196 moveContactSupportActionToShellHeader: true,197 //moveEditHomePageActionToShellHeader: true,198 //moveUserSettingsActionToShellHeader: true,199 //moveAppFinderActionToShellHeader: true,200 enableUserImgConsent: false,201 sizeBehavior : "Responsive",202 title: "Welcome FLP User, this is a very long long long long longtitle",203 enableAutomaticSignout : false,204 applications: {205 "Shell-home" : {206 optimizeTileLoadingThreshold: 200,207 enableEasyAccess: true,208 enableEasyAccessSAPMenu: true,209 enableEasyAccessSAPMenuSearch: true,210 enableEasyAccessUserMenu: true,211 enableEasyAccessUserMenuSearch: true,212 enableCatalogSearch: true,213 enableCatalogTagFilter: true,214 enableActionModeMenuButton: true,215 disableSortedLockedGroups: false,216 enableTileActionsIcon: false,217 appFinderDisplayMode: "appBoxes", //"tiles"218 enableHideGroups: true,219 enableTilesOpacity: false,220 homePageGroupDisplay: "scroll",221 enableHomePageSettings: true222 }223 },224 rootIntent: "Shell-home",225 esearch: {226 searchBusinessObjects: true227 }228 }229 }230 }231 },232 bootstrapPlugins: {233 NotificationsSampleData: {234 component: "sap.ushell.demo.NotificationsSampleData",235 url: "../../../../../test-resources/sap/ushell/demoapps/NotificationsSampleData"236 },237 PluginAddFakeCopilot: {238 component: "sap.ushell.demo.PluginAddFakeCopilot",239 url: "../../../../../test-resources/sap/ushell/demoapps/BootstrapPluginSample/PluginAddFakeCopilot"240 }241 }242 };243var oXHR = new XMLHttpRequest();244if (configFileUrl !== "undefined") {245 oXHR.open("GET", configFileUrl, false);246 oXHR.onreadystatechange = function () {247 "use strict";248 if (this.status === 200 && this.readyState === 4) {249 eval(oXHR.responseText);250 }251 };252 oXHR.send();253}...

Full Screen

Full Screen

getUrlParams.js

Source:getUrlParams.js Github

copy

Full Screen

1// Copyright (c) 2009-2017 SAP SE, All Rights Reserved2function getUrlParams() {3 "use strict";4 var vars = {};5 window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m,key,value) {6 vars[key] = value;7 });8 return vars;9}10var configFileUrl = decodeURIComponent(getUrlParams()["configFileUrl"]),11 sapUshellConfig = {12 services: {13 NavTargetResolution: {14 config: {15 // enable to inject the NavTarget for #Test-url etc. directly via url parameters16 // .../FioriLaunchpad.html?sap-ushell-test-url-url=%2Fushell%2Ftest-resources%2Fsap%2Fushell%2Fdemoapps%2FAppNavSample&sap-ushell-test-url-additionalInformation=SAPUI5.Component%3Dsap.ushell.demo.AppNavSample#Test-url17 allowTestUrlComponentConfig : true18 }19 },20 SupportTicket: {21 // service has to be enabled explicitly for the demo platform22 config: {23 enabled: true24 }25 },26 EndUserFeedback: {27 adapter: {28 config: {29 enabled: true30 }31 }32 },33 UsageAnalytics: {34 config: {35 enabled: true,36 setUsageAnalyticsPermitted : true,37 logClickEvents: false,38 logPageLoadEvents: false,39 pubToken: "f5d00f4d-e968-1649-8285-66ee86ba7845",40 baseUrl: "https://poc.warp.sap.com/tracker/"41 }42 },43 Notifications: {44 config: {45 enabled: true,46 serviceUrl: "/ushell/test-resources/sap/ushell/demoapps/NotificationsSampleData/model",47 //serviceUrl: "/sap/opu/odata4/iwngw/notification/default/iwngw/notification_srv/0001",48 pollingIntervalInSeconds: 30,49 enableNotificationsPreview: true50 }51 },52 AllMyApps: {53 config: {54 enabled: true,55 showHomePageApps: true,56 showCatalogApps: true,57 showExternalProviders: true58 }59 },60 UserInfo: {61 adapter: {62 config: {63 themes: [64 { id: "sap_fiori_3", name: "SAP Fiori 3" },65 { id: "sap_belize_plus", name: "SAP Belize Plus" },66 { id: "sap_belize", name: "SAP Belize" },67 { id: "theme1_id", name: "Custom Theme" },68 { id: "sap_belize_hcb", name: "SAP Belize HCB"},69 { id: "sap_belize_hcw", name: "SAP Belize HCW"}70 ]71 }72 }73 },74 ClientSideTargetResolution: {75 adapter: {76 config: {77 inbounds: {78 startTransactionSample: {79 semanticObject: "Shell",80 action: "startWDA",81 title: "CRM Europe",82 signature: {83 parameters: {84 "sap-system": {85 required: true,86 filter: {87 value: "AB1CLNT000"88 }89 }90 },91 additionalParameters: "allowed"92 },93 deviceTypes: {94 desktop: true,95 tablet: false,96 phone: false97 },98 resolutionResult: {99 applicationType: "SAPUI5",100 additionalInformation: "SAPUI5.Component=sap.ushell.demo.AppNavSample",101 url: "../../../../../test-resources/sap/ushell/demoapps/AppNavSample?array-param1=value1&array-param1=value2"102 }103 },104 startTransactionSample2: {105 semanticObject: "Shell",106 action: "startGUI",107 signature: {108 parameters: {109 "sap-system": {110 required: true,111 filter: {112 value: "U1YCLNT120"113 }114 }115 },116 additionalParameters: "allowed"117 },118 deviceTypes: {119 desktop: true,120 tablet: false,121 phone: false122 },123 resolutionResult: {124 applicationType: "SAPUI5",125 additionalInformation: "SAPUI5.Component=sap.ushell.demo.AppNavSample",126 url: "../../../../../test-resources/sap/ushell/demoapps/AppNavSample?array-param1=value1&array-param1=value2"127 }128 },129 "startTransactionSample3": {130 semanticObject: "Shell",131 action: "startWDA",132 title: "U1Y client 000",133 signature: {134 parameters: {135 "sap-system": {136 required: true,137 filter: {138 value: "LOCAL"139 }140 }141 },142 additionalParameters: "allowed"143 },144 deviceTypes: {145 desktop: true,146 tablet: false,147 phone: false148 },149 resolutionResult: {150 applicationType: "SAPUI5",151 additionalInformation: "SAPUI5.Component=sap.ushell.demo.AppNavSample",152 url: "../../../../../test-resources/sap/ushell/demoapps/AppNavSample?array-param1=value1&array-param1=value2"153 }154 }155 }156 }157 }158 }159 },160 renderers: {161 fiori2 : {162 componentData: {163 config: {164 animationMode: 'full',165 enableNotificationsUI: true,166 enableSetTheme: true,167 enableSetLanguage: true,168 enableHelp: true,169 preloadLibrariesForRootIntent: false,170 enableRecentActivity: true,171 enableRecentActivityLogging: true,172 enableContentDensity: true,173 enableUserDefaultParameters: true,174 enableBackGroundShapes: true,175 disableAppFinder: false,176 enableUserImgConsent: false,177 sizeBehavior : "Responsive",178 // sessionTimeoutIntervalInMinutes : 30,179 // sessionTimeoutReminderInMinutes : 5,180 // enableAutomaticSignout : false,181 applications: {182 "Shell-home" : {183 optimizeTileLoadingThreshold: 200,184 enableEasyAccess: true,185 enableEasyAccessSAPMenu: true,186 enableEasyAccessSAPMenuSearch: true,187 enableEasyAccessUserMenu: true,188 enableEasyAccessUserMenuSearch: true,189 enableCatalogSearch: true,190 enableCatalogTagFilter: true,191 enableActionModeMenuButton: true,192 disableSortedLockedGroups: false,193 enableTileActionsIcon: false,194 appFinderDisplayMode: "appBoxes", //"tiles"195 enableHideGroups: true,196 enableTilesOpacity: false,197 homePageGroupDisplay: "scroll",198 enableHomePageSettings: true199 }200 },201 rootIntent: "Shell-home",202 esearch: {203 searchBusinessObjects: true204 }205 }206 }207 }208 },209 bootstrapPlugins: {210 NotificationsSampleData: {211 component: "sap.ushell.demo.NotificationsSampleData",212 url: "../../../../../test-resources/sap/ushell/demoapps/NotificationsSampleData"213 }214 }215 };216var oXHR = new XMLHttpRequest();217if (configFileUrl !== "undefined") {218 oXHR.open("GET", configFileUrl, false);219 /* eslint-disable strict */220 oXHR.onreadystatechange = function () {221 if (this.status === 200 && this.readyState === 4) {222 eval(oXHR.responseText);223 }224 };225 /* eslint-enable strict */226 oXHR.send();227}...

Full Screen

Full Screen

wdaProxy.js

Source:wdaProxy.js Github

copy

Full Screen

...19 var wdaPath = options.wdaPath20 wda.on('restart',function(){21 if(!bRestart)22 return 23 plugin.restartWda()24 })25 plugin.start = async function(){26 if(options.type=='device'){27 proxyProMap.set(options.wdaPort,plugin.startIproxy(options.wdaPort,8100))28 proxyProMap.set(options.mjpegPort,plugin.startIproxy(options.mjpegPort,9100))29 }30 return plugin.startWda().then(function(){31 return plugin32 })33 }34 plugin.restartIproxy = function(localPort,remotePort){35 if (!exit)36 proxyPro = null;37 proxyProMap.set(localPort,plugin.startIproxy(localPort,remotePort));38 };39 plugin.startIproxy = function(localPort,remotePort){40 log.info("start iproxy with params:%d %d %s",localPort,remotePort,options.serial)41 pro = new SubpPocess("iproxy",[localPort,remotePort,options.serial])42 pro.start();43 pro.on("exit",(code,signal)=>{44 log.info("exit with code :%d",code)45 plugin.restartIproxy(localPort,remotePort);46 });47 pro.on("output",(stdout,stderr)=>{48 });49 return pro50 };51 plugin.restartWda = function(){52 if (wdaPro!=null&& bRestart)53 wdaPro.stop()54 if (!exit && bRestart)55 plugin.startWda();56 };57 plugin.startWda = function(){58 var platform = ""59 if(options.type=='emulator'){60 platform = " Simulator"61 }62 var params = ['build-for-testing', 'test-without-building','-project',path.join(wdaPath,'WebDriverAgent.xcodeproj')63 ,'-scheme','WebDriverAgentRunner','-destination','id='+options.serial+',platform=iOS'+platform64 ,'-configuration','Debug','IPHONEOS_DEPLOYMENT_TARGET=10.2']65 log.info("start WDA with params:%s",params);66 var wdaport = 810067 var mjpegport = 910068 if(options.type=='emulator'){69 wdaport = options.wdaPort70 mjpegport = options.mjpegPort71 }72 const env = { 73 USE_PORT: wdaport,74 MJPEG_SERVER_PORT:mjpegport75 }76 wdaPro = new SubpPocess("xcodebuild",params, {77 cwd: options.wdaPath,78 env,79 detached: true80 })81 wdaPro.start()82 wdaPro.on("exit",(code,signal)=>{83 wdaPro = null;84 bRestart = true85 plugin.restartWda();86 });87 return new Promise((resolve,reject)=>{88 wdaPro.on("stream-line",line=>{89 bRestart = false90 if (line.indexOf('=========')!=-1)91 log.info(line)92 if(line.indexOf("** TEST BUILD SUCCEEDED **")!=-1)93 log.info("xcodebuild构建成功")94 else if (line.indexOf("ServerURLHere->")!=-1){95 log.info("WDA启动成功")96 wda.launchApp('com.apple.Preferences')97 wda.initSession()98 plugin.emit("started");99 bRestart=true...

Full Screen

Full Screen

driver-specs.js

Source:driver-specs.js Github

copy

Full Screen

1import sinon from 'sinon';2import { settings as iosSettings } from 'appium-ios-driver';3import XCUITestDriver from '../..';4import xcode from 'appium-xcode';5import _ from 'lodash';6import log from '../../lib/logger';7const caps = {platformName: "iOS", deviceName: "iPhone 6", app: "/foo.app"};8const anoop = async () => {};9describe('driver commands', () => {10 let driver = new XCUITestDriver();11 let proxySpy = sinon.stub(driver, 'proxyCommand');12 afterEach(() => {13 proxySpy.reset();14 });15 describe('status', () => {16 it('should send status request to WDA', async () => {17 await driver.getStatus();18 proxySpy.calledOnce.should.be.true;19 proxySpy.firstCall.args[0].should.eql('/status');20 proxySpy.firstCall.args[1].should.eql('GET');21 });22 });23 describe('createSession', () => {24 let d;25 let sandbox;26 beforeEach(() => {27 d = new XCUITestDriver();28 sandbox = sinon.sandbox.create();29 sandbox.stub(d, "determineDevice", async () => {30 return {device: null, udid: null, realDevice: null};31 });32 sandbox.stub(d, "configureApp", anoop);33 sandbox.stub(d, "checkAppPresent", anoop);34 sandbox.stub(d, "startLogCapture", anoop);35 sandbox.stub(d, "startSim", anoop);36 sandbox.stub(d, "startWdaSession", anoop);37 sandbox.stub(d, "startWda", anoop);38 sandbox.stub(d, "extractBundleId", anoop);39 sandbox.stub(d, "installApp", anoop);40 sandbox.stub(iosSettings, "setLocale", anoop);41 sandbox.stub(iosSettings, "setPreferences", anoop);42 sandbox.stub(xcode, "getMaxIOSSDK", async () => {43 return '10.0';44 });45 });46 afterEach(() => {47 sandbox.restore();48 });49 it('should include server capabilities', async () => {50 let resCaps = await d.createSession(caps);51 resCaps[1].javascriptEnabled.should.be.true;52 });53 it('should warn', async () => {54 let warnStub = sinon.stub(log, "warn", async () => {});55 await d.createSession(_.defaults({autoAcceptAlerts: true}, caps));56 warnStub.calledTwice.should.be.true;57 _.filter(warnStub.args, (arg) => arg[0].indexOf('autoAcceptAlerts') !== -1)58 .should.have.length(1);59 warnStub.restore();60 });61 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const AppiumXcuitestDriver = require('./lib/driver');2const appiumXcuitestDriver = new AppiumXcuitestDriver();3appiumXcuitestDriver.startWda();4startWda() {5 console.log('Starting WDA');6}7const AppiumXcuitestDriver = require('appium-xcuitest-driver');8const appiumXcuitestDriver = new AppiumXcuitestDriver();9appiumXcuitestDriver.startWda();10startWda() {11 console.log('Starting WDA');12}13Appium version (or git revision) that exhibits the issue: 1.6.5, 1.7.114Last Appium version that did not exhibit the issue (if applicable): N/A15Node.js version (unless using Appium.app|exe): 8.6.0

Full Screen

Using AI Code Generation

copy

Full Screen

1const { startWda } = require('appium-xcuitest-driver').driver;2startWda();3const { startWda } = require('appium-xcuitest-driver').driver;4startWda();5const { startWda } = require('appium-xcuitest-driver').driver;6startWda();7const { startWda } = require('appium-xcuitest-driver').driver;8startWda();9const { startWda } = require('appium-xcuitest-driver').driver;10startWda();11const { startWda } = require('appium-xcuitest-driver').driver;12startWda();13const { startWda } = require('appium-xcuitest-driver').driver;14startWda();15const { startWda } = require('appium-xcuitest-driver').driver;16startWda();17const { startWda } = require('appium-xcuitest-driver').driver;18startWda();19const { startWda } = require('appium-xcuitest-driver').driver;20startWda();21const { startWda } = require('appium-xcuitest-driver').driver;22startWda();23const { startWda } = require('appium-xcuitest-driver').driver;24startWda();25const { startWda } = require('appium-xcuitest-driver').driver

Full Screen

Using AI Code Generation

copy

Full Screen

1const { startWda } = require('appium-xcuitest-driver/lib/wda');2const startWda = async function (wdaBaseUrl) {3 const wda = new startWda(wdaBaseUrl);4 await wda.start();5};6const { startWda } = require('appium-xcuitest-driver/lib/wda');7const startWda = async function (wdaBaseUrl) {8 const wda = new startWda(wdaBaseUrl);9 await wda.start();10};11const { startWda } = require('appium-xcuitest-driver/lib/wda');12const startWda = async function (wdaBaseUrl) {13 const wda = new startWda(wdaBaseUrl);14 await wda.start();15};16const { startWda } = require('appium-xcuitest-driver/lib/wda');17const startWda = async function (wdaBaseUrl) {18 const wda = new startWda(wdaBaseUrl);19 await wda.start();20};21const { startWda } = require('appium-xcuitest-driver/lib/wda');22const startWda = async function (wdaBaseUrl) {23 const wda = new startWda(wdaBaseUrl);24 await wda.start();25};26const { startWda } = require('appium-xcuitest-driver/lib/wda');27const startWda = async function (wdaBaseUrl) {28 const wda = new startWda(wdaBaseUrl);29 await wda.start();30};31const { startWda } = require('appium-x

Full Screen

Using AI Code Generation

copy

Full Screen

1const { startWda } = require('appium-xcuitest-driver');2const startWda = async function () {3}4startWda();5const { startWda } = require('appium-xcuitest-driver');6const startWda = async function () {7}8startWda();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful