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).toContainEqual(
expect.objectContaining({
_id: db.generateUserMetadataID(user1._id),
_id: db.generateUserMetadataID(user1._id!),
})
)
expect(metadata).toContainEqual(
expect.objectContaining({
_id: db.generateUserMetadataID(user2._id),
_id: db.generateUserMetadataID(user2._id!),
})
)
})
@ -59,7 +59,7 @@ describe("syncGlobalUsers", () => {
expect(metadata).toHaveLength(1)
expect(metadata).not.toContainEqual(
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 user1 = 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 syncGlobalUsers()
@ -87,12 +87,12 @@ describe("syncGlobalUsers", () => {
expect(metadata).toHaveLength(3)
expect(metadata).toContainEqual(
expect.objectContaining({
_id: db.generateUserMetadataID(user1._id),
_id: db.generateUserMetadataID(user1._id!),
})
)
expect(metadata).toContainEqual(
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 },
],
})
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 syncGlobalUsers()

View File

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