Skip to content

Commit

Permalink
Merge pull request #1 from rico-projects/runIntTestsInCi
Browse files Browse the repository at this point in the history
add integration test execution in travisCI
  • Loading branch information
giftkugel authored Jan 14, 2019
2 parents f567d9e + 3d893da commit 03f3803
Show file tree
Hide file tree
Showing 12 changed files with 410 additions and 174 deletions.
32 changes: 30 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,36 @@ notifications:
email: true
node_js:
- '9'
script:
- npm run dist
services:
- docker

# Set DISPLAY for Xvfb
env:
- DISPLAY=:99.0

# Use APT Addon to install Chrome
addons:
apt:
sources:
- google-chrome
packages:
- google-chrome-stable

# Start Xvfb so you can run Chrome
before_install:
- sh -e /etc/init.d/xvfb start

jobs:
include:
- stage: build
script:
- npm run dist
# - stage: "integration test"
# script:
# - npm run start-int-test-server
# - npm run int-test-ci
# - npm run stop-int-test-server

after_success:
- npm run semantic-release
branches:
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ For a complete working example, please refer to https://github.com/rico-projects

=== Run library integration tests

Prerequsite: Have Docker installed.
Prerequsite: Have https://docs.docker.com/install/[Docker] installed.

Then, have a integration tests server running using Docker:

Expand Down
9 changes: 8 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = function (config) {
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-junit-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
Expand All @@ -20,7 +21,13 @@ module.exports = function (config) {
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
reporters: ['progress', 'kjhtml', 'junit'],
junitReporter: {
outputDir: 'test-reports', // results will be saved as $outputDir/$browserName.xml
outputFile: 'test-results.xml', // if included, results will be saved as $outputDir/$browserName/$outputFile
suite: '', // suite will become the package name attribute in xml testsuite element
useBrowserName: true // add browser name to report and classes names
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"dist": "npm run build && npm run pack",
"start-int-test-server": "docker run -d -p 8085:8080 --rm --name rico-angular-int-server ricoprojects/integration:tomee-1.0.0-CR2",
"int-test": "npm-install-peers && ng test --main src/test.integration.ts --ts-config tsconfig.spec.integration.json",
"int-test-ci": "npm-install-peers && ng test --main src/test.integration.ts --ts-config tsconfig.spec.integration.json --code-coverage --watch false",
"stop-int-test-server": "docker stop rico-angular-int-server",
"semantic-release": "semantic-release"
},
Expand Down Expand Up @@ -49,6 +50,7 @@
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-junit-reporter": "^1.2.0",
"ng-packagr": "^4.4.5",
"npm-install-peers": "^1.2.1",
"protractor": "~5.4.0",
Expand Down
32 changes: 12 additions & 20 deletions src/lib/controller-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class ControllerProxy {
private internalModel: any;
private vanillaControllerProxy: any;
private appRef: ApplicationRef;
private clientContext: any
private clientContext: any;
private modelContainer: Map<any, Map<any, any>>;

constructor(appRef: ApplicationRef, clientContext: any) {
Expand All @@ -28,13 +28,6 @@ export class ControllerProxy {
public get model(): any {
return this.internalModel;
}
public set model(v: any) {
this.internalModel = v;
}

public get vanillaModel(): any {
return this.vanillaControllerProxy.model;
}

invoke(name: string, params?: any): Promise<any> {
return this.vanillaControllerProxy.invoke(name, params);
Expand All @@ -51,16 +44,17 @@ export class ControllerProxy {
proxy.internalModel = controllerProxy.model;

if (ControllerProxy.LOGGER.isLogLevel(LogLevel.DEBUG)) {
// TODO: remove the quick hack to peek into the model :-)
// @ts-ignore
window._ricoModel = controllerProxy.model;
ControllerProxy.LOGGER.debug('Model ', JSON.stringify(controllerProxy.model));
}

resolve(proxy);

}); //createController does not handle a reject case, so there is no point in implement a proper handling here
// TODO: implment as it has been fixed in rico-js
})
.catch((error) => {
reject(error);
});
});
}

Expand All @@ -75,14 +69,14 @@ export class ControllerProxy {
const onArrayUpdateHandlerResult = beanManager.onArrayUpdate(this.onArrayUpdateHandler);
// TODO The results should be used to clean up at the end

ControllerProxy.LOGGER.info('Rico remoting model binding listeners for Angular registered');
ControllerProxy.LOGGER.debug('Rico remoting model binding listeners for Angular registered');
}

private onBeanAddedHandler(bean: any) {
this.modelContainer.set(bean, new Map());
ControllerProxy.LOGGER.debug('onBeanAddedHandler', bean);

for (const propertyName in bean) {
for (const propertyName of Object.keys(bean)) {
this.watchProperty(bean, propertyName);
}
}
Expand All @@ -105,8 +99,6 @@ export class ControllerProxy {
return;
}

//

if (newProperty) {
this.watchProperty(bean, propertyName);
}
Expand All @@ -130,11 +122,11 @@ export class ControllerProxy {
} else {
this.injectArray(array, index, newElements);

for (bean in newElements) {
for (const currentPropertyName in bean) {
this.watchProperty(bean, currentPropertyName);
newElements.forEach( (element) => {
for (const currentPropertyName of Object.keys(element)) {
this.watchProperty(element, currentPropertyName);
}
}
});
}

this.appRef.tick();
Expand All @@ -148,7 +140,7 @@ export class ControllerProxy {
Object.defineProperty(bean, propertyName, {
// Create a new getter for the property
get: function () {
ControllerProxy.LOGGER.trace("Get for " + propertyName);
ControllerProxy.LOGGER.trace('Get for ' + propertyName);
return valueMap.get(propertyName);
},
// Create a new setter for the property
Expand Down
2 changes: 1 addition & 1 deletion src/lib/rico-angular.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import { ControllerProxy } from './controller-proxy';

export class RicoAngularModule {
constructor(private service: RicoService) {
console.log('RicoAngularModule created', service.getClientContextFactory());

}
}
Loading

0 comments on commit 03f3803

Please sign in to comment.