build: update dependencies

Additionally adjust the code after the latest
rebase.
This commit is contained in:
Jovan Krunić
2019-04-08 11:28:43 +02:00
parent 3e697b17b4
commit 75ca8c8a73
10 changed files with 566 additions and 561 deletions

View File

@@ -1,27 +0,0 @@
/*
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* An error that can occur in the StApps app
*/
export class AppError extends Error {
/**
* Instantiate a new error
*/
constructor(name: string, message: string) {
super(message);
this.name = name;
}
}

View File

@@ -1,140 +0,0 @@
/*
* Copyright (C) 2018, 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {HttpEvent,
HttpHandler, HttpInterceptor, HttpRequest, HttpResponse} from '@angular/common/http';
import {Injectable} from '@angular/core';
import {SCIndexResponse} from '@openstapps/core';
import {Observable, of} from 'rxjs';
const sampleIndexResponse: SCIndexResponse = {
app: {
campusPolygon: {
coordinates: [
[
[
13.31916332244873,
52.50796756998264,
],
[
13.336544036865234,
52.50796756998264,
],
[
13.336544036865234,
52.51726547416385,
],
[
13.31916332244873,
52.51726547416385,
],
[
13.31916332244873,
52.50796756998264,
],
],
],
type: 'Polygon',
},
features: {
widgets: true,
},
menus: [],
name: 'StApps - Technische Universität Berlin',
privacyPolicyUrl: 'https://stappsbe01.innocampus.tu-berlin.de/_static/privacy.md',
settings: [],
},
backend: {
SCVersion: '1.0.0',
hiddenTypes: [
'date series',
'diff',
'floor',
],
name: 'Technische Universität Berlin',
namespace: '909a8cbc-8520-456c-b474-ef1525f14209',
sortableFields: [
{
fieldName: 'name',
sortTypes: ['ducet'],
},
{
fieldName: 'type',
sortTypes: ['ducet'],
},
{
fieldName: 'categories',
onlyOnTypes: [
'academic event',
'building',
'catalog',
'dish',
'point of interest',
'room',
],
sortTypes: ['ducet'],
},
{
fieldName: 'geo.point.coordinates',
onlyOnTypes: [
'building',
'point of interest',
'room',
],
sortTypes: ['distance'],
},
{
fieldName: 'geo.point.coordinates',
onlyOnTypes: [
'building',
'point of interest',
'room',
],
sortTypes: ['distance'],
},
{
fieldName: 'inPlace.geo.point.coordinates',
onlyOnTypes: [
'date series',
'dish',
'floor',
'organization',
'point of interest',
'room',
'ticket',
],
sortTypes: ['distance'],
},
{
fieldName: 'offers',
onlyOnTypes: [
'dish',
],
sortTypes: ['price'],
},
],
},
};
@Injectable()
export class FakeBackendInterceptor implements HttpInterceptor {
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
if (request.url.endsWith('/') && request.method === 'POST') {
// respond 200 OK
return of(new HttpResponse({status: 200, body: sampleIndexResponse}));
} else {
return next.handle(request);
}
}
}

View File

@@ -13,8 +13,8 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {TestBed} from '@angular/core/testing';
import {SCIndexResponse} from '@openstapps/core';
import {StAppsWebHttpClient} from '../data/data.provider';
import {SCIndexResponse, SCThingOriginType, SCThingType} from '@openstapps/core';
import {StAppsWebHttpClient} from '../data/stapps-web-http-client.provider';
import {StorageProvider} from '../storage/storage.provider';
import {ConfigProvider, STORAGE_KEY_CONFIG} from './config.provider';
import {
@@ -50,7 +50,7 @@ describe('ConfigProvider', () => {
});
it('should fetch app configuration', async () => {
spyOn(configProvider.client, 'handshake').and.returnValue(sampleIndexResponse);
spyOn(configProvider.client, 'handshake').and.returnValue(Promise.resolve(sampleIndexResponse));
const result = await configProvider.fetch();
expect(result).toEqual(sampleIndexResponse);
});
@@ -67,8 +67,8 @@ describe('ConfigProvider', () => {
});
it('should init from remote and saved config not available', async () => {
storageProviderSpy.has.and.returnValue(false);
spyOn(configProvider.client, 'handshake').and.returnValue(sampleIndexResponse);
storageProviderSpy.has.and.returnValue(Promise.resolve(false));
spyOn(configProvider.client, 'handshake').and.returnValue(Promise.resolve(sampleIndexResponse));
try {
await configProvider.init();
} catch (error) {
@@ -82,8 +82,8 @@ describe('ConfigProvider', () => {
});
it('should init from storage with remote fails', async () => {
storageProviderSpy.has.and.returnValue(true);
storageProviderSpy.get.and.returnValue(sampleIndexResponse);
storageProviderSpy.has.and.returnValue(Promise.resolve(true));
storageProviderSpy.get.and.returnValue(Promise.resolve(sampleIndexResponse));
spyOn(configProvider.client, 'handshake').and.throwError('');
let error = new Error('');
try {
@@ -99,7 +99,7 @@ describe('ConfigProvider', () => {
});
it('should throw error on failed initialisation', async () => {
storageProviderSpy.has.and.returnValue(false);
storageProviderSpy.has.and.returnValue(Promise.resolve(false));
spyOn(configProvider.client, 'handshake').and.throwError('');
let error = null;
try {
@@ -111,11 +111,11 @@ describe('ConfigProvider', () => {
});
it('should throw error on wrong config version in storage', async () => {
storageProviderSpy.has.and.returnValue(true);
storageProviderSpy.has.and.returnValue(Promise.resolve(true));
const wrongConfig = JSON.parse(JSON.stringify(sampleIndexResponse));
wrongConfig.backend.SCVersion = '0.1.0';
storageProviderSpy.get.and.returnValue(wrongConfig);
spyOn(configProvider.client, 'handshake').and.returnValue(sampleIndexResponse);
spyOn(configProvider.client, 'handshake').and.returnValue(Promise.resolve(sampleIndexResponse));
let error = null;
try {
await configProvider.init();
@@ -126,7 +126,7 @@ describe('ConfigProvider', () => {
});
it('should throw error on saved app configuration not available', async () => {
storageProviderSpy.has.and.returnValue(false);
storageProviderSpy.has.and.returnValue(Promise.resolve(false));
let error = new Error('');
try {
await configProvider.loadLocal();
@@ -147,16 +147,16 @@ describe('ConfigProvider', () => {
});
it('should return app configuration value', async () => {
storageProviderSpy.has.and.returnValue(true);
storageProviderSpy.get.and.returnValue(sampleIndexResponse);
spyOn(configProvider.client, 'handshake').and.returnValue(sampleIndexResponse);
storageProviderSpy.has.and.returnValue(Promise.resolve(true));
storageProviderSpy.get.and.returnValue(Promise.resolve(sampleIndexResponse));
spyOn(configProvider.client, 'handshake').and.returnValue(Promise.resolve(sampleIndexResponse));
await configProvider.init();
expect(await configProvider.getValue('name')).toEqual(sampleIndexResponse.app.name);
});
it('should return app configuration value if only saved config is available and fetch fails', async () => {
storageProviderSpy.has.and.returnValue(true);
storageProviderSpy.get.and.returnValue(sampleIndexResponse);
storageProviderSpy.has.and.returnValue(Promise.resolve(true));
storageProviderSpy.get.and.returnValue(Promise.resolve(sampleIndexResponse));
spyOn(configProvider.client, 'handshake').and.throwError('');
expect(await configProvider.getValue('name')).toEqual(sampleIndexResponse.app.name);
});
@@ -216,6 +216,7 @@ const sampleIndexResponse: SCIndexResponse = {
origin: {
indexed: '2018-09-11T12:30:00Z',
name: 'Dummy',
type: SCThingOriginType.Remote,
},
translations: {
de: {
@@ -227,7 +228,7 @@ const sampleIndexResponse: SCIndexResponse = {
name: 'Username',
},
},
type: 'setting',
type: SCThingType.Setting,
uid: '',
},
],
@@ -235,10 +236,12 @@ const sampleIndexResponse: SCIndexResponse = {
backend: {
SCVersion: '1.0.0',
hiddenTypes: [
'date series',
'diff',
'floor',
SCThingType.DateSeries,
SCThingType.Diff,
SCThingType.Floor,
],
maxMultiSearchRouteQueries: 5,
maxRequestBodySize: 512 * 1024,
name: 'Technische Universität Berlin',
namespace: '909a8cbc-8520-456c-b474-ef1525f14209',
sortableFields: [
@@ -253,50 +256,50 @@ const sampleIndexResponse: SCIndexResponse = {
{
fieldName: 'categories',
onlyOnTypes: [
'academic event',
'building',
'catalog',
'dish',
'point of interest',
'room',
SCThingType.AcademicEvent,
SCThingType.Building,
SCThingType.Catalog,
SCThingType.Dish,
SCThingType.PointOfInterest,
SCThingType.Room,
],
sortTypes: ['ducet'],
},
{
fieldName: 'geo.point.coordinates',
onlyOnTypes: [
'building',
'point of interest',
'room',
SCThingType.Building,
SCThingType.PointOfInterest,
SCThingType.Room,
],
sortTypes: ['distance'],
},
{
fieldName: 'geo.point.coordinates',
onlyOnTypes: [
'building',
'point of interest',
'room',
SCThingType.Building,
SCThingType.PointOfInterest,
SCThingType.Room,
],
sortTypes: ['distance'],
},
{
fieldName: 'inPlace.geo.point.coordinates',
onlyOnTypes: [
'date series',
'dish',
'floor',
'organization',
'point of interest',
'room',
'ticket',
SCThingType.DateSeries,
SCThingType.Dish,
SCThingType.Floor,
SCThingType.Organization,
SCThingType.PointOfInterest,
SCThingType.Room,
SCThingType.Ticket,
],
sortTypes: ['distance'],
},
{
fieldName: 'offers',
onlyOnTypes: [
'dish',
SCThingType.Dish,
],
sortTypes: ['price'],
},

View File

@@ -17,7 +17,7 @@ import {Client} from '@openstapps/api/lib/client';
import {SCAppConfiguration, SCIndexResponse} from '@openstapps/core';
import {Logger} from '@openstapps/logger';
import {environment} from '../../../environments/environment';
import {StAppsWebHttpClient} from '../data/data.provider';
import {StAppsWebHttpClient} from '../data/stapps-web-http-client.provider';
import {StorageProvider} from '../storage/storage.provider';
import {
ConfigFetchError,

View File

@@ -13,7 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {AppError} from '../_helpers/errors';
import {AppError} from './../../_helpers/errors';
/**
* Error that is thrown when fetching from backend fails

View File

@@ -85,7 +85,7 @@ describe('DataProvider', () => {
});
it('should provide backend data items using search query', async () => {
spyOn(Client.prototype, 'search').and.callFake(() => {
spyOn(Client.prototype as any, 'search').and.callFake(() => {
return {
then: (callback: any) => {
return callback(sampleResponse);
@@ -98,7 +98,7 @@ describe('DataProvider', () => {
it('should put an data item into the local database (storage)', async () => {
let providedThing: SCSaveableThing<SCThing>;
spyOn(storageProvider, 'put').and.callFake((_id: any, thing: any) => {
spyOn(storageProvider, 'put' as any).and.callFake((_id: any, thing: any) => {
providedThing = thing;
providedThing.origin.created = sampleSavable.origin.created;
});
@@ -131,7 +131,7 @@ describe('DataProvider', () => {
});
it('should provide single data from the backend', async () => {
spyOn(Client.prototype, 'getThing').and.callFake(() => {
spyOn(Client.prototype, 'getThing' as any).and.callFake(() => {
return {
then: (callback: any) => {
return callback(sampleThing);
@@ -145,14 +145,14 @@ describe('DataProvider', () => {
});
it('should get an item from both local and remote database', async () => {
spyOn(Client.prototype, 'getThing').and.callFake(() => {
spyOn(Client.prototype, 'getThing' as any).and.callFake(() => {
return {
then: (callback: any) => {
return callback(sampleThing);
},
};
});
spyOn(storageProvider, 'get').and.callFake(() => {
spyOn(storageProvider, 'get' as any).and.callFake(() => {
return {
then: (callback: any) => {
return callback(sampleSavable);

View File

@@ -61,7 +61,7 @@ describe('DataDetailComponent', () => {
beforeEach(async () => {
dataProvider = TestBed.get(DataProvider);
refresher = jasmine.createSpyObj('refresher', ['complete']);
spyOn(dataProvider, 'get').and.returnValue(Promise.resolve(sampleThing));
spyOn(dataProvider, 'get' as any).and.returnValue(Promise.resolve(sampleThing));
spyOn(DataDetailComponent.prototype, 'getItem').and.callThrough();
fixture = await TestBed.createComponent(DataDetailComponent);
comp = fixture.componentInstance;