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 1 commit
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.18.0",
MengyiGong marked this conversation as resolved.
Show resolved Hide resolved
"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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Updated types for `{externalAppCardActionsForCEA}` capability.",
MengyiGong marked this conversation as resolved.
Show resolved Hide resolved
"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, conversationId, url],
MengyiGong marked this conversation as resolved.
Show resolved Hide resolved
);
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,
MengyiGong marked this conversation as resolved.
Show resolved Hide resolved
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, 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, 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, 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, testConversationId, testUrl.href]);
utils.respondToMessage(message, testError, null);
}

Expand Down
Loading