Skip to content

Commit

Permalink
♻️ refactor(actions): remove needless activation ID
Browse files Browse the repository at this point in the history
  • Loading branch information
thrownullexception committed Jan 12, 2024
1 parent 5dadd67 commit 06319f3
Show file tree
Hide file tree
Showing 63 changed files with 371 additions and 739 deletions.
16 changes: 1 addition & 15 deletions src/__tests__/_/api-handlers/actions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { rest } from "msw";
import { HTTP_ACTIVATION_ID } from "shared/types/actions";
import { BASE_TEST_URL } from "./_utils";

export const actionsApiHandlers = [
Expand Down Expand Up @@ -63,20 +62,7 @@ export const actionsApiHandlers = [
rest.get(
BASE_TEST_URL("/api/integrations/actions/active"),
async (_, res, ctx) => {
return res(
ctx.json([
{
activationId: HTTP_ACTIVATION_ID,
integrationKey: "http",
credentialsGroupKey: "HTTP",
},
{
activationId: "slack-activation-id",
integrationKey: "slack",
credentialsGroupKey: "SLACK",
},
])
);
return res(ctx.json(["http", "slack"]));
}
),
// rest.put(
Expand Down
15 changes: 6 additions & 9 deletions src/__tests__/api/_test-utils/_action-instances.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
import { createConfigDomainPersistenceService } from "backend/lib/config-persistence";
import { HTTP_ACTIVATION_ID, IActionInstance } from "shared/types/actions";
import { ActionIntegrationKeys, IActionInstance } from "shared/types/actions";
import { DataEventActions } from "shared/types/data";

const TEST_ACTION_INSTANCES: IActionInstance[] = [
{
instanceId: "instance-id-1",
activatedActionId: "activation-id-1",
integrationKey: "smtp",
integrationKey: ActionIntegrationKeys.SMTP,
entity: "base-model",
implementationKey: "SEND_MESSAGE",
triggerLogic: "some-test-trigger-logic",
formAction: "create",
formAction: DataEventActions.Create,
configuration: {
foo: "bar",
},
},
{
instanceId: "instance-id-2",
activatedActionId: HTTP_ACTIVATION_ID,
integrationKey: "http",
integrationKey: ActionIntegrationKeys.HTTP,
entity: "secondary-model",
implementationKey: "POST",
triggerLogic: "another-trigger-logic",
formAction: "delete",
formAction: DataEventActions.Delete,
configuration: {
bar: "foo",
},
Expand Down
27 changes: 0 additions & 27 deletions src/__tests__/api/_test-utils/_activated-actions.ts

This file was deleted.

20 changes: 20 additions & 0 deletions src/__tests__/api/_test-utils/_activated-integrations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { createKeyValueDomainPersistenceService } from "backend/lib/key-value";
import { ActionIntegrationKeys } from "shared/types/actions";

const TEST_ACTIVATED_ACTIONS: ActionIntegrationKeys[] = [
ActionIntegrationKeys.SMTP,
ActionIntegrationKeys.SLACK,
];

export const setupActivatedIntegrationsTestData = async (
testActivatedActions: ActionIntegrationKeys[] = TEST_ACTIVATED_ACTIONS
) => {
const activatedIntegrationsPersistenceService =
createKeyValueDomainPersistenceService<ActionIntegrationKeys[]>(
"activated-integrations"
);

await activatedIntegrationsPersistenceService.persistItem(
testActivatedActions
);
};
4 changes: 2 additions & 2 deletions src/__tests__/api/_test-utils/_all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { setupRolesTestData } from "./_roles";
import { setupSchemaTestData } from "./_schema";
import { setupUsersTestData } from "./_users";
import { setupIntegrationsEnvTestData } from "./_integrations-env";
import { setupActivatedActionTestData } from "./_activated-actions";
import { setupActivatedIntegrationsTestData } from "./_activated-integrations";
import { setupActionInstanceTestData } from "./_action-instances";
import { setupTestDatabaseData } from "./_data";
import { portalTestData } from "./portal";
Expand All @@ -25,7 +25,7 @@ export const setupAllTestData = async (domains: DomainTypes[]) => {
["dashboard-widgets", setupDashboardTestData],
["schema", setupSchemaTestData],
["data", setupTestDatabaseData],
["activated-actions", setupActivatedActionTestData],
["activated-integrations", setupActivatedIntegrationsTestData],
["action-instances", setupActionInstanceTestData],
["constants", setupIntegrationsConstantsTestData],
["environment-variables", setupIntegrationsEnvTestData],
Expand Down
20 changes: 10 additions & 10 deletions src/__tests__/api/integrations/actions/[key]/credentials.spec.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import handler from "pages/api/integrations/actions/[key]/credentials";
import { HTTP_ACTIVATION_ID } from "shared/types/actions";
import {
createAuthenticatedMocks,
setupAllTestData,
setupCredentialsTestData,
} from "__tests__/api/_test-utils";
import { ActionIntegrationKeys } from "shared/types/actions";

describe("/api/integrations/actions/[key]/credentials", () => {
beforeAll(async () => {
await setupAllTestData(["activated-actions", "users"]);
await setupAllTestData(["activated-integrations", "users"]);
await setupCredentialsTestData({
RANDOM___authUser:
"aad0f7e776963ae66b7459222d54871433f8e119ab9a9712d4e82e8cbb77246e47a750a773c0ea316c110a1d3f2ee16c2509906fb89f1c4b039d09f139b1d7eacc26908c25137c46f269cfb13f63221da2f1631bf4f59cbe14cc18cbfb8993098bd7e2d865f20717",
SMTP___authUser:
ACTION__SMTP___authUser:
"aad0f7e776963ae66b7459222d54871433f8e119ab9a9712d4e82e8cbb77246e47a750a773c0ea316c110a1d3f2ee16c2509906fb89f1c4b039d09f139b1d7eacc26908c25137c46f269cfb13f63221da2f1631bf4f59cbe14cc18cbfb8993098bd7e2d865f20717",
SMTP___invalidField:
ACTION__SMTP___invalidField:
"aad0f7e776963ae66b7459222d54871433f8e119ab9a9712d4e82e8cbb77246e47a750a773c0ea316c110a1d3f2ee16c2509906fb89f1c4b039d09f139b1d7eacc26908c25137c46f269cfb13f63221da2f1631bf4f59cbe14cc18cbfb8993098bd7e2d865f20717",
SMTP___host:
ACTION__SMTP___host:
"aad0f7e776963ae66b7459222d54871433f8e119ab9a9712d4e82e8cbb77246e47a750a773c0ea316c110a1d3f2ee16c2509906fb89f1c4b039d09f139b1d7eacc26908c25137c46f269cfb13f63221da2f1631bf4f59cbe14cc18cbfb8993098bd7e2d865f20717",
SMTP___port:
ACTION__SMTP___port:
"68ba76e500daa5d670930d24bbb425018571f18decc16d63ed901b85f6e99f74d3cf68225dcceb677b9a080cb1e8e8fd50abccbcf7d45fcf24c9578395b05b8aec57a763694e92fdbd2836bb91e66f17dc338bce18ae54cbb17098e1f1894c39870d7ff1cd",
});
});
Expand All @@ -27,7 +27,7 @@ describe("/api/integrations/actions/[key]/credentials", () => {
const { req, res } = createAuthenticatedMocks({
method: "POST",
query: {
key: "http",
key: ActionIntegrationKeys.SMTP,
},
body: {
_password: "invalid password",
Expand All @@ -51,7 +51,7 @@ describe("/api/integrations/actions/[key]/credentials", () => {
const { req, res } = createAuthenticatedMocks({
method: "POST",
query: {
key: "smtp-activation-id-1",
key: ActionIntegrationKeys.SMTP,
},
body: {
_password: "password",
Expand All @@ -69,11 +69,11 @@ describe("/api/integrations/actions/[key]/credentials", () => {
`);
});

it("should return empty for http activationId", async () => {
it("should return empty for http", async () => {
const { req, res } = createAuthenticatedMocks({
method: "POST",
query: {
key: HTTP_ACTIVATION_ID,
key: ActionIntegrationKeys.HTTP,
},
body: {
_password: "password",
Expand Down
Loading

0 comments on commit 06319f3

Please sign in to comment.