-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Open App Store & Notify App Install Completed Capability (#2626)
* enable open app store experience and add unit test file * changefile * update unit tes file * update teams-test-app StoreApis * 1. eliminate some parameters of openStoreExperience & fix by comment 2. add e2e test 3. update unit test * update isSupported * otherAppStateChange file change migration @Zhitao * Update change/@microsoft-teams-js-07829a41-a760-48a1-a793-df938ea61c13.json Co-authored-by: Trevor Harris <trharris@microsoft.com> * Update packages/teams-js/src/private/store.ts Co-authored-by: Trevor Harris <trharris@microsoft.com> * Update packages/teams-js/src/private/store.ts Co-authored-by: Trevor Harris <trharris@microsoft.com> * add unit test for notifyInstall & update error thrown code * append 'hostSdkVersion' parameter in e2e test data * Update packages/teams-js/src/private/store.ts * Update packages/teams-js/src/private/store.ts Co-authored-by: Trevor Harris <trharris@microsoft.com> * update e2e test * update e2e test for notifyAppInstall * add collectionId parameter & modify related test files * add new error message for invalid dialog type & update test file * try catch error in test app * parse open store params json to hub sdk to eliminate redundant knowledge in hub sdk * update e2e test file * rename notifyAppInstall with notifyInstallCompleted * update name * parse parameters to hub sdk * add test cases to store e2e & update notify install title * update store e2e --------- Co-authored-by: Hang Yin <hangyin@microsoft.com> Co-authored-by: Trevor Harris <trharris@microsoft.com>
- Loading branch information
1 parent
8d2d55b
commit b558cec
Showing
13 changed files
with
545 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
{ | ||
"name": "Store", | ||
"platforms": "Web", | ||
"checkIsSupported": { | ||
"domElementName": "checkCapabilityStore" | ||
}, | ||
"version": ">2.31.0", | ||
"hostSdkVersion": { | ||
"web": ">4.5.0" | ||
}, | ||
"testCases": [ | ||
{ | ||
"title": "openStoreExperience API Call Full Store - Success", | ||
"type": "callResponse", | ||
"boxSelector": "#box_storeOpen", | ||
"inputValue": { | ||
"dialogType": "fullstore" | ||
}, | ||
"expectedAlertValue": "openStoreExperience called with ##JSON_INPUT_VALUE##" | ||
}, | ||
{ | ||
"title": "openStoreExperience API Call In-Context-Store - Success", | ||
"type": "callResponse", | ||
"boxSelector": "#box_storeOpen", | ||
"inputValue": { | ||
"dialogType": "ics" | ||
}, | ||
"expectedAlertValue": "openStoreExperience called with ##JSON_INPUT_VALUE##" | ||
}, | ||
{ | ||
"title": "openStoreExperience API Call App Detail - Success", | ||
"type": "callResponse", | ||
"boxSelector": "#box_storeOpen", | ||
"inputValue": { | ||
"dialogType": "appdetail", | ||
"appId": "1542629c-01b3-4a6d-8f76-1938b779e48d" | ||
}, | ||
"expectedAlertValue": "openStoreExperience called with ##JSON_INPUT_VALUE##" | ||
}, | ||
{ | ||
"title": "openStoreExperience API Call App Detail With Invalid AppId - Fail", | ||
"type": "callResponse", | ||
"boxSelector": "#box_storeOpen", | ||
"inputValue": { | ||
"dialogType": "appdetail", | ||
"appId": "123" | ||
}, | ||
"expectedTestAppValue": "Error: Error: Potential app id (123) is invalid; its length 3 is not within the length limits (4-256)." | ||
}, | ||
{ | ||
"title": "openStoreExperience API Call App Detail With Empty AppId - Fail", | ||
"type": "callResponse", | ||
"boxSelector": "#box_storeOpen", | ||
"inputValue": { | ||
"dialogType": "appdetail", | ||
"appId": "" | ||
}, | ||
"expectedTestAppValue": "Error: Error: Potential app id () is invalid; its length 0 is not within the length limits (4-256)." | ||
}, | ||
{ | ||
"title": "openStoreExperience API Call App Detail Without AppId - Fail", | ||
"type": "callResponse", | ||
"boxSelector": "#box_storeOpen", | ||
"inputValue": { | ||
"dialogType": "appdetail" | ||
}, | ||
"expectedTestAppValue": "Error: Error: No App Id present, but AppId needed to open AppDetail store" | ||
}, | ||
{ | ||
"title": "openStoreExperience API Call Specific Store - Success", | ||
"type": "callResponse", | ||
"boxSelector": "#box_storeOpen", | ||
"inputValue": { | ||
"dialogType": "specificstore", | ||
"collectionId": "copilotplugins" | ||
}, | ||
"expectedAlertValue": "openStoreExperience called with ##JSON_INPUT_VALUE##" | ||
}, | ||
{ | ||
"title": "openStoreExperience API Call Specific Store With Empty CollectionId - Fail", | ||
"type": "callResponse", | ||
"boxSelector": "#box_storeOpen", | ||
"inputValue": { | ||
"dialogType": "specificstore", | ||
"collectionId": "" | ||
}, | ||
"expectedTestAppValue": "Error: Error: No Collection Id present, but CollectionId needed to open a store specific to a collection" | ||
}, | ||
{ | ||
"title": "openStoreExperience API Call Specific Store Without CollectionId - Fail", | ||
"type": "callResponse", | ||
"boxSelector": "#box_storeOpen", | ||
"inputValue": { | ||
"dialogType": "specificstore" | ||
}, | ||
"expectedTestAppValue": "Error: Error: No Collection Id present, but CollectionId needed to open a store specific to a collection" | ||
}, | ||
{ | ||
"title": "openStoreExperience API Call With Invalid Dialog Type - Fail", | ||
"type": "callResponse", | ||
"boxSelector": "#box_storeOpen", | ||
"inputValue": { | ||
"dialogType": "123" | ||
}, | ||
"expectedTestAppValue": "Error: Error: Invalid store dialog type, but type needed to specify store to open" | ||
}, | ||
{ | ||
"title": "openStoreExperience API Call Without Permission - Fail", | ||
"type": "callResponse", | ||
"boxSelector": "#box_storeOpen", | ||
"inputValue": { | ||
"dialogType": "fullstore" | ||
}, | ||
"testUrlParams": [["appDefOverrides", "{\"isFullTrustApp\": false, \"isMicrosoftOwned\": false}"]], | ||
"expectedTestAppValue": "Error: Error: 500, message: App does not have the required permissions for this operation" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { AppId, store } from '@microsoft/teams-js'; | ||
import { ReactElement } from 'react'; | ||
import React from 'react'; | ||
|
||
import { ApiWithoutInput, ApiWithTextInput } from './utils'; | ||
import { ModuleWrapper } from './utils/ModuleWrapper'; | ||
|
||
const StoreAPIs = (): ReactElement => { | ||
const CheckStoreCapability = (): ReactElement => | ||
ApiWithoutInput({ | ||
name: 'checkCapabilityStore', | ||
title: 'Check Capability Store', | ||
onClick: async () => { | ||
if (store.isSupported()) { | ||
return 'Store module is supported'; | ||
} else { | ||
return 'Store module is not supported'; | ||
} | ||
}, | ||
}); | ||
|
||
const OpenStore = (): ReactElement => | ||
ApiWithTextInput<{ dialogType: string; appId?: string; collectionId?: string }>({ | ||
name: 'storeOpen', | ||
title: 'Store Open', | ||
onClick: { | ||
validateInput: (input) => { | ||
if (input?.dialogType === undefined) { | ||
throw new Error('store type undefined'); | ||
} | ||
}, | ||
submit: async (input) => { | ||
const appId = input.appId === undefined ? undefined : new AppId(input.appId); | ||
const openStoreParam = { | ||
dialogType: input.dialogType, | ||
appId: appId, | ||
collectionId: input.collectionId, | ||
}; | ||
// eslint-disable-next-line no-useless-catch | ||
try { | ||
await store.openStoreExperience(openStoreParam as store.OpenStoreParams); | ||
return 'store opened'; | ||
} catch (e) { | ||
throw e; | ||
} | ||
}, | ||
}, | ||
defaultInput: JSON.stringify({ | ||
dialogType: 'appdetail', | ||
appId: '1542629c-01b3-4a6d-8f76-1938b779e48d', | ||
}), | ||
}); | ||
return ( | ||
<ModuleWrapper title="Store"> | ||
<CheckStoreCapability /> | ||
<OpenStore /> | ||
</ModuleWrapper> | ||
); | ||
}; | ||
|
||
export default StoreAPIs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
change/@microsoft-teams-js-07829a41-a760-48a1-a793-df938ea61c13.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Added `store` capability that will enable user to open several types of app store dialogs.. The capability is still awaiting support in one or most host applications. To track availability of this capability across different hosts see https://aka.ms/capmatrix", | ||
"packageName": "@microsoft/teams-js", | ||
"email": "yt6520143@163.com", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.