Fix tests/types.

This commit is contained in:
Sam Rose 2023-10-23 10:48:10 +01:00
parent 9e279be4c3
commit febfab0927
No known key found for this signature in database
2 changed files with 9 additions and 12 deletions

View File

@ -39,12 +39,12 @@ describe("syncGlobalUsers", () => {
expect(metadata).toHaveLength(3) expect(metadata).toHaveLength(3)
expect(metadata).toContainEqual( expect(metadata).toContainEqual(
expect.objectContaining({ expect.objectContaining({
_id: db.generateUserMetadataID(user1._id), _id: db.generateUserMetadataID(user1._id!),
}) })
) )
expect(metadata).toContainEqual( expect(metadata).toContainEqual(
expect.objectContaining({ expect.objectContaining({
_id: db.generateUserMetadataID(user2._id), _id: db.generateUserMetadataID(user2._id!),
}) })
) )
}) })
@ -59,7 +59,7 @@ describe("syncGlobalUsers", () => {
expect(metadata).toHaveLength(1) expect(metadata).toHaveLength(1)
expect(metadata).not.toContainEqual( expect(metadata).not.toContainEqual(
expect.objectContaining({ expect.objectContaining({
_id: db.generateUserMetadataID(user._id), _id: db.generateUserMetadataID(user._id!),
}) })
) )
}) })
@ -70,7 +70,7 @@ describe("syncGlobalUsers", () => {
const group = await proSdk.groups.save(structures.userGroups.userGroup()) const group = await proSdk.groups.save(structures.userGroups.userGroup())
const user1 = await config.createUser({ admin: false, builder: false }) const user1 = await config.createUser({ admin: false, builder: false })
const user2 = await config.createUser({ admin: false, builder: false }) const user2 = await config.createUser({ admin: false, builder: false })
await proSdk.groups.addUsers(group.id, [user1._id, user2._id]) await proSdk.groups.addUsers(group.id, [user1._id!, user2._id!])
await config.doInContext(config.appId, async () => { await config.doInContext(config.appId, async () => {
await syncGlobalUsers() await syncGlobalUsers()
@ -87,12 +87,12 @@ describe("syncGlobalUsers", () => {
expect(metadata).toHaveLength(3) expect(metadata).toHaveLength(3)
expect(metadata).toContainEqual( expect(metadata).toContainEqual(
expect.objectContaining({ expect.objectContaining({
_id: db.generateUserMetadataID(user1._id), _id: db.generateUserMetadataID(user1._id!),
}) })
) )
expect(metadata).toContainEqual( expect(metadata).toContainEqual(
expect.objectContaining({ expect.objectContaining({
_id: db.generateUserMetadataID(user2._id), _id: db.generateUserMetadataID(user2._id!),
}) })
) )
}) })
@ -109,7 +109,7 @@ describe("syncGlobalUsers", () => {
{ appId: config.prodAppId!, roleId: roles.BUILTIN_ROLE_IDS.BASIC }, { appId: config.prodAppId!, roleId: roles.BUILTIN_ROLE_IDS.BASIC },
], ],
}) })
await proSdk.groups.addUsers(group.id, [user1._id, user2._id]) await proSdk.groups.addUsers(group.id, [user1._id!, user2._id!])
await config.doInContext(config.appId, async () => { await config.doInContext(config.appId, async () => {
await syncGlobalUsers() await syncGlobalUsers()

View File

@ -295,7 +295,7 @@ class TestConfiguration {
admin?: boolean admin?: boolean
roles?: UserRoles roles?: UserRoles
} = {} } = {}
) { ): Promise<User> {
let { id, firstName, lastName, email, builder, admin, roles } = user let { id, firstName, lastName, email, builder, admin, roles } = user
firstName = firstName || this.defaultUserValues.firstName firstName = firstName || this.defaultUserValues.firstName
lastName = lastName || this.defaultUserValues.lastName lastName = lastName || this.defaultUserValues.lastName
@ -315,10 +315,7 @@ class TestConfiguration {
roles, roles,
}) })
await cache.user.invalidateUser(globalId) await cache.user.invalidateUser(globalId)
return { return resp
...resp,
globalId,
}
} }
async createGroup(roleId: string = roles.BUILTIN_ROLE_IDS.BASIC) { async createGroup(roleId: string = roles.BUILTIN_ROLE_IDS.BASIC) {