first commit

This commit is contained in:
2025-04-25 22:19:01 +02:00
commit 777a29d3bc
35 changed files with 14665 additions and 0 deletions

View File

@ -0,0 +1,81 @@
<!DOCTYPE HTML>
<html lang="en">
<!-- Copyright (c) 2015 SAP AG, All Rights Reserved -->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{appTitle}}</title>
<!-- Bootstrap the unified shell in sandbox mode for standalone usage.
The renderer is specified in the global Unified Shell configuration object "sap-ushell-config".
The fiori2 renderer will render the shell header allowing, for instance,
testing of additional application setting buttons.
The navigation target resolution service is configured in a way that the empty URL hash is
resolved to our own application.
This example uses relative path references for the SAPUI5 resources and test-resources;
it might be necessary to adapt them depending on the target runtime platform.
The sandbox platform is restricted to development or demo use cases and must NOT be used
for productive scenarios.
-->
<script type="text/javascript">
window["sap-ushell-config"] = {
defaultRenderer: "fiori2",
bootstrapPlugins: {
"RuntimeAuthoringPlugin": {
component: "sap.ushell.plugins.rta",
config: {
validateAppVersion: false
}
}
},
renderers: {
fiori2: {
componentData: {
config: {
search: "hidden",
enableSearch: false
}
}
}
},
applications: {
"mvcapp00124-display": {
title: "Flighty",
description: "Flighty",
additionalInformation: "SAPUI5.Component=mvcapp00124",
applicationType: "URL",
url: "../"
}
}
};
</script>
<script src="../test-resources/sap/ushell/bootstrap/sandbox.js" id="sap-ushell-bootstrap"></script>
<!-- Bootstrap the UI5 core library. 'data-sap-ui-frameOptions="allow"'' is a NON-SECURE setting for test environments -->
<script id="sap-ui-bootstrap"
src="../resources/sap-ui-core.js"
data-sap-ui-libs="sap.m,sap.ui.core,sap.ushell"
data-sap-ui-async="true"
data-sap-ui-preload="async"
data-sap-ui-theme="sap_fiori_3"
data-sap-ui-compatVersion="edge"
data-sap-ui-language="en"
data-sap-ui-resourceroots='{"mvcapp00124": "../"}'
data-sap-ui-frameOptions="allow"
data-sap-ui-flexibilityServices='[{"connector": "LocalStorageConnector"}]'>
</script>
<script id="locate-reuse-libs" src="./locate-reuse-libs.js" data-sap-ui-manifest-uri="../manifest.json">
</script>
</head>
<!-- UI Content -->
<body class="sapUiBody" id="content">
</body>
</html>

View File

@ -0,0 +1,13 @@
sap.ui.define([
"sap/ui/test/Opa5",
"./arrangements/Startup",
"./NavigationJourney"
], function (Opa5, Startup) {
"use strict";
Opa5.extendConfig({
arrangements: new Startup(),
viewNamespace: "mvcapp00124.view.",
autoWait: true
});
});

View File

@ -0,0 +1,23 @@
/*global QUnit*/
sap.ui.define([
"sap/ui/test/opaQunit",
"./pages/App",
"./pages/Main"
], function (opaTest) {
"use strict";
QUnit.module("Navigation Journey");
opaTest("Should see the initial page of the app", function (Given, When, Then) {
// Arrangements
Given.iStartMyApp();
// Assertions
Then.onTheAppPage.iShouldSeeTheApp();
Then.onTheViewPage.iShouldSeeThePageView();
//Cleanup
Then.iTeardownMyApp();
});
});

View File

@ -0,0 +1,25 @@
sap.ui.define([
"sap/ui/test/Opa5"
], function (Opa5) {
"use strict";
return Opa5.extend("integration.arrangements.Startup", {
iStartMyApp: function (oOptionsParameter) {
var oOptions = oOptionsParameter || {};
// start the app with a minimal delay to make tests fast but still async to discover basic timing issues
oOptions.delay = oOptions.delay || 50;
// start the app UI component
this.iStartMyUIComponent({
componentConfig: {
name: "mvcapp00124",
async: true
},
hash: oOptions.hash,
autoWait: oOptions.autoWait
});
}
});
});

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Integration tests for Basic Template</title>
<script
id="sap-ui-bootstrap"
src="../../resources/sap-ui-core.js"
data-sap-ui-theme="sap_fiori_3"
data-sap-ui-resourceroots='{
"mvcapp00124": "../../",
"integration": "./"
}'
data-sap-ui-animation="false"
data-sap-ui-compatVersion="edge"
data-sap-ui-async="true"
data-sap-ui-preload="async">
</script>
<link rel="stylesheet" type="text/css" href="../../resources/sap/ui/thirdparty/qunit-2.css">
<script src="../../resources/sap/ui/thirdparty/qunit-2.js"></script>
<script src="../../resources/sap/ui/qunit/qunit-junit.js"></script>
<script src="opaTests.qunit.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>

