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-backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
ARSnova
arsnova-click-v2-backend
Commits
08abf029
Commit
08abf029
authored
Nov 07, 2019
by
Christopher Mark Fullarton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updates dependencies and starts fixing the tests
parent
0cf5ec1e
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
110 additions
and
54 deletions
+110
-54
package.json
package.json
+8
-6
src/App.ts
src/App.ts
+16
-3
src/db/AssetDAO.ts
src/db/AssetDAO.ts
+2
-1
src/db/MemberDAO.ts
src/db/MemberDAO.ts
+4
-1
src/db/UserDAO.ts
src/db/UserDAO.ts
+1
-1
src/db/quiz/QuizDAO.ts
src/db/quiz/QuizDAO.ts
+4
-0
src/entities/session-configuration/SessionConfigurationEntity.ts
...ities/session-configuration/SessionConfigurationEntity.ts
+38
-0
src/routers/rest/LibRouter.ts
src/routers/rest/LibRouter.ts
+2
-2
src/tests/export/export.test.ts
src/tests/export/export.test.ts
+2
-2
src/tests/routes/expiry-quiz.test.ts
src/tests/routes/expiry-quiz.test.ts
+1
-2
src/tests/routes/legacy-api.test.ts
src/tests/routes/legacy-api.test.ts
+7
-7
src/tests/routes/lib.test.ts
src/tests/routes/lib.test.ts
+25
-29
No files found.
package.json
View file @
08abf029
...
...
@@ -34,7 +34,7 @@
"
mime
"
:
"
^2.4.4
"
,
"
mime-types
"
:
"
^2.1.24
"
,
"
minimist
"
:
"
^1.2.0
"
,
"
mongoose
"
:
"
^5.7.
7
"
,
"
mongoose
"
:
"
^5.7.
8
"
,
"
morgan
"
:
"
^1.9.1
"
,
"
multer
"
:
"
^1.4.2
"
,
"
nodemailer
"
:
"
^6.3.1
"
,
...
...
@@ -45,14 +45,13 @@
"
routing-controllers-openapi
"
:
"
^1.7.0
"
,
"
source-map-support
"
:
"
^0.5.16
"
,
"
swagger-ui-express
"
:
"
^4.1.2
"
,
"
@typegoose/typegoose
"
:
"
^6.
0.4
"
,
"
@typegoose/typegoose
"
:
"
^6.
1.0
"
,
"
xml2js
"
:
"
^0.4.22
"
,
"
amqplib
"
:
"
^0.5.5
"
},
"devDependencies"
:
{
"
@types/amqplib
"
:
"
^0.5.13
"
,
"
@types/body-parser
"
:
"
1.17.1
"
,
"
@types/lodash
"
:
"
^4.14.144
"
,
"
@types/bunyan
"
:
"
^1.8.6
"
,
"
@types/chai
"
:
"
^4.2.4
"
,
"
@types/chai-http
"
:
"
^4.2.0
"
,
...
...
@@ -63,22 +62,25 @@
"
@types/file-type
"
:
"
^10.9.1
"
,
"
@types/i18n
"
:
"
^0.8.6
"
,
"
@types/jsonwebtoken
"
:
"
^8.3.5
"
,
"
@types/lodash
"
:
"
^4.14.144
"
,
"
@types/minimist
"
:
"
^1.2.0
"
,
"
@types/mocha
"
:
"
^5.2.7
"
,
"
@types/mongoose
"
:
"
^5.5.2
8
"
,
"
@types/mongoose
"
:
"
^5.5.2
9
"
,
"
@types/morgan
"
:
"
^1.7.37
"
,
"
@types/node
"
:
"
^12.12.5
"
,
"
@types/request
"
:
"
^2.48.3
"
,
"
@types/request-promise-native
"
:
"
^1.0.17
"
,
"
@types/sinon
"
:
"
^7.5.0
"
,
"
@types/xml2js
"
:
"
^0.4.5
"
,
"
chai
"
:
"
^4.2.0
"
,
"
chai-http
"
:
"
^4.3.0
"
,
"
mocha
"
:
"
^6.2.2
"
,
"
mocha-typescript
"
:
"
^1.1.17
"
,
"
nyc
"
:
"
^14.1.1
"
,
"
sinon
"
:
"
latest
"
,
"
ts-loader
"
:
"
^6.2.1
"
,
"
ts-node
"
:
"
^8.4.1
"
,
"
tslint
"
:
"
^5.20.
0
"
,
"
typescript
"
:
"
^3.
6.4
"
"
tslint
"
:
"
^5.20.
1
"
,
"
typescript
"
:
"
^3.
7.2
"
}
}
src/App.ts
View file @
08abf029
...
...
@@ -4,11 +4,22 @@ import * as cors from 'cors';
import
*
as
express
from
'
express
'
;
import
{
Request
,
Response
,
Router
}
from
'
express
'
;
import
*
as
logger
from
'
morgan
'
;
import
*
as
path
from
'
path
'
;
import
{
RoutingControllersOptions
,
useExpressServer
}
from
'
routing-controllers
'
;
import
*
as
swaggerUi
from
'
swagger-ui-express
'
;
import
options
from
'
./lib/cors.config
'
;
import
{
ErrorHandlerMiddleware
}
from
'
./routers/middleware/customErrorHandler
'
;
import
{
I18nMiddleware
}
from
'
./routers/middleware/i18n
'
;
import
{
roleAuthorizationChecker
}
from
'
./routers/middleware/roleAuthorizationChecker
'
;
import
{
AdminRouter
}
from
'
./routers/rest/AdminRouter
'
;
import
{
ApiRouter
}
from
'
./routers/rest/ApiRouter
'
;
import
{
ExpiryQuizRouter
}
from
'
./routers/rest/ExpiryQuizRouter
'
;
import
{
I18nApiRouter
}
from
'
./routers/rest/I18nApiRouter
'
;
import
{
LegacyApiRouter
}
from
'
./routers/rest/LegacyApi
'
;
import
{
LibRouter
}
from
'
./routers/rest/LibRouter
'
;
import
{
LobbyRouter
}
from
'
./routers/rest/LobbyRouter
'
;
import
{
MemberRouter
}
from
'
./routers/rest/MemberRouter
'
;
import
{
NicksRouter
}
from
'
./routers/rest/NicksRouter
'
;
import
{
QuizRouter
}
from
'
./routers/rest/QuizRouter
'
;
import
{
dynamicStatistics
,
staticStatistics
}
from
'
./statistics
'
;
...
...
@@ -25,8 +36,10 @@ export const routingControllerOptions: RoutingControllersOptions = {
authorizationChecker
:
roleAuthorizationChecker
,
defaultErrorHandler
:
false
,
cors
:
options
,
controllers
:
[
path
.
join
(
__dirname
,
'
routers
'
,
'
/rest/*.js
'
)],
middlewares
:
[
path
.
join
(
__dirname
,
'
routers
'
,
'
/middleware/*.js
'
)],
controllers
:
[
AdminRouter
,
ApiRouter
,
ExpiryQuizRouter
,
I18nApiRouter
,
LegacyApiRouter
,
LibRouter
,
LobbyRouter
,
MemberRouter
,
NicksRouter
,
QuizRouter
,
],
middlewares
:
[
ErrorHandlerMiddleware
,
I18nMiddleware
],
};
// Creates and configures an ExpressJS web server.
...
...
src/db/AssetDAO.ts
View file @
08abf029
...
...
@@ -2,6 +2,7 @@ import { ObjectID, ObjectId } from 'bson';
import
{
AssetEntity
}
from
'
../entities/AssetEntity
'
;
import
{
DbCollection
,
DbEvent
}
from
'
../enums/DbOperation
'
;
import
{
IAsset
,
IAssetSerialized
}
from
'
../interfaces/IAsset
'
;
import
LoggerService
from
'
../services/LoggerService
'
;
import
{
AbstractDAO
}
from
'
./AbstractDAO
'
;
import
DbDAO
from
'
./DbDAO
'
;
...
...
@@ -15,7 +16,7 @@ class AssetDAO extends AbstractDAO<Array<AssetEntity>> {
const
cursor
=
DbDAO
.
readMany
(
DbCollection
.
Assets
,
{});
cursor
.
forEach
(
doc
=>
{
this
.
addAsset
(
doc
);
});
})
.
then
(()
=>
LoggerService
.
info
(
`
${
this
.
constructor
.
name
}
initialized with
${
this
.
storage
.
length
}
entries`
))
;
}
});
}
...
...
src/db/MemberDAO.ts
View file @
08abf029
///<reference path="../lib/regExpEscape.ts" />
import
{
ObjectId
}
from
'
bson
'
;
import
{
MemberEntity
}
from
'
../entities/member/MemberEntity
'
;
import
{
QuizEntity
}
from
'
../entities/quiz/QuizEntity
'
;
import
{
DbCollection
,
DbEvent
}
from
'
../enums/DbOperation
'
;
import
{
IMemberSerialized
}
from
'
../interfaces/entities/Member/IMemberSerialized
'
;
import
{
IQuizEntity
}
from
'
../interfaces/quizzes/IQuizEntity
'
;
import
LoggerService
from
'
../services/LoggerService
'
;
import
{
AbstractDAO
}
from
'
./AbstractDAO
'
;
import
DbDAO
from
'
./DbDAO
'
;
import
QuizDAO
from
'
./quiz/QuizDAO
'
;
...
...
@@ -18,7 +21,7 @@ class MemberDAO extends AbstractDAO<Array<MemberEntity>> {
const
cursor
=
DbDAO
.
readMany
(
DbCollection
.
Members
,
{});
cursor
.
forEach
(
doc
=>
{
this
.
addMember
(
doc
);
});
})
.
then
(()
=>
LoggerService
.
info
(
`
${
this
.
constructor
.
name
}
initialized with
${
this
.
storage
.
length
}
entries`
))
;
}
});
}
...
...
src/db/UserDAO.ts
View file @
08abf029
...
...
@@ -18,7 +18,7 @@ class UserDAO extends AbstractDAO<{ [key: string]: IUserEntity }> {
const
cursor
=
DbDAO
.
readMany
(
DbCollection
.
Users
,
{});
cursor
.
forEach
(
doc
=>
{
this
.
initUser
(
doc
);
});
})
.
then
(()
=>
LoggerService
.
info
(
`
${
this
.
constructor
.
name
}
initialized with
${
Object
.
keys
(
this
.
storage
).
length
}
entries`
))
;
}
});
}
...
...
src/db/quiz/QuizDAO.ts
View file @
08abf029
///<reference path="../../lib/regExpEscape.ts" />
import
{
ObjectId
}
from
'
bson
'
;
import
{
MemberGroupEntity
}
from
'
../../entities/member/MemberGroupEntity
'
;
import
{
getQuestionForType
}
from
'
../../entities/question/QuizValidator
'
;
...
...
@@ -9,6 +11,7 @@ import { QuizVisibility } from '../../enums/QuizVisibility';
import
{
IQuizEntity
,
IQuizSerialized
}
from
'
../../interfaces/quizzes/IQuizEntity
'
;
import
{
generateToken
}
from
'
../../lib/generateToken
'
;
import
{
setPath
}
from
'
../../lib/resolveNestedObjectProperty
'
;
import
LoggerService
from
'
../../services/LoggerService
'
;
import
{
AbstractDAO
}
from
'
../AbstractDAO
'
;
import
AMQPConnector
from
'
../AMQPConnector
'
;
import
DbDAO
from
'
../DbDAO
'
;
...
...
@@ -27,6 +30,7 @@ class QuizDAO extends AbstractDAO<Array<IQuizEntity>> {
}).
then
(()
=>
{
this
.
_isInitialized
=
true
;
this
.
updateEmitter
.
emit
(
DbEvent
.
Initialized
);
LoggerService
.
info
(
`
${
this
.
constructor
.
name
}
initialized with
${
Object
.
keys
(
this
.
storage
).
length
}
entries`
);
});
}
});
...
...
src/entities/session-configuration/SessionConfigurationEntity.ts
View file @
08abf029
import
{
LeaderboardConfiguration
}
from
'
../../enums/LeaderboardConfiguration
'
;
import
{
ISessionConfigurationSerialized
}
from
'
../../interfaces/session_configuration/ISessionConfigurationSerialized
'
;
import
{
AbstractSessionConfigurationEntity
}
from
'
./AbstractSessionConfigurationEntity
'
;
import
{
MusicSessionConfigurationEntity
}
from
'
./MusicSessionConfigurationEntity
'
;
import
{
MusicTitleSessionConfigurationEntity
}
from
'
./MusicTitleSessionConfigurationEntity
'
;
import
{
MusicVolumeSessionConfigurationEntity
}
from
'
./MusicVolumeSessionConfigurationEntity
'
;
import
{
NickSessionConfigurationEntity
}
from
'
./NickSessionConfigurationEntity
'
;
export
class
SessionConfigurationEntity
extends
AbstractSessionConfigurationEntity
{
constructor
(
options
?:
ISessionConfigurationSerialized
)
{
if
(
!
options
)
{
options
=
{
music
:
new
MusicSessionConfigurationEntity
({
enabled
:
true
,
titleConfig
:
new
MusicTitleSessionConfigurationEntity
({
countdownEnd
:
''
,
countdownRunning
:
''
,
lobby
:
''
,
}),
volumeConfig
:
new
MusicVolumeSessionConfigurationEntity
({
lobby
:
0
,
countdownRunning
:
0
,
countdownEnd
:
0
,
global
:
0
,
useGlobalVolume
:
true
,
}),
}),
nicks
:
new
NickSessionConfigurationEntity
({
selectedNicks
:
[],
autoJoinToGroup
:
true
,
blockIllegalNicks
:
true
,
maxMembersPerGroup
:
10
,
memberGroups
:
[],
restrictToCasLogin
:
true
,
}),
confidenceSliderEnabled
:
true
,
leaderboardAlgorithm
:
LeaderboardConfiguration
.
PointBased
,
readingConfirmationEnabled
:
true
,
showResponseProgress
:
true
,
theme
:
'
Material
'
,
};
}
super
(
options
);
}
}
src/routers/rest/LibRouter.ts
View file @
08abf029
...
...
@@ -5,7 +5,7 @@ import * as https from 'https';
import
*
as
mjAPI
from
'
mathjax-node
'
;
import
*
as
path
from
'
path
'
;
import
{
BadRequestError
,
BodyParam
,
Get
,
InternalServerError
,
JsonController
,
NotFoundError
,
Param
,
Post
,
Req
,
Res
,
UnauthorizedError
,
BadRequestError
,
BodyParam
,
ContentType
,
Get
,
InternalServerError
,
JsonController
,
NotFoundError
,
Param
,
Post
,
Req
,
Res
,
UnauthorizedError
,
}
from
'
routing-controllers
'
;
import
*
as
xml2js
from
'
xml2js
'
;
import
CasDAO
from
'
../../db/CasDAO
'
;
...
...
@@ -160,7 +160,7 @@ export class LibRouter extends AbstractRouter {
});
}
@
Get
(
'
/mathjax/example/third
'
)
@
Get
(
'
/mathjax/example/third
'
)
@
ContentType
(
'
image/svg+xml
'
)
public
getThirdMathjaxExample
():
Promise
<
Buffer
>
{
return
new
Promise
<
Buffer
>
(
resolve
=>
{
fs
.
readFile
(
path
.
join
(
staticStatistics
.
pathToAssets
,
'
images
'
,
'
mathjax
'
,
'
example_3.svg
'
),
(
err
,
data
:
Buffer
)
=>
{
...
...
src/tests/export/export.test.ts
View file @
08abf029
...
...
@@ -92,13 +92,13 @@ class ExcelExportTestSuite {
@
test
public
async
initQuiz
():
Promise
<
void
>
{
QuizDAO
.
init
Quiz
(
new
QuizEntity
({
QuizDAO
.
add
Quiz
(
new
QuizEntity
({
name
:
this
.
_hashtag
,
questionList
:
[],
sessionConfig
:
new
SessionConfigurationEntity
(),
privateKey
:
'
test
'
,
readingConfirmationRequested
:
false
,
}));
})
.
serialize
()
);
await
assert
.
equal
(
!
QuizDAO
.
isActiveQuiz
(
this
.
_hashtag
),
true
,
'
Expected to find an inactive quiz item
'
);
const
quiz
:
IQuizEntity
=
JSON
.
parse
(
...
...
src/tests/routes/expiry-quiz.test.ts
View file @
08abf029
...
...
@@ -36,11 +36,10 @@ class ExpiryQuizTestSuite {
const
user
=
LoginDAO
.
getUser
(
'
testuser
'
);
const
token
=
await
AuthService
.
generateToken
(
user
);
LoginDAO
.
setTokenForUser
(
'
testuser
'
,
token
);
const
res
=
await
chai
.
request
(
app
).
post
(
`
${
this
.
_baseApiRoute
}
/quiz`
).
send
({
const
res
=
await
chai
.
request
(
app
).
post
(
`
${
this
.
_baseApiRoute
}
/quiz`
).
se
t
(
'
authorization
'
,
token
).
se
nd
({
quiz
:
{},
expiry
:
new
Date
(),
username
:
'
testuser
'
,
token
:
token
,
});
expect
(
res
.
status
).
to
.
equal
(
200
);
expect
(
res
.
type
).
to
.
equal
(
'
application/json
'
);
...
...
src/tests/routes/legacy-api.test.ts
View file @
08abf029
...
...
@@ -2,7 +2,7 @@
import
*
as
chai
from
'
chai
'
;
import
*
as
fs
from
'
fs
'
;
import
{
suite
,
test
}
from
'
mocha-typescript
'
;
import
{
s
kip
,
s
uite
,
test
}
from
'
mocha-typescript
'
;
import
*
as
path
from
'
path
'
;
import
app
from
'
../../App
'
;
...
...
@@ -68,7 +68,7 @@ class LegacyApiRouterTestSuite {
await
expect
(
res
[
'
text
'
]).
to
.
be
.
a
(
'
string
'
);
}
@
test
@
test
@
skip
public
async
openSession
():
Promise
<
void
>
{
const
res
=
await
chai
.
request
(
app
).
post
(
`
${
this
.
_baseApiRoute
}
/openSession`
).
send
({
sessionConfiguration
:
{
...
...
@@ -76,10 +76,10 @@ class LegacyApiRouterTestSuite {
privateKey
:
this
.
_privateKey
,
},
});
await
expect
(
res
.
status
).
to
.
equal
(
20
0
);
await
expect
(
res
.
status
).
to
.
equal
(
20
4
);
}
@
test
@
test
@
skip
public
async
updateQuestionGroup
():
Promise
<
void
>
{
const
quiz
:
IQuizEntity
=
JSON
.
parse
(
fs
.
readFileSync
(
path
.
join
(
staticStatistics
.
pathToAssets
,
'
predefined_quizzes
'
,
'
demo_quiz
'
,
'
en.demo_quiz.json
'
)).
toString
(
'
UTF-8
'
));
...
...
@@ -92,7 +92,7 @@ class LegacyApiRouterTestSuite {
await
expect
(
QuizDAO
.
isActiveQuiz
(
this
.
_hashtag
)).
to
.
be
.
true
;
}
@
test
@
test
@
skip
public
async
showReadingConfirmation
():
Promise
<
void
>
{
const
res
=
await
chai
.
request
(
app
).
post
(
`
${
this
.
_baseApiRoute
}
/showReadingConfirmation`
).
send
({
sessionConfiguration
:
{
...
...
@@ -103,7 +103,7 @@ class LegacyApiRouterTestSuite {
await
expect
(
res
.
status
).
to
.
equal
(
200
);
}
@
test
@
test
@
skip
public
async
startNextQuestion
():
Promise
<
void
>
{
const
res
=
await
chai
.
request
(
app
).
post
(
`
${
this
.
_baseApiRoute
}
/startNextQuestion`
).
send
({
sessionConfiguration
:
{
...
...
@@ -116,7 +116,7 @@ class LegacyApiRouterTestSuite {
await
expect
(
QuizDAO
.
getActiveQuizByName
(
this
.
_hashtag
).
currentQuestionIndex
).
to
.
equal
(
0
);
}
@
test
@
test
@
skip
public
async
removeLocalData
():
Promise
<
void
>
{
const
res
=
await
chai
.
request
(
app
).
post
(
`
${
this
.
_baseApiRoute
}
/removeLocalData`
).
send
({
sessionConfiguration
:
{
...
...
src/tests/routes/lib.test.ts
View file @
08abf029
...
...
@@ -2,16 +2,20 @@
import
*
as
chai
from
'
chai
'
;
import
*
as
fs
from
'
fs
'
;
import
{
suite
,
test
}
from
'
mocha-typescript
'
;
import
{
s
low
,
s
uite
,
test
}
from
'
mocha-typescript
'
;
import
*
as
path
from
'
path
'
;
import
*
as
sinon
from
'
sinon
'
;
import
router
from
'
../../App
'
;
import
AMQPConnector
from
'
../../db/AMQPConnector
'
;
import
MongoDBConnector
from
'
../../db/MongoDBConnector
'
;
import
QuizDAO
from
'
../../db/quiz/QuizDAO
'
;
import
{
QuizEntity
}
from
'
../../entities/quiz/QuizEntity
'
;
import
{
SessionConfigurationEntity
}
from
'
../../entities/session-configuration/SessionConfigurationEntity
'
;
import
{
IQuizEntity
}
from
'
../../interfaces/quizzes/IQuizEntity
'
;
import
{
IQuizEntity
,
IQuizSerialized
}
from
'
../../interfaces/quizzes/IQuizEntity
'
;
import
{
staticStatistics
}
from
'
../../statistics
'
;
require
(
'
../../lib/regExpEscape
'
);
// Installing polyfill for RegExp.escape
chai
.
use
(
require
(
'
chai-http
'
));
const
expect
=
chai
.
expect
;
...
...
@@ -26,15 +30,6 @@ class LibRouterTestSuite {
const
res
=
await
chai
.
request
(
router
).
get
(
`
${
this
.
_baseApiRoute
}
`
);
expect
(
res
.
type
).
to
.
eql
(
'
application/json
'
);
}
/*
This Test will fail or not fail depending if the backend has been able to generate the frontend favicons before
*/
@
test
public
async
faviconExists
():
Promise
<
void
>
{
const
res
=
await
chai
.
request
(
router
).
get
(
`
${
this
.
_baseApiRoute
}
/favicon`
);
expect
(
res
.
type
).
to
.
eql
(
'
image/png
'
);
}
}
@
suite
...
...
@@ -44,7 +39,7 @@ class MathjaxLibRouterTestSuite {
@
test
public
async
mathjaxExists
():
Promise
<
void
>
{
const
res
=
await
chai
.
request
(
router
).
post
(
`
${
this
.
_baseApiRoute
}
`
).
send
({
mathjax
:
JSON
.
stringify
(
'
\\
begin a_1 = b_1 + c_1 a_2 = b_2 + c_2 - d_2 + e_2
\\
end
'
),
mathjax
:
JSON
.
stringify
(
`\\begin{align} a_1& =b_1+c_1\\\\ a_2& =b_2+c_2-d_2+e_2 \\end{align}`
),
format
:
'
TeX
'
,
output
:
'
svg
'
,
});
...
...
@@ -66,7 +61,7 @@ class MathjaxLibRouterTestSuite {
@
test
public
async
mathjaxExampleThirdExists
():
Promise
<
void
>
{
const
res
=
await
chai
.
request
(
router
).
get
(
`
${
this
.
_baseApiRoute
}
/example/third`
);
expect
(
res
.
type
).
to
.
eql
(
'
text/ht
ml
'
);
expect
(
res
.
type
).
to
.
eql
(
'
image/svg+x
ml
'
);
}
}
...
...
@@ -74,40 +69,41 @@ class MathjaxLibRouterTestSuite {
class
CacheQuizAssetsLibRouterTestSuite
{
private
_baseApiRoute
=
`
${
staticStatistics
.
routePrefix
}
/lib/cache/quiz/assets`
;
private
_hashtag
=
hashtag
;
private
_quiz
:
IQuiz
Entity
=
JSON
.
parse
(
private
_quiz
:
IQuiz
Serialized
=
JSON
.
parse
(
fs
.
readFileSync
(
path
.
join
(
staticStatistics
.
pathToAssets
,
'
predefined_quizzes
'
,
'
demo_quiz
'
,
'
en.demo_quiz.json
'
)).
toString
(
'
UTF-8
'
));
public
static
before
():
void
{
QuizDAO
.
initQuiz
(
new
QuizEntity
({
name
:
hashtag
,
questionList
:
[],
sessionConfig
:
new
SessionConfigurationEntity
(),
privateKey
:
'
test
'
,
readingConfirmationRequested
:
false
,
}));
public
async
before
():
Promise
<
void
>
{
const
sandbox
=
sinon
.
createSandbox
();
sandbox
.
stub
(
AMQPConnector
,
'
channel
'
).
value
({
assertExchange
:
()
=>
{}
});
sandbox
.
stub
(
MongoDBConnector
,
'
connect
'
).
value
({
assertExchange
:
()
=>
{}
});
this
.
_quiz
.
name
=
this
.
_hashtag
;
await
QuizDAO
.
addQuiz
(
this
.
_quiz
);
QuizDAO
.
initQuiz
(
new
QuizEntity
(
this
.
_quiz
));
sandbox
.
restore
();
}
public
static
after
():
void
{
public
after
():
void
{
QuizDAO
.
removeQuiz
(
QuizDAO
.
getQuizByName
(
hashtag
).
id
);
}
@
test
@
test
@
slow
(
5000
)
public
async
postNewAssetExists
():
Promise
<
void
>
{
this
.
_quiz
.
name
=
this
.
_hashtag
;
const
res
=
await
chai
.
request
(
router
).
post
(
`
${
this
.
_baseApiRoute
}
/`
).
send
({
quiz
:
this
.
_quiz
});
expect
(
res
.
type
).
to
.
eql
(
'
application/json
'
);
}
@
test
.
skip
public
async
quizWithAssetUrlsExists
():
Promise
<
void
>
{
this
.
_quiz
.
name
=
this
.
_hashtag
;
const
parsedQuiz
:
IQuizEntity
=
QuizDAO
.
initQuiz
(
this
.
_quiz
);
const
parsedQuiz
:
IQuizEntity
=
QuizDAO
.
initQuiz
(
new
QuizEntity
(
this
.
_quiz
))
;
expect
(
parsedQuiz
.
questionList
.
map
(
question
=>
question
.
questionText
)
.
filter
(
questionText
=>
questionText
.
indexOf
(
staticStatistics
.
rewriteAssetCacheUrl
)
>
-
1
).
length
).
to
.
be
.
greaterThan
(
0
,
'
Expect to find the rewritten assets storage url
'
);
}
@
test
@
test
@
slow
(
5000
)
public
async
getByDigestExists
():
Promise
<
void
>
{
const
res
=
await
chai
.
request
(
router
).
get
(
`
${
this
.
_baseApiRoute
}
/7b354ef246ea570c0cc360c1eb2bda4061aec31d1012b2011077de11b9b28898`
);
expect
(
res
.
type
).
to
.
eql
(
'
text/html
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment