chore: Treat internal event differently, primarely do not display info logs for those events (#8767)

* chore: Treat internal event differently, primarely do not display info log for those events

* revert doc

* add few tests

* only set internal option if present

* revert to previous condition

* start including feedback after discussion

* include feedback

* fix modules integration tests

* fix modules integration tests

* fix event bus local
This commit is contained in:
Adrien de Peretti
2024-08-28 16:46:40 +02:00
committed by GitHub
parent 6cfe9bd874
commit 5bec38538a
27 changed files with 915 additions and 465 deletions
@@ -172,12 +172,17 @@ moduleIntegrationTestRunner<IUserModuleService>({
])
expect(eventBusSpy).toHaveBeenCalledTimes(1)
expect(eventBusSpy).toHaveBeenCalledWith([
expect.objectContaining({
data: { id: "1" },
name: UserEvents.INVITE_UPDATED,
}),
])
expect(eventBusSpy).toHaveBeenCalledWith(
[
expect.objectContaining({
data: { id: "1" },
name: UserEvents.INVITE_UPDATED,
}),
],
{
internal: true,
}
)
})
})
@@ -189,12 +194,17 @@ moduleIntegrationTestRunner<IUserModuleService>({
await service.refreshInviteTokens(["1"])
expect(eventBusSpy).toHaveBeenCalledTimes(2)
expect(eventBusSpy).toHaveBeenCalledWith([
expect.objectContaining({
data: { id: "1" },
name: UserEvents.INVITE_TOKEN_GENERATED,
}),
])
expect(eventBusSpy).toHaveBeenCalledWith(
[
expect.objectContaining({
data: { id: "1" },
name: UserEvents.INVITE_TOKEN_GENERATED,
}),
],
{
internal: true,
}
)
})
})
describe("createInvitie", () => {
@@ -218,24 +228,29 @@ moduleIntegrationTestRunner<IUserModuleService>({
await service.createInvites(defaultInviteData)
expect(eventBusSpy).toHaveBeenCalledTimes(1)
expect(eventBusSpy).toHaveBeenCalledWith([
expect.objectContaining({
data: { id: "1" },
name: UserEvents.INVITE_CREATED,
}),
expect.objectContaining({
data: { id: "2" },
name: UserEvents.INVITE_CREATED,
}),
expect.objectContaining({
data: { id: "1" },
name: UserEvents.INVITE_TOKEN_GENERATED,
}),
expect.objectContaining({
data: { id: "2" },
name: UserEvents.INVITE_TOKEN_GENERATED,
}),
])
expect(eventBusSpy).toHaveBeenCalledWith(
[
expect.objectContaining({
data: { id: "1" },
name: UserEvents.INVITE_CREATED,
}),
expect.objectContaining({
data: { id: "2" },
name: UserEvents.INVITE_CREATED,
}),
expect.objectContaining({
data: { id: "1" },
name: UserEvents.INVITE_TOKEN_GENERATED,
}),
expect.objectContaining({
data: { id: "2" },
name: UserEvents.INVITE_TOKEN_GENERATED,
}),
],
{
internal: true,
}
)
})
})
})
@@ -217,12 +217,17 @@ moduleIntegrationTestRunner<IUserModuleService>({
])
expect(eventBusSpy).toHaveBeenCalledTimes(1)
expect(eventBusSpy).toHaveBeenCalledWith([
expect.objectContaining({
data: { id: "1" },
name: UserEvents.USER_UPDATED,
}),
])
expect(eventBusSpy).toHaveBeenCalledWith(
[
expect.objectContaining({
data: { id: "1" },
name: UserEvents.USER_UPDATED,
}),
],
{
internal: true,
}
)
})
})
@@ -247,16 +252,21 @@ moduleIntegrationTestRunner<IUserModuleService>({
await service.createUsers(defaultUserData)
expect(eventBusSpy).toHaveBeenCalledTimes(1)
expect(eventBusSpy).toHaveBeenCalledWith([
expect.objectContaining({
data: { id: "1" },
name: UserEvents.USER_CREATED,
}),
expect.objectContaining({
data: { id: "2" },
name: UserEvents.USER_CREATED,
}),
])
expect(eventBusSpy).toHaveBeenCalledWith(
[
expect.objectContaining({
data: { id: "1" },
name: UserEvents.USER_CREATED,
}),
expect.objectContaining({
data: { id: "2" },
name: UserEvents.USER_CREATED,
}),
],
{
internal: true,
}
)
})
})
})