Skip to content

Commit

Permalink
Merge pull request #5 from IObert/master
Browse files Browse the repository at this point in the history
PR for features of the next iteration
  • Loading branch information
Marius Obert authored Mar 19, 2019
2 parents 1cee15b + 2ce805f commit ff8d741
Show file tree
Hide file tree
Showing 25 changed files with 1,452 additions and 52 deletions.
14 changes: 5 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,32 @@ version: 2
defaults: &defaults
working_directory: ~/repo
docker:
- image: circleci/node:10.6.0
- image: circleci/node:10.6.0-browsers

workflows:
version: 2
test-deploy:
jobs:
- test:
filters:
tags:
only: /^v.*/ #fix this
- build
- deploy:
requires:
- test
- build
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/

jobs:
test:
build:
<<: *defaults
steps:
- checkout

- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- v1-dependencies- # fallback to using the latest cache if no exact match is found

- run: npm install
- run:
Expand Down
2 changes: 1 addition & 1 deletion generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ module.exports = class extends Generator {
this.installDependencies({
bower: false,
npm: true
}).then(() => this.log('Everything is ready!'));
});
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"start": "node node_modules/@sap/approuter/approuter.js"
},
"dependencies": {
"@sap/approuter": "^5.8.0"
"@sap/approuter": "^5.13.0"
}
}
28 changes: 28 additions & 0 deletions generators/app/templates/karma-ci.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Karma configuration
// Generated on Wed Jun 13 2018 14:38:44 GMT+0200 (CEST)

module.exports = function(config) {
require("./karma.conf")(config);
config.set({

client: {
qunit: {
showUI: false
}
},

// test results reporter to use
// possible values: 'dots', 'progress', 'coverage'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['ChromeHeadless'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true

});
};
69 changes: 69 additions & 0 deletions generators/app/templates/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Karma configuration
// Generated on Wed Jun 13 2018 14:38:44 GMT+0200 (CEST)

module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: 'webapp',

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['qunit', 'openui5'],

openui5: {
path: 'http://localhost:8080/resources/sap-ui-core.js'
},

client: {
openui5: {
config: {
theme: 'sap_belize',
language: 'EN',
bindingSyntax: 'complex',
compatVersion: 'edge',
async: true,
resourceroots: {'<%=namespace%>.<%=projectname%>': './base'}
},
tests: [
'<%=namespace.replace(/\./g, '/')%>/<%=projectname%>/test/integration/AllJourneys'
]
},
clearContext: false,
qunit: {
showUI: true
}
},

// list of files / patterns to load in the browser
files: [
{ pattern: '**', included: false, served: true, watched: true }
],

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

// level of browser logging
browserConsoleLogOptions: {
level: 'error'
},

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false

});
};
32 changes: 21 additions & 11 deletions generators/app/templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,36 @@
},
"scripts": {
"start": "ui5 serve -o index.html",
"serve": "ui5 serve",
"test": "mocha",
"karma-ci": "karma start karma-ci.conf.js",
"karma": "rimraf coverage && start-server-and-test serve http://localhost:8080 karma-ci",
"lint": "eslint webapp",
"build-ui": "rimraf dist && ui5 build --a",
"package-cf": "npm run build-ui && cp cf_deployment_resources/package.json dist/package.json && cp cf_deployment_resources/xs-app.json dist/xs-app.json && mbt init && make -f Makefile.mta p=cf",
"deploy-cf": "npm run package-cf && cross-var cf deploy mta_archives/<%=projectname%>_$npm_package_version.mtar",
"cf_log": "cf logs <%= projectname %>",
"lint": "eslint webapp",
"watch": "start-server-and-test start http://localhost:8080 karma",
"test": "npm run lint && rimraf coverage && start-server-and-test start http://localhost:8080 karma-ci",
"build-ui": "rimraf dist && ui5 build --a"
"cf-log": "cf logs <%= projectname %>"
},
"dependencies": {
"@ui5/cli": "^1.2.0",
"rimraf": "^2.6.2",
"@openui5/sap.m": "^1.63.0",
"@openui5/sap.ui.core": "^1.63.0",
"@openui5/sap.ui.layout": "^1.63.0",
"@openui5/themelib_sap_belize": "^1.63.0",
"cross-var": "^1.1.0"
"@openui5/themelib_sap_belize": "^1.63.0"
},
"devDependencies": {
"eslint": "^5.15.0",
"@ui5/cli": "^1.2.0",
"rimraf": "^2.6.2",
"karma": "^3.1.3",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.2",
"karma-openui5": "^0.2.3",
"karma-qunit": "^1.2.1",
"qunitjs": "^2.4.1",
"start-server-and-test": "^1.4.1"
"yeoman-assert": "^3.1.1",
"cross-var": "^1.1.0",
"eslint": "^5.15.0",
"execa": "^1.0.0",
"mocha": "^6.0.2",
"start-server-and-test": "^1.7.12"
}
}
24 changes: 24 additions & 0 deletions generators/app/templates/test/basic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const path = require('path');
const execa = require('execa');
const assert = require('yeoman-assert');