View File

@ -0,0 +1,7 @@
/* global QUnit */
sap.ui.require(["mvcapp00124/test/integration/AllJourneys"
], function () {
QUnit.config.autostart = false;
QUnit.start();
});

View File

@ -0,0 +1,28 @@
sap.ui.define([
"sap/ui/test/Opa5"
], function (Opa5) {
"use strict";
var sViewName = "App";
Opa5.createPageObjects({
onTheAppPage: {
actions: {},
assertions: {
iShouldSeeTheApp: function () {
return this.waitFor({
id: "app",
viewName: sViewName,
success: function () {
Opa5.assert.ok(true, "The " + sViewName + " view is displayed");
},
errorMessage: "Did not find the " + sViewName + " view"
});
}
}
}
});
});

View File

@ -0,0 +1,28 @@
sap.ui.define([
"sap/ui/test/Opa5"
], function (Opa5) {
"use strict";
var sViewName = "Main";
Opa5.createPageObjects({
onTheViewPage: {
actions: {},
assertions: {
iShouldSeeThePageView: function () {
return this.waitFor({
id: "page",
viewName: sViewName,
success: function () {
Opa5.assert.ok(true, "The " + sViewName + " view is displayed");
},
errorMessage: "Did not find the " + sViewName + " view"
});
}
}
}
});
});

View File

