-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Rename ids of plugins to match remote (#28014)
- Loading branch information
1 parent
e3f66e3
commit c9b50f2
Showing
5 changed files
with
26 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,8 @@ describe('CdpCyclotronWorkerPlugins', () => { | |
return item | ||
} | ||
|
||
const intercomPlugin = PLUGINS_BY_ID['posthog-intercom-plugin'] | ||
|
||
beforeEach(async () => { | ||
await resetTestDatabase() | ||
hub = await createHub() | ||
|
@@ -64,7 +66,7 @@ describe('CdpCyclotronWorkerPlugins', () => { | |
|
||
fn = await insertHogFunction({ | ||
name: 'Plugin test', | ||
template_id: 'plugin-intercom', | ||
template_id: 'plugin-posthog-intercom-plugin', | ||
}) | ||
globals = { | ||
...createHogExecutionGlobals({ | ||
|
@@ -105,7 +107,7 @@ describe('CdpCyclotronWorkerPlugins', () => { | |
|
||
describe('setupPlugin', () => { | ||
it('should setup a plugin on first call', async () => { | ||
jest.spyOn(PLUGINS_BY_ID['intercom'] as any, 'setupPlugin') | ||
jest.spyOn(intercomPlugin, 'setupPlugin') | ||
|
||
const results = processor.processBatch([ | ||
createInvocation(fn, globals), | ||
|
@@ -115,8 +117,8 @@ describe('CdpCyclotronWorkerPlugins', () => { | |
|
||
expect(await results).toMatchObject([{ finished: true }, { finished: true }, { finished: true }]) | ||
|
||
expect(PLUGINS_BY_ID['intercom'].setupPlugin).toHaveBeenCalledTimes(1) | ||
expect(jest.mocked(PLUGINS_BY_ID['intercom'].setupPlugin!).mock.calls[0][0]).toMatchInlineSnapshot(` | ||
expect(intercomPlugin.setupPlugin).toHaveBeenCalledTimes(1) | ||
expect(jest.mocked(intercomPlugin.setupPlugin!).mock.calls[0][0]).toMatchInlineSnapshot(` | ||
{ | ||
"config": { | ||
"ignoredEmailDomains": "dev.posthog.com", | ||
|
@@ -139,7 +141,7 @@ describe('CdpCyclotronWorkerPlugins', () => { | |
|
||
describe('onEvent', () => { | ||
it('should call the plugin onEvent method', async () => { | ||
jest.spyOn(PLUGINS_BY_ID['intercom'] as any, 'onEvent') | ||
jest.spyOn(intercomPlugin, 'onEvent') | ||
|
||
const invocation = createInvocation(fn, globals) | ||
invocation.globals.event.event = 'mycustomevent' | ||
|
@@ -154,9 +156,8 @@ describe('CdpCyclotronWorkerPlugins', () => { | |
|
||
await processor.processBatch([invocation]) | ||
|
||
expect(PLUGINS_BY_ID['intercom'].onEvent).toHaveBeenCalledTimes(1) | ||
expect(forSnapshot(jest.mocked(PLUGINS_BY_ID['intercom'].onEvent!).mock.calls[0][0])) | ||
.toMatchInlineSnapshot(` | ||
expect(intercomPlugin.onEvent).toHaveBeenCalledTimes(1) | ||
expect(forSnapshot(jest.mocked(intercomPlugin.onEvent!).mock.calls[0][0])).toMatchInlineSnapshot(` | ||
{ | ||
"distinct_id": "distinct_id", | ||
"event": "mycustomevent", | ||
|
@@ -219,7 +220,7 @@ describe('CdpCyclotronWorkerPlugins', () => { | |
}) | ||
|
||
it('should mock out fetch if it is a test function', async () => { | ||
jest.spyOn(PLUGINS_BY_ID['intercom'] as any, 'onEvent') | ||
jest.spyOn(intercomPlugin, 'onEvent') | ||
|
||
const invocation = createInvocation(fn, globals) | ||
invocation.hogFunction.name = 'My function [CDP-TEST-HIDDEN]' | ||
|
@@ -232,12 +233,12 @@ describe('CdpCyclotronWorkerPlugins', () => { | |
|
||
expect(mockFetch).toHaveBeenCalledTimes(0) | ||
|
||
expect(PLUGINS_BY_ID['intercom'].onEvent).toHaveBeenCalledTimes(1) | ||
expect(intercomPlugin.onEvent).toHaveBeenCalledTimes(1) | ||
|
||
expect(forSnapshot(getProducedKafkaMessagesForTopic('log_entries_test').map((m) => m.value.message))) | ||
.toMatchInlineSnapshot(` | ||
[ | ||
"Executing plugin intercom", | ||
"Executing plugin posthog-intercom-plugin", | ||
"Fetch called but mocked due to test function", | ||
"Unable to search contact [email protected] in Intercom. Status Code: undefined. Error message: ", | ||
"Execution successful", | ||
|
@@ -246,7 +247,7 @@ describe('CdpCyclotronWorkerPlugins', () => { | |
}) | ||
|
||
it('should handle and collect errors', async () => { | ||
jest.spyOn(PLUGINS_BY_ID['intercom'] as any, 'onEvent') | ||
jest.spyOn(intercomPlugin, 'onEvent') | ||
|
||
const invocation = createInvocation(fn, globals) | ||
invocation.globals.event.event = 'mycustomevent' | ||
|
@@ -258,7 +259,7 @@ describe('CdpCyclotronWorkerPlugins', () => { | |
|
||
const res = await processor.processBatch([invocation]) | ||
|
||
expect(PLUGINS_BY_ID['intercom'].onEvent).toHaveBeenCalledTimes(1) | ||
expect(intercomPlugin.onEvent).toHaveBeenCalledTimes(1) | ||
|
||
expect(res[0].error).toBeInstanceOf(Error) | ||
expect(forSnapshot(res[0].logs)).toMatchInlineSnapshot(`[]`) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters