Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added E2E tests for externalAppCardActionsForCEA APIs #2530

Merged
merged 6 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "ExternalAppCardActionsForCEA",
"version": ">=2.29.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,9 +14,9 @@ const CheckExternalAppCardActionsForCEACapability = (): React.ReactElement =>
} supported`,
});

const CECProcessActionSubmit = (): React.ReactElement =>
const ProcessActionSubmitForCEA = (): React.ReactElement =>
ApiWithTextInput<{
appId: AppId;
appId: string;
conversationId: string;
actionSubmitPayload: IAdaptiveCardActionSubmit;
}>({
Expand All @@ -27,13 +27,16 @@ 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');
}
},
submit: async (input) => {
await externalAppCardActionsForCEA.processActionSubmit(
input.appId,
new AppId(input.appId),
input.conversationId,
input.actionSubmitPayload,
);
Expand All @@ -42,16 +45,17 @@ const CECProcessActionSubmit = (): React.ReactElement =>
},
defaultInput: JSON.stringify({
appId: 'b7f8c0a0-6c1d-4a9a-9c0a-2c3f1c0a3b0a',
conversationId: 'conversationId',
actionSubmitPayload: {
id: 'submitId',
data: 'data1',
},
}),
});

const CECProcessActionOpenUrl = (): React.ReactElement =>
const ProcessActionOpenUrlForCEA = (): React.ReactElement =>
ApiWithTextInput<{
appId: AppId;
appId: string;
conversationId: string;
url: string;
}>({
Expand All @@ -62,13 +66,16 @@ 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');
}
},
submit: async (input) => {
const result = await externalAppCardActionsForCEA.processActionOpenUrl(
input.appId,
new AppId(input.appId),
input.conversationId,
new URL(input.url),
);
Expand All @@ -77,15 +84,16 @@ const CECProcessActionOpenUrl = (): React.ReactElement =>
},
defaultInput: JSON.stringify({
appId: 'b7f8c0a0-6c1d-4a9a-9c0a-2c3f1c0a3b0a',
conversationId: 'conversationID',
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Updated types for `externalAppCardActionsForCEA` capability.",
"packageName": "@microsoft/teams-js",
"email": "[email protected]",
"dependentChangeType": "patch"
}
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.toString(), conversationId, url.href],
);
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.toString(),
conversationId,
actionSubmitPayload,
);
if (error) {
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('externalAppCardActionsForCEA', () => {
const message = utils.findMessageByFunc(ApiName.ExternalAppCardActionsForCEA_ProcessActionSubmit);
if (message && message.args) {
expect(message).not.toBeNull();
expect(message.args[0]).toEqual([testAppId, testConversationId, testActionSubmitPayload]);
expect(message.args).toEqual([testAppId.toString(), testConversationId, testActionSubmitPayload]);
utils.respondToMessage(message, undefined);
}

Expand All @@ -94,7 +94,7 @@ describe('externalAppCardActionsForCEA', () => {
const message = utils.findMessageByFunc(ApiName.ExternalAppCardActionsForCEA_ProcessActionSubmit);
if (message && message.args) {
expect(message).not.toBeNull();
expect(message.args[0]).toEqual([testAppId, testConversationId, testActionSubmitPayload]);
expect(message.args).toEqual([testAppId.toString(), testConversationId, testActionSubmitPayload]);
utils.respondToMessage(message, testError);
}
await expect(promise).rejects.toEqual(testError);
Expand Down Expand Up @@ -161,7 +161,7 @@ describe('externalAppCardActionsForCEA', () => {
const message = utils.findMessageByFunc(ApiName.ExternalAppCardActionsForCEA_ProcessActionOpenUrl);
if (message && message.args) {
expect(message).not.toBeNull();
expect(message.args).toEqual([testAppId, testUrl.href, testConversationId]);
expect(message.args).toEqual([testAppId.toString(), testConversationId, testUrl.href]);
utils.respondToMessage(message, null, testResponse);
}

Expand All @@ -178,7 +178,7 @@ describe('externalAppCardActionsForCEA', () => {
const message = utils.findMessageByFunc(ApiName.ExternalAppCardActionsForCEA_ProcessActionOpenUrl);
if (message && message.args) {
expect(message).not.toBeNull();
expect(message.args).toEqual([testAppId, testUrl.href, testConversationId]);
expect(message.args).toEqual([testAppId.toString(), testConversationId, testUrl.href]);
utils.respondToMessage(message, testError, null);
}

Expand Down
Loading