diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2858083477..501bbf8592 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -218,26 +218,26 @@ extends: shardNum: 2 shardIndex: 1 - - job: E2ETestIOS - displayName: 'E2E Tests - IOS - Plan A' - pool: - name: Azure Pipelines - image: macos-latest-internal - os: macOS - steps: - - template: tools/yaml-templates/ios-test.yml@self - parameters: - iOSAppHostingSdkGitPath: IOSAppHostingSdk - testPlan: iosE2ETestPlanA - - - job: E2ETestIOS2 - displayName: 'E2E Tests - IOS - Plan B' - pool: - name: Azure Pipelines - image: macos-latest-internal - os: macOS - steps: - - template: tools/yaml-templates/ios-test.yml@self - parameters: - iOSAppHostingSdkGitPath: IOSAppHostingSdk - testPlan: iosE2ETestPlanB + # - job: E2ETestIOS + # displayName: 'E2E Tests - IOS - Plan A' + # pool: + # name: Azure Pipelines + # image: macos-latest-internal + # os: macOS + # steps: + # - template: tools/yaml-templates/ios-test.yml@self + # parameters: + # iOSAppHostingSdkGitPath: IOSAppHostingSdk + # testPlan: iosE2ETestPlanA + + # - job: E2ETestIOS2 + # displayName: 'E2E Tests - IOS - Plan B' + # pool: + # name: Azure Pipelines + # image: macos-latest-internal + # os: macOS + # steps: + # - template: tools/yaml-templates/ios-test.yml@self + # parameters: + # iOSAppHostingSdkGitPath: IOSAppHostingSdk + # testPlan: iosE2ETestPlanB diff --git a/change/@microsoft-teams-js-0bfc106c-dcbd-4193-b604-49700784ee6d.json b/change/@microsoft-teams-js-0bfc106c-dcbd-4193-b604-49700784ee6d.json new file mode 100644 index 0000000000..d00f7a2ad2 --- /dev/null +++ b/change/@microsoft-teams-js-0bfc106c-dcbd-4193-b604-49700784ee6d.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "Added `nestedAppAuth` capability against a new client version `2.1.1` to support isNAAChannelRecommended for Teams Mobile", + "packageName": "@microsoft/teams-js", + "email": "singhmanp@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/teams-js/src/public/nestedAppAuth.ts b/packages/teams-js/src/public/nestedAppAuth.ts index 47be26730e..8f01b1b252 100644 --- a/packages/teams-js/src/public/nestedAppAuth.ts +++ b/packages/teams-js/src/public/nestedAppAuth.ts @@ -4,7 +4,9 @@ * @module */ +import { GlobalVars } from '../internal/globalVars'; import { ensureInitialized } from '../internal/internalAPIs'; +import { HostClientType } from './constants'; import { runtime } from './runtime'; /** @@ -16,5 +18,26 @@ import { runtime } from './runtime'; * @beta */ export function isNAAChannelRecommended(): boolean { - return (ensureInitialized(runtime) && runtime.isNAAChannelRecommended) ?? false; + return ( + (ensureInitialized(runtime) && + (runtime.isNAAChannelRecommended || isNAAChannelRecommendedForLegacyTeamsMobile())) ?? + false + ); +} + +function isNAAChannelRecommendedForLegacyTeamsMobile(): boolean { + return ensureInitialized(runtime) && + isHostAndroidOrIOSOrIPadOS() && + runtime.isLegacyTeams && + runtime.supports.nestedAppAuth + ? true + : false; +} + +function isHostAndroidOrIOSOrIPadOS(): boolean { + return ( + GlobalVars.hostClientType === HostClientType.android || + GlobalVars.hostClientType === HostClientType.ios || + GlobalVars.hostClientType === HostClientType.ipados + ); } diff --git a/packages/teams-js/src/public/runtime.ts b/packages/teams-js/src/public/runtime.ts index 1ac1773148..88c183b7ae 100644 --- a/packages/teams-js/src/public/runtime.ts +++ b/packages/teams-js/src/public/runtime.ts @@ -593,6 +593,12 @@ export const mapTeamsVersionToSupportedCapabilities: Record { +describe('nestedAppAuth.isNAAChannelRecommended', () => { const utils = new Utils(); beforeEach(() => { @@ -63,4 +63,97 @@ describe('nestedAppAuth', () => { utils.setRuntimeConfig(runtimeConfig); expect(nestedAppAuth.isNAAChannelRecommended()).toBeFalsy(); }); + + it('should return false if isNAAChannelRecommended is false in runtimeConfig for macos client', async () => { + await utils.initializeWithContext(FrameContexts.content, HostClientType.macos); + const runtimeConfig: Runtime = { + apiVersion: 4, + supports: {}, + isNAAChannelRecommended: false, + }; + utils.setRuntimeConfig(runtimeConfig); + expect(nestedAppAuth.isNAAChannelRecommended()).toBeFalsy(); + }); + + it('should return false if isNAAChannelRecommended is false in runtimeConfig for desktop client', async () => { + await utils.initializeWithContext(FrameContexts.content, HostClientType.desktop); + const runtimeConfig: Runtime = { + apiVersion: 4, + supports: {}, + isNAAChannelRecommended: false, + }; + utils.setRuntimeConfig(runtimeConfig); + expect(nestedAppAuth.isNAAChannelRecommended()).toBeFalsy(); + }); + + it('should return false if isNAAChannelRecommended is false in runtimeConfig for web client', async () => { + await utils.initializeWithContext(FrameContexts.content, HostClientType.web); + const runtimeConfig: Runtime = { + apiVersion: 4, + supports: {}, + isNAAChannelRecommended: false, + }; + utils.setRuntimeConfig(runtimeConfig); + expect(nestedAppAuth.isNAAChannelRecommended()).toBeFalsy(); + }); + + it('should return false if isNAAChannelRecommended is false and isLegacyTeams is false in runtimeConfig', async () => { + await utils.initializeWithContext(FrameContexts.content, HostClientType.android); + const runtimeConfig: Runtime = { + apiVersion: 4, + supports: {}, + isNAAChannelRecommended: false, + isLegacyTeams: false, + }; + utils.setRuntimeConfig(runtimeConfig); + expect(nestedAppAuth.isNAAChannelRecommended()).toBeFalsy(); + }); + + it('should return false if isNAAChannelRecommended is false and isLegacyTeams is true in runtimeConfig for android client that does not supports nestedAppAuth', async () => { + await utils.initializeWithContext(FrameContexts.content, HostClientType.android); + const runtimeConfig: Runtime = { + apiVersion: 4, + supports: {}, + isNAAChannelRecommended: false, + isLegacyTeams: true, + }; + utils.setRuntimeConfig(runtimeConfig); + expect(nestedAppAuth.isNAAChannelRecommended()).toBeFalsy(); + }); + + it('should return true if isNAAChannelRecommended is false and isLegacyTeams is true in runtimeConfig for android client that supports nestedAppAuth', async () => { + await utils.initializeWithContext(FrameContexts.content, HostClientType.android); + const runtimeConfig: Runtime = { + apiVersion: 4, + supports: { nestedAppAuth }, + isNAAChannelRecommended: false, + isLegacyTeams: true, + }; + utils.setRuntimeConfig(runtimeConfig); + expect(nestedAppAuth.isNAAChannelRecommended()).toBeTruthy(); + }); + + it('should return true if isNAAChannelRecommended is false and isLegacyTeams is true in runtimeConfig for ios client that supports nestedAppAuth', async () => { + await utils.initializeWithContext(FrameContexts.content, HostClientType.ios); + const runtimeConfig: Runtime = { + apiVersion: 4, + supports: { nestedAppAuth }, + isNAAChannelRecommended: false, + isLegacyTeams: true, + }; + utils.setRuntimeConfig(runtimeConfig); + expect(nestedAppAuth.isNAAChannelRecommended()).toBeTruthy(); + }); + + it('should return true if isNAAChannelRecommended is false and isLegacyTeams is true in runtimeConfig for ipados client that supports nestedAppAuth', async () => { + await utils.initializeWithContext(FrameContexts.content, HostClientType.ipados); + const runtimeConfig: Runtime = { + apiVersion: 4, + supports: { nestedAppAuth }, + isNAAChannelRecommended: false, + isLegacyTeams: true, + }; + utils.setRuntimeConfig(runtimeConfig); + expect(nestedAppAuth.isNAAChannelRecommended()).toBeTruthy(); + }); }); diff --git a/packages/teams-js/test/public/runtime.spec.ts b/packages/teams-js/test/public/runtime.spec.ts index 1c351c3858..29904a6e6b 100644 --- a/packages/teams-js/test/public/runtime.spec.ts +++ b/packages/teams-js/test/public/runtime.spec.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/ban-types */ import { errorRuntimeNotInitialized } from '../../src/internal/constants'; +import { GlobalVars } from '../../src/internal/globalVars'; import { compareSDKVersions } from '../../src/internal/utils'; import { app, HostClientType } from '../../src/public'; import { @@ -243,6 +244,7 @@ describe('runtime', () => { for (const clientType of capabilityAdditionsInASpecificVersion.hostClientTypes) { await utils.initializeWithContext('content', clientType); + GlobalVars.hostClientType = clientType; const generatedCapabilityObjectForThisVersion = generateVersionBasedTeamsRuntimeConfig( version, versionAndPlatformAgnosticTeamsRuntimeConfig,