fix(server tests): fixed all non awaited rejected promisses
This commit is contained in:
@@ -5,7 +5,8 @@ const config = {
|
||||
spec: ['modules/**/*.spec.js'],
|
||||
require: 'test/hooks.js',
|
||||
slow: 0,
|
||||
timeout: '10000',
|
||||
// timeout: '15000',
|
||||
timeout: '1500000000000',
|
||||
exit: true
|
||||
}
|
||||
|
||||
|
||||
Vendored
+8
-1
@@ -44,7 +44,14 @@
|
||||
{
|
||||
"name": "NPM test",
|
||||
"request": "launch",
|
||||
"runtimeArgs": ["run-script", "test", "--", "-g='Comments @comments'", "--exit"],
|
||||
"runtimeArgs": [
|
||||
"run-script",
|
||||
"test",
|
||||
"--",
|
||||
// "-g='@apps-api'",
|
||||
"--exit",
|
||||
"--timeout=0"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"env": {
|
||||
// "POSTGRES_URL": "postgres://speckle:speckle@localhost/speckle2_test",
|
||||
|
||||
@@ -85,7 +85,7 @@ describe('Services @apps-services', () => {
|
||||
})
|
||||
|
||||
it('Should fail to register an app with no scopes', async () => {
|
||||
createApp({ name: 'test application2', redirectUrl: 'http://localhost:1335' })
|
||||
await createApp({ name: 'test application2', redirectUrl: 'http://localhost:1335' })
|
||||
.then(() => {
|
||||
throw new Error('this should have been rejected')
|
||||
})
|
||||
@@ -192,7 +192,7 @@ describe('Services @apps-services', () => {
|
||||
let validationResponse = await validateToken(apiTokenResponse.token)
|
||||
expect(validationResponse.valid).to.equal(false)
|
||||
|
||||
refreshAppToken({
|
||||
await refreshAppToken({
|
||||
refreshToken: apiTokenResponse.refreshToken,
|
||||
appId: myTestApp.id,
|
||||
appSecret: myTestApp.secret
|
||||
@@ -202,7 +202,7 @@ describe('Services @apps-services', () => {
|
||||
})
|
||||
.catch((err) => expect(err.message).to.equal('Invalid request'))
|
||||
|
||||
createAppTokenFromAccessCode({
|
||||
await createAppTokenFromAccessCode({
|
||||
appId: myTestApp.id,
|
||||
appSecret: myTestApp.secret,
|
||||
accessCode: unusedAccessCode,
|
||||
@@ -239,7 +239,7 @@ describe('Services @apps-services', () => {
|
||||
userId: secondUser.id
|
||||
})
|
||||
|
||||
refreshAppToken({
|
||||
await refreshAppToken({
|
||||
refreshToken: apiTokenResponse.refreshToken,
|
||||
appId: myTestApp.id,
|
||||
appSecret: myTestApp.secret
|
||||
@@ -255,7 +255,7 @@ describe('Services @apps-services', () => {
|
||||
challenge
|
||||
})
|
||||
|
||||
createAppTokenFromAccessCode({
|
||||
await createAppTokenFromAccessCode({
|
||||
appId: myTestApp.id,
|
||||
appSecret: myTestApp.secret,
|
||||
accessCode: unusedAccessCode,
|
||||
|
||||
@@ -19,6 +19,7 @@ let server
|
||||
describe('Auth @auth', () => {
|
||||
describe('Local authN & authZ (token endpoints)', () => {
|
||||
before(async () => {
|
||||
console.log('before auth')
|
||||
;({ app } = await beforeEachContext())
|
||||
;({ server, sendRequest } = await initializeTestServer(app))
|
||||
})
|
||||
|
||||
@@ -80,7 +80,7 @@ describe('Comments @comments', () => {
|
||||
})
|
||||
|
||||
it('Should not be allowed to comment without specifying at least one target resource', async () => {
|
||||
return await createComment({
|
||||
await createComment({
|
||||
userId: user.id,
|
||||
input: {
|
||||
streamId: stream.id,
|
||||
@@ -129,7 +129,7 @@ describe('Comments @comments', () => {
|
||||
})
|
||||
|
||||
// create a comment on streamA but objectB
|
||||
createComment({
|
||||
await createComment({
|
||||
userId: user.id,
|
||||
input: {
|
||||
streamId: streamA.id,
|
||||
@@ -142,7 +142,7 @@ describe('Comments @comments', () => {
|
||||
.catch((error) => expect(error.message).to.be.equal('Object not found'))
|
||||
|
||||
// create a comment on streamA but commitB
|
||||
createComment({
|
||||
await createComment({
|
||||
userId: user.id,
|
||||
input: {
|
||||
streamId: streamA.id,
|
||||
@@ -155,7 +155,7 @@ describe('Comments @comments', () => {
|
||||
.catch((error) => expect(error.message).to.be.equal('Commit not found'))
|
||||
|
||||
// mixed bag of resources (A, B)
|
||||
createComment({
|
||||
await createComment({
|
||||
userId: user.id,
|
||||
input: {
|
||||
streamId: streamA.id,
|
||||
@@ -183,7 +183,7 @@ describe('Comments @comments', () => {
|
||||
})
|
||||
|
||||
// replies should also not be swappable
|
||||
createCommentReply({
|
||||
await createCommentReply({
|
||||
authorId: user.id,
|
||||
parentCommentId: correctCommentId,
|
||||
streamId: streamB.id,
|
||||
@@ -351,7 +351,7 @@ describe('Comments @comments', () => {
|
||||
})
|
||||
|
||||
it('Should not be allowed to comment targeting multiple streams as a resource', async () => {
|
||||
return await createComment({
|
||||
await createComment({
|
||||
userId: user.id,
|
||||
input: {
|
||||
streamId: stream.id,
|
||||
@@ -714,7 +714,7 @@ describe('Comments @comments', () => {
|
||||
})
|
||||
|
||||
it('Should not be allowed to edit a not existing comment', async () => {
|
||||
editComment({ userId: user.id, input: { id: 'this is not going to be found' } })
|
||||
await editComment({ userId: user.id, input: { id: 'this is not going to be found' } })
|
||||
.then(() => {
|
||||
throw new Error('This should have been rejected')
|
||||
})
|
||||
@@ -738,7 +738,7 @@ describe('Comments @comments', () => {
|
||||
}
|
||||
})
|
||||
|
||||
editComment({ userId: otherUser.id, input: { id: commentId, text: 'properText' } })
|
||||
await editComment({ userId: otherUser.id, input: { id: commentId, text: 'properText' } })
|
||||
.then(() => {
|
||||
throw new Error('This should have been rejected')
|
||||
})
|
||||
@@ -780,7 +780,7 @@ describe('Comments @comments', () => {
|
||||
})
|
||||
|
||||
it('Should not be allowed to archive a not existing comment', async () => {
|
||||
archiveComment({ commentId: 'badabumm', streamId: stream.id, userId: user.id })
|
||||
await archiveComment({ commentId: 'badabumm', streamId: stream.id, userId: user.id })
|
||||
.then(() => {
|
||||
throw new Error('This should have been rejected')
|
||||
})
|
||||
@@ -802,7 +802,7 @@ describe('Comments @comments', () => {
|
||||
}
|
||||
})
|
||||
|
||||
archiveComment({ commentId, streamId: stream.id, userId: otherUser.id })
|
||||
await archiveComment({ commentId, streamId: stream.id, userId: otherUser.id })
|
||||
.then(() => {
|
||||
throw new Error('This should have been rejected')
|
||||
})
|
||||
|
||||
@@ -17,7 +17,7 @@ describe('Generic AuthN & AuthZ controller tests', () => {
|
||||
})
|
||||
|
||||
it('Validate scopes', async () => {
|
||||
validateScopes()
|
||||
await validateScopes()
|
||||
.then(() => {
|
||||
throw new Error('This should have been rejected')
|
||||
})
|
||||
@@ -25,7 +25,7 @@ describe('Generic AuthN & AuthZ controller tests', () => {
|
||||
expect('You do not have the required privileges.').to.equal(err.message)
|
||||
)
|
||||
|
||||
validateScopes(['a'], 'b')
|
||||
await validateScopes(['a'], 'b')
|
||||
.then(() => {
|
||||
throw new Error('This should have been rejected')
|
||||
})
|
||||
@@ -48,7 +48,7 @@ describe('Generic AuthN & AuthZ controller tests', () => {
|
||||
})
|
||||
|
||||
it('Should validate server role', async () => {
|
||||
validateServerRole({ auth: true, role: 'server:user' }, 'server:admin')
|
||||
await validateServerRole({ auth: true, role: 'server:user' }, 'server:admin')
|
||||
.then(() => {
|
||||
throw new Error('This should have been rejected')
|
||||
})
|
||||
@@ -56,13 +56,13 @@ describe('Generic AuthN & AuthZ controller tests', () => {
|
||||
expect('You do not have the required server role').to.equal(err.message)
|
||||
)
|
||||
|
||||
validateServerRole({ auth: true, role: 'HACZOR' }, '133TCR3w')
|
||||
await validateServerRole({ auth: true, role: 'HACZOR' }, '133TCR3w')
|
||||
.then(() => {
|
||||
throw new Error('This should have been rejected')
|
||||
})
|
||||
.catch((err) => expect('Invalid server role specified').to.equal(err.message))
|
||||
|
||||
validateServerRole({ auth: true, role: 'server:admin' }, '133TCR3w')
|
||||
await validateServerRole({ auth: true, role: 'server:admin' }, '133TCR3w')
|
||||
.then(() => {
|
||||
throw new Error('This should have been rejected')
|
||||
})
|
||||
@@ -76,14 +76,14 @@ describe('Generic AuthN & AuthZ controller tests', () => {
|
||||
})
|
||||
|
||||
it('Resolver Authorization Should fail nicely when roles & resources are wanky', async () => {
|
||||
authorizeResolver(null, 'foo', 'bar')
|
||||
await authorizeResolver(null, 'foo', 'bar')
|
||||
.then(() => {
|
||||
throw new Error('This should have been rejected')
|
||||
})
|
||||
.catch((err) => expect('Unknown role: bar').to.equal(err.message))
|
||||
|
||||
// this caught me out, but streams:read is not a valid role for now
|
||||
authorizeResolver('foo', 'bar', 'streams:read')
|
||||
await authorizeResolver('foo', 'bar', 'streams:read')
|
||||
.then(() => {
|
||||
throw new Error('This should have been rejected')
|
||||
})
|
||||
|
||||
@@ -154,7 +154,7 @@ describe('Streams @core-streams', () => {
|
||||
})
|
||||
|
||||
it('Should not revoke owner permissions', async () => {
|
||||
revokePermissionsStream({ streamId: testStream.id, userId: userOne.id })
|
||||
await revokePermissionsStream({ streamId: testStream.id, userId: userOne.id })
|
||||
.then(() => {
|
||||
throw new Error('This should have thrown')
|
||||
})
|
||||
|
||||
@@ -137,7 +137,7 @@ describe('Actors & Tokens @user-services', () => {
|
||||
newUser.email = 'bill@gates.com'
|
||||
newUser.password = 'testthebest'
|
||||
|
||||
createUser(newUser)
|
||||
await createUser(newUser)
|
||||
.then(() => {
|
||||
throw new Error('This should have failed with duplicate email error')
|
||||
})
|
||||
|
||||
@@ -58,7 +58,7 @@ describe('Server Invites @server-invites', () => {
|
||||
message: 'Hey, join!'
|
||||
})
|
||||
|
||||
createAndSendInvite({
|
||||
await createAndSendInvite({
|
||||
email: 'cat@speckle.systems',
|
||||
inviterId: actor.id,
|
||||
message: 'Hey, join!'
|
||||
@@ -70,8 +70,8 @@ describe('Server Invites @server-invites', () => {
|
||||
expect(err.message).to.equal('Already invited!')
|
||||
})
|
||||
})
|
||||
it('low multiple invites for the same email regardles of casing', () => {
|
||||
createAndSendInvite({
|
||||
it('low multiple invites for the same email regardles of casing', async () => {
|
||||
await createAndSendInvite({
|
||||
email: 'dIdImItrIe@gmaIl.com',
|
||||
inviterId: actor.id,
|
||||
message: 'Hey, join!'
|
||||
@@ -85,7 +85,7 @@ describe('Server Invites @server-invites', () => {
|
||||
})
|
||||
|
||||
it('should not allow self invites', async () => {
|
||||
createAndSendInvite({
|
||||
await createAndSendInvite({
|
||||
email: 'didimitrie-100@gmail.com',
|
||||
inviterId: actor.id
|
||||
})
|
||||
@@ -100,7 +100,7 @@ describe('Server Invites @server-invites', () => {
|
||||
})
|
||||
|
||||
it('should not allow invites from no user', async () => {
|
||||
createAndSendInvite({
|
||||
await createAndSendInvite({
|
||||
email: 'didimitrie233-100@gmail.com',
|
||||
inviterId: 'fake'
|
||||
})
|
||||
@@ -113,7 +113,7 @@ describe('Server Invites @server-invites', () => {
|
||||
})
|
||||
|
||||
it('should not allow invites with a too long message', async () => {
|
||||
createAndSendInvite({
|
||||
await createAndSendInvite({
|
||||
email: '123456@gmail.com',
|
||||
inviterId: actor.id,
|
||||
message: longInviteMessage
|
||||
@@ -189,7 +189,7 @@ describe('Server Invites @server-invites', () => {
|
||||
message: 'Hey, join!'
|
||||
})
|
||||
|
||||
useInvite({ id: inviteId, email: 'parrot@speckle.systems' })
|
||||
await useInvite({ id: inviteId, email: 'parrot@speckle.systems' })
|
||||
.then(() => {
|
||||
throw new Error('This should have thrown')
|
||||
})
|
||||
@@ -205,7 +205,7 @@ describe('Server Invites @server-invites', () => {
|
||||
expect(result).equals(true)
|
||||
expect(invite.used).equals(true)
|
||||
|
||||
useInvite({ id: inviteId, email: 'CrOw@speckle.systems' })
|
||||
await useInvite({ id: inviteId, email: 'CrOw@speckle.systems' })
|
||||
.then(() => {
|
||||
throw new Error('This should have thrown')
|
||||
})
|
||||
|
||||
@@ -75,7 +75,9 @@ exports.mochaHooks = {
|
||||
}
|
||||
|
||||
exports.beforeEachContext = async () => {
|
||||
console.log('running before each')
|
||||
await exports.truncateTables()
|
||||
console.log('done truncating tables')
|
||||
const { app, graphqlServer } = await init()
|
||||
return { app, graphqlServer }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user