@ -0,0 +1,267 @@
(function (sap) {
var fioriToolsGetManifestLibs = function (manifestPath) {
var url = manifestPath;
var result = "";
// SAPUI5 delivered namespaces from https://ui5.sap.com/#/api/sap
var ui5Libs = [
"sap.apf",
"sap.base",
"sap.chart",
"sap.collaboration",
"sap.f",
"sap.fe",
"sap.fileviewer",
"sap.gantt",
"sap.landvisz",
"sap.m",
"sap.ndc",
"sap.ovp",
"sap.rules",
"sap.suite",
"sap.tnt",
"sap.ui",
"sap.uiext",
"sap.ushell",
"sap.uxap",
"sap.viz",
"sap.webanalytics",
"sap.zen"
];
var getKeys = function (libOrComp, libOrCompKeysString) {
var libOrCompKeysStringTmp = libOrCompKeysString;
Object.keys(libOrComp).forEach(function (libOrCompKey) {
// ignore libs or Components that start with SAPUI5 delivered namespaces
if (!ui5Libs.some(function (substring) { return libOrCompKey === substring || libOrCompKey.startsWith(substring + "."); })) {
if (libOrCompKeysStringTmp.length > 0) {
libOrCompKeysStringTmp = libOrCompKeysStringTmp + "," + libOrCompKey;
} else {
libOrCompKeysStringTmp = libOrCompKey;
}
}
});
return libOrCompKeysStringTmp;
};
var getComponentUsageNames = function (compUsages, libOrCompKeysString) {
var libOrCompKeysStringTmp = libOrCompKeysString;
var compNames = Object.keys(compUsages).map(function (compUsageKey) {
return compUsages[compUsageKey].name;
});
compNames.forEach(function (compName) {
// ignore libs or Components that start with SAPUI5 delivered namespaces
if (!ui5Libs.some(function (substring) { return compName === substring || compName.startsWith(substring + "."); })) {
if (libOrCompKeysStringTmp.length > 0) {
libOrCompKeysStringTmp = libOrCompKeysStringTmp + "," + compName;
} else {
libOrCompKeysStringTmp = compName;
}
}
});
return libOrCompKeysStringTmp;
};
return new Promise(function (resolve, reject) {
sap.ui.require(["sap/ui/thirdparty/jquery"], function (localJQuery) {
localJQuery.ajax(url)
.done(function (manifest) {
if (manifest) {
if (
manifest["sap.ui5"] &&
manifest["sap.ui5"].dependencies
) {
if (manifest["sap.ui5"].dependencies.libs) {
result = getKeys(manifest["sap.ui5"].dependencies.libs, result);
}
if (manifest["sap.ui5"].dependencies.components) {
result = getKeys(manifest["sap.ui5"].dependencies.components, result);
}
}
if (
manifest["sap.ui5"] &&
manifest["sap.ui5"].componentUsages
) {
result = getComponentUsageNames(manifest["sap.ui5"].componentUsages, result);
}
}
resolve(result);
})
.fail(function () {
reject(new Error("Could not fetch manifest at '" + manifestPath));
});
});
});
};
var registerModules = function (dataFromAppIndex) {
Object.keys(dataFromAppIndex).forEach(function (moduleDefinitionKey) {
var moduleDefinition = dataFromAppIndex[moduleDefinitionKey];
if (moduleDefinition && moduleDefinition.dependencies) {
moduleDefinition.dependencies.forEach(function (dependency) {
if (dependency.url && dependency.url.length > 0 && dependency.type === "UI5LIB") {
sap.ui.require(["sap/base/Log"], function (Log) {
Log.info("Registering Library " +
encodeURI(dependency.componentId) +
" from server " +
encodeURI(dependency.url));
});
var compId = dependency.componentId.replace(/\./g, "/");
var config = {
paths: {
}
};
config.paths[compId] = dependency.url;
sap.ui.loader.config(config);
}
});
}
});
};
/**
* Registers the module paths for dependencies of the given component.
* @param {string} manifestPath The the path to the app manifest path
* for which the dependencies should be registered.
* @returns {Promise} A promise which is resolved when the ajax request for
* the app-index was successful and the module paths were registered.
*/
var registerComponentDependencyPaths = function (manifestPath) {
return fioriToolsGetManifestLibs(manifestPath).then(function (libs) {
if (libs && libs.length > 0) {
var url = "/sap/bc/ui2/app_index/ui5_app_info?id=" + libs;
var sapClient = "";
return new Promise(
function (resolve) {
sapClient = new URLSearchParams(window.location.search).get("sap-client");
if (sapClient && sapClient.length === 3) {
url = url + "&sap-client=" + sapClient;
}
resolve(url);
}).then(function (url2) {
sap.ui.require(["sap/ui/thirdparty/jquery"], function (localJQuery) {
return localJQuery.ajax(url2)
.done(function (data) {
if (data) {
registerModules(data);
}
});
});
});
} else {
return undefined;
}
});
};
var registerSAPFonts = function () {
sap.ui.require(["sap/ui/core/IconPool"], function (IconPool) {
//Fiori Theme font family and URI
var fioriTheme = {
fontFamily: "SAP-icons-TNT",
fontURI: sap.ui.require.toUrl("sap/tnt/themes/base/fonts/")
};
//Registering to the icon pool
IconPool.registerFont(fioriTheme);
//SAP Business Suite Theme font family and URI
var bSuiteTheme = {
fontFamily: "BusinessSuiteInAppSymbols",
fontURI: sap.ui.require.toUrl("sap/ushell/themes/base/fonts/")
};
//Registering to the icon pool
IconPool.registerFont(bSuiteTheme);
});
};
/*eslint-disable fiori-custom/sap-browser-api-warning, fiori-custom/sap-no-dom-access*/
var currentScript = document.getElementById("locate-reuse-libs");
if (!currentScript) {
currentScript = document.currentScript;
}
var manifestUri = currentScript.getAttribute("data-sap-ui-manifest-uri");
var componentName = currentScript.getAttribute("data-sap-ui-componentName");
var useMockserver = currentScript.getAttribute("data-sap-ui-use-mockserver");
// Patch (KW): resourceRoot is needed to load the correct ResourceBundles
var resourceRoot = manifestUri.substring(0, manifestUri.lastIndexOf('/')+1);
return registerComponentDependencyPaths(manifestUri)
.catch(function (error) {
sap.ui.require(["sap/base/Log"], function (Log) {
Log.error(error);
});
})
.finally(function () {
// setting the app title with internationalization
sap.ui.require(["sap/ui/core/Core"], async function(Core) {
Core.ready(() => {
sap.ui.require(["sap/base/i18n/Localization"], function (Localization) {
sap.ui.require(["sap/base/i18n/ResourceBundle"], function (ResourceBundle) {
var oResourceBundle = ResourceBundle.create({
// Patch (KW): resourceRoot is needed to load the correct ResourceBundles
url: resourceRoot + "i18n/i18n.properties",
locale: Localization.getLanguage()
});
document.title = oResourceBundle.getText("appTitle");
});
});
});
});
if (componentName && componentName.length > 0) {
if (useMockserver && useMockserver === "true") {
sap.ui.require(["sap/ui/core/Core"], async function(Core) {
Core.ready(() => {
registerSAPFonts();
sap.ui.require([componentName.replace(/\./g, "/") + "/localService/mockserver"], function (server) {
// set up test service for local testing
server.init();
// initialize the ushell sandbox component
sap.ui.require(["sap/ushell/Container"], async function (Container) {
Container.createRenderer(true).then(function (component) {
component.placeAt("content");
});
});
});
});
});
} else {
// Requiring the ComponentSupport module automatically executes the component initialisation for all declaratively defined components
sap.ui.require(["sap/ui/core/ComponentSupport"]);
// setting the app title with the i18n text
sap.ui.require(["sap/ui/core/Core"], async function(Core) {
Core.ready(() => {
registerSAPFonts();
sap.ui.require(["sap/base/i18n/Localization"], function (Localization) {
sap.ui.require(["sap/base/i18n/ResourceBundle"], function (ResourceBundle) {
var oResourceBundle = ResourceBundle.create({
// Patch (KW): resourceRoot is needed to load the correct ResourceBundles
url: resourceRoot + "i18n/i18n.properties",
locale: Localization.getLanguage()
});
document.title = oResourceBundle.getText("appTitle");
});
});
});
});
}
} else {
sap.ui.require(["sap/ui/core/Core"], async function(Core) {
Core.ready(() => {
registerSAPFonts();
// initialize the ushell sandbox component
sap.ui.require(["sap/ushell/Container"], async function (Container) {
try {
Container.createRenderer(true).then(function (component) {
component.placeAt("content");
});
} catch (error) {
// support older versions of ui5
Container.createRenderer().placeAt("content");
}
});
});
});
}
});
})(sap);

