Switches database and fixes bug where a user was not shown after joining a quiz

parent 8884d87f
......@@ -10,19 +10,6 @@
"prefix": "app",
"schematics": {},
"architect": {
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/server",
"main": "src/main.server.ts",
"tsConfig": "src/tsconfig.server.json",
"stylePreprocessorOptions": {
"includePaths": [
"src/styles/themes"
]
}
}
},
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
......@@ -44,7 +31,6 @@
"src/assets/imageDerivates.json",
"src/assets/themeData.json",
"src/assets/piwik/piwik.js",
"src/assets/dbmigrate.html",
{
"glob": "robots.txt",
"input": "src/assets",
......
......@@ -46,7 +46,7 @@
},
"private": true,
"dependencies": {
"@angular-devkit/build-angular": "~0.800.0-beta.7",
"@angular-devkit/build-angular": "~0.803.17",
"@angular/animations": "^8.2.13",
"@angular/common": "^8.2.13",
"@angular/compiler": "^8.2.13",
......@@ -70,7 +70,6 @@
"angulartics2": "^7.5.2",
"angularx-qrcode": "^1.6.4",
"bootstrap": "^4.3.1",
"classlist.js": "^1.1.20150312",
"cors": "^2.8.5",
"dexie": "^2.0.4",
"highlight.js": "^9.16.2",
......@@ -81,9 +80,10 @@
"ngx-toastr": "^10.2.0",
"ngx-translate-messageformat-compiler": "^4.5.0",
"node-sass": "^4.13.0",
"rxjs": "^6.5.3",
"rxjs": "~6.4.0",
"ts-loader": "^6.2.1",
"web-animations-js": "^2.3.2",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
......@@ -93,7 +93,7 @@
"@types/jasmine": "^3.3.16",
"@types/jasminewd2": "^2.0.8",
"@types/modernizr": "^3.5.3",
"@types/node": "^10.17.3",
"@types/node": "~8.9.4",
"@types/webpack": "^4.39.8",
"angular-http-server": "^1.9.0",
"chrome-launcher": "^0.10.7",
......@@ -101,13 +101,13 @@
"codelyzer": "^5.2.0",
"imagemin": "^6.1.0",
"imagemin-pngquant": "^6.0.1",
"jasmine-core": "~3.3.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^3.1.4",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.1.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"karma-jasmine-html-reporter": "^1.4.0",
"karma-mocha-reporter": "^2.2.5",
"karma-phantomjs-launcher": "^1.0.4",
"minimist": "^1.2.0",
......@@ -117,12 +117,9 @@
"purify-css": "~1.2.5",
"rimraf": "^3.0.0",
"sharp": "^0.22.1",
"ts-node": "~8.3.0",
"tslib": "^1.10.0",
"ts-node": "~7.0.0",
"tslint": "~5.18.0",
"typescript": "~3.5.3",
"webpack-cli": "^3.3.10",
"webpack-node-externals": "^1.7.2"
"typescript": "~3.5.3"
},
"keywords": [
"arsnova",
......
import { HttpClientModule } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { PLATFORM_ID } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
import { TranslateService } from '@ngx-translate/core';
import { RxStompService } from '@stomp/ng2-stompjs';
import { TranslateServiceMock } from '../../../_mocks/TranslateServiceMock';
import { jwtOptionsFactory } from '../../lib/jwt.factory';
import { ConnectionMockService } from '../../service/connection/connection.mock.service';
import { ConnectionService } from '../../service/connection/connection.service';
import { FooterBarService } from '../../service/footer-bar/footer-bar.service';
......@@ -29,9 +33,16 @@ describe('AdminOverviewComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule, HttpClientModule, HttpClientTestingModule,
SharedModule, RouterTestingModule, HttpClientModule, HttpClientTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [PLATFORM_ID],
},
}),
],
providers: [
RxStompService,
{
provide: TranslateService,
useClass: TranslateServiceMock,
......
......@@ -5,6 +5,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtHelperService, JwtModule } from '@auth0/angular-jwt';
import { TranslateService } from '@ngx-translate/core';
import { RxStompService } from '@stomp/ng2-stompjs';
import { TranslateServiceMock } from '../../../_mocks/TranslateServiceMock';
import { jwtOptionsFactory } from '../../lib/jwt.factory';
import { ConnectionMockService } from '../../service/connection/connection.mock.service';
......@@ -51,6 +52,7 @@ describe('QuizAdminComponent', () => {
}),
],
providers: [
RxStompService,
{
provide: TranslateService,
useClass: TranslateServiceMock,
......
......@@ -5,6 +5,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtHelperService, JwtModule } from '@auth0/angular-jwt';
import { TranslateService } from '@ngx-translate/core';
import { RxStompService } from '@stomp/ng2-stompjs';
import { TranslateServiceMock } from '../../../_mocks/TranslateServiceMock';
import { jwtOptionsFactory } from '../../lib/jwt.factory';
import { ConnectionMockService } from '../../service/connection/connection.mock.service';
......@@ -42,6 +43,7 @@ describe('UserAdminComponent', () => {
}),
],
providers: [
RxStompService,
{
provide: TranslateService,
useClass: TranslateServiceMock,
......
import { HttpClientModule } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { PLATFORM_ID } from '@angular/core';
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core';
import { RxStompService } from '@stomp/ng2-stompjs';
import { TranslateServiceMock } from '../../../_mocks/TranslateServiceMock';
import { jwtOptionsFactory } from '../../lib/jwt.factory';
import { ConnectionMockService } from '../../service/connection/connection.mock.service';
import { ConnectionService } from '../../service/connection/connection.service';
import { FileUploadService } from '../../service/file-upload/file-upload.service';
......@@ -28,9 +32,16 @@ describe('FooterBarComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule, HttpClientModule, HttpClientTestingModule, NgbModule,
SharedModule, RouterTestingModule, HttpClientModule, HttpClientTestingModule, NgbModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [PLATFORM_ID],
},
}),
],
providers: [
RxStompService,
{
provide: StorageService,
useClass: StorageServiceMock,
......
import { NgModule } from '@angular/core';
import { SharedModule } from '../shared/shared.module';
import { AdditionalDataComponent } from './additional-data/additional-data.component';
import { FooterBarComponent } from './footer-bar/footer-bar.component';
@NgModule({
imports: [SharedModule],
declarations: [FooterBarComponent, AdditionalDataComponent],
exports: [FooterBarComponent, AdditionalDataComponent],
})
......
......@@ -6,6 +6,7 @@ import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
import { NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core';
import { RxStompService } from '@stomp/ng2-stompjs';
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
import { TranslateServiceMock } from '../../../_mocks/TranslateServiceMock';
import { jwtOptionsFactory } from '../../lib/jwt.factory';
......@@ -38,6 +39,7 @@ describe('I18nManagerOverviewComponent', () => {
}), HttpClientTestingModule, NgbModalModule, SharedModule, PipesModule, RouterTestingModule, HttpClientModule, InfiniteScrollModule,
],
providers: [
RxStompService,
{
provide: TranslateService,
useClass: TranslateServiceMock,
......
......@@ -5,7 +5,7 @@ import { DbName, DbTable, StorageKey } from '../enums/enums';
export class AppDb extends Dexie {
public readonly initialized: ReplaySubject<void> = new ReplaySubject<void>(1);
public readonly [DbTable.Config]: Dexie.Table<{ type: StorageKey, value: any }, string>;
public readonly [DbTable.Config]: Dexie.Table<{ type: StorageKey, value: any }, StorageKey>;
public readonly [DbTable.Quiz]: Dexie.Table<QuizEntity, string>;
constructor(dbName: DbName) {
......@@ -15,15 +15,18 @@ export class AppDb extends Dexie {
[DbTable.Quiz]: 'name',
});
this.Config.get(DbTable.Config).then(privateKey => {
if (!privateKey) {
privateKey = {
value: AppDb.generatePrivateKey(),
type: StorageKey.PrivateKey,
};
sessionStorage.setItem(StorageKey.PrivateKey, privateKey.value);
this.Config.put(privateKey).then(() => this.initialized.next());
this.Config.get(StorageKey.PrivateKey).then(privateKey => {
if (privateKey) {
this.initialized.next();
return;
}
privateKey = {
value: AppDb.generatePrivateKey(),
type: StorageKey.PrivateKey,
};
sessionStorage.setItem(StorageKey.PrivateKey, privateKey.value);
this.Config.put(privateKey).then(() => this.initialized.next());
});
}
......
......@@ -14,10 +14,4 @@ import { UnusedKeyFilterPipe } from './unused-key-filter/unused-key-filter.pipe'
declarations: [JustAFewPipe, FilterKeysPipe, SearchFilterPipe, SortPipe, UnusedKeyFilterPipe, QuizAdminFilterPipe, GenericFilterPipe],
})
export class PipesModule {
public static forRoot(): object {
return {
ngModule: PipesModule,
providers: [],
};
}
}
......@@ -30,7 +30,7 @@ export class QuizDuplicateComponent implements OnInit, OnDestroy {
this.route.paramMap.pipe(map(params => params.get('name')), filter(() => this.userService.isAuthorizedFor(UserRole.CreateQuiz)),
distinctUntilChanged(), takeUntil(this._destroy), switchMap(name => this.quizApiService.initQuizInstance(name)))
.subscribe(data => {
this.storageService.db.Quiz.add(data.payload.quiz, data.payload.quiz.name);
this.storageService.db.Quiz.put(data.payload.quiz);
this.quizService.quiz = new QuizEntity(data.payload.quiz);
this.quizService.isOwner = true;
this.router.navigate(['/quiz', 'flow']);
......
import { PLATFORM_ID } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
import { TranslateService } from '@ngx-translate/core';
import { RxStompService } from '@stomp/ng2-stompjs';
import { SimpleMQ } from 'ng2-simple-mq';
import { Subscription } from 'rxjs';
import { TranslateServiceMock } from '../../../../_mocks/TranslateServiceMock';
import { jwtOptionsFactory } from '../../../lib/jwt.factory';
import { ServerUnavailableModalComponent } from '../../../modals/server-unavailable-modal/server-unavailable-modal.component';
import { MemberApiService } from '../../../service/api/member/member-api.service';
import { AttendeeMockService } from '../../../service/attendee/attendee.mock.service';
......@@ -29,10 +33,16 @@ describe('QuizFlow: ConfidenceRateComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule,
SharedModule, RouterTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [PLATFORM_ID],
},
}),
],
providers: [
SimpleMQ, {
RxStompService, SimpleMQ, {
provide: StorageService,
useClass: StorageServiceMock,
}, {
......
import { SecurityContext } from '@angular/core';
import { PLATFORM_ID, SecurityContext } from '@angular/core';
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core';
import { RxStompService } from '@stomp/ng2-stompjs';
import { SimpleMQ } from 'ng2-simple-mq';
import { TranslateServiceMock } from '../../../../_mocks/TranslateServiceMock';
import { jwtOptionsFactory } from '../../../lib/jwt.factory';
import { ServerUnavailableModalComponent } from '../../../modals/server-unavailable-modal/server-unavailable-modal.component';
import { AttendeeMockService } from '../../../service/attendee/attendee.mock.service';
import { AttendeeService } from '../../../service/attendee/attendee.service';
......@@ -34,9 +37,16 @@ describe('LeaderboardComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule,
SharedModule, RouterTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [PLATFORM_ID],
},
}),
],
providers: [
RxStompService,
SimpleMQ, {
provide: StorageService,
useClass: StorageServiceMock,
......
......@@ -5,6 +5,7 @@ import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/t
import { RouterTestingModule } from '@angular/router/testing';
import { NgbModal, NgbModalRef, NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core';
import { RxStompService } from '@stomp/ng2-stompjs';
import { QRCodeModule } from 'angularx-qrcode';
import { SimpleMQ } from 'ng2-simple-mq';
import { TranslateServiceMock } from '../../../../_mocks/TranslateServiceMock';
......@@ -43,6 +44,7 @@ describe('QuizLobbyComponent', () => {
RouterTestingModule, SharedModule, QRCodeModule, NgbModule,
],
providers: [
RxStompService,
{
provide: StorageService,
useClass: StorageServiceMock,
......
......@@ -85,6 +85,8 @@ export class QuizLobbyComponent implements OnInit, OnDestroy {
return;
}
this.handleMessages();
this.sharedService.isLoadingEmitter.next(false);
if (this.quizService.isOwner) {
console.log('QuizLobbyComponent: quiz for owner initialized', this.quizService.quiz);
......@@ -95,7 +97,6 @@ export class QuizLobbyComponent implements OnInit, OnDestroy {
});
this.quizService.loadDataToPlay(sessionStorage.getItem(StorageKey.CurrentQuizName)).then(() => {
this.handleMessages();
});
this.connectionService.serverStatusEmitter.pipe(takeUntil(this._destroy)).subscribe(isConnected => {
......@@ -268,6 +269,7 @@ export class QuizLobbyComponent implements OnInit, OnDestroy {
}),
]);
this.quizService.isOwner ? this.handleMessagesForOwner() : this.handleMessagesForAttendee();
console.log('QuizLobbyComponent: Message handler attached');
}
private handleMessagesForOwner(): void {
......
import { SecurityContext } from '@angular/core';
import { PLATFORM_ID, SecurityContext } from '@angular/core';
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { DomSanitizer } from '@angular/platform-browser';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core';
import { RxStompService } from '@stomp/ng2-stompjs';
import { SimpleMQ } from 'ng2-simple-mq';
import { TranslateServiceMock } from '../../../../../_mocks/TranslateServiceMock';
import { jwtOptionsFactory } from '../../../../lib/jwt.factory';
import { ServerUnavailableModalComponent } from '../../../../modals/server-unavailable-modal/server-unavailable-modal.component';
import { AttendeeMockService } from '../../../../service/attendee/attendee.mock.service';
import { AttendeeService } from '../../../../service/attendee/attendee.service';
......@@ -34,9 +37,16 @@ describe('QuestionDetailsComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule,
SharedModule, RouterTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [PLATFORM_ID],
},
}),
],
providers: [
RxStompService,
{
provide: StorageService,
useClass: StorageServiceMock,
......
import { Component, OnDestroy, OnInit, SecurityContext } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { ActivatedRoute, Router } from '@angular/router';
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
......@@ -75,7 +75,7 @@ export class QuestionDetailsComponent implements OnInit, OnDestroy {
}
public sanitizeHTML(value: string): SafeHtml {
return this.sanitizer.sanitize(SecurityContext.HTML, `${value}`);
return this.sanitizer.bypassSecurityTrustHtml(`${value}`);
}
public normalizeAnswerIndex(index: number): string {
......
import { PLATFORM_ID } from '@angular/core';
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
import { TranslateService } from '@ngx-translate/core';
import { RxStompService } from '@stomp/ng2-stompjs';
import { SimpleMQ } from 'ng2-simple-mq';
import { TranslateServiceMock } from '../../../../_mocks/TranslateServiceMock';
import { Attendee } from '../../../lib/attendee/attendee';
import { SurveyQuestionEntity } from '../../../lib/entities/question/SurveyQuestionEntity';
import { Language } from '../../../lib/enums/enums';
import { jwtOptionsFactory } from '../../../lib/jwt.factory';
import { ServerUnavailableModalComponent } from '../../../modals/server-unavailable-modal/server-unavailable-modal.component';
import { AttendeeMockService } from '../../../service/attendee/attendee.mock.service';
import { AttendeeService } from '../../../service/attendee/attendee.service';
......@@ -42,10 +47,16 @@ describe('QuizResultsComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule,
SharedModule, RouterTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [PLATFORM_ID],
},
}),
],
providers: [
{
RxStompService, {
provide: StorageService,
useClass: StorageServiceMock,
}, TranslateService, FooterBarService, SettingsService, {
......@@ -93,7 +104,7 @@ describe('QuizResultsComponent', () => {
});
it(`#showLeaderBoardButton`, inject([QuizService], (quizService: QuizService) => {
expect(quizService.quiz[quizService.quiz.currentQuestionIndex].TYPE === 'SurveyQuestion').toBeFalsy();
expect(quizService.quiz.questionList[quizService.quiz.currentQuestionIndex] instanceof SurveyQuestionEntity).toBeFalsy();
expect(component.showLeaderBoardButton(quizService.quiz.currentQuestionIndex)).toBeTruthy();
}));
......
import { SecurityContext } from '@angular/core';
import { PLATFORM_ID, SecurityContext } from '@angular/core';
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { DomSanitizer } from '@angular/platform-browser';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
import { TranslateService } from '@ngx-translate/core';
import { RxStompService } from '@stomp/ng2-stompjs';
import { SimpleMQ } from 'ng2-simple-mq';
import { TranslateServiceMock } from '../../../../_mocks/TranslateServiceMock';
import { jwtOptionsFactory } from '../../../lib/jwt.factory';
import { ServerUnavailableModalComponent } from '../../../modals/server-unavailable-modal/server-unavailable-modal.component';
import { AttendeeMockService } from '../../../service/attendee/attendee.mock.service';
import { AttendeeService } from '../../../service/attendee/attendee.service';
......@@ -31,9 +34,16 @@ describe('QuizFlow: ReadingConfirmationComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule,
SharedModule, RouterTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [PLATFORM_ID],
},
}),
],
providers: [
RxStompService,
{
provide: StorageService,
useClass: StorageServiceMock,
......
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { PLATFORM_ID } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core';
import { RxStompService } from '@stomp/ng2-stompjs';
import { SimpleMQ } from 'ng2-simple-mq';
import { TranslatePipeMock } from '../../../../_mocks/TranslatePipeMock';
import { TranslateServiceMock } from '../../../../_mocks/TranslateServiceMock';
import { jwtOptionsFactory } from '../../../lib/jwt.factory';
import { ServerUnavailableModalComponent } from '../../../modals/server-unavailable-modal/server-unavailable-modal.component';
import { MemberApiService } from '../../../service/api/member/member-api.service';
import { QuizApiService } from '../../../service/api/quiz/quiz-api.service';
......@@ -33,9 +37,16 @@ describe('VotingComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule, FontAwesomeModule, HttpClientTestingModule, NgbModalModule,
RouterTestingModule, FontAwesomeModule, HttpClientTestingModule, NgbModalModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [PLATFORM_ID],
},
}),
],
providers: [
RxStompService,
{
provide: StorageService,
useClass: StorageServiceMock,
......
......@@ -2,7 +2,6 @@ import { Component, Inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core
import { ActivatedRoute, Router } from '@angular/router';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { StorageKey } from '../../lib/enums/enums';
import { MessageProtocol, StatusProtocol } from '../../lib/enums/Message';
import { QuizApiService } from '../../service/api/quiz/quiz-api.service';
import { CasLoginService } from '../../service/login/cas-login.service';
......@@ -19,13 +18,15 @@ export class QuizJoinComponent implements OnInit, OnDestroy {
public static TYPE = 'QuizJoinComponent';
private readonly _destroy = new Subject();
constructor(public quizService: QuizService,
@Inject(PLATFORM_ID) private platformId: Object,
private route: ActivatedRoute,
private router: Router,
private casService: CasLoginService,
private themesService: ThemesService,
private quizApiService: QuizApiService, private sharedService: SharedService,
constructor(
public quizService: QuizService,
@Inject(PLATFORM_ID) private platformId: Object,
private route: ActivatedRoute,
private router: Router,
private casService: CasLoginService,
private themesService: ThemesService,
private quizApiService: QuizApiService,
private sharedService: SharedService,
) {
}
......@@ -40,9 +41,6 @@ export class QuizJoinComponent implements OnInit, OnDestroy {
}
this.sharedService.isLoadingEmitter.next(true);
if (!sessionStorage.getItem(StorageKey.PrivateKey)) {
await this.quizService.loadDataToPlay(params.quizName);
}
this.quizApiService.getFullQuizStatusData(params.quizName).subscribe(quizStatusData => this.resolveQuizStatusData(quizStatusData));
});
}
......
......@@ -6,6 +6,7 @@ import { TranslateService } from '@ngx-translate/core';
import { of } from 'rxjs';
import { TranslatePipeMock } from '../../../../../../_mocks/TranslatePipeMock';
import { TranslateServiceMock } from '../../../../../../_mocks/TranslateServiceMock';
import { FreeTextAnswerEntity } from '../../../../../lib/entities/answer/FreetextAnwerEntity';
import { ConnectionMockService } from '../../../../../service/connection/connection.mock.service';
import { ConnectionService } from '../../../../../service/connection/connection.service';
import { FooterBarService } from '../../../../../service/footer-bar/footer-bar.service';
......@@ -107,9 +108,9 @@ describe('AnsweroptionsFreetextComponent', () => {
});
it('should set a validation configuration of the question', () => {
const initValue = (component.question.answerOptionList[0]).getConfig()[0];
const initValue = (component.question.answerOptionList[0] as FreeTextAnswerEntity).getConfig()[0];
component.setConfig(initValue.id, !initValue.enabled);
const newValue = (component.question.answerOptionList[0]).getConfig()[0];
const newValue = (component.question.answerOptionList[0] as FreeTextAnswerEntity).getConfig()[0];
expect(newValue.id).toEqual(initValue.id);
expect(newValue.enabled).not.toEqual(initValue.enabled);
});
......
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { PLATFORM_ID } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { SwUpdate } from '@angular/service-worker';
import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { NgbModalModule, NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core';
import { RxStompService } from '@stomp/ng2-stompjs';
import { AngularSvgIconModule } from 'angular-svg-icon';
import { TOAST_CONFIG } from 'ngx-toastr';
import { of } from 'rxjs';
......@@ -13,6 +16,7 @@ import { SwUpdateMock } from '../../../../../_mocks/SwUpdateMock';
import { TranslatePipeMock } from '../../../../../_mocks/TranslatePipeMock';
import { TranslateServiceMock } from '../../../../../_mocks/TranslateServiceMock';
import { HeaderComponent } from '../../../../header/header/header.component';
import { jwtOptionsFactory } from '../../../../lib/jwt.factory';
import { LivePreviewComponent } from '../../../../live-preview/live-preview/live-preview.component';
import { ConnectionMockService } from '../../../../service/connection/connection.mock.service';
import { ConnectionService } from '../../../../service/connection/connection.service';
......@@ -41,9 +45,16 @@ describe('AnsweroptionsComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
HttpClientTestingModule, RouterTestingModule, NgbModalModule, AngularSvgIconModule, NgbPopoverModule, FontAwesomeModule,
HttpClientTestingModule, RouterTestingModule, NgbModalModule, AngularSvgIconModule, NgbPopoverModule, FontAwesomeModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [PLATFORM_ID],
},