Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Commit

Permalink
Merge branch 'develop' into wip/action-module-directive-existingName
Browse files Browse the repository at this point in the history
  • Loading branch information
kilchenmann committed Sep 6, 2018
2 parents b8ecadc + 28154eb commit c329865
Show file tree
Hide file tree
Showing 109 changed files with 9,509 additions and 6,012 deletions.
6 changes: 4 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
node --version \
&& yarn --version \
&& git --version
- run: yarn install

- save_cache:
Expand All @@ -35,13 +36,14 @@ jobs:
key: v1-dependencies-{{ checksum "yarn.lock" }}

# Build the libraries
# - run: yarn build:core
- run: yarn build-lib

# Build the demo apps (from library packages)
# Build the demo app
# - run: yarn build:app

# Run unit tests!
# - run: xvfb-run -a yarn ci:test
- run: yarn ng t --project @knora/core --watch=false --browsers=ChromeHeadless

# Run e2e tests!
# - run: xvfb-run -a yarn ci:e2e
Expand Down
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
dist: trusty
sudo: required

language: node_js

node_js:
- "8"

cache:
yarn: true
directories:
- node_modules

addons:
chrome: stable
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.9

env:
global:
- CXX=g++-4.9

install: export CXX="g++-4.9"

before_script:
- yarn global add @angular/cli
- yarn install

script: ng t --project @knora/core --watch=false --browsers=ChromeHeadless
83 changes: 70 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Knora-ui

[![CircleCI](https://circleci.com/gh/dhlab-basel/Knora-ui/tree/wip%2Fcore-module-tests.svg?style=svg)](https://circleci.com/gh/dhlab-basel/Knora-ui/tree/wip%2Fcore-module-tests)

This is the demo and developing environment for Knora ui modules, which will be published on [npm](https://www.npmjs.com/~knora).

The modules helps to create a graphical user interface for [Knora](https://knora.org) in a quick and simple way. They're written in [Angular](https://angular.io) (v6) including the [material design](https://material.angular.io).
Expand Down Expand Up @@ -79,16 +81,71 @@ To create new e.g. component inside existing module use the following command:
* properties (as form elements)
* resource_class_form

<!--
@knora/admin
<!-- ![npm (scoped)](https://img.shields.io/npm/v/@knora/admin.svg) --
* project (incl. ontology-editor)
* system
* user
* dashboard
* ontology_form incl. resource-class-form (new-/edit-resource-class)
* project_form
* user_form
* list_form
-->
<!-- ---
## Unit Testing Services
Testing services with HttpClient and HttpTestingController
* Then a test expects that certain requests have or have not been made, performs assertions against those requests, and finally provide responses by "flushing" each expected request.
https://angular.io/guide/http#testing-http-requests
* See https://stackblitz.com/edit/angular-uy5cdl?file=src%2Fapp%2Fheroes%2Fheroes.service.spec.ts for a working example.
```
getAllHeroes (): Observable<any[]> {
const observables = [];
for (let i = 0; i <= 2; i++) {
observables.push(
this.http.get<Hero[]>(this.heroesUrl)
.pipe(
catchError(this.handleError('getAllHeroes', []))
)
);
}
return forkJoin(observables);
}
```
* Several http requests are created and pushed on an array, then they are passed to forkJoin and returned. With forkJoin, we get one Observable that we can subscribe to (executed once all Observables have been completed). Then we get the results of all Observables from within the subscription to the Observable returned by forkJoin.
```
it('should get all heroes', () => {
let res = heroService.getAllHeroes();
res.subscribe(
(obs) => {
console.log("test")
expect(obs[0]).toEqual(expectedHeroes, 'should return expected heroes');
expect(obs[1]).toEqual(expectedHeroes, 'should return expected heroes');
expect(obs[2]).toEqual(expectedHeroes, 'should return expected heroes');
}, fail
);
// HeroService should have made three requests to GET heroes from expected URL
const req = httpTestingController.match(
(request) => {
return request.url === heroService.heroesUrl && request.method === 'GET'
}
);
// Respond with the mock heroes
expect(req.length).toEqual(3);
req[0].flush(expectedHeroes)
req[1].flush(expectedHeroes)
req[2].flush(expectedHeroes)
});
```
* The clue is that for each http request made, a response has to be "flushed". Otherwise the subscription to the Observable returned by forkJoin is never executed:
If an inner observable does not complete forkJoin will never emit a value!
https://www.learnrxjs.io/operators/combination/forkjoin.html
> This is why the subscription never worked, because we did not flush all necessary responses. -->
2 changes: 1 addition & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,4 @@
"styleext": "scss"
}
}
}
}
Binary file modified docs/viewerModule.bmpr
Binary file not shown.
66 changes: 66 additions & 0 deletions karma.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('karma-html-detailed-reporter'),
require('karma-spec-reporter'),
require('@angular/cli/plugins/karma')
],
client:{
captureConsole: true,
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
browserConsoleLogOptions: {
level: 'log',
format: '%b %T: %m',
terminal: true
},
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['@angular/cli']
},
mime: {
'text/x-typescript': ['ts','tsx']
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
logLevel: config.LOG_LOG,
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml'],
specReporter: {
suppressPassed: false, // do not print information about passed tests
suppressSkipped: true, // do not print information about skipped tests
},
port: 9876,
colors: true,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
customLaunchers: {
ChromeHeadless: {
base: 'Chrome',
flags: [
// See https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
'--headless',
'--disable-gpu',
// Without a remote debugging port, Google Chrome exits immediately.
'--remote-debugging-port=9222'
]
}
}
});
};
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-marbles": "^0.3.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~1.4.2",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-cli": "~1.0.1",
"karma-html-detailed-reporter": "^1.1.4",
"karma-spec-reporter": "^0.0.32",
"ng-packagr": "^3.0.0-rc.0",
"protractor": "~5.3.0",
"ts-node": "~5.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ export class KnoraConstants {
public static OwlRestriction = KnoraConstants.owl + '#Restriction';

