Run auto fix.
This commit is contained in:
parent
25c23d5245
commit
1f63f0bddf
|
@ -8,7 +8,7 @@ describe("platformLogout", () => {
|
|||
await testEnv.withTenant(async () => {
|
||||
const ctx = structures.koa.newContext()
|
||||
await auth.platformLogout({ ctx, userId: "test" })
|
||||
expect(events.auth.logout).toBeCalledTimes(1)
|
||||
expect(events.auth.logout).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -239,7 +239,7 @@ describe("docWritethrough", () => {
|
|||
|
||||
await config.doInTenant(async () => {
|
||||
let patches = await parallelPatch(5)
|
||||
expect(queueMessageSpy).toBeCalledTimes(5)
|
||||
expect(queueMessageSpy).toHaveBeenCalledTimes(5)
|
||||
|
||||
await waitForQueueCompletion()
|
||||
expect(await db.get(documentId)).toEqual(
|
||||
|
@ -247,7 +247,7 @@ describe("docWritethrough", () => {
|
|||
)
|
||||
|
||||
patches = { ...patches, ...(await parallelPatch(40)) }
|
||||
expect(queueMessageSpy).toBeCalledTimes(45)
|
||||
expect(queueMessageSpy).toHaveBeenCalledTimes(45)
|
||||
|
||||
await waitForQueueCompletion()
|
||||
expect(await db.get(documentId)).toEqual(
|
||||
|
@ -255,7 +255,7 @@ describe("docWritethrough", () => {
|
|||
)
|
||||
|
||||
patches = { ...patches, ...(await parallelPatch(10)) }
|
||||
expect(queueMessageSpy).toBeCalledTimes(55)
|
||||
expect(queueMessageSpy).toHaveBeenCalledTimes(55)
|
||||
|
||||
await waitForQueueCompletion()
|
||||
expect(await db.get(documentId)).toEqual(
|
||||
|
|
|
@ -55,8 +55,8 @@ describe("user cache", () => {
|
|||
})),
|
||||
})
|
||||
|
||||
expect(UserDB.bulkGet).toBeCalledTimes(1)
|
||||
expect(UserDB.bulkGet).toBeCalledWith(userIdsToRequest)
|
||||
expect(UserDB.bulkGet).toHaveBeenCalledTimes(1)
|
||||
expect(UserDB.bulkGet).toHaveBeenCalledWith(userIdsToRequest)
|
||||
})
|
||||
|
||||
it("on a second all, all of them are retrieved from cache", async () => {
|
||||
|
@ -82,7 +82,7 @@ describe("user cache", () => {
|
|||
),
|
||||
})
|
||||
|
||||
expect(UserDB.bulkGet).toBeCalledTimes(1)
|
||||
expect(UserDB.bulkGet).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("when some users are cached, only the missing ones are retrieved from db", async () => {
|
||||
|
@ -110,8 +110,8 @@ describe("user cache", () => {
|
|||
),
|
||||
})
|
||||
|
||||
expect(UserDB.bulkGet).toBeCalledTimes(1)
|
||||
expect(UserDB.bulkGet).toBeCalledWith([
|
||||
expect(UserDB.bulkGet).toHaveBeenCalledTimes(1)
|
||||
expect(UserDB.bulkGet).toHaveBeenCalledWith([
|
||||
userIdsToRequest[1],
|
||||
userIdsToRequest[2],
|
||||
userIdsToRequest[4],
|
||||
|
|
|
@ -246,7 +246,7 @@ describe("context", () => {
|
|||
context.doInAppMigrationContext(db.generateAppID(), async () => {
|
||||
await otherContextCall()
|
||||
})
|
||||
).rejects.toThrowError(
|
||||
).rejects.toThrow(
|
||||
"The context cannot be changed, a migration is currently running"
|
||||
)
|
||||
}
|
||||
|
|
|
@ -114,11 +114,11 @@ describe("sso", () => {
|
|||
// tenant id added
|
||||
ssoUser.tenantId = context.getTenantId()
|
||||
|
||||
expect(mockSaveUser).toBeCalledWith(ssoUser, {
|
||||
expect(mockSaveUser).toHaveBeenCalledWith(ssoUser, {
|
||||
hashPassword: false,
|
||||
requirePassword: false,
|
||||
})
|
||||
expect(mockDone).toBeCalledWith(null, ssoUser)
|
||||
expect(mockDone).toHaveBeenCalledWith(null, ssoUser)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -159,11 +159,11 @@ describe("sso", () => {
|
|||
// existing id preserved
|
||||
ssoUser._id = existingUser._id
|
||||
|
||||
expect(mockSaveUser).toBeCalledWith(ssoUser, {
|
||||
expect(mockSaveUser).toHaveBeenCalledWith(ssoUser, {
|
||||
hashPassword: false,
|
||||
requirePassword: false,
|
||||
})
|
||||
expect(mockDone).toBeCalledWith(null, ssoUser)
|
||||
expect(mockDone).toHaveBeenCalledWith(null, ssoUser)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -187,11 +187,11 @@ describe("sso", () => {
|
|||
// existing id preserved
|
||||
ssoUser._id = existingUser._id
|
||||
|
||||
expect(mockSaveUser).toBeCalledWith(ssoUser, {
|
||||
expect(mockSaveUser).toHaveBeenCalledWith(ssoUser, {
|
||||
hashPassword: false,
|
||||
requirePassword: false,
|
||||
})
|
||||
expect(mockDone).toBeCalledWith(null, ssoUser)
|
||||
expect(mockDone).toHaveBeenCalledWith(null, ssoUser)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -24,13 +24,13 @@ function buildUserCtx(user: ContextUser) {
|
|||
}
|
||||
|
||||
function passed(throwFn: jest.Func, nextFn: jest.Func) {
|
||||
expect(throwFn).not.toBeCalled()
|
||||
expect(nextFn).toBeCalled()
|
||||
expect(throwFn).not.toHaveBeenCalled()
|
||||
expect(nextFn).toHaveBeenCalled()
|
||||
}
|
||||
|
||||
function threw(throwFn: jest.Func) {
|
||||
// cant check next, the throw function doesn't actually throw - so it still continues
|
||||
expect(throwFn).toBeCalled()
|
||||
expect(throwFn).toHaveBeenCalled()
|
||||
}
|
||||
|
||||
describe("adminOnly middleware", () => {
|
||||
|
|
|
@ -184,7 +184,7 @@ describe("redis", () => {
|
|||
const key = structures.uuid()
|
||||
await redis.store(key, value)
|
||||
|
||||
await expect(redis.increment(key)).rejects.toThrowError(
|
||||
await expect(redis.increment(key)).rejects.toThrow(
|
||||
"ERR value is not an integer or out of range"
|
||||
)
|
||||
})
|
||||
|
|
|
@ -96,7 +96,7 @@ describe("redlockImpl", () => {
|
|||
task: mockTask,
|
||||
executionTimeMs: lockTtl * 2,
|
||||
})
|
||||
).rejects.toThrowError(
|
||||
).rejects.toThrow(
|
||||
`Unable to fully release the lock on resource \"lock:${config.tenantId}_persist_writethrough\".`
|
||||
)
|
||||
}
|
||||
|
|
|
@ -158,8 +158,8 @@ describe("getTenantIDFromCtx", () => {
|
|||
],
|
||||
}
|
||||
expect(getTenantIDFromCtx(ctx, mockOpts)).toBeUndefined()
|
||||
expect(ctx.throw).toBeCalledTimes(1)
|
||||
expect(ctx.throw).toBeCalledWith(403, "Tenant id not set")
|
||||
expect(ctx.throw).toHaveBeenCalledTimes(1)
|
||||
expect(ctx.throw).toHaveBeenCalledWith(403, "Tenant id not set")
|
||||
})
|
||||
|
||||
it("returns undefined if allowNoTenant is true", () => {
|
||||
|
|
|
@ -128,7 +128,7 @@ describe("/applications", () => {
|
|||
it("creates empty app", async () => {
|
||||
const app = await config.api.application.create({ name: utils.newid() })
|
||||
expect(app._id).toBeDefined()
|
||||
expect(events.app.created).toBeCalledTimes(1)
|
||||
expect(events.app.created).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("creates app from template", async () => {
|
||||
|
@ -139,8 +139,8 @@ describe("/applications", () => {
|
|||
templateString: "{}",
|
||||
})
|
||||
expect(app._id).toBeDefined()
|
||||
expect(events.app.created).toBeCalledTimes(1)
|
||||
expect(events.app.templateImported).toBeCalledTimes(1)
|
||||
expect(events.app.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.app.templateImported).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("creates app from file", async () => {
|
||||
|
@ -150,8 +150,8 @@ describe("/applications", () => {
|
|||
templateFile: "src/api/routes/tests/data/export.txt",
|
||||
})
|
||||
expect(app._id).toBeDefined()
|
||||
expect(events.app.created).toBeCalledTimes(1)
|
||||
expect(events.app.fileImported).toBeCalledTimes(1)
|
||||
expect(events.app.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.app.fileImported).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should apply authorization to endpoint", async () => {
|
||||
|
@ -181,8 +181,8 @@ describe("/applications", () => {
|
|||
expect(app.navigation!.navTextColor).toBe(
|
||||
"var(--spectrum-global-color-gray-50)"
|
||||
)
|
||||
expect(events.app.created).toBeCalledTimes(1)
|
||||
expect(events.app.fileImported).toBeCalledTimes(1)
|
||||
expect(events.app.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.app.fileImported).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should reject with a known name", async () => {
|
||||
|
@ -228,32 +228,32 @@ describe("/applications", () => {
|
|||
name: "TEST_APP",
|
||||
})
|
||||
expect(updatedApp._rev).toBeDefined()
|
||||
expect(events.app.updated).toBeCalledTimes(1)
|
||||
expect(events.app.updated).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe("publish", () => {
|
||||
it("should publish app with dev app ID", async () => {
|
||||
await config.api.application.publish(app.appId)
|
||||
expect(events.app.published).toBeCalledTimes(1)
|
||||
expect(events.app.published).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should publish app with prod app ID", async () => {
|
||||
await config.api.application.publish(app.appId.replace("_dev", ""))
|
||||
expect(events.app.published).toBeCalledTimes(1)
|
||||
expect(events.app.published).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe("manage client library version", () => {
|
||||
it("should be able to update the app client library version", async () => {
|
||||
await config.api.application.updateClient(app.appId)
|
||||
expect(events.app.versionUpdated).toBeCalledTimes(1)
|
||||
expect(events.app.versionUpdated).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should be able to revert the app client library version", async () => {
|
||||
await config.api.application.updateClient(app.appId)
|
||||
await config.api.application.revertClient(app.appId)
|
||||
expect(events.app.versionReverted).toBeCalledTimes(1)
|
||||
expect(events.app.versionReverted).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -310,26 +310,26 @@ describe("/applications", () => {
|
|||
describe("unpublish", () => {
|
||||
it("should unpublish app with dev app ID", async () => {
|
||||
await config.api.application.unpublish(app.appId)
|
||||
expect(events.app.unpublished).toBeCalledTimes(1)
|
||||
expect(events.app.unpublished).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should unpublish app with prod app ID", async () => {
|
||||
await config.api.application.unpublish(app.appId.replace("_dev", ""))
|
||||
expect(events.app.unpublished).toBeCalledTimes(1)
|
||||
expect(events.app.unpublished).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe("delete", () => {
|
||||
it("should delete published app and dev apps with dev app ID", async () => {
|
||||
await config.api.application.delete(app.appId)
|
||||
expect(events.app.deleted).toBeCalledTimes(1)
|
||||
expect(events.app.unpublished).toBeCalledTimes(1)
|
||||
expect(events.app.deleted).toHaveBeenCalledTimes(1)
|
||||
expect(events.app.unpublished).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should delete published app and dev app with prod app ID", async () => {
|
||||
await config.api.application.delete(app.appId.replace("_dev", ""))
|
||||
expect(events.app.deleted).toBeCalledTimes(1)
|
||||
expect(events.app.unpublished).toBeCalledTimes(1)
|
||||
expect(events.app.deleted).toHaveBeenCalledTimes(1)
|
||||
expect(events.app.unpublished).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -346,7 +346,7 @@ describe("/applications", () => {
|
|||
}
|
||||
)
|
||||
|
||||
expect(events.app.duplicated).toBeCalled()
|
||||
expect(events.app.duplicated).toHaveBeenCalled()
|
||||
expect(resp.duplicateAppId).toBeDefined()
|
||||
expect(resp.sourceAppId).toEqual(app.appId)
|
||||
expect(resp.duplicateAppId).not.toEqual(app.appId)
|
||||
|
@ -374,7 +374,7 @@ describe("/applications", () => {
|
|||
},
|
||||
{ body: { message: "App name is already in use." }, status: 400 }
|
||||
)
|
||||
expect(events.app.duplicated).not.toBeCalled()
|
||||
expect(events.app.duplicated).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should reject with a known url", async () => {
|
||||
|
@ -386,7 +386,7 @@ describe("/applications", () => {
|
|||
},
|
||||
{ body: { message: "App URL is already in use." }, status: 400 }
|
||||
)
|
||||
expect(events.app.duplicated).not.toBeCalled()
|
||||
expect(events.app.duplicated).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -95,8 +95,8 @@ describe("/automations", () => {
|
|||
expect(res.body.message).toEqual("Automation created successfully")
|
||||
expect(res.body.automation.name).toEqual("My Automation")
|
||||
expect(res.body.automation._id).not.toEqual(null)
|
||||
expect(events.automation.created).toBeCalledTimes(1)
|
||||
expect(events.automation.stepCreated).not.toBeCalled()
|
||||
expect(events.automation.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.automation.stepCreated).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("creates an automation with steps", async () => {
|
||||
|
@ -114,8 +114,8 @@ describe("/automations", () => {
|
|||
expect(res.body.message).toEqual("Automation created successfully")
|
||||
expect(res.body.automation.name).toEqual("My Automation")
|
||||
expect(res.body.automation._id).not.toEqual(null)
|
||||
expect(events.automation.created).toBeCalledTimes(1)
|
||||
expect(events.automation.stepCreated).toBeCalledTimes(2)
|
||||
expect(events.automation.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.automation.stepCreated).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it("should apply authorization to endpoint", async () => {
|
||||
|
@ -158,7 +158,7 @@ describe("/automations", () => {
|
|||
automation = await config.createAutomation(automation)
|
||||
await setup.delay(500)
|
||||
const res = await testAutomation(config, automation)
|
||||
expect(events.automation.tested).toBeCalledTimes(1)
|
||||
expect(events.automation.tested).toHaveBeenCalledTimes(1)
|
||||
// this looks a bit mad but we don't actually have a way to wait for a response from the automation to
|
||||
// know that it has finished all of its actions - this is currently the best way
|
||||
// also when this runs in CI it is very temper-mental so for now trying to make run stable by repeating until it works
|
||||
|
@ -265,10 +265,10 @@ describe("/automations", () => {
|
|||
`Automation ${automation._id} updated successfully.`
|
||||
)
|
||||
// events
|
||||
expect(events.automation.created).not.toBeCalled()
|
||||
expect(events.automation.stepCreated).not.toBeCalled()
|
||||
expect(events.automation.stepDeleted).not.toBeCalled()
|
||||
expect(events.automation.triggerUpdated).not.toBeCalled()
|
||||
expect(events.automation.created).not.toHaveBeenCalled()
|
||||
expect(events.automation.stepCreated).not.toHaveBeenCalled()
|
||||
expect(events.automation.stepDeleted).not.toHaveBeenCalled()
|
||||
expect(events.automation.triggerUpdated).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("updates a automations name using POST request", async () => {
|
||||
|
@ -293,10 +293,10 @@ describe("/automations", () => {
|
|||
`Automation ${automation._id} updated successfully.`
|
||||
)
|
||||
// events
|
||||
expect(events.automation.created).not.toBeCalled()
|
||||
expect(events.automation.stepCreated).not.toBeCalled()
|
||||
expect(events.automation.stepDeleted).not.toBeCalled()
|
||||
expect(events.automation.triggerUpdated).not.toBeCalled()
|
||||
expect(events.automation.created).not.toHaveBeenCalled()
|
||||
expect(events.automation.stepCreated).not.toHaveBeenCalled()
|
||||
expect(events.automation.stepDeleted).not.toHaveBeenCalled()
|
||||
expect(events.automation.triggerUpdated).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("updates an automation trigger", async () => {
|
||||
|
@ -310,10 +310,10 @@ describe("/automations", () => {
|
|||
await update(automation)
|
||||
|
||||
// events
|
||||
expect(events.automation.created).not.toBeCalled()
|
||||
expect(events.automation.stepCreated).not.toBeCalled()
|
||||
expect(events.automation.stepDeleted).not.toBeCalled()
|
||||
expect(events.automation.triggerUpdated).toBeCalledTimes(1)
|
||||
expect(events.automation.created).not.toHaveBeenCalled()
|
||||
expect(events.automation.stepCreated).not.toHaveBeenCalled()
|
||||
expect(events.automation.stepDeleted).not.toHaveBeenCalled()
|
||||
expect(events.automation.triggerUpdated).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("adds automation steps", async () => {
|
||||
|
@ -327,10 +327,10 @@ describe("/automations", () => {
|
|||
await update(automation)
|
||||
|
||||
// events
|
||||
expect(events.automation.stepCreated).toBeCalledTimes(2)
|
||||
expect(events.automation.created).not.toBeCalled()
|
||||
expect(events.automation.stepDeleted).not.toBeCalled()
|
||||
expect(events.automation.triggerUpdated).not.toBeCalled()
|
||||
expect(events.automation.stepCreated).toHaveBeenCalledTimes(2)
|
||||
expect(events.automation.created).not.toHaveBeenCalled()
|
||||
expect(events.automation.stepDeleted).not.toHaveBeenCalled()
|
||||
expect(events.automation.triggerUpdated).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("removes automation steps", async () => {
|
||||
|
@ -344,10 +344,10 @@ describe("/automations", () => {
|
|||
await update(automation)
|
||||
|
||||
// events
|
||||
expect(events.automation.stepDeleted).toBeCalledTimes(2)
|
||||
expect(events.automation.stepCreated).not.toBeCalled()
|
||||
expect(events.automation.created).not.toBeCalled()
|
||||
expect(events.automation.triggerUpdated).not.toBeCalled()
|
||||
expect(events.automation.stepDeleted).toHaveBeenCalledTimes(2)
|
||||
expect(events.automation.stepCreated).not.toHaveBeenCalled()
|
||||
expect(events.automation.created).not.toHaveBeenCalled()
|
||||
expect(events.automation.triggerUpdated).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("adds and removes automation steps", async () => {
|
||||
|
@ -360,10 +360,10 @@ describe("/automations", () => {
|
|||
await update(automation)
|
||||
|
||||
// events
|
||||
expect(events.automation.stepCreated).toBeCalledTimes(2)
|
||||
expect(events.automation.stepDeleted).toBeCalledTimes(1)
|
||||
expect(events.automation.created).not.toBeCalled()
|
||||
expect(events.automation.triggerUpdated).not.toBeCalled()
|
||||
expect(events.automation.stepCreated).toHaveBeenCalledTimes(2)
|
||||
expect(events.automation.stepDeleted).toHaveBeenCalledTimes(1)
|
||||
expect(events.automation.created).not.toHaveBeenCalled()
|
||||
expect(events.automation.triggerUpdated).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -400,7 +400,7 @@ describe("/automations", () => {
|
|||
.expect(200)
|
||||
|
||||
expect(res.body.id).toEqual(automation._id)
|
||||
expect(events.automation.deleted).toBeCalledTimes(1)
|
||||
expect(events.automation.deleted).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should apply authorization to endpoint", async () => {
|
||||
|
|
|
@ -21,7 +21,7 @@ describe("/backups", () => {
|
|||
it("should be able to export app", async () => {
|
||||
const body = await config.api.backup.exportBasicBackup(config.getAppId()!)
|
||||
expect(body instanceof Buffer).toBe(true)
|
||||
expect(events.app.exported).toBeCalledTimes(1)
|
||||
expect(events.app.exported).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should apply authorization to endpoint", async () => {
|
||||
|
|
|
@ -40,7 +40,7 @@ describe("/datasources", () => {
|
|||
|
||||
expect(res.body.datasource.name).toEqual("Test")
|
||||
expect(res.body.errors).toEqual({})
|
||||
expect(events.datasource.created).toBeCalledTimes(1)
|
||||
expect(events.datasource.created).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -56,7 +56,7 @@ describe("/datasources", () => {
|
|||
|
||||
expect(res.body.datasource.name).toEqual("Updated Test")
|
||||
expect(res.body.errors).toBeUndefined()
|
||||
expect(events.datasource.updated).toBeCalledTimes(1)
|
||||
expect(events.datasource.updated).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
describe("dynamic variables", () => {
|
||||
|
@ -196,7 +196,7 @@ describe("/datasources", () => {
|
|||
.expect(200)
|
||||
|
||||
expect(res.body.length).toEqual(1)
|
||||
expect(events.datasource.deleted).toBeCalledTimes(1)
|
||||
expect(events.datasource.deleted).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should apply authorization to endpoint", async () => {
|
||||
|
|
|
@ -138,10 +138,10 @@ describe("/api/env/variables", () => {
|
|||
.expect("Content-Type", /json/)
|
||||
.expect(200)
|
||||
expect(res.body.rows.length).toEqual(0)
|
||||
expect(events.query.previewed).toBeCalledTimes(1)
|
||||
expect(events.query.previewed).toHaveBeenCalledTimes(1)
|
||||
// API doesn't include config in response
|
||||
delete response.body.datasource.config
|
||||
expect(events.query.previewed).toBeCalledWith(
|
||||
expect(events.query.previewed).toHaveBeenCalledWith(
|
||||
response.body.datasource,
|
||||
queryPreview
|
||||
)
|
||||
|
|
|
@ -81,8 +81,8 @@ describe("/queries", () => {
|
|||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
})
|
||||
expect(events.query.created).toBeCalledTimes(1)
|
||||
expect(events.query.updated).not.toBeCalled()
|
||||
expect(events.query.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.query.updated).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -106,8 +106,8 @@ describe("/queries", () => {
|
|||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
})
|
||||
expect(events.query.created).not.toBeCalled()
|
||||
expect(events.query.updated).toBeCalledTimes(1)
|
||||
expect(events.query.created).not.toHaveBeenCalled()
|
||||
expect(events.query.updated).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -210,8 +210,8 @@ describe("/queries", () => {
|
|||
.expect(200)
|
||||
|
||||
expect(res.body).toEqual([])
|
||||
expect(events.query.deleted).toBeCalledTimes(1)
|
||||
expect(events.query.deleted).toBeCalledWith(datasource, query)
|
||||
expect(events.query.deleted).toHaveBeenCalledTimes(1)
|
||||
expect(events.query.deleted).toHaveBeenCalledWith(datasource, query)
|
||||
})
|
||||
|
||||
it("should apply authorization to endpoint", async () => {
|
||||
|
@ -243,9 +243,9 @@ describe("/queries", () => {
|
|||
b: { type: "number", name: "b" },
|
||||
})
|
||||
expect(responseBody.rows.length).toEqual(1)
|
||||
expect(events.query.previewed).toBeCalledTimes(1)
|
||||
expect(events.query.previewed).toHaveBeenCalledTimes(1)
|
||||
delete datasource.config
|
||||
expect(events.query.previewed).toBeCalledWith(datasource, queryPreview)
|
||||
expect(events.query.previewed).toHaveBeenCalledWith(datasource, queryPreview)
|
||||
})
|
||||
|
||||
it("should apply authorization to endpoint", async () => {
|
||||
|
|
|
@ -64,8 +64,8 @@ describe("/tables", () => {
|
|||
"Table TestTable saved successfully."
|
||||
)
|
||||
expect(res.body.name).toEqual("TestTable")
|
||||
expect(events.table.created).toBeCalledTimes(1)
|
||||
expect(events.table.created).toBeCalledWith(res.body)
|
||||
expect(events.table.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.table.created).toHaveBeenCalledWith(res.body)
|
||||
})
|
||||
|
||||
it("creates all the passed fields", async () => {
|
||||
|
@ -135,12 +135,12 @@ describe("/tables", () => {
|
|||
|
||||
const res = await createTable(table)
|
||||
|
||||
expect(events.table.created).toBeCalledTimes(1)
|
||||
expect(events.table.created).toBeCalledWith(res.body)
|
||||
expect(events.table.imported).toBeCalledTimes(1)
|
||||
expect(events.table.imported).toBeCalledWith(res.body)
|
||||
expect(events.rows.imported).toBeCalledTimes(1)
|
||||
expect(events.rows.imported).toBeCalledWith(res.body, 1)
|
||||
expect(events.table.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.table.created).toHaveBeenCalledWith(res.body)
|
||||
expect(events.table.imported).toHaveBeenCalledTimes(1)
|
||||
expect(events.table.imported).toHaveBeenCalledWith(res.body)
|
||||
expect(events.rows.imported).toHaveBeenCalledTimes(1)
|
||||
expect(events.rows.imported).toHaveBeenCalledWith(res.body, 1)
|
||||
})
|
||||
|
||||
it("should apply authorization to endpoint", async () => {
|
||||
|
@ -164,8 +164,8 @@ describe("/tables", () => {
|
|||
.expect("Content-Type", /json/)
|
||||
.expect(200)
|
||||
|
||||
expect(events.table.updated).toBeCalledTimes(1)
|
||||
expect(events.table.updated).toBeCalledWith(res.body)
|
||||
expect(events.table.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.table.updated).toHaveBeenCalledWith(res.body)
|
||||
})
|
||||
|
||||
it("updates all the row fields for a table when a schema key is renamed", async () => {
|
||||
|
@ -335,8 +335,8 @@ describe("/tables", () => {
|
|||
.expect(200)
|
||||
|
||||
expect(events.table.created).not.toHaveBeenCalled()
|
||||
expect(events.rows.imported).toBeCalledTimes(1)
|
||||
expect(events.rows.imported).toBeCalledWith(
|
||||
expect(events.rows.imported).toHaveBeenCalledTimes(1)
|
||||
expect(events.rows.imported).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
name: "TestTable",
|
||||
_id: table._id,
|
||||
|
@ -527,8 +527,8 @@ describe("/tables", () => {
|
|||
.expect("Content-Type", /json/)
|
||||
.expect(200)
|
||||
expect(res.body.message).toEqual(`Table ${testTable._id} deleted.`)
|
||||
expect(events.table.deleted).toBeCalledTimes(1)
|
||||
expect(events.table.deleted).toBeCalledWith({
|
||||
expect(events.table.deleted).toHaveBeenCalledTimes(1)
|
||||
expect(events.table.deleted).toHaveBeenCalledWith({
|
||||
...testTable,
|
||||
tableId: testTable._id,
|
||||
})
|
||||
|
|
|
@ -75,7 +75,7 @@ describe("/views", () => {
|
|||
describe("create", () => {
|
||||
it("returns a success message when the view is successfully created", async () => {
|
||||
const res = await saveView()
|
||||
expect(events.view.created).toBeCalledTimes(1)
|
||||
expect(events.view.created).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("creates a view with a calculation", async () => {
|
||||
|
@ -84,14 +84,14 @@ describe("/views", () => {
|
|||
const view = await saveView({ calculation: ViewCalculation.COUNT })
|
||||
|
||||
expect(view.tableId).toBe(table._id)
|
||||
expect(events.view.created).toBeCalledTimes(1)
|
||||
expect(events.view.updated).not.toBeCalled()
|
||||
expect(events.view.calculationCreated).toBeCalledTimes(1)
|
||||
expect(events.view.calculationUpdated).not.toBeCalled()
|
||||
expect(events.view.calculationDeleted).not.toBeCalled()
|
||||
expect(events.view.filterCreated).not.toBeCalled()
|
||||
expect(events.view.filterUpdated).not.toBeCalled()
|
||||
expect(events.view.filterDeleted).not.toBeCalled()
|
||||
expect(events.view.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.view.updated).not.toHaveBeenCalled()
|
||||
expect(events.view.calculationCreated).toHaveBeenCalledTimes(1)
|
||||
expect(events.view.calculationUpdated).not.toHaveBeenCalled()
|
||||
expect(events.view.calculationDeleted).not.toHaveBeenCalled()
|
||||
expect(events.view.filterCreated).not.toHaveBeenCalled()
|
||||
expect(events.view.filterUpdated).not.toHaveBeenCalled()
|
||||
expect(events.view.filterDeleted).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("creates a view with a filter", async () => {
|
||||
|
@ -109,14 +109,14 @@ describe("/views", () => {
|
|||
})
|
||||
|
||||
expect(view.tableId).toBe(table._id)
|
||||
expect(events.view.created).toBeCalledTimes(1)
|
||||
expect(events.view.updated).not.toBeCalled()
|
||||
expect(events.view.calculationCreated).not.toBeCalled()
|
||||
expect(events.view.calculationUpdated).not.toBeCalled()
|
||||
expect(events.view.calculationDeleted).not.toBeCalled()
|
||||
expect(events.view.filterCreated).toBeCalledTimes(1)
|
||||
expect(events.view.filterUpdated).not.toBeCalled()
|
||||
expect(events.view.filterDeleted).not.toBeCalled()
|
||||
expect(events.view.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.view.updated).not.toHaveBeenCalled()
|
||||
expect(events.view.calculationCreated).not.toHaveBeenCalled()
|
||||
expect(events.view.calculationUpdated).not.toHaveBeenCalled()
|
||||
expect(events.view.calculationDeleted).not.toHaveBeenCalled()
|
||||
expect(events.view.filterCreated).toHaveBeenCalledTimes(1)
|
||||
expect(events.view.filterUpdated).not.toHaveBeenCalled()
|
||||
expect(events.view.filterDeleted).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("updates the table row with the new view metadata", async () => {
|
||||
|
@ -165,14 +165,14 @@ describe("/views", () => {
|
|||
|
||||
await saveView()
|
||||
|
||||
expect(events.view.created).not.toBeCalled()
|
||||
expect(events.view.updated).toBeCalledTimes(1)
|
||||
expect(events.view.calculationCreated).not.toBeCalled()
|
||||
expect(events.view.calculationUpdated).not.toBeCalled()
|
||||
expect(events.view.calculationDeleted).not.toBeCalled()
|
||||
expect(events.view.filterCreated).not.toBeCalled()
|
||||
expect(events.view.filterUpdated).not.toBeCalled()
|
||||
expect(events.view.filterDeleted).not.toBeCalled()
|
||||
expect(events.view.created).not.toHaveBeenCalled()
|
||||
expect(events.view.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.view.calculationCreated).not.toHaveBeenCalled()
|
||||
expect(events.view.calculationUpdated).not.toHaveBeenCalled()
|
||||
expect(events.view.calculationDeleted).not.toHaveBeenCalled()
|
||||
expect(events.view.filterCreated).not.toHaveBeenCalled()
|
||||
expect(events.view.filterUpdated).not.toHaveBeenCalled()
|
||||
expect(events.view.filterDeleted).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("updates a view calculation", async () => {
|
||||
|
@ -181,14 +181,14 @@ describe("/views", () => {
|
|||
|
||||
await saveView({ calculation: ViewCalculation.COUNT })
|
||||
|
||||
expect(events.view.created).not.toBeCalled()
|
||||
expect(events.view.updated).toBeCalledTimes(1)
|
||||
expect(events.view.calculationCreated).not.toBeCalled()
|
||||
expect(events.view.calculationUpdated).toBeCalledTimes(1)
|
||||
expect(events.view.calculationDeleted).not.toBeCalled()
|
||||
expect(events.view.filterCreated).not.toBeCalled()
|
||||
expect(events.view.filterUpdated).not.toBeCalled()
|
||||
expect(events.view.filterDeleted).not.toBeCalled()
|
||||
expect(events.view.created).not.toHaveBeenCalled()
|
||||
expect(events.view.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.view.calculationCreated).not.toHaveBeenCalled()
|
||||
expect(events.view.calculationUpdated).toHaveBeenCalledTimes(1)
|
||||
expect(events.view.calculationDeleted).not.toHaveBeenCalled()
|
||||
expect(events.view.filterCreated).not.toHaveBeenCalled()
|
||||
expect(events.view.filterUpdated).not.toHaveBeenCalled()
|
||||
expect(events.view.filterDeleted).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("deletes a view calculation", async () => {
|
||||
|
@ -197,14 +197,14 @@ describe("/views", () => {
|
|||
|
||||
await saveView({ calculation: undefined })
|
||||
|
||||
expect(events.view.created).not.toBeCalled()
|
||||
expect(events.view.updated).toBeCalledTimes(1)
|
||||
expect(events.view.calculationCreated).not.toBeCalled()
|
||||
expect(events.view.calculationUpdated).not.toBeCalled()
|
||||
expect(events.view.calculationDeleted).toBeCalledTimes(1)
|
||||
expect(events.view.filterCreated).not.toBeCalled()
|
||||
expect(events.view.filterUpdated).not.toBeCalled()
|
||||
expect(events.view.filterDeleted).not.toBeCalled()
|
||||
expect(events.view.created).not.toHaveBeenCalled()
|
||||
expect(events.view.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.view.calculationCreated).not.toHaveBeenCalled()
|
||||
expect(events.view.calculationUpdated).not.toHaveBeenCalled()
|
||||
expect(events.view.calculationDeleted).toHaveBeenCalledTimes(1)
|
||||
expect(events.view.filterCreated).not.toHaveBeenCalled()
|
||||
expect(events.view.filterUpdated).not.toHaveBeenCalled()
|
||||
expect(events.view.filterDeleted).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("updates a view filter", async () => {
|
||||
|
@ -229,14 +229,14 @@ describe("/views", () => {
|
|||
],
|
||||
})
|
||||
|
||||
expect(events.view.created).not.toBeCalled()
|
||||
expect(events.view.updated).toBeCalledTimes(1)
|
||||
expect(events.view.calculationCreated).not.toBeCalled()
|
||||
expect(events.view.calculationUpdated).not.toBeCalled()
|
||||
expect(events.view.calculationDeleted).not.toBeCalled()
|
||||
expect(events.view.filterCreated).not.toBeCalled()
|
||||
expect(events.view.filterUpdated).toBeCalledTimes(1)
|
||||
expect(events.view.filterDeleted).not.toBeCalled()
|
||||
expect(events.view.created).not.toHaveBeenCalled()
|
||||
expect(events.view.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.view.calculationCreated).not.toHaveBeenCalled()
|
||||
expect(events.view.calculationUpdated).not.toHaveBeenCalled()
|
||||
expect(events.view.calculationDeleted).not.toHaveBeenCalled()
|
||||
expect(events.view.filterCreated).not.toHaveBeenCalled()
|
||||
expect(events.view.filterUpdated).toHaveBeenCalledTimes(1)
|
||||
expect(events.view.filterDeleted).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("deletes a view filter", async () => {
|
||||
|
@ -253,14 +253,14 @@ describe("/views", () => {
|
|||
|
||||
await saveView({ filters: [] })
|
||||
|
||||
expect(events.view.created).not.toBeCalled()
|
||||
expect(events.view.updated).toBeCalledTimes(1)
|
||||
expect(events.view.calculationCreated).not.toBeCalled()
|
||||
expect(events.view.calculationUpdated).not.toBeCalled()
|
||||
expect(events.view.calculationDeleted).not.toBeCalled()
|
||||
expect(events.view.filterCreated).not.toBeCalled()
|
||||
expect(events.view.filterUpdated).not.toBeCalled()
|
||||
expect(events.view.filterDeleted).toBeCalledTimes(1)
|
||||
expect(events.view.created).not.toHaveBeenCalled()
|
||||
expect(events.view.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.view.calculationCreated).not.toHaveBeenCalled()
|
||||
expect(events.view.calculationUpdated).not.toHaveBeenCalled()
|
||||
expect(events.view.calculationDeleted).not.toHaveBeenCalled()
|
||||
expect(events.view.filterCreated).not.toHaveBeenCalled()
|
||||
expect(events.view.filterUpdated).not.toHaveBeenCalled()
|
||||
expect(events.view.filterDeleted).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -393,7 +393,7 @@ describe("/views", () => {
|
|||
const deletedView = await config.api.legacyView.destroy(view.name!)
|
||||
expect(deletedView.map).toBeDefined()
|
||||
expect(deletedView.meta?.tableId).toEqual(table._id)
|
||||
expect(events.view.deleted).toBeCalledTimes(1)
|
||||
expect(events.view.deleted).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -443,8 +443,8 @@ describe("/views", () => {
|
|||
const res = await config.api.legacyView.export(table._id!, "json")
|
||||
|
||||
assertJsonExport(res)
|
||||
expect(events.table.exported).toBeCalledTimes(1)
|
||||
expect(events.table.exported).toBeCalledWith(table, "json")
|
||||
expect(events.table.exported).toHaveBeenCalledTimes(1)
|
||||
expect(events.table.exported).toHaveBeenCalledWith(table, "json")
|
||||
})
|
||||
|
||||
it("should be able to export a table as CSV", async () => {
|
||||
|
@ -453,8 +453,8 @@ describe("/views", () => {
|
|||
const res = await config.api.legacyView.export(table._id!, "csv")
|
||||
|
||||
assertCSVExport(res)
|
||||
expect(events.table.exported).toBeCalledTimes(1)
|
||||
expect(events.table.exported).toBeCalledWith(table, "csv")
|
||||
expect(events.table.exported).toHaveBeenCalledTimes(1)
|
||||
expect(events.table.exported).toHaveBeenCalledWith(table, "csv")
|
||||
})
|
||||
|
||||
it("should be able to export a view as JSON", async () => {
|
||||
|
@ -470,8 +470,8 @@ describe("/views", () => {
|
|||
let res = await config.api.legacyView.export(view.name!, "json")
|
||||
|
||||
assertJsonExport(res)
|
||||
expect(events.view.exported).toBeCalledTimes(1)
|
||||
expect(events.view.exported).toBeCalledWith(table, "json")
|
||||
expect(events.view.exported).toHaveBeenCalledTimes(1)
|
||||
expect(events.view.exported).toHaveBeenCalledWith(table, "json")
|
||||
})
|
||||
|
||||
it("should be able to export a view as CSV", async () => {
|
||||
|
@ -487,8 +487,8 @@ describe("/views", () => {
|
|||
let res = await config.api.legacyView.export(view.name!, "csv")
|
||||
|
||||
assertCSVExport(res)
|
||||
expect(events.view.exported).toBeCalledTimes(1)
|
||||
expect(events.view.exported).toBeCalledWith(table, "csv")
|
||||
expect(events.view.exported).toHaveBeenCalledTimes(1)
|
||||
expect(events.view.exported).toHaveBeenCalledWith(table, "csv")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -140,7 +140,7 @@ describe("/webhooks", () => {
|
|||
})
|
||||
})
|
||||
|
||||
it("should trigger a synchronous webhook call ", async () => {
|
||||
it("should trigger a synchronous webhook call", async () => {
|
||||
mocks.licenses.useSyncAutomations()
|
||||
let automation = collectAutomation()
|
||||
let newAutomation = await config.createAutomation(automation)
|
||||
|
|
|
@ -45,7 +45,7 @@ describe("migrationsProcessor", () => {
|
|||
|
||||
await expect(
|
||||
config.doInContext(appId, () => processMigrations(appId, testMigrations))
|
||||
).rejects.toThrowError(
|
||||
).rejects.toThrow(
|
||||
"The context cannot be changed, a migration is currently running"
|
||||
)
|
||||
})
|
||||
|
|
|
@ -306,7 +306,7 @@ describe("mysql integrations", () => {
|
|||
}
|
||||
delete expectedTable._add
|
||||
|
||||
expect(emitDatasourceUpdateMock).toBeCalledTimes(1)
|
||||
expect(emitDatasourceUpdateMock).toHaveBeenCalledTimes(1)
|
||||
const emittedDatasource: Datasource =
|
||||
emitDatasourceUpdateMock.mock.calls[0][1]
|
||||
expect(emittedDatasource.entities!["table"]).toEqual(expectedTable)
|
||||
|
|
|
@ -109,9 +109,9 @@ describe("Google Sheets Integration", () => {
|
|||
sheetsByTitle[table.name] = sheet
|
||||
await integration.updateTable(table)
|
||||
|
||||
expect(sheet.loadHeaderRow).toBeCalledTimes(1)
|
||||
expect(sheet.setHeaderRow).toBeCalledTimes(1)
|
||||
expect(sheet.setHeaderRow).toBeCalledWith(tableColumns)
|
||||
expect(sheet.loadHeaderRow).toHaveBeenCalledTimes(1)
|
||||
expect(sheet.setHeaderRow).toHaveBeenCalledTimes(1)
|
||||
expect(sheet.setHeaderRow).toHaveBeenCalledWith(tableColumns)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -127,9 +127,9 @@ describe("Google Sheets Integration", () => {
|
|||
await integration.updateTable(table)
|
||||
return sheet
|
||||
})
|
||||
expect(sheet.loadHeaderRow).toBeCalledTimes(1)
|
||||
expect(sheet.setHeaderRow).toBeCalledTimes(1)
|
||||
expect(sheet.setHeaderRow).toBeCalledWith(["name"])
|
||||
expect(sheet.loadHeaderRow).toHaveBeenCalledTimes(1)
|
||||
expect(sheet.setHeaderRow).toHaveBeenCalledTimes(1)
|
||||
expect(sheet.setHeaderRow).toHaveBeenCalledWith(["name"])
|
||||
|
||||
// No undefined are sent
|
||||
expect((sheet.setHeaderRow as any).mock.calls[0][0]).toHaveLength(1)
|
||||
|
@ -148,7 +148,7 @@ describe("Google Sheets Integration", () => {
|
|||
|
||||
const res = await integration.getTableNames()
|
||||
|
||||
expect(mockGoogleIntegration.loadInfo).toBeCalledTimes(1)
|
||||
expect(mockGoogleIntegration.loadInfo).toHaveBeenCalledTimes(1)
|
||||
expect(res).toEqual(sheetNames)
|
||||
})
|
||||
})
|
||||
|
@ -159,7 +159,7 @@ describe("Google Sheets Integration", () => {
|
|||
await config.doInContext(structures.uuid(), async () => {
|
||||
const res = await integration.testConnection()
|
||||
|
||||
expect(mockGoogleIntegration.loadInfo).toBeCalledTimes(1)
|
||||
expect(mockGoogleIntegration.loadInfo).toHaveBeenCalledTimes(1)
|
||||
expect(res).toEqual({ connected: true })
|
||||
})
|
||||
})
|
||||
|
|
|
@ -76,7 +76,7 @@ describe("MySQL Integration", () => {
|
|||
})
|
||||
|
||||
describe("binding type coerce", () => {
|
||||
it("ignores non-string types ", async () => {
|
||||
it("ignores non-string types", async () => {
|
||||
const sql = "select * from users;"
|
||||
const date = new Date()
|
||||
await config.integration.read({
|
||||
|
|
|
@ -79,7 +79,7 @@ describe("S3 Integration", () => {
|
|||
})
|
||||
})
|
||||
|
||||
it("calls the delete method with the correct params ", async () => {
|
||||
it("calls the delete method with the correct params", async () => {
|
||||
await config.integration.delete({
|
||||
bucket: "test",
|
||||
delete: `{
|
||||
|
|
|
@ -30,12 +30,12 @@ describe("jsRunner (using isolated-vm)", () => {
|
|||
)
|
||||
}
|
||||
|
||||
it("it can run a basic javascript", async () => {
|
||||
it("can run a basic javascript", async () => {
|
||||
const output = await processJS(`return 1 + 2`)
|
||||
expect(output).toBe(3)
|
||||
})
|
||||
|
||||
it("it can execute sloppy javascript", async () => {
|
||||
it("can execute sloppy javascript", async () => {
|
||||
const output = await processJS(`a=2;b=3;return a + b`)
|
||||
expect(output).toBe(5)
|
||||
})
|
||||
|
|
|
@ -213,11 +213,11 @@ describe("Authorization middleware", () => {
|
|||
it("will fetch resource permissions when resource is set", async () => {
|
||||
await config.executeMiddleware()
|
||||
|
||||
expect(config.throw).not.toBeCalled()
|
||||
expect(config.throw).not.toHaveBeenCalled()
|
||||
expect(config.next).toHaveBeenCalled()
|
||||
|
||||
expect(mockedGetResourcePerms).toBeCalledTimes(1)
|
||||
expect(mockedGetResourcePerms).toBeCalledWith(resourceId)
|
||||
expect(mockedGetResourcePerms).toHaveBeenCalledTimes(1)
|
||||
expect(mockedGetResourcePerms).toHaveBeenCalledWith(resourceId)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -133,8 +133,8 @@ describe("trimViewRowInfo middleware", () => {
|
|||
})
|
||||
expect(config.params.sourceId).toEqual(table._id)
|
||||
|
||||
expect(config.next).toBeCalledTimes(1)
|
||||
expect(config.throw).not.toBeCalled()
|
||||
expect(config.next).toHaveBeenCalledTimes(1)
|
||||
expect(config.throw).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("when columns are defined, trimmed data is returned", async () => {
|
||||
|
@ -162,7 +162,7 @@ describe("trimViewRowInfo middleware", () => {
|
|||
})
|
||||
expect(config.params.sourceId).toEqual(table._id)
|
||||
|
||||
expect(config.next).toBeCalledTimes(1)
|
||||
expect(config.throw).not.toBeCalled()
|
||||
expect(config.next).toHaveBeenCalledTimes(1)
|
||||
expect(config.throw).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
|
|
@ -66,25 +66,25 @@ describe("migrations", () => {
|
|||
)[0]
|
||||
await migrations.runMigration(migration)
|
||||
|
||||
expect(events.app.created).toBeCalledTimes(1)
|
||||
expect(events.app.published).toBeCalledTimes(1)
|
||||
expect(events.automation.created).toBeCalledTimes(2)
|
||||
expect(events.automation.stepCreated).toBeCalledTimes(1)
|
||||
expect(events.datasource.created).toBeCalledTimes(2)
|
||||
expect(events.layout.created).toBeCalledTimes(1)
|
||||
expect(events.query.created).toBeCalledTimes(2)
|
||||
expect(events.role.created).toBeCalledTimes(2)
|
||||
expect(events.table.created).toBeCalledTimes(3)
|
||||
expect(events.view.created).toBeCalledTimes(2)
|
||||
expect(events.view.calculationCreated).toBeCalledTimes(1)
|
||||
expect(events.view.filterCreated).toBeCalledTimes(1)
|
||||
expect(events.screen.created).toBeCalledTimes(2)
|
||||
expect(events.backfill.appSucceeded).toBeCalledTimes(2)
|
||||
expect(events.app.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.app.published).toHaveBeenCalledTimes(1)
|
||||
expect(events.automation.created).toHaveBeenCalledTimes(2)
|
||||
expect(events.automation.stepCreated).toHaveBeenCalledTimes(1)
|
||||
expect(events.datasource.created).toHaveBeenCalledTimes(2)
|
||||
expect(events.layout.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.query.created).toHaveBeenCalledTimes(2)
|
||||
expect(events.role.created).toHaveBeenCalledTimes(2)
|
||||
expect(events.table.created).toHaveBeenCalledTimes(3)
|
||||
expect(events.view.created).toHaveBeenCalledTimes(2)
|
||||
expect(events.view.calculationCreated).toHaveBeenCalledTimes(1)
|
||||
expect(events.view.filterCreated).toHaveBeenCalledTimes(1)
|
||||
expect(events.screen.created).toHaveBeenCalledTimes(2)
|
||||
expect(events.backfill.appSucceeded).toHaveBeenCalledTimes(2)
|
||||
|
||||
// to make sure caching is working as expected
|
||||
expect(
|
||||
events.processors.analyticsProcessor.processEvent
|
||||
).toBeCalledTimes(23)
|
||||
).toHaveBeenCalledTimes(23)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -120,22 +120,22 @@ describe("migrations", () => {
|
|||
)[0]
|
||||
await migrations.runMigration(migration)
|
||||
|
||||
expect(events.user.created).toBeCalledTimes(3)
|
||||
expect(events.role.assigned).toBeCalledTimes(2)
|
||||
expect(events.user.permissionBuilderAssigned).toBeCalledTimes(1) // default test user
|
||||
expect(events.user.permissionAdminAssigned).toBeCalledTimes(1) // admin from above
|
||||
expect(events.rows.created).toBeCalledTimes(1)
|
||||
expect(events.rows.created).toBeCalledWith(2, timestamp)
|
||||
expect(events.email.SMTPCreated).toBeCalledTimes(1)
|
||||
expect(events.auth.SSOCreated).toBeCalledTimes(2)
|
||||
expect(events.auth.SSOActivated).toBeCalledTimes(2)
|
||||
expect(events.org.logoUpdated).toBeCalledTimes(1)
|
||||
expect(events.org.nameUpdated).toBeCalledTimes(1)
|
||||
expect(events.org.platformURLUpdated).toBeCalledTimes(1)
|
||||
expect(events.backfill.tenantSucceeded).toBeCalledTimes(1)
|
||||
expect(events.user.created).toHaveBeenCalledTimes(3)
|
||||
expect(events.role.assigned).toHaveBeenCalledTimes(2)
|
||||
expect(events.user.permissionBuilderAssigned).toHaveBeenCalledTimes(1) // default test user
|
||||
expect(events.user.permissionAdminAssigned).toHaveBeenCalledTimes(1) // admin from above
|
||||
expect(events.rows.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.rows.created).toHaveBeenCalledWith(2, timestamp)
|
||||
expect(events.email.SMTPCreated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSOCreated).toHaveBeenCalledTimes(2)
|
||||
expect(events.auth.SSOActivated).toHaveBeenCalledTimes(2)
|
||||
expect(events.org.logoUpdated).toHaveBeenCalledTimes(1)
|
||||
expect(events.org.nameUpdated).toHaveBeenCalledTimes(1)
|
||||
expect(events.org.platformURLUpdated).toHaveBeenCalledTimes(1)
|
||||
expect(events.backfill.tenantSucceeded).toHaveBeenCalledTimes(1)
|
||||
|
||||
// to make sure caching is working as expected
|
||||
expect(events.processors.analyticsProcessor.processEvent).toBeCalledTimes(
|
||||
expect(events.processors.analyticsProcessor.processEvent).toHaveBeenCalledTimes(
|
||||
19
|
||||
)
|
||||
})
|
||||
|
|
|
@ -84,7 +84,7 @@ describe("table sdk", () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(sdk.views.enrichSchema).toBeCalledTimes(3)
|
||||
expect(sdk.views.enrichSchema).toHaveBeenCalledTimes(3)
|
||||
|
||||
expect(res).toEqual({
|
||||
...basicTable,
|
||||
|
|
|
@ -44,7 +44,7 @@ import { db as dbCore } from "@budibase/backend-core"
|
|||
import sdk from "../index"
|
||||
|
||||
describe("should be able to re-write attachment URLs", () => {
|
||||
it("it should update URLs on a number of rows over the limit", async () => {
|
||||
it("should update URLs on a number of rows over the limit", async () => {
|
||||
const db = dbCore.getDB("app_aaa")
|
||||
await db.put(table)
|
||||
const limit = 30
|
||||
|
|
|
@ -64,12 +64,12 @@ describe("attachment cleanup", () => {
|
|||
await AttachmentCleanup.tableUpdate(originalTable, [row()], {
|
||||
oldTable: table(),
|
||||
})
|
||||
expect(mockedDeleteFiles).toBeCalledWith(BUCKET, [FILE_NAME])
|
||||
expect(mockedDeleteFiles).toHaveBeenCalledWith(BUCKET, [FILE_NAME])
|
||||
})
|
||||
|
||||
it("should be able to cleanup a table deletion", async () => {
|
||||
await AttachmentCleanup.tableDelete(table(), [row()])
|
||||
expect(mockedDeleteFiles).toBeCalledWith(BUCKET, [FILE_NAME])
|
||||
expect(mockedDeleteFiles).toHaveBeenCalledWith(BUCKET, [FILE_NAME])
|
||||
})
|
||||
|
||||
it("should handle table column renaming", async () => {
|
||||
|
@ -80,12 +80,12 @@ describe("attachment cleanup", () => {
|
|||
oldTable: table(),
|
||||
rename: { old: "attach", updated: "attach2" },
|
||||
})
|
||||
expect(mockedDeleteFiles).not.toBeCalled()
|
||||
expect(mockedDeleteFiles).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("shouldn't cleanup if no table changes", async () => {
|
||||
await AttachmentCleanup.tableUpdate(table(), [row()], { oldTable: table() })
|
||||
expect(mockedDeleteFiles).not.toBeCalled()
|
||||
expect(mockedDeleteFiles).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should handle row updates", async () => {
|
||||
|
@ -95,12 +95,12 @@ describe("attachment cleanup", () => {
|
|||
row: updatedRow,
|
||||
oldRow: row(),
|
||||
})
|
||||
expect(mockedDeleteFiles).toBeCalledWith(BUCKET, [FILE_NAME])
|
||||
expect(mockedDeleteFiles).toHaveBeenCalledWith(BUCKET, [FILE_NAME])
|
||||
})
|
||||
|
||||
it("should handle row deletion", async () => {
|
||||
await AttachmentCleanup.rowDelete(table(), [row()])
|
||||
expect(mockedDeleteFiles).toBeCalledWith(BUCKET, [FILE_NAME])
|
||||
expect(mockedDeleteFiles).toHaveBeenCalledWith(BUCKET, [FILE_NAME])
|
||||
})
|
||||
|
||||
it("should handle row deletion and not throw when attachments are undefined", async () => {
|
||||
|
@ -113,7 +113,7 @@ describe("attachment cleanup", () => {
|
|||
|
||||
it("shouldn't cleanup attachments if row not updated", async () => {
|
||||
await AttachmentCleanup.rowUpdate(table(), { row: row(), oldRow: row() })
|
||||
expect(mockedDeleteFiles).not.toBeCalled()
|
||||
expect(mockedDeleteFiles).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should be able to cleanup a column and not throw when attachments are undefined", async () => {
|
||||
|
@ -126,8 +126,8 @@ describe("attachment cleanup", () => {
|
|||
oldTable: table(),
|
||||
}
|
||||
)
|
||||
expect(mockedDeleteFiles).toBeCalledTimes(1)
|
||||
expect(mockedDeleteFiles).toBeCalledWith(BUCKET, ["file 1", "file 2"])
|
||||
expect(mockedDeleteFiles).toHaveBeenCalledTimes(1)
|
||||
expect(mockedDeleteFiles).toHaveBeenCalledWith(BUCKET, ["file 1", "file 2"])
|
||||
})
|
||||
|
||||
it("should be able to cleanup a column and not throw when ALL attachments are undefined", async () => {
|
||||
|
@ -140,6 +140,6 @@ describe("attachment cleanup", () => {
|
|||
oldTable: table(),
|
||||
}
|
||||
)
|
||||
expect(mockedDeleteFiles).not.toBeCalled()
|
||||
expect(mockedDeleteFiles).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
|
|
@ -67,8 +67,8 @@ describe("bbReferenceProcessor", () => {
|
|||
)
|
||||
|
||||
expect(result).toEqual(userId)
|
||||
expect(cacheGetUsersSpy).toBeCalledTimes(1)
|
||||
expect(cacheGetUsersSpy).toBeCalledWith([userId])
|
||||
expect(cacheGetUsersSpy).toHaveBeenCalledTimes(1)
|
||||
expect(cacheGetUsersSpy).toHaveBeenCalledWith([userId])
|
||||
})
|
||||
|
||||
it("throws an error given an invalid id", async () => {
|
||||
|
@ -78,9 +78,9 @@ describe("bbReferenceProcessor", () => {
|
|||
config.doInTenant(() =>
|
||||
processInputBBReferences(userId, FieldSubtype.USER)
|
||||
)
|
||||
).rejects.toThrowError(new InvalidBBRefError(userId, FieldSubtype.USER))
|
||||
expect(cacheGetUsersSpy).toBeCalledTimes(1)
|
||||
expect(cacheGetUsersSpy).toBeCalledWith([userId])
|
||||
).rejects.toThrow(new InvalidBBRefError(userId, FieldSubtype.USER))
|
||||
expect(cacheGetUsersSpy).toHaveBeenCalledTimes(1)
|
||||
expect(cacheGetUsersSpy).toHaveBeenCalledWith([userId])
|
||||
})
|
||||
|
||||
it("validates valid user ids as csv", async () => {
|
||||
|
@ -92,8 +92,8 @@ describe("bbReferenceProcessor", () => {
|
|||
)
|
||||
|
||||
expect(result).toEqual(userIds.join(","))
|
||||
expect(cacheGetUsersSpy).toBeCalledTimes(1)
|
||||
expect(cacheGetUsersSpy).toBeCalledWith(userIds)
|
||||
expect(cacheGetUsersSpy).toHaveBeenCalledTimes(1)
|
||||
expect(cacheGetUsersSpy).toHaveBeenCalledWith(userIds)
|
||||
})
|
||||
|
||||
it("throws an error given an invalid id in a csv", async () => {
|
||||
|
@ -110,7 +110,7 @@ describe("bbReferenceProcessor", () => {
|
|||
config.doInTenant(() =>
|
||||
processInputBBReferences(userIdCsv, FieldSubtype.USER)
|
||||
)
|
||||
).rejects.toThrowError(
|
||||
).rejects.toThrow(
|
||||
new InvalidBBRefError(wrongId, FieldSubtype.USER)
|
||||
)
|
||||
})
|
||||
|
@ -123,8 +123,8 @@ describe("bbReferenceProcessor", () => {
|
|||
)
|
||||
|
||||
expect(result).toEqual(userId)
|
||||
expect(cacheGetUsersSpy).toBeCalledTimes(1)
|
||||
expect(cacheGetUsersSpy).toBeCalledWith([userId])
|
||||
expect(cacheGetUsersSpy).toHaveBeenCalledTimes(1)
|
||||
expect(cacheGetUsersSpy).toHaveBeenCalledWith([userId])
|
||||
})
|
||||
|
||||
it("validate valid user object array", async () => {
|
||||
|
@ -135,8 +135,8 @@ describe("bbReferenceProcessor", () => {
|
|||
)
|
||||
|
||||
expect(result).toEqual(userIds.join(","))
|
||||
expect(cacheGetUsersSpy).toBeCalledTimes(1)
|
||||
expect(cacheGetUsersSpy).toBeCalledWith(userIds)
|
||||
expect(cacheGetUsersSpy).toHaveBeenCalledTimes(1)
|
||||
expect(cacheGetUsersSpy).toHaveBeenCalledWith(userIds)
|
||||
})
|
||||
|
||||
it("empty strings will return null", async () => {
|
||||
|
@ -185,8 +185,8 @@ describe("bbReferenceProcessor", () => {
|
|||
lastName: user.lastName,
|
||||
},
|
||||
])
|
||||
expect(cacheGetUsersSpy).toBeCalledTimes(1)
|
||||
expect(cacheGetUsersSpy).toBeCalledWith([userId])
|
||||
expect(cacheGetUsersSpy).toHaveBeenCalledTimes(1)
|
||||
expect(cacheGetUsersSpy).toHaveBeenCalledWith([userId])
|
||||
})
|
||||
|
||||
it("fetches user given a valid string id csv", async () => {
|
||||
|
@ -213,8 +213,8 @@ describe("bbReferenceProcessor", () => {
|
|||
}))
|
||||
)
|
||||
)
|
||||
expect(cacheGetUsersSpy).toBeCalledTimes(1)
|
||||
expect(cacheGetUsersSpy).toBeCalledWith([userId1, userId2])
|
||||
expect(cacheGetUsersSpy).toHaveBeenCalledTimes(1)
|
||||
expect(cacheGetUsersSpy).toHaveBeenCalledWith([userId1, userId2])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -62,8 +62,8 @@ describe("rowProcessor - inputProcessing", () => {
|
|||
|
||||
const { row } = await inputProcessing(userId, table, newRow)
|
||||
|
||||
expect(bbReferenceProcessor.processInputBBReferences).toBeCalledTimes(1)
|
||||
expect(bbReferenceProcessor.processInputBBReferences).toBeCalledWith(
|
||||
expect(bbReferenceProcessor.processInputBBReferences).toHaveBeenCalledTimes(1)
|
||||
expect(bbReferenceProcessor.processInputBBReferences).toHaveBeenCalledWith(
|
||||
"123",
|
||||
"user"
|
||||
)
|
||||
|
@ -71,7 +71,7 @@ describe("rowProcessor - inputProcessing", () => {
|
|||
expect(row).toEqual({ ...newRow, user })
|
||||
})
|
||||
|
||||
it("it does not process BB references if on the schema but it is not populated", async () => {
|
||||
it("does not process BB references if on the schema but it is not populated", async () => {
|
||||
const userId = generator.guid()
|
||||
|
||||
const table: Table = {
|
||||
|
@ -107,12 +107,12 @@ describe("rowProcessor - inputProcessing", () => {
|
|||
|
||||
const { row } = await inputProcessing(userId, table, newRow)
|
||||
|
||||
expect(bbReferenceProcessor.processInputBBReferences).not.toBeCalled()
|
||||
expect(bbReferenceProcessor.processInputBBReferences).not.toHaveBeenCalled()
|
||||
expect(row).toEqual({ ...newRow, user: undefined })
|
||||
})
|
||||
|
||||
it.each([undefined, null, ""])(
|
||||
"it does not process BB references the field is $%",
|
||||
"does not process BB references the field is $%",
|
||||
async userValue => {
|
||||
const userId = generator.guid()
|
||||
|
||||
|
@ -150,12 +150,12 @@ describe("rowProcessor - inputProcessing", () => {
|
|||
|
||||
const { row } = await inputProcessing(userId, table, newRow)
|
||||
|
||||
expect(bbReferenceProcessor.processInputBBReferences).not.toBeCalled()
|
||||
expect(bbReferenceProcessor.processInputBBReferences).not.toHaveBeenCalled()
|
||||
expect(row).toEqual(newRow)
|
||||
}
|
||||
)
|
||||
|
||||
it("it does not process BB references if not in the schema", async () => {
|
||||
it("does not process BB references if not in the schema", async () => {
|
||||
const userId = generator.guid()
|
||||
|
||||
const table: Table = {
|
||||
|
@ -191,7 +191,7 @@ describe("rowProcessor - inputProcessing", () => {
|
|||
|
||||
const { row } = await inputProcessing(userId, table, newRow)
|
||||
|
||||
expect(bbReferenceProcessor.processInputBBReferences).not.toBeCalled()
|
||||
expect(bbReferenceProcessor.processInputBBReferences).not.toHaveBeenCalled()
|
||||
expect(row).toEqual({
|
||||
name: "Jack",
|
||||
user: 123,
|
||||
|
|
|
@ -64,8 +64,8 @@ describe("rowProcessor - outputProcessing", () => {
|
|||
|
||||
expect(result).toEqual({ name: "Jack", user })
|
||||
|
||||
expect(bbReferenceProcessor.processOutputBBReferences).toBeCalledTimes(1)
|
||||
expect(bbReferenceProcessor.processOutputBBReferences).toBeCalledWith(
|
||||
expect(bbReferenceProcessor.processOutputBBReferences).toHaveBeenCalledTimes(1)
|
||||
expect(bbReferenceProcessor.processOutputBBReferences).toHaveBeenCalledWith(
|
||||
"123",
|
||||
FieldSubtype.USER
|
||||
)
|
||||
|
@ -150,7 +150,7 @@ describe("rowProcessor - outputProcessing", () => {
|
|||
|
||||
expect(result).toEqual({ name: "Jack" })
|
||||
|
||||
expect(bbReferenceProcessor.processOutputBBReferences).toBeCalledTimes(1)
|
||||
expect(bbReferenceProcessor.processOutputBBReferences).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("does not fetch bb references when not in the schema", async () => {
|
||||
|
@ -189,6 +189,6 @@ describe("rowProcessor - outputProcessing", () => {
|
|||
|
||||
expect(result).toEqual({ name: "Jack", user: "123" })
|
||||
|
||||
expect(bbReferenceProcessor.processOutputBBReferences).not.toBeCalled()
|
||||
expect(bbReferenceProcessor.processOutputBBReferences).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
|
|
@ -58,7 +58,7 @@ describe("/api/global/auth", () => {
|
|||
const response = await config.api.auth.login(tenantId, email, password)
|
||||
|
||||
expectSetAuthCookie(response)
|
||||
expect(events.auth.login).toBeCalledTimes(1)
|
||||
expect(events.auth.login).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should return 403 with incorrect credentials", async () => {
|
||||
|
@ -139,7 +139,7 @@ describe("/api/global/auth", () => {
|
|||
describe("POST /api/global/auth/logout", () => {
|
||||
it("should logout", async () => {
|
||||
const response = await config.api.auth.logout()
|
||||
expect(events.auth.logout).toBeCalledTimes(1)
|
||||
expect(events.auth.logout).toHaveBeenCalledTimes(1)
|
||||
|
||||
const authCookie = getAuthCookie(response)
|
||||
expect(authCookie).toBe("")
|
||||
|
@ -160,8 +160,8 @@ describe("/api/global/auth", () => {
|
|||
})
|
||||
expect(sendMailMock).toHaveBeenCalled()
|
||||
expect(code).toBeDefined()
|
||||
expect(events.user.passwordResetRequested).toBeCalledTimes(1)
|
||||
expect(events.user.passwordResetRequested).toBeCalledWith(user)
|
||||
expect(events.user.passwordResetRequested).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.passwordResetRequested).toHaveBeenCalledWith(user)
|
||||
})
|
||||
|
||||
describe("sso user", () => {
|
||||
|
@ -211,8 +211,8 @@ describe("/api/global/auth", () => {
|
|||
delete user.password
|
||||
|
||||
expect(res.body).toEqual({ message: "password reset successfully." })
|
||||
expect(events.user.passwordReset).toBeCalledTimes(1)
|
||||
expect(events.user.passwordReset).toBeCalledWith(user)
|
||||
expect(events.user.passwordReset).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.passwordReset).toHaveBeenCalledWith(user)
|
||||
|
||||
// login using new password
|
||||
await config.api.auth.login(user.tenantId, user.email, newPassword)
|
||||
|
@ -360,8 +360,8 @@ describe("/api/global/auth", () => {
|
|||
|
||||
const res = await config.api.configs.OIDCCallback(configId, preAuthRes)
|
||||
|
||||
expect(events.auth.login).toBeCalledWith("oidc", "oauth@example.com")
|
||||
expect(events.auth.login).toBeCalledTimes(1)
|
||||
expect(events.auth.login).toHaveBeenCalledWith("oidc", "oauth@example.com")
|
||||
expect(events.auth.login).toHaveBeenCalledTimes(1)
|
||||
expect(res.status).toBe(302)
|
||||
const location: string = res.get("location")
|
||||
expect(location).toBe("/")
|
||||
|
|
|
@ -57,20 +57,20 @@ describe("configs", () => {
|
|||
describe("create", () => {
|
||||
it("should create activated google config", async () => {
|
||||
await saveGoogleConfig()
|
||||
expect(events.auth.SSOCreated).toBeCalledTimes(1)
|
||||
expect(events.auth.SSOCreated).toBeCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSODeactivated).not.toBeCalled()
|
||||
expect(events.auth.SSOActivated).toBeCalledTimes(1)
|
||||
expect(events.auth.SSOActivated).toBeCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSOCreated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSOCreated).toHaveBeenCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSODeactivated).not.toHaveBeenCalled()
|
||||
expect(events.auth.SSOActivated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSOActivated).toHaveBeenCalledWith(ConfigType.GOOGLE)
|
||||
await config.deleteConfig(ConfigType.GOOGLE)
|
||||
})
|
||||
|
||||
it("should create deactivated google config", async () => {
|
||||
await saveGoogleConfig({ activated: false })
|
||||
expect(events.auth.SSOCreated).toBeCalledTimes(1)
|
||||
expect(events.auth.SSOCreated).toBeCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSOActivated).not.toBeCalled()
|
||||
expect(events.auth.SSODeactivated).not.toBeCalled()
|
||||
expect(events.auth.SSOCreated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSOCreated).toHaveBeenCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSOActivated).not.toHaveBeenCalled()
|
||||
expect(events.auth.SSODeactivated).not.toHaveBeenCalled()
|
||||
await config.deleteConfig(ConfigType.GOOGLE)
|
||||
})
|
||||
})
|
||||
|
@ -84,11 +84,11 @@ describe("configs", () => {
|
|||
googleConf._id,
|
||||
googleConf._rev
|
||||
)
|
||||
expect(events.auth.SSOUpdated).toBeCalledTimes(1)
|
||||
expect(events.auth.SSOUpdated).toBeCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSOActivated).not.toBeCalled()
|
||||
expect(events.auth.SSODeactivated).toBeCalledTimes(1)
|
||||
expect(events.auth.SSODeactivated).toBeCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSOUpdated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSOUpdated).toHaveBeenCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSOActivated).not.toHaveBeenCalled()
|
||||
expect(events.auth.SSODeactivated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSODeactivated).toHaveBeenCalledWith(ConfigType.GOOGLE)
|
||||
await config.deleteConfig(ConfigType.GOOGLE)
|
||||
})
|
||||
|
||||
|
@ -100,11 +100,11 @@ describe("configs", () => {
|
|||
googleConf._id,
|
||||
googleConf._rev
|
||||
)
|
||||
expect(events.auth.SSOUpdated).toBeCalledTimes(1)
|
||||
expect(events.auth.SSOUpdated).toBeCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSODeactivated).not.toBeCalled()
|
||||
expect(events.auth.SSOActivated).toBeCalledTimes(1)
|
||||
expect(events.auth.SSOActivated).toBeCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSOUpdated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSOUpdated).toHaveBeenCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSODeactivated).not.toHaveBeenCalled()
|
||||
expect(events.auth.SSOActivated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSOActivated).toHaveBeenCalledWith(ConfigType.GOOGLE)
|
||||
await config.deleteConfig(ConfigType.GOOGLE)
|
||||
})
|
||||
})
|
||||
|
@ -123,20 +123,20 @@ describe("configs", () => {
|
|||
describe("create", () => {
|
||||
it("should create activated OIDC config", async () => {
|
||||
await saveOIDCConfig()
|
||||
expect(events.auth.SSOCreated).toBeCalledTimes(1)
|
||||
expect(events.auth.SSOCreated).toBeCalledWith(ConfigType.OIDC)
|
||||
expect(events.auth.SSODeactivated).not.toBeCalled()
|
||||
expect(events.auth.SSOActivated).toBeCalledTimes(1)
|
||||
expect(events.auth.SSOActivated).toBeCalledWith(ConfigType.OIDC)
|
||||
expect(events.auth.SSOCreated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSOCreated).toHaveBeenCalledWith(ConfigType.OIDC)
|
||||
expect(events.auth.SSODeactivated).not.toHaveBeenCalled()
|
||||
expect(events.auth.SSOActivated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSOActivated).toHaveBeenCalledWith(ConfigType.OIDC)
|
||||
await config.deleteConfig(ConfigType.OIDC)
|
||||
})
|
||||
|
||||
it("should create deactivated OIDC config", async () => {
|
||||
await saveOIDCConfig({ activated: false })
|
||||
expect(events.auth.SSOCreated).toBeCalledTimes(1)
|
||||
expect(events.auth.SSOCreated).toBeCalledWith(ConfigType.OIDC)
|
||||
expect(events.auth.SSOActivated).not.toBeCalled()
|
||||
expect(events.auth.SSODeactivated).not.toBeCalled()
|
||||
expect(events.auth.SSOCreated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSOCreated).toHaveBeenCalledWith(ConfigType.OIDC)
|
||||
expect(events.auth.SSOActivated).not.toHaveBeenCalled()
|
||||
expect(events.auth.SSODeactivated).not.toHaveBeenCalled()
|
||||
await config.deleteConfig(ConfigType.OIDC)
|
||||
})
|
||||
})
|
||||
|
@ -150,11 +150,11 @@ describe("configs", () => {
|
|||
oidcConf._id,
|
||||
oidcConf._rev
|
||||
)
|
||||
expect(events.auth.SSOUpdated).toBeCalledTimes(1)
|
||||
expect(events.auth.SSOUpdated).toBeCalledWith(ConfigType.OIDC)
|
||||
expect(events.auth.SSOActivated).not.toBeCalled()
|
||||
expect(events.auth.SSODeactivated).toBeCalledTimes(1)
|
||||
expect(events.auth.SSODeactivated).toBeCalledWith(ConfigType.OIDC)
|
||||
expect(events.auth.SSOUpdated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSOUpdated).toHaveBeenCalledWith(ConfigType.OIDC)
|
||||
expect(events.auth.SSOActivated).not.toHaveBeenCalled()
|
||||
expect(events.auth.SSODeactivated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSODeactivated).toHaveBeenCalledWith(ConfigType.OIDC)
|
||||
await config.deleteConfig(ConfigType.OIDC)
|
||||
})
|
||||
|
||||
|
@ -166,11 +166,11 @@ describe("configs", () => {
|
|||
oidcConf._id,
|
||||
oidcConf._rev
|
||||
)
|
||||
expect(events.auth.SSOUpdated).toBeCalledTimes(1)
|
||||
expect(events.auth.SSOUpdated).toBeCalledWith(ConfigType.OIDC)
|
||||
expect(events.auth.SSODeactivated).not.toBeCalled()
|
||||
expect(events.auth.SSOActivated).toBeCalledTimes(1)
|
||||
expect(events.auth.SSOActivated).toBeCalledWith(ConfigType.OIDC)
|
||||
expect(events.auth.SSOUpdated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSOUpdated).toHaveBeenCalledWith(ConfigType.OIDC)
|
||||
expect(events.auth.SSODeactivated).not.toHaveBeenCalled()
|
||||
expect(events.auth.SSOActivated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSOActivated).toHaveBeenCalledWith(ConfigType.OIDC)
|
||||
await config.deleteConfig(ConfigType.OIDC)
|
||||
})
|
||||
})
|
||||
|
@ -190,8 +190,8 @@ describe("configs", () => {
|
|||
it("should create SMTP config", async () => {
|
||||
await config.deleteConfig(ConfigType.SMTP)
|
||||
await saveSMTPConfig()
|
||||
expect(events.email.SMTPUpdated).not.toBeCalled()
|
||||
expect(events.email.SMTPCreated).toBeCalledTimes(1)
|
||||
expect(events.email.SMTPUpdated).not.toHaveBeenCalled()
|
||||
expect(events.email.SMTPCreated).toHaveBeenCalledTimes(1)
|
||||
await config.deleteConfig(ConfigType.SMTP)
|
||||
})
|
||||
})
|
||||
|
@ -201,8 +201,8 @@ describe("configs", () => {
|
|||
const smtpConf = await saveSMTPConfig()
|
||||
jest.clearAllMocks()
|
||||
await saveSMTPConfig(smtpConf.config, smtpConf._id, smtpConf._rev)
|
||||
expect(events.email.SMTPCreated).not.toBeCalled()
|
||||
expect(events.email.SMTPUpdated).toBeCalledTimes(1)
|
||||
expect(events.email.SMTPCreated).not.toHaveBeenCalled()
|
||||
expect(events.email.SMTPUpdated).toHaveBeenCalledTimes(1)
|
||||
await config.deleteConfig(ConfigType.SMTP)
|
||||
})
|
||||
})
|
||||
|
@ -215,9 +215,9 @@ describe("configs", () => {
|
|||
|
||||
await saveSettingsConfig()
|
||||
|
||||
expect(events.org.nameUpdated).not.toBeCalled()
|
||||
expect(events.org.logoUpdated).not.toBeCalled()
|
||||
expect(events.org.platformURLUpdated).not.toBeCalled()
|
||||
expect(events.org.nameUpdated).not.toHaveBeenCalled()
|
||||
expect(events.org.logoUpdated).not.toHaveBeenCalled()
|
||||
expect(events.org.platformURLUpdated).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should create settings config with non-default settings", async () => {
|
||||
|
@ -231,9 +231,9 @@ describe("configs", () => {
|
|||
|
||||
await saveSettingsConfig(conf)
|
||||
|
||||
expect(events.org.nameUpdated).toBeCalledTimes(1)
|
||||
expect(events.org.logoUpdated).toBeCalledTimes(1)
|
||||
expect(events.org.platformURLUpdated).toBeCalledTimes(1)
|
||||
expect(events.org.nameUpdated).toHaveBeenCalledTimes(1)
|
||||
expect(events.org.logoUpdated).toHaveBeenCalledTimes(1)
|
||||
expect(events.org.platformURLUpdated).toHaveBeenCalledTimes(1)
|
||||
config.cloudHosted()
|
||||
})
|
||||
})
|
||||
|
@ -253,9 +253,9 @@ describe("configs", () => {
|
|||
settingsConfig._rev
|
||||
)
|
||||
|
||||
expect(events.org.nameUpdated).toBeCalledTimes(1)
|
||||
expect(events.org.logoUpdated).toBeCalledTimes(1)
|
||||
expect(events.org.platformURLUpdated).toBeCalledTimes(1)
|
||||
expect(events.org.nameUpdated).toHaveBeenCalledTimes(1)
|
||||
expect(events.org.logoUpdated).toHaveBeenCalledTimes(1)
|
||||
expect(events.org.platformURLUpdated).toHaveBeenCalledTimes(1)
|
||||
config.cloudHosted()
|
||||
})
|
||||
})
|
||||
|
|
|
@ -25,9 +25,9 @@ describe("/api/global/groups", () => {
|
|||
it("should be able to create a new group", async () => {
|
||||
const group = structures.groups.UserGroup()
|
||||
await config.api.groups.saveGroup(group)
|
||||
expect(events.group.created).toBeCalledTimes(1)
|
||||
expect(events.group.updated).not.toBeCalled()
|
||||
expect(events.group.permissionsEdited).not.toBeCalled()
|
||||
expect(events.group.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.group.updated).not.toHaveBeenCalled()
|
||||
expect(events.group.permissionsEdited).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should not allow undefined names", async () => {
|
||||
|
@ -57,7 +57,7 @@ describe("/api/global/groups", () => {
|
|||
it("should trim names", async () => {
|
||||
const group = { ...structures.groups.UserGroup(), name: " group name " }
|
||||
await config.api.groups.saveGroup(group)
|
||||
expect(events.group.created).toBeCalledWith(
|
||||
expect(events.group.created).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ name: "group name" })
|
||||
)
|
||||
})
|
||||
|
@ -100,8 +100,8 @@ describe("/api/global/groups", () => {
|
|||
}
|
||||
await config.api.groups.saveGroup(updatedGroup)
|
||||
|
||||
expect(events.group.updated).toBeCalledTimes(1)
|
||||
expect(events.group.permissionsEdited).not.toBeCalled()
|
||||
expect(events.group.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.group.permissionsEdited).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
describe("scim", () => {
|
||||
|
@ -135,7 +135,7 @@ describe("/api/global/groups", () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(events.group.updated).not.toBeCalled()
|
||||
expect(events.group.updated).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("update will not amend the SCIM fields", async () => {
|
||||
|
@ -151,7 +151,7 @@ describe("/api/global/groups", () => {
|
|||
expect: 200,
|
||||
})
|
||||
|
||||
expect(events.group.updated).toBeCalledTimes(1)
|
||||
expect(events.group.updated).toHaveBeenCalledTimes(1)
|
||||
expect(
|
||||
(
|
||||
await config.api.groups.find(group._id!, {
|
||||
|
@ -176,7 +176,7 @@ describe("/api/global/groups", () => {
|
|||
let oldGroup = await config.api.groups.saveGroup(group)
|
||||
await config.api.groups.deleteGroup(oldGroup.body._id, oldGroup.body._rev)
|
||||
|
||||
expect(events.group.deleted).toBeCalledTimes(1)
|
||||
expect(events.group.deleted).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ describe("/api/global/license", () => {
|
|||
it("returns 200", async () => {
|
||||
const res = await config.api.license.refresh()
|
||||
expect(res.status).toBe(200)
|
||||
expect(licensing.cache.refresh).toBeCalledTimes(1)
|
||||
expect(licensing.cache.refresh).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -42,7 +42,7 @@ describe("/api/global/license", () => {
|
|||
licenseKey: "licenseKey",
|
||||
})
|
||||
expect(res.status).toBe(200)
|
||||
expect(licensing.keys.activateLicenseKey).toBeCalledWith("licenseKey")
|
||||
expect(licensing.keys.activateLicenseKey).toHaveBeenCalledWith("licenseKey")
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -64,7 +64,7 @@ describe("/api/global/license", () => {
|
|||
describe("DELETE /api/global/license/key", () => {
|
||||
it("returns 204", async () => {
|
||||
const res = await config.api.license.deleteLicenseKey()
|
||||
expect(licensing.keys.deleteLicenseKey).toBeCalledTimes(1)
|
||||
expect(licensing.keys.deleteLicenseKey).toHaveBeenCalledTimes(1)
|
||||
expect(res.status).toBe(204)
|
||||
})
|
||||
})
|
||||
|
@ -74,7 +74,7 @@ describe("/api/global/license", () => {
|
|||
const res = await config.api.license.activateOfflineLicense({
|
||||
offlineLicenseToken: "offlineLicenseToken",
|
||||
})
|
||||
expect(licensing.offline.activateOfflineLicenseToken).toBeCalledWith(
|
||||
expect(licensing.offline.activateOfflineLicenseToken).toHaveBeenCalledWith(
|
||||
"offlineLicenseToken"
|
||||
)
|
||||
expect(res.status).toBe(200)
|
||||
|
@ -102,7 +102,7 @@ describe("/api/global/license", () => {
|
|||
it("returns 204", async () => {
|
||||
const res = await config.api.license.deleteOfflineLicense()
|
||||
expect(res.status).toBe(204)
|
||||
expect(licensing.offline.deleteOfflineLicenseToken).toBeCalledTimes(1)
|
||||
expect(licensing.offline.deleteOfflineLicenseToken).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -304,7 +304,7 @@ describe("scim", () => {
|
|||
|
||||
await postScimUser({ body })
|
||||
|
||||
expect(events.user.created).toBeCalledTimes(1)
|
||||
expect(events.user.created).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("if the username is an email, the user name will be used as email", async () => {
|
||||
|
@ -571,7 +571,7 @@ describe("scim", () => {
|
|||
|
||||
await patchScimUser({ id: user.id, body })
|
||||
|
||||
expect(events.user.updated).toBeCalledTimes(1)
|
||||
expect(events.user.updated).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -603,7 +603,7 @@ describe("scim", () => {
|
|||
it("an event is dispatched", async () => {
|
||||
await deleteScimUser(user.id, { expect: 204 })
|
||||
|
||||
expect(events.user.deleted).toBeCalledTimes(1)
|
||||
expect(events.user.deleted).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("an account holder cannot be removed even when synched", async () => {
|
||||
|
|
|
@ -41,10 +41,10 @@ describe("/api/global/self", () => {
|
|||
user._rev = dbUser._rev
|
||||
user.dayPassRecordedAt = mocks.date.MOCK_DATE.toISOString()
|
||||
expect(res.body._id).toBe(user._id)
|
||||
expect(events.user.updated).toBeCalledTimes(1)
|
||||
expect(events.user.updated).toBeCalledWith(dbUser)
|
||||
expect(events.user.passwordUpdated).toBeCalledTimes(1)
|
||||
expect(events.user.passwordUpdated).toBeCalledWith(dbUser)
|
||||
expect(events.user.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.updated).toHaveBeenCalledWith(dbUser)
|
||||
expect(events.user.passwordUpdated).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.passwordUpdated).toHaveBeenCalledWith(dbUser)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ describe("/api/global/users", () => {
|
|||
|
||||
expect(sendMailMock).toHaveBeenCalled()
|
||||
expect(code).toBeDefined()
|
||||
expect(events.user.invited).toBeCalledTimes(1)
|
||||
expect(events.user.invited).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should not be able to generate an invitation for existing user", async () => {
|
||||
|
@ -52,7 +52,7 @@ describe("/api/global/users", () => {
|
|||
expect(res.body.message).toBe(`Unavailable`)
|
||||
expect(sendMailMock).toHaveBeenCalledTimes(0)
|
||||
expect(code).toBeUndefined()
|
||||
expect(events.user.invited).toBeCalledTimes(0)
|
||||
expect(events.user.invited).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it("should not invite the same user twice", async () => {
|
||||
|
@ -70,7 +70,7 @@ describe("/api/global/users", () => {
|
|||
expect(res.body.message).toBe(`Unavailable`)
|
||||
expect(sendMailMock).toHaveBeenCalledTimes(0)
|
||||
expect(code).toBeUndefined()
|
||||
expect(events.user.invited).toBeCalledTimes(0)
|
||||
expect(events.user.invited).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it("should be able to create new user from invite", async () => {
|
||||
|
@ -86,8 +86,8 @@ describe("/api/global/users", () => {
|
|||
const user = await config.getUser(email)
|
||||
expect(user).toBeDefined()
|
||||
expect(user!._id).toEqual(res.body._id)
|
||||
expect(events.user.inviteAccepted).toBeCalledTimes(1)
|
||||
expect(events.user.inviteAccepted).toBeCalledWith(user)
|
||||
expect(events.user.inviteAccepted).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.inviteAccepted).toHaveBeenCalledWith(user)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -105,7 +105,7 @@ describe("/api/global/users", () => {
|
|||
expect(body.successful.length).toBe(2)
|
||||
expect(body.unsuccessful.length).toBe(0)
|
||||
expect(sendMailMock).toHaveBeenCalledTimes(2)
|
||||
expect(events.user.invited).toBeCalledTimes(2)
|
||||
expect(events.user.invited).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it("should not be able to generate an invitation for existing user", async () => {
|
||||
|
@ -118,7 +118,7 @@ describe("/api/global/users", () => {
|
|||
expect(body.unsuccessful.length).toBe(1)
|
||||
expect(body.unsuccessful[0].reason).toBe("Unavailable")
|
||||
expect(sendMailMock).toHaveBeenCalledTimes(0)
|
||||
expect(events.user.invited).toBeCalledTimes(0)
|
||||
expect(events.user.invited).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it("should not be able to generate an invitation for user that has already been invited", async () => {
|
||||
|
@ -135,7 +135,7 @@ describe("/api/global/users", () => {
|
|||
expect(body.unsuccessful.length).toBe(1)
|
||||
expect(body.unsuccessful[0].reason).toBe("Unavailable")
|
||||
expect(sendMailMock).toHaveBeenCalledTimes(0)
|
||||
expect(events.user.invited).toBeCalledTimes(0)
|
||||
expect(events.user.invited).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -149,7 +149,7 @@ describe("/api/global/users", () => {
|
|||
expect(response.created?.successful.length).toBe(0)
|
||||
expect(response.created?.unsuccessful.length).toBe(1)
|
||||
expect(response.created?.unsuccessful[0].email).toBe(user.email)
|
||||
expect(events.user.created).toBeCalledTimes(0)
|
||||
expect(events.user.created).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it("should ignore users existing in other tenants", async () => {
|
||||
|
@ -162,7 +162,7 @@ describe("/api/global/users", () => {
|
|||
expect(response.created?.successful.length).toBe(0)
|
||||
expect(response.created?.unsuccessful.length).toBe(1)
|
||||
expect(response.created?.unsuccessful[0].email).toBe(user.email)
|
||||
expect(events.user.created).toBeCalledTimes(0)
|
||||
expect(events.user.created).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -177,7 +177,7 @@ describe("/api/global/users", () => {
|
|||
expect(response.created?.successful.length).toBe(0)
|
||||
expect(response.created?.unsuccessful.length).toBe(1)
|
||||
expect(response.created?.unsuccessful[0].email).toBe(user.email)
|
||||
expect(events.user.created).toBeCalledTimes(0)
|
||||
expect(events.user.created).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it("should be able to bulk create users", async () => {
|
||||
|
@ -196,9 +196,9 @@ describe("/api/global/users", () => {
|
|||
expect(response.created?.successful[1].email).toBe(admin.email)
|
||||
expect(response.created?.successful[2].email).toBe(user.email)
|
||||
expect(response.created?.unsuccessful.length).toBe(0)
|
||||
expect(events.user.created).toBeCalledTimes(3)
|
||||
expect(events.user.permissionAdminAssigned).toBeCalledTimes(1)
|
||||
expect(events.user.permissionBuilderAssigned).toBeCalledTimes(2)
|
||||
expect(events.user.created).toHaveBeenCalledTimes(3)
|
||||
expect(events.user.permissionAdminAssigned).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionBuilderAssigned).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -208,10 +208,10 @@ describe("/api/global/users", () => {
|
|||
|
||||
await config.api.users.saveUser(user)
|
||||
|
||||
expect(events.user.created).toBeCalledTimes(1)
|
||||
expect(events.user.updated).not.toBeCalled()
|
||||
expect(events.user.permissionBuilderAssigned).not.toBeCalled()
|
||||
expect(events.user.permissionAdminAssigned).not.toBeCalled()
|
||||
expect(events.user.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.updated).not.toHaveBeenCalled()
|
||||
expect(events.user.permissionBuilderAssigned).not.toHaveBeenCalled()
|
||||
expect(events.user.permissionAdminAssigned).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should be able to create an admin user", async () => {
|
||||
|
@ -219,10 +219,10 @@ describe("/api/global/users", () => {
|
|||
|
||||
await config.api.users.saveUser(user)
|
||||
|
||||
expect(events.user.created).toBeCalledTimes(1)
|
||||
expect(events.user.updated).not.toBeCalled()
|
||||
expect(events.user.permissionBuilderAssigned).toBeCalledTimes(1)
|
||||
expect(events.user.permissionAdminAssigned).toBeCalledTimes(1)
|
||||
expect(events.user.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.updated).not.toHaveBeenCalled()
|
||||
expect(events.user.permissionBuilderAssigned).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionAdminAssigned).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should be able to create a builder user", async () => {
|
||||
|
@ -230,10 +230,10 @@ describe("/api/global/users", () => {
|
|||
|
||||
await config.api.users.saveUser(user)
|
||||
|
||||
expect(events.user.created).toBeCalledTimes(1)
|
||||
expect(events.user.updated).not.toBeCalled()
|
||||
expect(events.user.permissionBuilderAssigned).toBeCalledTimes(1)
|
||||
expect(events.user.permissionAdminAssigned).not.toBeCalled()
|
||||
expect(events.user.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.updated).not.toHaveBeenCalled()
|
||||
expect(events.user.permissionBuilderAssigned).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionAdminAssigned).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should be able to assign app roles", async () => {
|
||||
|
@ -246,11 +246,11 @@ describe("/api/global/users", () => {
|
|||
await config.api.users.saveUser(user)
|
||||
|
||||
const savedUser = await config.getUser(user.email)
|
||||
expect(events.user.created).toBeCalledTimes(1)
|
||||
expect(events.user.updated).not.toBeCalled()
|
||||
expect(events.role.assigned).toBeCalledTimes(2)
|
||||
expect(events.role.assigned).toBeCalledWith(savedUser, "role1")
|
||||
expect(events.role.assigned).toBeCalledWith(savedUser, "role2")
|
||||
expect(events.user.created).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.updated).not.toHaveBeenCalled()
|
||||
expect(events.role.assigned).toHaveBeenCalledTimes(2)
|
||||
expect(events.role.assigned).toHaveBeenCalledWith(savedUser, "role1")
|
||||
expect(events.role.assigned).toHaveBeenCalledWith(savedUser, "role2")
|
||||
})
|
||||
|
||||
it("should not be able to create user that exists in same tenant", async () => {
|
||||
|
@ -264,7 +264,7 @@ describe("/api/global/users", () => {
|
|||
expect(response.body.message).toBe(
|
||||
`Email already in use: '${user.email}'`
|
||||
)
|
||||
expect(events.user.created).toBeCalledTimes(0)
|
||||
expect(events.user.created).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it("should not be able to create user that exists in other tenant", async () => {
|
||||
|
@ -278,7 +278,7 @@ describe("/api/global/users", () => {
|
|||
expect(response.body.message).toBe(
|
||||
`Email already in use: '${user.email}'`
|
||||
)
|
||||
expect(events.user.created).toBeCalledTimes(0)
|
||||
expect(events.user.created).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -292,7 +292,7 @@ describe("/api/global/users", () => {
|
|||
expect(response.body.message).toBe(
|
||||
`Email already in use: '${user.email}'`
|
||||
)
|
||||
expect(events.user.created).toBeCalledTimes(0)
|
||||
expect(events.user.created).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it("should not be able to create a user with the same email and different casing", async () => {
|
||||
|
@ -302,7 +302,7 @@ describe("/api/global/users", () => {
|
|||
user.email = user.email.toUpperCase()
|
||||
await config.api.users.saveUser(user, 400)
|
||||
|
||||
expect(events.user.created).toBeCalledTimes(1)
|
||||
expect(events.user.created).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should not be able to bulk create a user with the same email and different casing", async () => {
|
||||
|
@ -312,7 +312,7 @@ describe("/api/global/users", () => {
|
|||
user.email = user.email.toUpperCase()
|
||||
await config.api.users.bulkCreateUsers([user])
|
||||
|
||||
expect(events.user.created).toBeCalledTimes(1)
|
||||
expect(events.user.created).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should not allow a non-admin user to create a new user", async () => {
|
||||
|
@ -335,11 +335,11 @@ describe("/api/global/users", () => {
|
|||
|
||||
await config.api.users.saveUser(user)
|
||||
|
||||
expect(events.user.created).not.toBeCalled()
|
||||
expect(events.user.updated).toBeCalledTimes(1)
|
||||
expect(events.user.permissionBuilderAssigned).not.toBeCalled()
|
||||
expect(events.user.permissionAdminAssigned).not.toBeCalled()
|
||||
expect(events.user.passwordForceReset).not.toBeCalled()
|
||||
expect(events.user.created).not.toHaveBeenCalled()
|
||||
expect(events.user.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionBuilderAssigned).not.toHaveBeenCalled()
|
||||
expect(events.user.permissionAdminAssigned).not.toHaveBeenCalled()
|
||||
expect(events.user.passwordForceReset).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should not allow a user to update their own admin/builder status", async () => {
|
||||
|
@ -367,11 +367,11 @@ describe("/api/global/users", () => {
|
|||
user.password = "tempPassword"
|
||||
await config.api.users.saveUser(user)
|
||||
|
||||
expect(events.user.created).not.toBeCalled()
|
||||
expect(events.user.updated).toBeCalledTimes(1)
|
||||
expect(events.user.permissionBuilderAssigned).not.toBeCalled()
|
||||
expect(events.user.permissionAdminAssigned).not.toBeCalled()
|
||||
expect(events.user.passwordForceReset).toBeCalledTimes(1)
|
||||
expect(events.user.created).not.toHaveBeenCalled()
|
||||
expect(events.user.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionBuilderAssigned).not.toHaveBeenCalled()
|
||||
expect(events.user.permissionAdminAssigned).not.toHaveBeenCalled()
|
||||
expect(events.user.passwordForceReset).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should be able to update a basic user to an admin user", async () => {
|
||||
|
@ -380,10 +380,10 @@ describe("/api/global/users", () => {
|
|||
|
||||
await config.api.users.saveUser(structures.users.adminUser(user))
|
||||
|
||||
expect(events.user.created).not.toBeCalled()
|
||||
expect(events.user.updated).toBeCalledTimes(1)
|
||||
expect(events.user.permissionBuilderAssigned).toBeCalledTimes(1)
|
||||
expect(events.user.permissionAdminAssigned).toBeCalledTimes(1)
|
||||
expect(events.user.created).not.toHaveBeenCalled()
|
||||
expect(events.user.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionBuilderAssigned).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionAdminAssigned).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should be able to update a basic user to a builder user", async () => {
|
||||
|
@ -392,10 +392,10 @@ describe("/api/global/users", () => {
|
|||
|
||||
await config.api.users.saveUser(structures.users.builderUser(user))
|
||||
|
||||
expect(events.user.created).not.toBeCalled()
|
||||
expect(events.user.updated).toBeCalledTimes(1)
|
||||
expect(events.user.permissionBuilderAssigned).toBeCalledTimes(1)
|
||||
expect(events.user.permissionAdminAssigned).not.toBeCalled()
|
||||
expect(events.user.created).not.toHaveBeenCalled()
|
||||
expect(events.user.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionBuilderAssigned).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionAdminAssigned).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should be able to update an admin user to a basic user", async () => {
|
||||
|
@ -406,10 +406,10 @@ describe("/api/global/users", () => {
|
|||
|
||||
await config.api.users.saveUser(user)
|
||||
|
||||
expect(events.user.created).not.toBeCalled()
|
||||
expect(events.user.updated).toBeCalledTimes(1)
|
||||
expect(events.user.permissionAdminRemoved).toBeCalledTimes(1)
|
||||
expect(events.user.permissionBuilderRemoved).toBeCalledTimes(1)
|
||||
expect(events.user.created).not.toHaveBeenCalled()
|
||||
expect(events.user.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionAdminRemoved).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionBuilderRemoved).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should be able to update an builder user to a basic user", async () => {
|
||||
|
@ -419,10 +419,10 @@ describe("/api/global/users", () => {
|
|||
|
||||
await config.api.users.saveUser(user)
|
||||
|
||||
expect(events.user.created).not.toBeCalled()
|
||||
expect(events.user.updated).toBeCalledTimes(1)
|
||||
expect(events.user.permissionBuilderRemoved).toBeCalledTimes(1)
|
||||
expect(events.user.permissionAdminRemoved).not.toBeCalled()
|
||||
expect(events.user.created).not.toHaveBeenCalled()
|
||||
expect(events.user.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionBuilderRemoved).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionAdminRemoved).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should be able to assign app roles", async () => {
|
||||
|
@ -436,11 +436,11 @@ describe("/api/global/users", () => {
|
|||
await config.api.users.saveUser(user)
|
||||
|
||||
const savedUser = await config.getUser(user.email)
|
||||
expect(events.user.created).not.toBeCalled()
|
||||
expect(events.user.updated).toBeCalledTimes(1)
|
||||
expect(events.role.assigned).toBeCalledTimes(2)
|
||||
expect(events.role.assigned).toBeCalledWith(savedUser, "role1")
|
||||
expect(events.role.assigned).toBeCalledWith(savedUser, "role2")
|
||||
expect(events.user.created).not.toHaveBeenCalled()
|
||||
expect(events.user.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.role.assigned).toHaveBeenCalledTimes(2)
|
||||
expect(events.role.assigned).toHaveBeenCalledWith(savedUser, "role1")
|
||||
expect(events.role.assigned).toHaveBeenCalledWith(savedUser, "role2")
|
||||
})
|
||||
|
||||
it("should be able to unassign app roles", async () => {
|
||||
|
@ -456,11 +456,11 @@ describe("/api/global/users", () => {
|
|||
await config.api.users.saveUser(user)
|
||||
|
||||
const savedUser = await config.getUser(user.email)
|
||||
expect(events.user.created).not.toBeCalled()
|
||||
expect(events.user.updated).toBeCalledTimes(1)
|
||||
expect(events.role.unassigned).toBeCalledTimes(2)
|
||||
expect(events.role.unassigned).toBeCalledWith(savedUser, "role1")
|
||||
expect(events.role.unassigned).toBeCalledWith(savedUser, "role2")
|
||||
expect(events.user.created).not.toHaveBeenCalled()
|
||||
expect(events.user.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.role.unassigned).toHaveBeenCalledTimes(2)
|
||||
expect(events.role.unassigned).toHaveBeenCalledWith(savedUser, "role1")
|
||||
expect(events.role.unassigned).toHaveBeenCalledWith(savedUser, "role2")
|
||||
})
|
||||
|
||||
it("should be able to update existing app roles", async () => {
|
||||
|
@ -479,12 +479,12 @@ describe("/api/global/users", () => {
|
|||
await config.api.users.saveUser(user)
|
||||
|
||||
const savedUser = await config.getUser(user.email)
|
||||
expect(events.user.created).not.toBeCalled()
|
||||
expect(events.user.updated).toBeCalledTimes(1)
|
||||
expect(events.role.unassigned).toBeCalledTimes(1)
|
||||
expect(events.role.unassigned).toBeCalledWith(savedUser, "role2")
|
||||
expect(events.role.assigned).toBeCalledTimes(1)
|
||||
expect(events.role.assigned).toBeCalledWith(savedUser, "role2-edit")
|
||||
expect(events.user.created).not.toHaveBeenCalled()
|
||||
expect(events.user.updated).toHaveBeenCalledTimes(1)
|
||||
expect(events.role.unassigned).toHaveBeenCalledTimes(1)
|
||||
expect(events.role.unassigned).toHaveBeenCalledWith(savedUser, "role2")
|
||||
expect(events.role.assigned).toHaveBeenCalledTimes(1)
|
||||
expect(events.role.assigned).toHaveBeenCalledWith(savedUser, "role2-edit")
|
||||
})
|
||||
|
||||
it("should not be able to update email address", async () => {
|
||||
|
@ -534,7 +534,7 @@ describe("/api/global/users", () => {
|
|||
const response = await config.api.users.bulkDeleteUsers([user._id!], 400)
|
||||
|
||||
expect(response.message).toBe("Unable to delete self.")
|
||||
expect(events.user.deleted).not.toBeCalled()
|
||||
expect(events.user.deleted).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should not be able to bulk delete account owner", async () => {
|
||||
|
@ -551,7 +551,7 @@ describe("/api/global/users", () => {
|
|||
"Account holder cannot be deleted"
|
||||
)
|
||||
expect(response.deleted?.unsuccessful[0]._id).toBe(user._id)
|
||||
expect(events.user.deleted).not.toBeCalled()
|
||||
expect(events.user.deleted).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should be able to bulk delete users", async () => {
|
||||
|
@ -574,9 +574,9 @@ describe("/api/global/users", () => {
|
|||
|
||||
expect(response.deleted?.successful.length).toBe(3)
|
||||
expect(response.deleted?.unsuccessful.length).toBe(0)
|
||||
expect(events.user.deleted).toBeCalledTimes(3)
|
||||
expect(events.user.permissionAdminRemoved).toBeCalledTimes(1)
|
||||
expect(events.user.permissionBuilderRemoved).toBeCalledTimes(2)
|
||||
expect(events.user.deleted).toHaveBeenCalledTimes(3)
|
||||
expect(events.user.permissionAdminRemoved).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionBuilderRemoved).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -669,9 +669,9 @@ describe("/api/global/users", () => {
|
|||
|
||||
await config.api.users.deleteUser(user._id!)
|
||||
|
||||
expect(events.user.deleted).toBeCalledTimes(1)
|
||||
expect(events.user.permissionBuilderRemoved).not.toBeCalled()
|
||||
expect(events.user.permissionAdminRemoved).not.toBeCalled()
|
||||
expect(events.user.deleted).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionBuilderRemoved).not.toHaveBeenCalled()
|
||||
expect(events.user.permissionAdminRemoved).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should be able to destroy an admin user", async () => {
|
||||
|
@ -680,9 +680,9 @@ describe("/api/global/users", () => {
|
|||
|
||||
await config.api.users.deleteUser(user._id!)
|
||||
|
||||
expect(events.user.deleted).toBeCalledTimes(1)
|
||||
expect(events.user.permissionBuilderRemoved).toBeCalledTimes(1)
|
||||
expect(events.user.permissionAdminRemoved).toBeCalledTimes(1)
|
||||
expect(events.user.deleted).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionBuilderRemoved).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionAdminRemoved).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("should be able to destroy a builder user", async () => {
|
||||
|
@ -691,9 +691,9 @@ describe("/api/global/users", () => {
|
|||
|
||||
await config.api.users.deleteUser(user._id!)
|
||||
|
||||
expect(events.user.deleted).toBeCalledTimes(1)
|
||||
expect(events.user.permissionBuilderRemoved).toBeCalledTimes(1)
|
||||
expect(events.user.permissionAdminRemoved).not.toBeCalled()
|
||||
expect(events.user.deleted).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionBuilderRemoved).toHaveBeenCalledTimes(1)
|
||||
expect(events.user.permissionAdminRemoved).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should not be able to destroy account owner", async () => {
|
||||
|
|
|
@ -31,13 +31,13 @@ describe("/api/system/migrations", () => {
|
|||
status: 403,
|
||||
})
|
||||
expect(res.body).toEqual({ message: "Unauthorized", status: 403 })
|
||||
expect(migrateFn).toBeCalledTimes(0)
|
||||
expect(migrateFn).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it("runs migrations", async () => {
|
||||
const res = await config.api.migrations.runMigrations()
|
||||
expect(res.text).toBe("OK")
|
||||
expect(migrateFn).toBeCalledTimes(1)
|
||||
expect(migrateFn).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ describe("/api/system/status", () => {
|
|||
passing: true,
|
||||
},
|
||||
})
|
||||
expect(accounts.getStatus).toBeCalledTimes(0)
|
||||
expect(accounts.getStatus).toHaveBeenCalledTimes(0)
|
||||
config.cloudHosted()
|
||||
})
|
||||
|
||||
|
@ -45,7 +45,7 @@ describe("/api/system/status", () => {
|
|||
|
||||
const res = await config.api.status.getStatus()
|
||||
|
||||
expect(accounts.getStatus).toBeCalledTimes(1)
|
||||
expect(accounts.getStatus).toHaveBeenCalledTimes(1)
|
||||
expect(res.body).toEqual(value)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -15,7 +15,7 @@ describe("offline", () => {
|
|||
|
||||
// TODO: Currently requires a self host install + account portal
|
||||
// Ignored until we set this up
|
||||
xit("creates, activates and deletes offline license", async () => {
|
||||
it.skip("creates, activates and deletes offline license", async () => {
|
||||
// installation: Delete any token
|
||||
await config.internalApi.license.deleteOfflineLicenseToken()
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import TestConfiguration from "../../config/TestConfiguration"
|
|||
import * as fixtures from "../../fixtures"
|
||||
import { Query } from "@budibase/types"
|
||||
|
||||
xdescribe("Internal API - Data Sources: MongoDB", () => {
|
||||
describe.skip("Internal API - Data Sources: MongoDB", () => {
|
||||
const config = new TestConfiguration()
|
||||
|
||||
beforeAll(async () => {
|
||||
|
|
Loading…
Reference in New Issue