Skip to content

Commit

Permalink
Added E2E tests for externalAppCardActionsForCEA APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
MengyiGong committed Sep 27, 2024
1 parent 5851073 commit 58b023d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "ExternalAppCardActionsForCEA",
"version": ">2.18.0",
"platform": "Web",
"testCases": [
{
"title": "checkExternalAppCardActionsForCEACapability API Call - Success",
"type": "callResponse",
"boxSelector": "#box_checkExternalAppCardActionsForCEACapability",
"expectedTestAppValue": "External App Card Actions For CEA module is supported"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const CheckExternalAppCardActionsForCEACapability = (): React.ReactElement =>
} supported`,
});

const CECProcessActionSubmit = (): React.ReactElement =>
const ProcessActionSubmitForCEA = (): React.ReactElement =>
ApiWithTextInput<{
appId: AppId;
conversationId: string;
Expand All @@ -27,6 +27,9 @@ const CECProcessActionSubmit = (): React.ReactElement =>
if (!input.appId) {
throw new Error('appId is required');
}
if (!input.conversationId) {
throw new Error('conversationId is required');
}
if (!input.actionSubmitPayload) {
throw new Error('actionSubmitPayload is required');
}
Expand All @@ -41,19 +44,20 @@ const CECProcessActionSubmit = (): React.ReactElement =>
},
},
defaultInput: JSON.stringify({
appId: 'b7f8c0a0-6c1d-4a9a-9c0a-2c3f1c0a3b0a',
appId: new AppId('b7f8c0a0-6c1d-4a9a-9c0a-2c3f1c0a3b0a'),
conversationId: 'conversationId',
actionSubmitPayload: {
id: 'submitId',
data: 'data1',
},
}),
});

const CECProcessActionOpenUrl = (): React.ReactElement =>
const ProcessActionOpenUrlForCEA = (): React.ReactElement =>
ApiWithTextInput<{
appId: AppId;
conversationId: string;
url: string;
url: URL;
}>({
name: 'processActionOpenUrlForCEA',
title: 'Process Action Open Url For CEA',
Expand All @@ -62,6 +66,9 @@ const CECProcessActionOpenUrl = (): React.ReactElement =>
if (!input.appId) {
throw new Error('appId is required');
}
if (!input.conversationId) {
throw new Error('conversationId is required');
}
if (!input.url) {
throw new Error('url is required');
}
Expand All @@ -70,22 +77,23 @@ const CECProcessActionOpenUrl = (): React.ReactElement =>
const result = await externalAppCardActionsForCEA.processActionOpenUrl(
input.appId,
input.conversationId,
new URL(input.url),
input.url,
);
return JSON.stringify(result);
},
},
defaultInput: JSON.stringify({
appId: 'b7f8c0a0-6c1d-4a9a-9c0a-2c3f1c0a3b0a',
url: 'https://www.example.com',
appId: new AppId('b7f8c0a0-6c1d-4a9a-9c0a-2c3f1c0a3b0a'),
conversationId: 'conversationID',
url: new URL('https://www.example.com'),
}),
});

const ExternalAppCardActionsForCEAAPIs = (): React.ReactElement => (
<ModuleWrapper title="External App Card Actions For CEA">
<CheckExternalAppCardActionsForCEACapability />
<CECProcessActionSubmit />
<CECProcessActionOpenUrl />
<ProcessActionSubmitForCEA />
<ProcessActionOpenUrlForCEA />
</ModuleWrapper>
);

Expand Down
6 changes: 4 additions & 2 deletions packages/teams-js/src/private/externalAppCardActionsForCEA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export namespace externalAppCardActionsForCEA {
ApiName.ExternalAppCardActionsForCEA_ProcessActionOpenUrl,
),
ApiName.ExternalAppCardActionsForCEA_ProcessActionOpenUrl,
[appId, url.href, conversationId],
[appId, conversationId, url],
);
if (error) {
throw error;
Expand Down Expand Up @@ -84,7 +84,9 @@ export namespace externalAppCardActionsForCEA {
ApiName.ExternalAppCardActionsForCEA_ProcessActionSubmit,
),
ApiName.ExternalAppCardActionsForCEA_ProcessActionSubmit,
[appId, conversationId, actionSubmitPayload],
appId,
conversationId,
actionSubmitPayload,
);
if (error) {
throw error;
Expand Down

0 comments on commit 58b023d

Please sign in to comment.