Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
arsnova-click-v2-frontend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
12
Merge Requests
12
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
ARSnova
arsnova-click-v2-frontend
Commits
64355228
Commit
64355228
authored
Jun 15, 2018
by
Christopher Mark Fullarton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds a login handling to restrict the access to the i18n-manager route
parent
436a8951
Changes
31
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
996 additions
and
472 deletions
+996
-472
package-lock.json
package-lock.json
+46
-138
package.json
package.json
+9
-9
src/app/footer/footer-bar/footer-bar.component.ts
src/app/footer/footer-bar/footer-bar.component.ts
+11
-4
src/app/i18n-manager/i18n-manager-overview/i18n-manager-overview.component.html
...18n-manager-overview/i18n-manager-overview.component.html
+0
-0
src/app/i18n-manager/i18n-manager-overview/i18n-manager-overview.component.scss
...18n-manager-overview/i18n-manager-overview.component.scss
+0
-0
src/app/i18n-manager/i18n-manager-overview/i18n-manager-overview.component.spec.ts
...-manager-overview/i18n-manager-overview.component.spec.ts
+28
-0
src/app/i18n-manager/i18n-manager-overview/i18n-manager-overview.component.ts
.../i18n-manager-overview/i18n-manager-overview.component.ts
+14
-8
src/app/i18n-manager/i18n-manager.module.ts
src/app/i18n-manager/i18n-manager.module.ts
+5
-3
src/app/quiz/quiz-flow/quiz-flow.module.ts
src/app/quiz/quiz-flow/quiz-flow.module.ts
+13
-32
src/app/quiz/quiz-join/quiz-join.component.spec.ts
src/app/quiz/quiz-join/quiz-join.component.spec.ts
+139
-133
src/app/quiz/quiz-join/quiz-join.component.ts
src/app/quiz/quiz-join/quiz-join.component.ts
+8
-3
src/app/root.module.ts
src/app/root.module.ts
+7
-3
src/app/root/home/home.component.spec.ts
src/app/root/home/home.component.spec.ts
+61
-35
src/app/root/home/home.component.ts
src/app/root/home/home.component.ts
+75
-56
src/app/root/login/login.component.html
src/app/root/login/login.component.html
+31
-0
src/app/root/login/login.component.scss
src/app/root/login/login.component.scss
+24
-0
src/app/root/login/login.component.spec.ts
src/app/root/login/login.component.spec.ts
+133
-0
src/app/root/login/login.component.ts
src/app/root/login/login.component.ts
+56
-0
src/app/root/nickname-chooser/nickname-chooser.module.spec.ts
...app/root/nickname-chooser/nickname-chooser.module.spec.ts
+13
-0
src/app/root/nickname-chooser/nickname-chooser.module.ts
src/app/root/nickname-chooser/nickname-chooser.module.ts
+7
-13
src/app/root/nickname-chooser/nickname-input/nickname-input.component.ts
...ckname-chooser/nickname-input/nickname-input.component.ts
+8
-3
src/app/root/nickname-chooser/nickname-select/nickname-select.component.ts
...name-chooser/nickname-select/nickname-select.component.ts
+1
-1
src/app/service/api/authorize/authorize-api.service.spec.ts
src/app/service/api/authorize/authorize-api.service.spec.ts
+28
-1
src/app/service/api/authorize/authorize-api.service.ts
src/app/service/api/authorize/authorize-api.service.ts
+17
-3
src/app/service/i18n/i18n.service.ts
src/app/service/i18n/i18n.service.ts
+2
-2
src/app/service/login/cas-login.service.spec.ts
src/app/service/login/cas-login.service.spec.ts
+5
-7
src/app/service/login/cas-login.service.ts
src/app/service/login/cas-login.service.ts
+51
-0
src/app/service/login/static-login.service.spec.ts
src/app/service/login/static-login.service.spec.ts
+15
-0
src/app/service/login/static-login.service.ts
src/app/service/login/static-login.service.ts
+27
-0
src/app/service/user/user.service.ts
src/app/service/user/user.service.ts
+161
-17
src/assets/i18n/en.json
src/assets/i18n/en.json
+1
-1
No files found.
package-lock.json
View file @
64355228
This diff is collapsed.
Click to expand it.
package.json
View file @
64355228
...
...
@@ -68,22 +68,21 @@
"
cors
"
:
"
^2.8.4
"
},
"devDependencies"
:
{
"
minimist
"
:
"
^1.2.0
"
,
"
@angular/compiler-cli
"
:
"
^6.0.2
"
,
"
@angular-devkit/build-angular
"
:
"
^0.6.3
"
,
"
tsickle
"
:
"
>=0.25.5
"
,
"
tslib
"
:
"
^1.7.1
"
,
"
typescript
"
:
"
^2.7
"
,
"
chrome-remote-interface
"
:
"
^0.25.6
"
,
"
@angular/cli
"
:
"
^6.0.3
"
,
"
@angular/compiler-cli
"
:
"
^6.0.2
"
,
"
@angular/language-service
"
:
"
^6.0.2
"
,
"
@types/jasmine
"
:
"
~2.8.7
"
,
"
@types/jasminewd2
"
:
"
~2.0.3
"
,
"
@types/node
"
:
"
^10.1.1
"
,
"
@types/webpack
"
:
"
~4.4.0
"
,
"arsnova-click-v2-types"
:
"git+https://git.thm.de/arsnova/arsnova-click-v2-types.git"
,
"
chrome-remote-interface
"
:
"
^0.25.6
"
,
"
codelyzer
"
:
"
^4.3.0
"
,
"
gm
"
:
"
^1.23.1
"
,
"
http-server
"
:
"
^0.11.1
"
,
"
imagemin
"
:
"
^5.3.1
"
,
"
imagemin-pngquant
"
:
"
^5.1.0
"
,
"
jasmine-core
"
:
"
~3.1.0
"
,
"
jasmine-spec-reporter
"
:
"
~4.2.1
"
,
"
karma
"
:
"
~2.0.2
"
,
...
...
@@ -93,13 +92,14 @@
"
karma-jasmine-html-reporter
"
:
"
^1.1.0
"
,
"
karma-mocha-reporter
"
:
"
^2.2.5
"
,
"
karma-phantomjs-launcher
"
:
"
^1.0.4
"
,
"
gm
"
:
"
^1.23.1
"
,
"
imagemin
"
:
"
^5.3.1
"
,
"
imagemin-pngquant
"
:
"
^5.1.0
"
,
"
minimist
"
:
"
^1.2.0
"
,
"
protractor
"
:
"
^5.3.2
"
,
"
purify-css
"
:
"
~1.2.5
"
,
"
ts-node
"
:
"
~6.0.3
"
,
"
tsickle
"
:
"
>=0.25.5
"
,
"
tslib
"
:
"
^1.7.1
"
,
"
tslint
"
:
"
~5.10.0
"
,
"
typescript
"
:
"
^2.7
"
,
"
webpack-cli
"
:
"
^2.1.4
"
},
"keywords"
:
[
...
...
src/app/footer/footer-bar/footer-bar.component.ts
View file @
64355228
...
...
@@ -22,8 +22,7 @@ export class FooterBarComponent implements OnInit, OnDestroy {
return
this
.
_footerElements
;
}
@
Input
()
set
footerElements
(
value
:
Array
<
IFooterBarElement
>
)
{
@
Input
()
set
footerElements
(
value
:
Array
<
IFooterBarElement
>
)
{
this
.
hasRightScrollElement
=
value
.
length
>
1
;
this
.
_footerElements
=
value
;
}
...
...
@@ -126,7 +125,9 @@ export class FooterBarComponent implements OnInit, OnDestroy {
}
else
{
const
child
=
navbarFooter
.
children
.
item
(
this
.
footerElemIndex
);
const
childWidth
=
child
.
clientWidth
;
navbarFooter
.
scrollLeft
-=
(
childWidth
);
navbarFooter
.
scrollLeft
-=
(
childWidth
);
}
}
...
...
@@ -146,7 +147,9 @@ export class FooterBarComponent implements OnInit, OnDestroy {
if
(
this
.
footerElemIndex
===
1
)
{
const
childWidth
=
child
.
clientWidth
;
const
leftButtonWidth
=
document
.
getElementById
(
'
footer-move-left
'
).
clientWidth
;
navbarFooter
.
scrollLeft
+=
(
childWidth
-
leftButtonWidth
);
navbarFooter
.
scrollLeft
+=
(
childWidth
-
leftButtonWidth
);
}
else
{
navbarFooter
.
scrollLeft
+=
child
.
clientWidth
;
}
...
...
@@ -158,6 +161,10 @@ export class FooterBarComponent implements OnInit, OnDestroy {
return
;
}
if
(
!
this
.
footerElements
.
length
)
{
return
true
;
}
const
navbarFooter
=
document
.
getElementById
(
'
navbar-footer-container
'
);
if
(
!
navbarFooter
)
{
return
false
;
...
...
src/app/i18n-manager/i18n-manager
/i18n-manager
.component.html
→
src/app/i18n-manager/i18n-manager
-overview/i18n-manager-overview
.component.html
View file @
64355228
File moved
src/app/i18n-manager/i18n-manager
/i18n-manager
.component.scss
→
src/app/i18n-manager/i18n-manager
-overview/i18n-manager-overview
.component.scss
View file @
64355228
File moved
src/app/i18n-manager/i18n-manager
/i18n-manager
.component.spec.ts
→
src/app/i18n-manager/i18n-manager
-overview/i18n-manager-overview
.component.spec.ts
View file @
64355228
import
{
async
,
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
I18nManager
Component
}
from
'
./i18n-manager
.component
'
;
import
{
I18nManager
OverviewComponent
}
from
'
./i18n-manager-overview
.component
'
;
describe
(
'
FeTranslation
Component
'
,
()
=>
{
let
component
:
I18nManagerComponent
;
let
fixture
:
ComponentFixture
<
I18nManagerComponent
>
;
describe
(
'
I18nManagerOverview
Component
'
,
()
=>
{
let
component
:
I18nManager
Overview
Component
;
let
fixture
:
ComponentFixture
<
I18nManager
Overview
Component
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
I18nManagerComponent
],
declarations
:
[
I18nManager
Overview
Component
],
})
.
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
I18nManagerComponent
);
fixture
=
TestBed
.
createComponent
(
I18nManager
Overview
Component
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
...
...
@@ -23,6 +23,6 @@ describe('FeTranslationComponent', () => {
expect
(
component
).
toBeTruthy
();
});
it
(
'
should contain a TYPE reference
'
,
()
=>
{
expect
(
I18nManager
Component
.
TYPE
).
toEqual
(
'
I18nManager
Component
'
);
expect
(
I18nManager
OverviewComponent
.
TYPE
).
toEqual
(
'
I18nManagerOverview
Component
'
);
});
});
src/app/i18n-manager/i18n-manager
/i18n-manager
.component.ts
→
src/app/i18n-manager/i18n-manager
-overview/i18n-manager-overview
.component.ts
View file @
64355228
...
...
@@ -3,18 +3,19 @@ import { Observable, of } from 'rxjs/index';
import
{
FooterBarService
}
from
'
../../service/footer-bar/footer-bar.service
'
;
import
{
HeaderLabelService
}
from
'
../../service/header-label/header-label.service
'
;
import
{
LanguageLoaderService
}
from
'
../../service/language-loader/language-loader.service
'
;
import
{
CasLoginService
}
from
'
../../service/login/cas-login.service
'
;
import
{
ModalOrganizerService
}
from
'
../../service/modal-organizer/modal-organizer.service
'
;
import
{
ProjectLoaderService
}
from
'
../../service/project-loader/project-loader.service
'
;
import
{
FILTER
,
PROJECT
}
from
'
../../shared/enums
'
;
@
Component
({
selector
:
'
app-
fe-translation
'
,
templateUrl
:
'
./i18n-manager.component.html
'
,
styleUrls
:
[
'
./i18n-manager.component.scss
'
],
selector
:
'
app-
i18n-manager-overview
'
,
templateUrl
:
'
./i18n-manager
-overview
.component.html
'
,
styleUrls
:
[
'
./i18n-manager
-overview
.component.scss
'
],
})
export
class
I18nManagerComponent
implements
OnInit
,
OnDestroy
{
export
class
I18nManager
Overview
Component
implements
OnInit
,
OnDestroy
{
public
static
readonly
TYPE
=
'
I18nManagerComponent
'
;
public
static
readonly
TYPE
=
'
I18nManager
Overview
Component
'
;
public
readonly
filters
=
FILTER
;
private
_langRef
=
[
'
en
'
,
'
de
'
,
'
fr
'
,
'
it
'
,
'
es
'
];
...
...
@@ -93,10 +94,15 @@ export class I18nManagerComponent implements OnInit, OnDestroy {
this
.
_hasAnyMatches
=
value
;
}
constructor
(
private
footerBarService
:
FooterBarService
,
private
headerLabelService
:
HeaderLabelService
,
public
modalOrganizerService
:
ModalOrganizerService
,
public
projectLoaderService
:
ProjectLoaderService
,
private
languageLoaderService
:
LanguageLoaderService
,
constructor
(
private
footerBarService
:
FooterBarService
,
private
headerLabelService
:
HeaderLabelService
,
public
modalOrganizerService
:
ModalOrganizerService
,
public
projectLoaderService
:
ProjectLoaderService
,
private
languageLoaderService
:
LanguageLoaderService
,
private
casService
:
CasLoginService
,
)
{
this
.
casService
.
casLoginRequired
=
true
;
this
.
headerLabelService
.
headerLabel
=
'
I18Nator
'
;
this
.
footerBarService
.
replaceFooterElements
([]);
}
...
...
src/app/i18n-manager/i18n-manager.module.ts
View file @
64355228
...
...
@@ -2,16 +2,18 @@ import { NgModule } from '@angular/core';
import
{
RouterModule
,
Routes
}
from
'
@angular/router
'
;
import
{
PipesModule
}
from
'
../pipes/pipes.module
'
;
import
{
LanguageLoaderService
}
from
'
../service/language-loader/language-loader.service
'
;
import
{
StaticLoginService
}
from
'
../service/login/static-login.service
'
;
import
{
ModalOrganizerService
}
from
'
../service/modal-organizer/modal-organizer.service
'
;
import
{
ProjectLoaderService
}
from
'
../service/project-loader/project-loader.service
'
;
import
{
SharedModule
}
from
'
../shared/shared.module
'
;
import
{
I18nManager
Component
}
from
'
./i18n-manager/i18n-manager
.component
'
;
import
{
I18nManager
OverviewComponent
}
from
'
./i18n-manager-overview/i18n-manager-overview
.component
'
;
import
{
KeyOutputComponent
}
from
'
./key-output/key-output.component
'
;
const
i18nManagerRoutes
:
Routes
=
[
{
path
:
'
i18n-manager
'
,
component
:
I18nManagerComponent
,
canActivate
:
[
StaticLoginService
],
component
:
I18nManagerOverviewComponent
,
},
];
...
...
@@ -19,7 +21,7 @@ const i18nManagerRoutes: Routes = [
imports
:
[
SharedModule
,
PipesModule
,
RouterModule
.
forChild
(
i18nManagerRoutes
),
],
declarations
:
[
I18nManagerComponent
,
KeyOutputComponent
],
declarations
:
[
I18nManager
Overview
Component
,
KeyOutputComponent
],
providers
:
[
LanguageLoaderService
,
ProjectLoaderService
,
ModalOrganizerService
,
],
...
...
src/app/quiz/quiz-flow/quiz-flow.module.ts
View file @
64355228
...
...
@@ -2,7 +2,7 @@ import { NgModule } from '@angular/core';
import
{
RouterModule
,
Routes
}
from
'
@angular/router
'
;
import
{
NgxQRCodeModule
}
from
'
@techiediaries/ngx-qrcode
'
;
import
{
MarkdownModule
}
from
'
../../markdown/markdown.module
'
;
import
{
Cas
Service
}
from
'
../../service/cas/cas
.service
'
;
import
{
Cas
LoginService
}
from
'
../../service/login/cas-login
.service
'
;
import
{
SharedModule
}
from
'
../../shared/shared.module
'
;
import
{
ThemesModule
}
from
'
../../themes/themes.module
'
;
import
{
ConfidenceRateComponent
}
from
'
./confidence-rate/confidence-rate.component
'
;
...
...
@@ -20,49 +20,40 @@ export const quizFlowRoutes: Routes = [
path
:
''
,
pathMatch
:
'
full
'
,
redirectTo
:
'
lobby
'
,
},
{
},
{
path
:
'
lobby
'
,
canLoad
:
[
CasService
],
canLoad
:
[
Cas
Login
Service
],
component
:
QuizLobbyComponent
,
data
:
{},
},
{
},
{
path
:
'
results
'
,
component
:
QuizResultsComponent
,
data
:
{},
},
{
},
{
path
:
'
results/:questionIndex
'
,
component
:
QuestionDetailsComponent
,
data
:
{},
},
{
},
{
path
:
'
theme
'
,
component
:
QuizThemeComponent
,
data
:
{},
},
{
},
{
path
:
'
leaderboard
'
,
component
:
LeaderboardComponent
,
data
:
{},
},
{
},
{
path
:
'
leaderboard/:questionIndex
'
,
component
:
LeaderboardComponent
,
data
:
{},
},
{
},
{
path
:
'
voting
'
,
component
:
VotingComponent
,
data
:
{},
},
{
},
{
path
:
'
reading-confirmation
'
,
component
:
ReadingConfirmationComponent
,
data
:
{},
},
{
},
{
path
:
'
confidence-rate
'
,
component
:
ConfidenceRateComponent
,
data
:
{},
...
...
@@ -71,20 +62,10 @@ export const quizFlowRoutes: Routes = [
@
NgModule
({
imports
:
[
MarkdownModule
,
SharedModule
,
ThemesModule
,
RouterModule
.
forChild
(
quizFlowRoutes
),
QuizResultsModule
,
NgxQRCodeModule
,
MarkdownModule
,
SharedModule
,
ThemesModule
,
RouterModule
.
forChild
(
quizFlowRoutes
),
QuizResultsModule
,
NgxQRCodeModule
,
],
declarations
:
[
QuizLobbyComponent
,
VotingComponent
,
LeaderboardComponent
,
QuizThemeComponent
,
ReadingConfirmationComponent
,
ConfidenceRateComponent
,
QuizLobbyComponent
,
VotingComponent
,
LeaderboardComponent
,
QuizThemeComponent
,
ReadingConfirmationComponent
,
ConfidenceRateComponent
,
],
})
export
class
QuizFlowModule
{
...
...
src/app/quiz/quiz-join/quiz-join.component.spec.ts
View file @
64355228
...
...
@@ -9,12 +9,12 @@ import { of } from 'rxjs/index';
import
{
createTranslateLoader
}
from
'
../../../lib/translation.factory
'
;
import
{
LobbyApiService
}
from
'
../../service/api/lobby/lobby-api.service
'
;
import
{
QuizApiService
}
from
'
../../service/api/quiz/quiz-api.service
'
;
import
{
CasService
}
from
'
../../service/cas/cas.service
'
;
import
{
ConnectionMockService
}
from
'
../../service/connection/connection.mock.service
'
;
import
{
ConnectionService
}
from
'
../../service/connection/connection.service
'
;
import
{
CurrentQuizMockService
}
from
'
../../service/current-quiz/current-quiz.mock.service
'
;
import
{
CurrentQuizService
}
from
'
../../service/current-quiz/current-quiz.service
'
;
import
{
FooterBarService
}
from
'
../../service/footer-bar/footer-bar.service
'
;
import
{
CasLoginService
}
from
'
../../service/login/cas-login.service
'
;
import
{
SettingsService
}
from
'
../../service/settings/settings.service
'
;
import
{
SharedService
}
from
'
../../service/shared/shared.service
'
;
import
{
ThemesMockService
}
from
'
../../service/themes/themes.mock.service
'
;
...
...
@@ -27,12 +27,20 @@ import { QuizJoinComponent } from './quiz-join.component';
class
MockRouter
{
public
queryParams
=
{
subscribe
:
(
next
)
=>
(
next
({
ticket
:
'
testCasTicket
'
})),
toPromise
:
()
=>
(
new
Promise
(
resolve
=>
resolve
({
ticket
:
'
testCasTicket
'
}))),
subscribe
:
(
next
)
=>
(
next
({
ticket
:
'
testCasTicket
'
})
),
toPromise
:
()
=>
(
new
Promise
(
resolve
=>
resolve
({
ticket
:
'
testCasTicket
'
}))
),
};
public
params
=
{
subscribe
:
(
next
)
=>
(
next
({
quizName
:
'
test
'
})),
toPromise
:
()
=>
(
new
Promise
(
resolve
=>
resolve
({
quizName
:
'
test
'
}))),
subscribe
:
(
next
)
=>
(
next
({
quizName
:
'
test
'
})
),
toPromise
:
()
=>
(
new
Promise
(
resolve
=>
resolve
({
quizName
:
'
test
'
}))
),
};
}
...
...
@@ -43,13 +51,12 @@ describe('QuizJoinComponent', () => {
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
imports
:
[
RouterTestingModule
,
HttpClientModule
,
HttpClientTestingModule
,
TranslateModule
.
forRoot
({
RouterTestingModule
,
HttpClientModule
,
HttpClientTestingModule
,
TranslateModule
.
forRoot
({
loader
:
{
provide
:
TranslateLoader
,
useFactory
:
(
createTranslateLoader
),
useFactory
:
(
createTranslateLoader
),
deps
:
[
HttpClient
],
},
compiler
:
{
...
...
@@ -59,17 +66,32 @@ describe('QuizJoinComponent', () => {
}),
],
providers
:
[
CasService
,
Cas
Login
Service
,
LobbyApiService
,
QuizApiService
,
{
provide
:
CurrentQuizService
,
useClass
:
CurrentQuizMockService
},
{
provide
:
ThemesService
,
useClass
:
ThemesMockService
},
{
provide
:
CurrentQuizService
,
useClass
:
CurrentQuizMockService
,
},
{
provide
:
ThemesService
,
useClass
:
ThemesMockService
,
},
UserService
,
FooterBarService
,
SettingsService
,
{
provide
:
ConnectionService
,
useClass
:
ConnectionMockService
},
{
provide
:
WebsocketService
,
useClass
:
WebsocketMockService
},
{
provide
:
ActivatedRoute
,
useClass
:
MockRouter
},
{
provide
:
ConnectionService
,
useClass
:
ConnectionMockService
,
},
{
provide
:
WebsocketService
,
useClass
:
WebsocketMockService
,
},
{
provide
:
ActivatedRoute
,
useClass
:
MockRouter
,
},
SharedService
,
],
declarations
:
[
QuizJoinComponent
],
...
...
@@ -90,33 +112,29 @@ describe('QuizJoinComponent', () => {
expect
(
QuizJoinComponent
.
TYPE
).
toEqual
(
'
QuizJoinComponent
'
);
}));
it
(
'
should redirect the user to / on failure
'
,
async
(
inject
([
Router
,
QuizApiService
],
(
router
:
Router
,
quizApiService
:
QuizApiService
)
=>
{
const
quizStatusData
=
{
status
:
'
STATUS:FAILED
'
,
step
:
'
QUIZ:UNAVAILABLE
'
,
payload
:
{
authorizeViaCas
:
true
,
provideNickSelection
:
false
,
},
};
it
(
'
should redirect the user to / on failure
'
,
async
(
inject
([
Router
,
QuizApiService
],
(
router
:
Router
,
quizApiService
:
QuizApiService
)
=>
{
const
quizStatusData
=
{
status
:
'
STATUS:FAILED
'
,
step
:
'
QUIZ:UNAVAILABLE
'
,
payload
:
{
authorizeViaCas
:
true
,
provideNickSelection
:
false
,
},
};
spyOn
(
quizApiService
,
'
getQuizStatus
'
).
and
.
returnValue
(
of
(
quizStatusData
));
spyOn
(
router
,
'
navigate
'
).
and
.
callFake
(()
=>
{});
spyOn
(
quizApiService
,
'
getQuizStatus
'
).
and
.
returnValue
(
of
(
quizStatusData
));
spyOn
(
router
,
'
navigate
'
).
and
.
callFake
(()
=>
{});
component
.
ngOnInit
();
expect
(
router
.
navigate
).
toHaveBeenCalledWith
([
'
/
'
]);
}),
),
);
it
(
'
should add a cas ticket to the casService if a ticket is supplied
'
,
async
(
inject
(
[
Router
,
CurrentQuizService
,
CasService
,
QuizApiService
,
LobbyApiService
],
(
router
:
Router
,
currentQuizService
:
CurrentQuizService
,
casService
:
CasService
,
quizApiService
:
QuizApiService
,
lobbyApiService
:
LobbyApiService
,
component
.
ngOnInit
();
expect
(
router
.
navigate
).
toHaveBeenCalledWith
([
'
/
'
]);
})));
it
(
'
should add a cas casTicket to the casService if a casTicket is supplied
'
,
async
(
inject
([
Router
,
CurrentQuizService
,
CasLoginService
,
QuizApiService
,
LobbyApiService
],
(
router
:
Router
,
currentQuizService
:
CurrentQuizService
,
casService
:
CasLoginService
,
quizApiService
:
QuizApiService
,
lobbyApiService
:
LobbyApiService
,
)
=>
{
const
quizStatusData
=
{
status
:
'
STATUS:SUCCESSFUL
'
,
...
...
@@ -145,108 +163,96 @@ describe('QuizJoinComponent', () => {
expect
(
casService
.
quizName
).
toEqual
(
'
test
'
);
})));
it
(
'
should redirect the user to the membergroup selection if there are multiple groups available
'
,
async
(
inject
(
[
Router
,
CurrentQuizService
,
QuizApiService
,
LobbyApiService
],
(
router
:
Router
,
currentQuizService
:
CurrentQuizService
,
quizApiService
:
QuizApiService
,
lobbyApiService
:
LobbyApiService
,
)
=>
{
const
customQuiz
=
currentQuizService
.
quiz
;
customQuiz
.
sessionConfig
.
nicks
.
memberGroups
=
[
'
Group1
'
,
'
Group2
'
];
const
quizStatusData
=
{
status
:
'
STATUS:SUCCESSFUL
'
,
step
:
'
QUIZ:AVAILABLE
'
,
payload
:
{
authorizeViaCas
:
true
,
provideNickSelection
:
false
,
},
};
const
lobbyStatusData
=
{
status
:
'
STATUS:SUCCESSFUL
'
,
step
:
'
QUIZ:AVAILABLE
'
,
payload
:
{
quiz
:
{
originalObject
:
customQuiz
.
serialize
(),
it
(
'
should redirect the user to the membergroup selection if there are multiple groups available
'
,
async
(
inject
([
Router
,
CurrentQuizService
,
QuizApiService
,
LobbyApiService
],
(
router
:
Router
,
currentQuizService
:
CurrentQuizService
,
quizApiService
:
QuizApiService
,
lobbyApiService
:
LobbyApiService
)
=>
{
const
customQuiz
=
currentQuizService
.
quiz
;
customQuiz
.
sessionConfig
.
nicks
.
memberGroups
=
[
'
Group1
'
,
'
Group2
'
];
const
quizStatusData
=
{
status
:
'
STATUS:SUCCESSFUL
'
,
step
:
'
QUIZ:AVAILABLE
'
,
payload
:
{
authorizeViaCas
:
true
,
provideNickSelection
:
false
,
},
},
};
};
const
lobbyStatusData
=
{
status
:
'
STATUS:SUCCESSFUL
'
,
step
:
'
QUIZ:AVAILABLE
'
,
payload
:
{
quiz
:
{
originalObject
:
customQuiz
.
serialize
(),
},
},
};
spyOn
(
quizApiService
,
'
getQuizStatus
'
).
and
.
returnValue
(
of
(
quizStatusData
));
spyOn
(
lobbyApiService
,
'
getLobbyStatus
'
).
and
.
returnValue
(
of
(
lobbyStatusData
));
spyOn
(
router
,
'
navigate
'
).
and
.
callFake
(()
=>
{});
spyOn
(
quizApiService
,
'
getQuizStatus
'
).
and
.
returnValue
(
of
(
quizStatusData
));
spyOn
(
lobbyApiService
,
'
getLobbyStatus
'
).
and
.
returnValue
(
of
(
lobbyStatusData
));
spyOn
(
router
,
'
navigate
'
).
and
.
callFake
(()
=>
{});
component
.
ngOnInit
();
expect
(
router
.
navigate
).
toHaveBeenCalledWith
([
'
/nicks
'
,
'
memberGroup
'
]);
})));
component
.
ngOnInit
();
expect
(
router
.
navigate
).
toHaveBeenCalledWith
([
'
/nicks
'
,
'
memberGroup
'
]);
})));
it
(
'
should redirect the user to input the nickname if no predefined nicks are available
'
,
async
(
inject
(
[
CurrentQuizService
,
Router
,
QuizApiService
,
LobbyApiService
],
(
currentQuizService
:
CurrentQuizService
,
router
:
Router
,
quizApiService
:
QuizApiService
,
lobbyApiService
:
LobbyApiService
,
)
=>
{
const
quizStatusData
=
{
status
:
'
STATUS:SUCCESSFUL
'
,
step
:
'
QUIZ:AVAILABLE
'
,
payload
:
{
authorizeViaCas
:
true
,
provideNickSelection
:
false
,
},
};
const
lobbyStatusData
=
{
status
:
'
STATUS:SUCCESSFUL
'
,
step
:
'
QUIZ:AVAILABLE
'
,
payload
:
{
quiz
:
{
originalObject
:
currentQuizService
.
quiz
.
serialize
(),
it
(
'
should redirect the user to input the nickname if no predefined nicks are available
'
,
async
(
inject
([
CurrentQuizService
,
Router
,
QuizApiService
,
LobbyApiService
],
(
currentQuizService
:
CurrentQuizService
,
router
:
Router
,
quizApiService
:
QuizApiService
,
lobbyApiService
:
LobbyApiService
)
=>
{
const
quizStatusData
=
{
status
:
'
STATUS:SUCCESSFUL
'
,
step
:
'
QUIZ:AVAILABLE
'
,
payload
:
{
authorizeViaCas
:
true
,
provideNickSelection
:
false
,
},
},
};
};
const
lobbyStatusData
=
{
status
:
'
STATUS:SUCCESSFUL
'
,
step
:
'
QUIZ:AVAILABLE
'
,
payload
:
{
quiz
:
{
originalObject
:
currentQuizService
.
quiz
.
serialize
(),
},
},
};
spyOn
(
quizApiService
,
'
getQuizStatus
'
).
and
.
returnValue
(
of
(
quizStatusData
));
spyOn
(
lobbyApiService
,
'
getLobbyStatus
'
).
and
.
returnValue
(
of
(
lobbyStatusData
));
spyOn
(
router
,
'
navigate
'
).
and
.
callFake
(()
=>
{});
spyOn
(
quizApiService
,
'
getQuizStatus
'
).
and
.
returnValue
(
of
(
quizStatusData
));
spyOn
(
lobbyApiService
,
'
getLobbyStatus
'
).
and
.
returnValue
(
of
(
lobbyStatusData
));
spyOn
(
router
,
'
navigate
'
).
and
.
callFake
(()
=>
{});
component
.
ngOnInit
();
expect
(
router
.
navigate
).
toHaveBeenCalledWith
([
'
/nicks
'
,
'
input
'
]);
})));
component
.
ngOnInit
();
expect
(
router
.
navigate
).
toHaveBeenCalledWith
([
'
/nicks
'
,
'
input
'
]);
})));
it
(
'
should redirect the user to the nickname selection if predefined nicks are available
'
,
async
(
inject
(
[
CurrentQuizService
,
Router
,
QuizApiService
,
LobbyApiService
],
(
currentQuizService
:
CurrentQuizService
,
router
:
Router
,
quizApiService
:
QuizApiService
,
lobbyApiService
:
LobbyApiService
,
)
=>
{
it
(
'
should redirect the user to the nickname selection if predefined nicks are available
'
,
async
(
inject
([
CurrentQuizService
,
Router
,
QuizApiService
,
LobbyApiService
],
(
currentQuizService
:
CurrentQuizService
,
router
:
Router
,
quizApiService
:
QuizApiService
,
lobbyApiService
:
LobbyApiService
)
=>
{
const
customQuiz
=
currentQuizService
.
quiz
;
customQuiz
.
sessionConfig
.
nicks
.
addSelectedNick
(
'
Predefined1
'
);
customQuiz
.
sessionConfig
.
nicks
.
addSelectedNick
(
'
Predefined2
'
);
const
quizStatusData
=
{
status
:
'
STATUS:SUCCESSFUL
'
,
step
:
'
QUIZ:AVAILABLE
'
,
payload
:
{
authorizeViaCas
:
true
,
provideNickSelection
:
true
,
},
};
const
lobbyStatusData
=
{
status
:
'
STATUS:SUCCESSFUL
'
,
step
:
'
QUIZ:AVAILABLE
'
,
payload
:
{
quiz
:
{
originalObject
:
customQuiz
.
serialize
(),
const
customQuiz
=
currentQuizService
.
quiz
;
customQuiz
.
sessionConfig
.
nicks
.
addSelectedNick
(
'
Predefined1
'
);
customQuiz
.
sessionConfig
.
nicks
.
addSelectedNick
(
'
Predefined2
'
);