message: test(server default apps): expand default apps update test with token scopes checks
diff: /* istanbul ignore file */
  const expect = require('chai').expect
  -const appRoot = require('app-root-path')
  -const { createUser } = require(`${appRoot}/modules/core/services/users`)
  -const { validateToken } = require(`${appRoot}/modules/core/services/tokens`)
  -const { beforeEachContext } = require(`${appRoot}/test/hooks`)
  +const { createUser } = require(`@/modules/core/services/users`)
  +const { validateToken } = require(`@/modules/core/services/tokens`)
  +const { beforeEachContext } = require(`@/test/hooks`)
  const {
  getApp,
  getAllPublicApps,
  @@ -19,6 +18,7 @@ const {
  const { Scopes } = require('@/modules/core/helpers/mainConstants')
  const { updateDefaultApp } = require('@/modules/auth/defaultApps')
  +const knex = require('@/db/knex')
  describe('Services @apps-services', () => {
  const actor = {
  @@ -243,14 +243,20 @@ describe('Services @apps-services', () => {
  // We now have one unused access code, an api token and a refresh token.
  // Proceed to update the app:
  const existingApp = await getApp({ id: speckleAppId })
  +
  + const newScopes = [Scopes.Streams.Write, Scopes.Users.Read]
  +
  await updateDefaultApp(
  {
  name: 'updated test application',
  id: speckleAppId,
  - scopes: [Scopes.Streams.Write, Scopes.Users.Read]
  + scopes: newScopes
  },
  existingApp
  )
  + const updatedApp = await getApp({ id: speckleAppId })
  +
  + expect(updatedApp.scopes.map((s) => s.name)).to.equalInAnyOrder(newScopes)
  const validationResponse = await validateToken(apiTokenResponse.token)
  expect(validationResponse.valid).to.equal(true)
  @@ -271,6 +277,19 @@ describe('Services @apps-services', () => {
  })
  expect(appToken.token).to.exist
  expect(appToken.refreshToken).to.exist
  +
  + const apiTokens = await knex('user_server_app_tokens')
  + .join(
  + 'token_scopes',
  + 'user_server_app_tokens.tokenId',
  + '=',
  + 'token_scopes.tokenId'
  + )
  + .where({
  + appId: speckleAppId
  + })
  +
  + expect(newScopes).to.include.members(apiTokens.map((t) => t.scopeName))
  })
  })
  