From f1909836d62ccc00377e13a21a0607abbb5cd240 Mon Sep 17 00:00:00 2001 From: Maggie Gong Date: Thu, 26 Sep 2024 13:40:25 -0700 Subject: [PATCH 1/4] Added E2E tests for externalAppCardActionsForCEA APIs --- .../externalAppCardActionsForCEA.json | 13 ++++++++++ .../ExternalAppCardActionsForCEAAPIs.tsx | 26 ++++++++++++------- ...-04213847-0138-4547-976c-ae02297702f0.json | 7 +++++ .../private/externalAppCardActionsForCEA.ts | 6 +++-- .../externalAppCardActionsForCEA.spec.ts | 8 +++--- 5 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 apps/teams-test-app/e2e-test-data/externalAppCardActionsForCEA.json create mode 100644 change/@microsoft-teams-js-04213847-0138-4547-976c-ae02297702f0.json diff --git a/apps/teams-test-app/e2e-test-data/externalAppCardActionsForCEA.json b/apps/teams-test-app/e2e-test-data/externalAppCardActionsForCEA.json new file mode 100644 index 0000000000..ff31dced5a --- /dev/null +++ b/apps/teams-test-app/e2e-test-data/externalAppCardActionsForCEA.json @@ -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" + } + ] +} diff --git a/apps/teams-test-app/src/components/privateApis/ExternalAppCardActionsForCEAAPIs.tsx b/apps/teams-test-app/src/components/privateApis/ExternalAppCardActionsForCEAAPIs.tsx index 282fc84f7f..ca03aa1d84 100644 --- a/apps/teams-test-app/src/components/privateApis/ExternalAppCardActionsForCEAAPIs.tsx +++ b/apps/teams-test-app/src/components/privateApis/ExternalAppCardActionsForCEAAPIs.tsx @@ -14,7 +14,7 @@ const CheckExternalAppCardActionsForCEACapability = (): React.ReactElement => } supported`, }); -const CECProcessActionSubmit = (): React.ReactElement => +const ProcessActionSubmitForCEA = (): React.ReactElement => ApiWithTextInput<{ appId: AppId; conversationId: string; @@ -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'); } @@ -41,7 +44,8 @@ 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', @@ -49,11 +53,11 @@ const CECProcessActionSubmit = (): React.ReactElement => }), }); -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', @@ -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'); } @@ -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 => ( - - + + ); diff --git a/change/@microsoft-teams-js-04213847-0138-4547-976c-ae02297702f0.json b/change/@microsoft-teams-js-04213847-0138-4547-976c-ae02297702f0.json new file mode 100644 index 0000000000..886a2bcb56 --- /dev/null +++ b/change/@microsoft-teams-js-04213847-0138-4547-976c-ae02297702f0.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Updated types for `{externalAppCardActionsForCEA}` capability.", + "packageName": "@microsoft/teams-js", + "email": "maggiegong@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/teams-js/src/private/externalAppCardActionsForCEA.ts b/packages/teams-js/src/private/externalAppCardActionsForCEA.ts index eea0d73ce8..4ca703b764 100644 --- a/packages/teams-js/src/private/externalAppCardActionsForCEA.ts +++ b/packages/teams-js/src/private/externalAppCardActionsForCEA.ts @@ -47,7 +47,7 @@ export namespace externalAppCardActionsForCEA { ApiName.ExternalAppCardActionsForCEA_ProcessActionOpenUrl, ), ApiName.ExternalAppCardActionsForCEA_ProcessActionOpenUrl, - [appId, url.href, conversationId], + [appId, conversationId, url], ); if (error) { throw error; @@ -84,7 +84,9 @@ export namespace externalAppCardActionsForCEA { ApiName.ExternalAppCardActionsForCEA_ProcessActionSubmit, ), ApiName.ExternalAppCardActionsForCEA_ProcessActionSubmit, - [appId, conversationId, actionSubmitPayload], + appId, + conversationId, + actionSubmitPayload, ); if (error) { throw error; diff --git a/packages/teams-js/test/private/externalAppCardActionsForCEA.spec.ts b/packages/teams-js/test/private/externalAppCardActionsForCEA.spec.ts index 2bd9e42196..d664f0b686 100644 --- a/packages/teams-js/test/private/externalAppCardActionsForCEA.spec.ts +++ b/packages/teams-js/test/private/externalAppCardActionsForCEA.spec.ts @@ -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); } @@ -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); @@ -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); } @@ -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); } From e31ec57ef3ccd1869803f04084b199b335342468 Mon Sep 17 00:00:00 2001 From: Maggie Gong Date: Fri, 27 Sep 2024 10:52:08 -0700 Subject: [PATCH 2/4] deserialize appid to AppId Object, url string to URL --- .../ExternalAppCardActionsForCEAAPIs.tsx | 18 +++++++++--------- .../private/externalAppCardActionsForCEA.ts | 4 ++-- .../externalAppCardActionsForCEA.spec.ts | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/teams-test-app/src/components/privateApis/ExternalAppCardActionsForCEAAPIs.tsx b/apps/teams-test-app/src/components/privateApis/ExternalAppCardActionsForCEAAPIs.tsx index ca03aa1d84..f82468b6e1 100644 --- a/apps/teams-test-app/src/components/privateApis/ExternalAppCardActionsForCEAAPIs.tsx +++ b/apps/teams-test-app/src/components/privateApis/ExternalAppCardActionsForCEAAPIs.tsx @@ -16,7 +16,7 @@ const CheckExternalAppCardActionsForCEACapability = (): React.ReactElement => const ProcessActionSubmitForCEA = (): React.ReactElement => ApiWithTextInput<{ - appId: AppId; + appId: string; conversationId: string; actionSubmitPayload: IAdaptiveCardActionSubmit; }>({ @@ -36,7 +36,7 @@ const ProcessActionSubmitForCEA = (): React.ReactElement => }, submit: async (input) => { await externalAppCardActionsForCEA.processActionSubmit( - input.appId, + new AppId(input.appId), input.conversationId, input.actionSubmitPayload, ); @@ -44,7 +44,7 @@ const ProcessActionSubmitForCEA = (): React.ReactElement => }, }, defaultInput: JSON.stringify({ - appId: new AppId('b7f8c0a0-6c1d-4a9a-9c0a-2c3f1c0a3b0a'), + appId: 'b7f8c0a0-6c1d-4a9a-9c0a-2c3f1c0a3b0a', conversationId: 'conversationId', actionSubmitPayload: { id: 'submitId', @@ -55,9 +55,9 @@ const ProcessActionSubmitForCEA = (): React.ReactElement => const ProcessActionOpenUrlForCEA = (): React.ReactElement => ApiWithTextInput<{ - appId: AppId; + appId: string; conversationId: string; - url: URL; + url: string; }>({ name: 'processActionOpenUrlForCEA', title: 'Process Action Open Url For CEA', @@ -75,17 +75,17 @@ const ProcessActionOpenUrlForCEA = (): React.ReactElement => }, submit: async (input) => { const result = await externalAppCardActionsForCEA.processActionOpenUrl( - input.appId, + new AppId(input.appId), input.conversationId, - input.url, + new URL(input.url), ); return JSON.stringify(result); }, }, defaultInput: JSON.stringify({ - appId: new AppId('b7f8c0a0-6c1d-4a9a-9c0a-2c3f1c0a3b0a'), + appId: 'b7f8c0a0-6c1d-4a9a-9c0a-2c3f1c0a3b0a', conversationId: 'conversationID', - url: new URL('https://www.example.com'), + url: 'https://www.example.com', }), }); diff --git a/packages/teams-js/src/private/externalAppCardActionsForCEA.ts b/packages/teams-js/src/private/externalAppCardActionsForCEA.ts index 4ca703b764..57c1644069 100644 --- a/packages/teams-js/src/private/externalAppCardActionsForCEA.ts +++ b/packages/teams-js/src/private/externalAppCardActionsForCEA.ts @@ -47,7 +47,7 @@ export namespace externalAppCardActionsForCEA { ApiName.ExternalAppCardActionsForCEA_ProcessActionOpenUrl, ), ApiName.ExternalAppCardActionsForCEA_ProcessActionOpenUrl, - [appId, conversationId, url], + [appId.toString(), conversationId, url.href], ); if (error) { throw error; @@ -84,7 +84,7 @@ export namespace externalAppCardActionsForCEA { ApiName.ExternalAppCardActionsForCEA_ProcessActionSubmit, ), ApiName.ExternalAppCardActionsForCEA_ProcessActionSubmit, - appId, + appId.toString(), conversationId, actionSubmitPayload, ); diff --git a/packages/teams-js/test/private/externalAppCardActionsForCEA.spec.ts b/packages/teams-js/test/private/externalAppCardActionsForCEA.spec.ts index d664f0b686..db8520e0d9 100644 --- a/packages/teams-js/test/private/externalAppCardActionsForCEA.spec.ts +++ b/packages/teams-js/test/private/externalAppCardActionsForCEA.spec.ts @@ -75,7 +75,7 @@ describe('externalAppCardActionsForCEA', () => { const message = utils.findMessageByFunc(ApiName.ExternalAppCardActionsForCEA_ProcessActionSubmit); if (message && message.args) { expect(message).not.toBeNull(); - expect(message.args).toEqual([testAppId, testConversationId, testActionSubmitPayload]); + expect(message.args).toEqual([testAppId.toString(), testConversationId, testActionSubmitPayload]); utils.respondToMessage(message, undefined); } @@ -94,7 +94,7 @@ describe('externalAppCardActionsForCEA', () => { const message = utils.findMessageByFunc(ApiName.ExternalAppCardActionsForCEA_ProcessActionSubmit); if (message && message.args) { expect(message).not.toBeNull(); - expect(message.args).toEqual([testAppId, testConversationId, testActionSubmitPayload]); + expect(message.args).toEqual([testAppId.toString(), testConversationId, testActionSubmitPayload]); utils.respondToMessage(message, testError); } await expect(promise).rejects.toEqual(testError); @@ -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, testConversationId, testUrl.href]); + expect(message.args).toEqual([testAppId.toString(), testConversationId, testUrl.href]); utils.respondToMessage(message, null, testResponse); } @@ -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, testConversationId, testUrl.href]); + expect(message.args).toEqual([testAppId.toString(), testConversationId, testUrl.href]); utils.respondToMessage(message, testError, null); } From c35b3f13d762811a58ed272998bf571bc7586604 Mon Sep 17 00:00:00 2001 From: Maggie Date: Fri, 27 Sep 2024 11:11:56 -0700 Subject: [PATCH 3/4] Update apps/teams-test-app/e2e-test-data/externalAppCardActionsForCEA.json Co-authored-by: Trevor Harris --- .../e2e-test-data/externalAppCardActionsForCEA.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/teams-test-app/e2e-test-data/externalAppCardActionsForCEA.json b/apps/teams-test-app/e2e-test-data/externalAppCardActionsForCEA.json index ff31dced5a..f6c1dfdf46 100644 --- a/apps/teams-test-app/e2e-test-data/externalAppCardActionsForCEA.json +++ b/apps/teams-test-app/e2e-test-data/externalAppCardActionsForCEA.json @@ -1,6 +1,6 @@ { "name": "ExternalAppCardActionsForCEA", - "version": ">2.18.0", + "version": ">=2.29.0", "platform": "Web", "testCases": [ { From 5c7e80b1e06153c4d824d3bbc422e1ecdee01e6d Mon Sep 17 00:00:00 2001 From: Maggie Date: Fri, 27 Sep 2024 11:12:04 -0700 Subject: [PATCH 4/4] Update change/@microsoft-teams-js-04213847-0138-4547-976c-ae02297702f0.json Co-authored-by: Trevor Harris --- ...microsoft-teams-js-04213847-0138-4547-976c-ae02297702f0.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/change/@microsoft-teams-js-04213847-0138-4547-976c-ae02297702f0.json b/change/@microsoft-teams-js-04213847-0138-4547-976c-ae02297702f0.json index 886a2bcb56..ad77d943d6 100644 --- a/change/@microsoft-teams-js-04213847-0138-4547-976c-ae02297702f0.json +++ b/change/@microsoft-teams-js-04213847-0138-4547-976c-ae02297702f0.json @@ -1,6 +1,6 @@ { "type": "patch", - "comment": "Updated types for `{externalAppCardActionsForCEA}` capability.", + "comment": "Updated types for `externalAppCardActionsForCEA` capability.", "packageName": "@microsoft/teams-js", "email": "maggiegong@microsoft.com", "dependentChangeType": "patch"