-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
108df5d
commit 0a64fb5
Showing
2 changed files
with
29 additions
and
7 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 |
---|---|---|
|
@@ -60,6 +60,24 @@ describe('HogFunctionManager', () => { | |
}) | ||
) | ||
|
||
hogFunctions.push( | ||
await insertHogFunction(hub.postgres, teamId1, { | ||
name: 'Email Provider team 1', | ||
type: 'email', | ||
inputs_schema: [ | ||
{ | ||
type: 'email', | ||
key: 'message', | ||
}, | ||
], | ||
inputs: { | ||
email: { | ||
value: { from: '[email protected]', to: '[email protected]', subject: 'subject', html: 'text' }, | ||
}, | ||
}, | ||
}) | ||
) | ||
|
||
hogFunctions.push( | ||
await insertHogFunction(hub.postgres, teamId2, { | ||
name: 'Test Hog Function team 2', | ||
|
@@ -89,7 +107,7 @@ describe('HogFunctionManager', () => { | |
}) | ||
|
||
it('returns the hog functions', async () => { | ||
let items = manager.getTeamHogFunctions(teamId1) | ||
let items = manager.getTeamHogDestinations(teamId1) | ||
|
||
expect(items).toEqual([ | ||
{ | ||
|
@@ -124,6 +142,10 @@ describe('HogFunctionManager', () => { | |
}, | ||
]) | ||
|
||
const allFunctions = manager.getTeamHogFunctions(teamId1) | ||
expect(allFunctions.length).toEqual(2) | ||
expect(allFunctions.map((f) => f.type).sort()).toEqual(['destination', 'email']) | ||
|
||
await hub.db.postgres.query( | ||
PostgresUse.COMMON_WRITE, | ||
`UPDATE posthog_hogfunction SET name='Test Hog Function team 1 updated' WHERE id = $1`, | ||
|
@@ -134,7 +156,7 @@ describe('HogFunctionManager', () => { | |
// This is normally dispatched by django | ||
await manager.reloadHogFunctions(teamId1, [hogFunctions[0].id]) | ||
|
||
items = manager.getTeamHogFunctions(teamId1) | ||
items = manager.getTeamHogDestinations(teamId1) | ||
|
||
expect(items).toMatchObject([ | ||
{ | ||
|
@@ -145,7 +167,7 @@ describe('HogFunctionManager', () => { | |
}) | ||
|
||
it('removes disabled functions', async () => { | ||
let items = manager.getTeamHogFunctions(teamId1) | ||
let items = manager.getTeamHogDestinations(teamId1) | ||
|
||
expect(items).toMatchObject([ | ||
{ | ||
|
@@ -163,14 +185,14 @@ describe('HogFunctionManager', () => { | |
// This is normally dispatched by django | ||
await manager.reloadHogFunctions(teamId1, [hogFunctions[0].id]) | ||
|
||
items = manager.getTeamHogFunctions(teamId1) | ||
items = manager.getTeamHogDestinations(teamId1) | ||
|
||
expect(items).toEqual([]) | ||
}) | ||
|
||
it('enriches integration inputs if found and belonging to the team', () => { | ||
const function1Inputs = manager.getTeamHogFunctions(teamId1)[0].inputs | ||
const function2Inputs = manager.getTeamHogFunctions(teamId2)[0].inputs | ||
const function1Inputs = manager.getTeamHogDestinations(teamId1)[0].inputs | ||
const function2Inputs = manager.getTeamHogDestinations(teamId2)[0].inputs | ||
|
||
// Only the right team gets the integration inputs enriched | ||
expect(function1Inputs).toEqual({ | ||
|