Skip to content

Commit

Permalink
Merge branch 'main' into user/hangyin/openstore
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorJoelHarris authored Nov 20, 2024
2 parents f67f2d3 + 3a07cf5 commit f238ddb
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 26 deletions.
46 changes: 23 additions & 23 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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"
}
25 changes: 24 additions & 1 deletion packages/teams-js/src/public/nestedAppAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* @module
*/

import { GlobalVars } from '../internal/globalVars';
import { ensureInitialized } from '../internal/internalAPIs';
import { HostClientType } from './constants';
import { runtime } from './runtime';

/**
Expand All @@ -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
);
}
6 changes: 6 additions & 0 deletions packages/teams-js/src/public/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,12 @@ export const mapTeamsVersionToSupportedCapabilities: Record<string, Array<ICapab
hostClientTypes: [HostClientType.android, HostClientType.ios],
},
],
'2.1.1': [
{
capability: { nestedAppAuth: {} },
hostClientTypes: [HostClientType.android, HostClientType.ios, HostClientType.ipados],
},
],
};

const generateBackCompatRuntimeConfigLogger = runtimeLogger.extend('generateBackCompatRuntimeConfig');
Expand Down
97 changes: 95 additions & 2 deletions packages/teams-js/test/public/nestedAppAuth.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { errorLibraryNotInitialized } from '../../src/internal/constants';
import { app, FrameContexts, nestedAppAuth } from '../../src/public';
import { app, FrameContexts, HostClientType, nestedAppAuth } from '../../src/public';
import { _minRuntimeConfigToUninitialize, Runtime } from '../../src/public/runtime';
import { Utils } from '../utils';

Expand All @@ -10,7 +10,7 @@ import { Utils } from '../utils';
/**
* Test cases for nested app auth APIs
*/
describe('nestedAppAuth', () => {
describe('nestedAppAuth.isNAAChannelRecommended', () => {
const utils = new Utils();

beforeEach(() => {
Expand Down Expand Up @@ -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();
});
});
2 changes: 2 additions & 0 deletions packages/teams-js/test/public/runtime.spec.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f238ddb

Please sign in to comment.