public static creationDate = KnoraConstants.KnoraApiV2WithValueObjectPath + 'creationDate';
public static lastModificationDate = KnoraConstants.KnoraApiV2WithValueObjectPath + 'lastModificationDate';
public static hasPermissions = KnoraConstants.KnoraApiV2WithValueObjectPath + 'hasPermissions';
public static attachedToProject = KnoraConstants.KnoraApiV2WithValueObjectPath + 'attachedToProject';
public static attachedToUser = KnoraConstants.KnoraApiV2WithValueObjectPath + 'attachedToUser';

public static Region = KnoraConstants.KnoraApiV2WithValueObjectPath + 'Region';

Expand Down
7 changes: 3 additions & 4 deletions projects/knora/core/src/lib/declarations/api/operators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ export class ValueLiteral implements Value {
*/
constructor(
public readonly value: string,
public readonly type: string,
private _gravSearchService?: GravsearchGenerationService) {
public readonly type: string) {
}


Expand All @@ -194,9 +193,9 @@ export class ValueLiteral implements Value {

// check if a Knora schema conversion is necessary, e.g., knora-api:dateValue (complex) to knora-api:date (simple).
// xsd types will remain unchanged
if (schema === KnoraSchema.simple && this._gravSearchService.typeConversionComplexToSimple[this.type] !== undefined) {
if (schema === KnoraSchema.simple && GravsearchGenerationService.typeConversionComplexToSimple[this.type] !== undefined) {
// convert to simple schema
literalType = this._gravSearchService.typeConversionComplexToSimple[this.type];
literalType = GravsearchGenerationService.typeConversionComplexToSimple[this.type];
} else {
// do not convert
literalType = this.type;
Expand Down
1 change: 0 additions & 1 deletion projects/knora/core/src/lib/declarations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export * from './utils';
* Interfaces for constants and operators
*/
export * from './api/knora-constants';
export * from './api/operators';

/**
* Interfaces for shared objects
Expand Down

0 comments on commit c329865

Please sign in to comment.