View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>QUnit test suite</title>
<script src="../resources/sap/ui/qunit/qunit-redirect.js"></script>
<script src="testsuite.qunit.js" data-sap-ui-testsuite></script>
</head>
<body></body>
</html>

View File

@ -0,0 +1,16 @@
/* global window, parent, location */
// eslint-disable-next-line fiori-custom/sap-no-global-define
window.suite = function() {
"use strict";
// eslint-disable-next-line
var oSuite = new parent.jsUnitTestSuite(),
sContextPath = location.pathname.substring(0, location.pathname.lastIndexOf('/') + 1);
oSuite.addTestPage(sContextPath + 'unit/unitTests.qunit.html');
oSuite.addTestPage(sContextPath + 'integration/opaTests.qunit.html');
return oSuite;
};

View File

@ -0,0 +1,5 @@
sap.ui.define([
"mvcapp00124/test/unit/controller/Main.controller"
], function () {
"use strict";
});

View File

@ -0,0 +1,16 @@
/*global QUnit*/
sap.ui.define([
"mvcapp00124/controller/Main.controller"
], function (Controller) {
"use strict";
QUnit.module("Main Controller");
QUnit.test("I should test the Main controller", function (assert) {
var oAppController = new Controller();
oAppController.onInit();
assert.ok(oAppController);
});
});

View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Unit tests for mvcapp00124</title>
<script
id="sap-ui-bootstrap"
src="../../resources/sap-ui-core.js"
data-sap-ui-resourceroots='{
"mvcapp00124": "../../",
"unit": "."
}'
data-sap-ui-async="true"
data-sap-ui-compat-version="edge">
</script>
<link rel="stylesheet" type="text/css" href="../../resources/sap/ui/thirdparty/qunit-2.css">
<script src="../../resources/sap/ui/thirdparty/qunit-2.js"></script>
<script src="../../resources/sap/ui/qunit/qunit-junit.js"></script>
<script src="../../resources/sap/ui/qunit/qunit-coverage.js"></script>
<script src="../../resources/sap/ui/thirdparty/sinon.js"></script>
<script src="../../resources/sap/ui/thirdparty/sinon-qunit.js"></script>
<script src="unitTests.qunit.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>

View File

@ -0,0 +1,12 @@
/* global QUnit */
QUnit.config.autostart = false;
sap.ui.getCore().attachInit(function () {
"use strict";
sap.ui.require([
"mvcapp00124/test/unit/AllTests"
], function () {
QUnit.start();
});
});