Skip to content

Commit

Permalink
Type file id with builtins (#241)
Browse files Browse the repository at this point in the history
* Add new type and update builtins

* Improve robustness of generated tests
  • Loading branch information
WilliamBergamin authored Nov 14, 2023
1 parent b160668 commit fef25e8
Show file tree
Hide file tree
Showing 32 changed files with 347 additions and 96 deletions.
1 change: 1 addition & 0 deletions src/dev_deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export {
assertInstanceOf,
AssertionError,
assertMatch,
assertNotStrictEquals,
assertRejects,
assertStrictEquals,
assertStringIncludes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const renderFunctionManifestTest = (
);
typescript.push(`const actual = ${functionName}.export();`);
typescript.push("");
typescript.push(`assertEquals(actual, expected);`);
typescript.push(`assertNotStrictEquals(actual, expected);`);
return `() => {${typescript.join("\n")}}`;
};

Expand Down Expand Up @@ -114,7 +114,7 @@ export function SlackTestFunctionTemplate(
const typescript: string[] = [];
typescript.push(autogeneratedComment());
typescript.push(
`import { assertEquals } from "../../../dev_deps.ts";`,
`import { assertEquals, assertNotStrictEquals } from "../../../dev_deps.ts";`,
);
typescript.push(
`import { DefineWorkflow } from "../../../workflows/mod.ts";`,
Expand Down Expand Up @@ -142,7 +142,7 @@ export function SlackTestFunctionTemplate(
}

typescript[1] =
`import { assertEquals, assertExists } from "../../../dev_deps.ts";`;
`import { assertEquals, assertNotStrictEquals, assertExists } from "../../../dev_deps.ts";`;
typescript.push("");
typescript.push(
`Deno.test("All outputs of Slack function ${functionName} should exist", ${
Expand Down
7 changes: 3 additions & 4 deletions src/schema/slack/functions/add_pin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import SlackTypes from "../schema_types.ts";
export default DefineFunction({
callback_id: "slack#/functions/add_pin",
source_file: "",
title: "Pin to channel",
description: "Pin a message to a channel",
title: "Pin a message",
input_parameters: {
properties: {
channel_id: {
Expand All @@ -17,8 +16,8 @@ export default DefineFunction({
},
message: {
type: SchemaTypes.string,
description: "Enter a message URL or message timestamp",
title: "Message URL or message timestamp",
description: "Enter a message link or message timestamp",
title: "Message link or message timestamp",
},
},
required: ["channel_id", "message"],
Expand Down
11 changes: 5 additions & 6 deletions src/schema/slack/functions/add_pin_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/
import { assertEquals } from "../../../dev_deps.ts";
import { assertEquals, assertNotStrictEquals } from "../../../dev_deps.ts";
import { DefineWorkflow } from "../../../workflows/mod.ts";
import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts";
import SchemaTypes from "../../schema_types.ts";
Expand All @@ -10,8 +10,7 @@ Deno.test("AddPin generates valid FunctionManifest", () => {
assertEquals(AddPin.definition.callback_id, "slack#/functions/add_pin");
const expected: ManifestFunctionSchema = {
source_file: "",
title: "Pin to channel",
description: "Pin a message to a channel",
title: "Pin a message",
input_parameters: {
properties: {
channel_id: {
Expand All @@ -21,8 +20,8 @@ Deno.test("AddPin generates valid FunctionManifest", () => {
},
message: {
type: SchemaTypes.string,
description: "Enter a message URL or message timestamp",
title: "Message URL or message timestamp",
description: "Enter a message link or message timestamp",
title: "Message link or message timestamp",
},
},
required: ["channel_id", "message"],
Expand All @@ -31,7 +30,7 @@ Deno.test("AddPin generates valid FunctionManifest", () => {
};
const actual = AddPin.export();

assertEquals(actual, expected);
assertNotStrictEquals(actual, expected);
});

Deno.test("AddPin can be used as a Slack function in a workflow step", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/schema/slack/functions/add_user_to_usergroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import SlackTypes from "../schema_types.ts";
export default DefineFunction({
callback_id: "slack#/functions/add_user_to_usergroup",
source_file: "",
title: "Add to user group",
description: "Add someone to a user group.",
title: "Add people to a user group",
description: "Additional permissions might be required",
input_parameters: {
properties: {
usergroup_id: {
Expand Down
12 changes: 8 additions & 4 deletions src/schema/slack/functions/add_user_to_usergroup_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/
import { assertEquals, assertExists } from "../../../dev_deps.ts";
import {
assertEquals,
assertExists,
assertNotStrictEquals,
} from "../../../dev_deps.ts";
import { DefineWorkflow } from "../../../workflows/mod.ts";
import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts";
import SchemaTypes from "../../schema_types.ts";
Expand All @@ -13,8 +17,8 @@ Deno.test("AddUserToUsergroup generates valid FunctionManifest", () => {
);
const expected: ManifestFunctionSchema = {
source_file: "",
title: "Add to user group",
description: "Add someone to a user group.",
title: "Add people to a user group",
description: "Additional permissions might be required",
input_parameters: {
properties: {
usergroup_id: {
Expand Down Expand Up @@ -44,7 +48,7 @@ Deno.test("AddUserToUsergroup generates valid FunctionManifest", () => {
};
const actual = AddUserToUsergroup.export();

assertEquals(actual, expected);
assertNotStrictEquals(actual, expected);
});

Deno.test("AddUserToUsergroup can be used as a Slack function in a workflow step", () => {
Expand Down
1 change: 0 additions & 1 deletion src/schema/slack/functions/archive_channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export default DefineFunction({
callback_id: "slack#/functions/archive_channel",
source_file: "",
title: "Archive a channel",
description: "Archive a Slack channel",
input_parameters: {
properties: {
channel_id: {
Expand Down
9 changes: 6 additions & 3 deletions src/schema/slack/functions/archive_channel_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/
import { assertEquals, assertExists } from "../../../dev_deps.ts";
import {
assertEquals,
assertExists,
assertNotStrictEquals,
} from "../../../dev_deps.ts";
import { DefineWorkflow } from "../../../workflows/mod.ts";
import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts";
import SlackTypes from "../schema_types.ts";
Expand All @@ -13,7 +17,6 @@ Deno.test("ArchiveChannel generates valid FunctionManifest", () => {
const expected: ManifestFunctionSchema = {
source_file: "",
title: "Archive a channel",
description: "Archive a Slack channel",
input_parameters: {
properties: {
channel_id: {
Expand All @@ -37,7 +40,7 @@ Deno.test("ArchiveChannel generates valid FunctionManifest", () => {
};
const actual = ArchiveChannel.export();

assertEquals(actual, expected);
assertNotStrictEquals(actual, expected);
});

Deno.test("ArchiveChannel can be used as a Slack function in a workflow step", () => {
Expand Down
1 change: 0 additions & 1 deletion src/schema/slack/functions/create_channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default DefineFunction({
callback_id: "slack#/functions/create_channel",
source_file: "",
title: "Create a channel",
description: "Create a Slack channel",
input_parameters: {
properties: {
channel_name: {
Expand Down
9 changes: 6 additions & 3 deletions src/schema/slack/functions/create_channel_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/
import { assertEquals, assertExists } from "../../../dev_deps.ts";
import {
assertEquals,
assertExists,
assertNotStrictEquals,
} from "../../../dev_deps.ts";
import { DefineWorkflow } from "../../../workflows/mod.ts";
import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts";
import SchemaTypes from "../../schema_types.ts";
Expand All @@ -14,7 +18,6 @@ Deno.test("CreateChannel generates valid FunctionManifest", () => {
const expected: ManifestFunctionSchema = {
source_file: "",
title: "Create a channel",
description: "Create a Slack channel",
input_parameters: {
properties: {
channel_name: {
Expand Down Expand Up @@ -55,7 +58,7 @@ Deno.test("CreateChannel generates valid FunctionManifest", () => {
};
const actual = CreateChannel.export();

assertEquals(actual, expected);
assertNotStrictEquals(actual, expected);
});

Deno.test("CreateChannel can be used as a Slack function in a workflow step", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/schema/slack/functions/create_usergroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default DefineFunction({
callback_id: "slack#/functions/create_usergroup",
source_file: "",
title: "Create a user group",
description: "Create a Slack user group",
description: "Additional permissions might be required",
input_parameters: {
properties: {
usergroup_handle: {
Expand Down
10 changes: 7 additions & 3 deletions src/schema/slack/functions/create_usergroup_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/
import { assertEquals, assertExists } from "../../../dev_deps.ts";
import {
assertEquals,
assertExists,
assertNotStrictEquals,
} from "../../../dev_deps.ts";
import { DefineWorkflow } from "../../../workflows/mod.ts";
import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts";
import SchemaTypes from "../../schema_types.ts";
Expand All @@ -14,7 +18,7 @@ Deno.test("CreateUsergroup generates valid FunctionManifest", () => {
const expected: ManifestFunctionSchema = {
source_file: "",
title: "Create a user group",
description: "Create a Slack user group",
description: "Additional permissions might be required",
input_parameters: {
properties: {
usergroup_handle: {
Expand Down Expand Up @@ -43,7 +47,7 @@ Deno.test("CreateUsergroup generates valid FunctionManifest", () => {
};
const actual = CreateUsergroup.export();

assertEquals(actual, expected);
assertNotStrictEquals(actual, expected);
});

Deno.test("CreateUsergroup can be used as a Slack function in a workflow step", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/schema/slack/functions/delay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import SchemaTypes from "../../schema_types.ts";
export default DefineFunction({
callback_id: "slack#/functions/delay",
source_file: "",
title: "Delay",
description: "Pause the workflow for a set amount of time",
title: "Delay this workflow",
description: "Pauses the workflow at this step",
input_parameters: {
properties: {
minutes_to_delay: {
Expand Down
8 changes: 4 additions & 4 deletions src/schema/slack/functions/delay_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/
import { assertEquals } from "../../../dev_deps.ts";
import { assertEquals, assertNotStrictEquals } from "../../../dev_deps.ts";
import { DefineWorkflow } from "../../../workflows/mod.ts";
import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts";
import SchemaTypes from "../../schema_types.ts";
Expand All @@ -9,8 +9,8 @@ Deno.test("Delay generates valid FunctionManifest", () => {
assertEquals(Delay.definition.callback_id, "slack#/functions/delay");
const expected: ManifestFunctionSchema = {
source_file: "",
title: "Delay",
description: "Pause the workflow for a set amount of time",
title: "Delay this workflow",
description: "Pauses the workflow at this step",
input_parameters: {
properties: {
minutes_to_delay: {
Expand All @@ -25,7 +25,7 @@ Deno.test("Delay generates valid FunctionManifest", () => {
};
const actual = Delay.export();

assertEquals(actual, expected);
assertNotStrictEquals(actual, expected);
});

Deno.test("Delay can be used as a Slack function in a workflow step", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/schema/slack/functions/invite_user_to_channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import SlackTypes from "../schema_types.ts";
export default DefineFunction({
callback_id: "slack#/functions/invite_user_to_channel",
source_file: "",
title: "Invite to channel",
title: "Add people to a channel",
description:
"Invite someone to a channel. This will only work if this workflow created the channel.",
"You or the people using the workflow must have permission to invite others to the channel",
input_parameters: {
properties: {
channel_ids: {
Expand Down
12 changes: 8 additions & 4 deletions src/schema/slack/functions/invite_user_to_channel_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/
import { assertEquals, assertExists } from "../../../dev_deps.ts";
import {
assertEquals,
assertExists,
assertNotStrictEquals,
} from "../../../dev_deps.ts";
import { DefineWorkflow } from "../../../workflows/mod.ts";
import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts";
import SchemaTypes from "../../schema_types.ts";
Expand All @@ -13,9 +17,9 @@ Deno.test("InviteUserToChannel generates valid FunctionManifest", () => {
);
const expected: ManifestFunctionSchema = {
source_file: "",
title: "Invite to channel",
title: "Add people to a channel",
description:
"Invite someone to a channel. This will only work if this workflow created the channel.",
"You or the people using the workflow must have permission to invite others to the channel",
input_parameters: {
properties: {
channel_ids: {
Expand Down Expand Up @@ -47,7 +51,7 @@ Deno.test("InviteUserToChannel generates valid FunctionManifest", () => {
};
const actual = InviteUserToChannel.export();

assertEquals(actual, expected);
assertNotStrictEquals(actual, expected);
});

Deno.test("InviteUserToChannel can be used as a Slack function in a workflow step", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/schema/slack/functions/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file was autogenerated on Thu Sep 07 2023. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/
/** This file was autogenerated on Thu Nov 02 2023. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/
import AddPin from "./add_pin.ts";
import AddUserToUsergroup from "./add_user_to_usergroup.ts";
import ArchiveChannel from "./archive_channel.ts";
Expand Down
27 changes: 24 additions & 3 deletions src/schema/slack/functions/open_form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { InternalSlackTypes } from "../types/custom/mod.ts";
export default DefineFunction({
callback_id: "slack#/functions/open_form",
source_file: "",
title: "Open a form",
description: "Opens a form for the user",
title: "Collect info in a form",
description: "Uses a form to collect information",
input_parameters: {
properties: {
title: {
Expand Down Expand Up @@ -52,7 +52,28 @@ export default DefineFunction({
description: "Context about the form submit action interactive event",
title: "interactivity",
},
submit_user: {
type: SlackTypes.user_id,
description: "Person who submitted the form",
title: "Person who submitted the form",
},
timestamp_started: {
type: SlackTypes.timestamp,
description: "Time when step started",
title: "Time when step started",
},
timestamp_completed: {
type: SlackTypes.timestamp,
description: "Time when step ended",
title: "Time when step ended",
},
},
required: ["fields", "interactivity"],
required: [
"fields",
"interactivity",
"submit_user",
"timestamp_started",
"timestamp_completed",
],
},
});
Loading

0 comments on commit fef25e8

Please sign in to comment.