Skip to content

Commit

Permalink
fix: opa test namespace and folder
Browse files Browse the repository at this point in the history
  • Loading branch information
tsaleksandrova authored and Marius Obert committed Jan 27, 2021
1 parent f731d84 commit fb166b7
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 43 deletions.
10 changes: 4 additions & 6 deletions generators/newopa5journey/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = class extends Generator {

if (this.options.isSubgeneratorCall) {
this.options.oneTimeConfig.projectname = this.options.projectname;
this.options.oneTimeConfig.namespace = this.options.namespace;
this.options.oneTimeConfig.namespaceInput = this.options.namespaceInput;
this.options.oneTimeConfig.modulename = this.options.modulename;
} else {
if (!this.config.getAll().viewtype) {
Expand All @@ -27,7 +27,7 @@ module.exports = class extends Generator {
default: "myUI5App"
}, {
type: "input",
name: "namespace",
name: "namespaceInput",
message: "Please enter the namespace you use currently",
validate: (s) => {
if (/^[a-zA-Z0-9_\.]*$/g.test(s)) {
Expand Down Expand Up @@ -64,10 +64,8 @@ module.exports = class extends Generator {
this.options.oneTimeConfig[key] = answers[key];
}

this.options.oneTimeConfig.namespaceInput = this.options.oneTimeConfig.namespaceInput || this.options.oneTimeConfig.namespace;
this.options.oneTimeConfig.journey = this.options.oneTimeConfig.journey.charAt(0).toUpperCase() + this.options.oneTimeConfig.journey.substr(1);
this.options.oneTimeConfig.namespaceURI = this.options.oneTimeConfig.namespace.split(".").join("/");
this.options.oneTimeConfig.appId = this.options.oneTimeConfig.appId || this.options.oneTimeConfig.namespace + "." + (this.options.oneTimeConfig.modulename || this.options.oneTimeConfig.projectname);
this.options.oneTimeConfig.appURI = this.options.oneTimeConfig.appURI || this.options.oneTimeConfig.namespaceURI + "/" + (this.options.oneTimeConfig.modulename || this.options.oneTimeConfig.projectname);

const journeys = this.config.get("opa5Journeys") || [];
journeys.push(this.options.oneTimeConfig.journey);
Expand All @@ -82,7 +80,7 @@ module.exports = class extends Generator {
}

async writing() {
const sModule = this.options.oneTimeConfig.modulename ? this.options.oneTimeConfig.modulename + "/webapp/" : "";
const sModule = (this.options.oneTimeConfig.modulename ? this.options.oneTimeConfig.modulename + "/" : "") + "webapp/";

this.fs.copyTpl(
this.templatePath("test/integration/$journey.js"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sap.ui.define([
"sap/ui/test/opaQunit",
// "<%= appURI %>/test/integration/pages/<%= journey %>"<% opa5pos.forEach(function (po) { %>,
"<%= appURI %>/test/integration/pages/<%= po %>"<% }) %>
// "./pages/<%= journey %>"<% opa5pos.forEach(function (po) { %>,
"./pages/<%= po %>"<% }) %>
], function (opaTest) {
"use strict";

Expand Down
11 changes: 7 additions & 4 deletions generators/newopa5po/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = class extends Generator {

if (this.options.isSubgeneratorCall) {
this.options.oneTimeConfig.projectname = this.options.projectname;
this.options.oneTimeConfig.namespace = this.options.namespace;
this.options.oneTimeConfig.namespaceInput = this.options.namespaceInput;
this.options.oneTimeConfig.modulename = this.options.modulename;
} else {
if (!this.config.getAll().viewtype) {
Expand All @@ -27,7 +27,7 @@ module.exports = class extends Generator {
default: "myUI5App"
}, {
type: "input",
name: "namespace",
name: "namespaceInput",
message: "Please enter the namespace you use currently",
validate: (s) => {
if (/^[a-zA-Z0-9_\.]*$/g.test(s)) {
Expand Down Expand Up @@ -71,8 +71,11 @@ module.exports = class extends Generator {
for (var key in answers) {
this.options.oneTimeConfig[key] = answers[key];
}

var appName = !this.options.oneTimeConfig.modulename || this.options.oneTimeConfig.modulename === "uimodule" ? this.options.oneTimeConfig.projectname : this.options.oneTimeConfig.modulename;
this.options.oneTimeConfig.namespaceInput = this.options.oneTimeConfig.namespaceInput || this.options.oneTimeConfig.namespace;
this.options.oneTimeConfig.poName = this.options.oneTimeConfig.poName.charAt(0).toUpperCase() + this.options.oneTimeConfig.poName.substr(1);
this.options.oneTimeConfig.appId = this.options.oneTimeConfig.appId || this.options.oneTimeConfig.namespace + "." + (this.options.oneTimeConfig.modulename || this.options.oneTimeConfig.projectname);
this.options.oneTimeConfig.appId = this.options.oneTimeConfig.appId || this.options.oneTimeConfig.namespaceInput + "." + appName;

const pos = this.config.get("opa5pos") || [];
pos.push(this.options.oneTimeConfig.poName);
Expand All @@ -82,7 +85,7 @@ module.exports = class extends Generator {
}

async writing() {
const sModule = this.options.oneTimeConfig.modulename ? this.options.oneTimeConfig.modulename + "/webapp/" : "";
const sModule = (this.options.oneTimeConfig.modulename ? this.options.oneTimeConfig.modulename + "/" : "") + "webapp/";
const journeys = this.config.get("opa5Journeys") || [];

this.fs.copyTpl(
Expand Down
14 changes: 7 additions & 7 deletions generators/newopa5po/templates/test/integration/pages/$poFile.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% function upperFirst (str) { return str.charAt(0).toUpperCase() + str.substr(1);} %>sap.ui.require([
"sap/ui/test/Opa5",
"sap/ui/test/actions/Press"
], function (Opa5, Press) {
"sap/ui/test/Opa5"<% if (action) { %>,
"sap/ui/test/actions/Press"<% } %>
], function (Opa5<% if (action) { %>, Press<% } %>) {
"use strict";

var sViewName = "<%= appId %>.view.<%= upperFirst(poName) %>View";
Expand All @@ -11,8 +11,8 @@
viewName: sViewName,

actions: {
// add action functions here
<% if (action) { %><%= action %>: function () {
// add action functions here<% if (action) { %>
<%= action %>: function () {
return this.waitFor({
controlType: "sap.m.Button",
actions: new Press(),
Expand All @@ -22,8 +22,8 @@
},

assertions: {
// add assertion functions here
<% if (assertion) { %><%= assertion %>: function () {
// add assertion functions here<% if (assertion) { %>
<%= assertion %>: function () {
return this.waitFor({
controlType: "sap.m.Title",
properties: {
Expand Down
3 changes: 2 additions & 1 deletion generators/newwebapp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ module.exports = class extends Generator {

if (answers.addOPA5) {
this.composeWith(require.resolve("../opa5"), Object.assign({}, this.options.oneTimeConfig, {
isSubgeneratorCall: true
isSubgeneratorCall: true,
namespaceInput: this.options.oneTimeConfig.namespace
}));
}
});
Expand Down
22 changes: 9 additions & 13 deletions generators/opa5/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = class extends Generator {

if (this.options.isSubgeneratorCall) {
this.options.oneTimeConfig.projectname = this.options.projectname;
this.options.oneTimeConfig.namespace = this.options.namespace;
this.options.oneTimeConfig.namespaceInput = this.options.namespaceInput;
this.options.oneTimeConfig.modulename = this.options.modulename;
} else {

Expand All @@ -28,7 +28,7 @@ module.exports = class extends Generator {
default: "myUI5App"
}, {
type: "input",
name: "namespace",
name: "namespaceInput",
message: "Please enter the namespace you use currently",
validate: (s) => {
if (/^[a-zA-Z0-9_\.]*$/g.test(s)) {
Expand Down Expand Up @@ -64,21 +64,17 @@ module.exports = class extends Generator {
default: true
});


return this.prompt(aPrompt).then((answers) => {
for (var key in answers) {
this.options.oneTimeConfig[key] = answers[key];
}

if (answers.projectname) {
this.options.oneTimeConfig.projectname = answers.projectname;
this.options.oneTimeConfig.namespace = answers.namespace;
this.options.oneTimeConfig.namespaceURI = answers.namespace.split(".").join("/");
}

this.options.oneTimeConfig.appId = this.options.oneTimeConfig.appId || this.options.oneTimeConfig.namespace + "." + (this.options.oneTimeConfig.modulename || this.options.oneTimeConfig.projectname);
this.options.oneTimeConfig.appURI = this.options.oneTimeConfig.appURI || this.options.oneTimeConfig.namespaceURI + "/" + (this.options.oneTimeConfig.modulename || this.options.oneTimeConfig.projectname);
this.options.oneTimeConfig.title = this.options.oneTimeConfig.modulename || this.options.oneTimeConfig.projectname;
var appName = !this.options.oneTimeConfig.modulename || this.options.oneTimeConfig.modulename === "uimodule" ? this.options.oneTimeConfig.projectname : this.options.oneTimeConfig.modulename;
this.options.oneTimeConfig.namespaceInput = this.options.oneTimeConfig.namespaceInput || this.options.oneTimeConfig.namespace;
this.options.oneTimeConfig.namespaceURI = this.options.oneTimeConfig.namespaceInput.split(".").join("/");
this.options.oneTimeConfig.appId = this.options.oneTimeConfig.namespaceInput + "." + appName;
this.options.oneTimeConfig.appURI = this.options.oneTimeConfig.namespaceURI + "/" + appName;
this.options.oneTimeConfig.title = appName;
});
}

Expand All @@ -105,7 +101,7 @@ module.exports = class extends Generator {
this.config.set("opa5pos", pos);
this.options.oneTimeConfig.opa5pos = pos;

const sModule = this.options.oneTimeConfig.modulename ? this.options.oneTimeConfig.modulename + "/webapp/" : "";
const sModule = (this.options.oneTimeConfig.modulename ? this.options.oneTimeConfig.modulename + "/" : "") + "webapp/";
this.sourceRoot(path.join(__dirname, "templates"));
glob.sync("**", {
cwd: this.sourceRoot(),
Expand Down
4 changes: 2 additions & 2 deletions generators/opa5/templates/test/integration/AllJourneys.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sap.ui.define([
"sap/ui/test/Opa5",
"<%= appURI %>/test/integration/arrangements/Startup"<% opa5Journeys.forEach(function (journey) { %>,
"<%= appURI %>/test/integration/<%=journey%>Journey"<% }) %>
"./arrangements/Startup"<% opa5Journeys.forEach(function (journey) { %>,
"./<%=journey%>Journey"<% }) %>
], function(Opa5, Startup) {
"use strict";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="utf-8">
<title>Integration tests for <%= title %></title>

<script id="sap-ui-bootstrap" src="../../resources/sap-ui-core.js"
<script id="sap-ui-bootstrap" src="../../../../../resources/sap-ui-core.js"
data-sap-ui-theme='sap_fiori_3'
data-sap-ui-resourceroots='{
"<%= appId %>": "../../"
Expand All @@ -16,10 +16,10 @@
data-sap-ui-async="true">
</script>

<link rel="stylesheet" type="text/css" href="../../resources/sap/ui/thirdparty/qunit-2.css">
<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/thirdparty/qunit-2.js"></script>
<script src="../../../../../resources/sap/ui/qunit/qunit-junit.js"></script>

<script src="opaTests.qunit.js"></script>
</head>
Expand Down
2 changes: 1 addition & 1 deletion generators/opa5/templates/test/testsuite.qunit.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title>QUnit test suite for <%= title %></title>
<script src="../resources/sap/ui/qunit/qunit-redirect.js"></script>
<script src="../../../../resources/sap/ui/qunit/qunit-redirect.js"></script>
<script src="testsuite.qunit.js" data-sap-ui-testsuite></script>
</head>
<body>
Expand Down
11 changes: 8 additions & 3 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,24 @@ describe("OPA5 tests", function () {

it("should add OPA5 tests and run them with karma", function () {
var appDir;
return helpers.run(path.join(__dirname, "../generators/app")).withPrompts({ viewtype: "XML", addOPA5: false })
.then(function (dir) {
appDir = path.join(dir, "com.myorg.myUI5App/uimodule/webapp");
return helpers.run(path.join(__dirname, "../generators/app")).withPrompts({
viewtype: "XML",
addOPA5: false
}).then(function (dir) {
appDir = path.join(dir, "com.myorg.myUI5App");
return helpers.run(path.join(__dirname, "../generators/opa5")).cd(appDir).withPrompts({
modulename: "uimodule",
addJourney: false,
addPO: false
});
}).then(function () {
return helpers.run(path.join(__dirname, "../generators/newopa5journey")).cd(appDir).withPrompts({
modulename: "uimodule",
journey: "Main"
});
}).then(function () {
return helpers.run(path.join(__dirname, "../generators/newopa5po")).cd(appDir).withPrompts({
modulename: "uimodule",
poName: "Main",
action: "iPressTheButton",
assertion: "iShouldSeeTheTitle"
Expand Down

0 comments on commit fb166b7

Please sign in to comment.