describe('Basic project capabilities', function() {

describe('Generated code', function() {
this.timeout(35000)

it('should contain eslint', function() {
return assert.file(['node_modules/.bin/eslint']);
});

it('should be lintable', function() {
return execa.shellSync('npm run lint')
});

it('should pass karma test suite', function() {
return execa.shellSync('npm run karma')
});

});

});
3 changes: 3 additions & 0 deletions generators/app/templates/webapp/i18n/i18n_en.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title=<%=projectname%>
appTitle=<%=projectname%>
appDescription=App Description
12 changes: 6 additions & 6 deletions generators/app/templates/webapp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

"sap.ui5": {
"rootView": {
"viewName": "<%=namespace%>.<%=projectname%>.view.<%=viewtype%><%=viewname%>",
"viewName": "<%=namespace%>.<%=projectname%>.view.<%=viewname%>",
"type": "<%=viewtype%>",
"async": true,
"id": "app"
Expand Down Expand Up @@ -70,15 +70,15 @@
"async": true
},
"routes": [{
"name": "Route<%=viewtype%><%=viewname%>",
"pattern": "Route<%=viewtype%><%=viewname%>",
"target": ["Target<%=viewtype%><%=viewname%>"]
"name": "Route<%=viewname%>",
"pattern": "Route<%=viewname%>",
"target": ["Target<%=viewname%>"]
}],
"targets": {
"Target<%=viewtype%><%=viewname%>": {
"Target<%=viewname%>": {
"viewType": "XML",
"viewLevel": 1,
"viewName": "<%=viewtype%><%=viewname%>"
"viewName": "<%=viewname%>"
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions generators/app/templates/webapp/test/integration/AllJourneys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sap.ui.define([
"sap/ui/test/Opa5",
"<%=namespace.replace(/\./g, '/')%>/<%=projectname%>/test/integration/arrangements/Startup",
"<%=namespace.replace(/\./g, '/')%>/<%=projectname%>/test/integration/BasicJourney"
], function(Opa5, Startup) {
"use strict";

Opa5.extendConfig({
arrangements: new Startup(),
pollingInterval: 1
});

});
19 changes: 19 additions & 0 deletions generators/app/templates/webapp/test/integration/BasicJourney.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
sap.ui.define([
"sap/ui/test/opaQunit",
"<%=namespace.replace(/\./g, '/')%>/<%=projectname%>/test/integration/pages/App"
], function (opaTest) {
"use strict";

opaTest("should show correct number of nested pages", function (Given, When, Then) {

// Arrangements
Given.iStartMyApp();

// Assertions
Then.onTheAppPage.iShouldSeePageCount(1);

// Cleanup
Then.iTeardownMyApp();
});

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
sap.ui.define([
"sap/ui/test/Opa5"
], function(Opa5) {
"use strict";

return Opa5.extend("<%=namespace%>.<%=projectname%>.test.integration.arrangements.Startup", {

iStartMyApp: function () {
this.iStartMyUIComponent({
componentConfig: {
name: "<%=namespace%>.<%=projectname%>",
async: true,
manifest: true
}
});
}

});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Integration tests for Todo App</title>

<script id="sap-ui-bootstrap"
src="../../resources/sap-ui-core.js"
data-sap-ui-theme='sap_belize'
data-sap-ui-resourceroots='{
"<%=namespace%>.<%=projectname%>": "../../"
}'
data-sap-ui-language="EN"
data-sap-ui-animation="false"
data-sap-ui-compatVersion="edge"
data-sap-ui-async="true">
</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>
13 changes: 13 additions & 0 deletions generators/app/templates/webapp/test/integration/opaTests.qunit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* global QUnit */

QUnit.config.autostart = false;

sap.ui.getCore().attachInit(function () {
"use strict";

sap.ui.require([
"<%=namespace.replace(/\./g, '/')%>/<%=projectname%>/test/integration/BasicJourney"
], function() {
QUnit.start();
});
});
34 changes: 34 additions & 0 deletions generators/app/templates/webapp/test/integration/pages/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
sap.ui.require([
"sap/ui/test/Opa5",
"sap/ui/test/matchers/AggregationLengthEquals"
], function (Opa5, AggregationLengthEquals) {
"use strict";

var sViewName = "<%=namespace%>.<%=projectname%>.view.<%=viewname%>";
var sAppId = "idAppControl";

Opa5.createPageObjects({
onTheAppPage: {

assertions: {

iShouldSeePageCount: function(iItemCount) {
return this.waitFor({
id: sAppId,
viewName: sViewName,
matchers: [new AggregationLengthEquals({
name: "pages",
length: iItemCount
})],
success: function() {
Opa5.assert.ok(true, "The app contains one page");
},
errorMessage: "App does not have expected number of pages '" + iItemCount + "'."
});
}
}

}
});

});
Loading

0 comments on commit ff8d741

Please sign in to comment.