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

Adding UUIDs to MessageRequests and MessageResponses #2240

Merged
merged 73 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
94fd54e
Adding UUIDs to MessageRequests and MessageResponses
jadahiya-MSFT Mar 28, 2024
31a6fff
Merge branch 'main' of https://github.com/OfficeDev/microsoft-teams-l…
jadahiya-MSFT Mar 29, 2024
c88d928
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT Apr 5, 2024
c4cf4f5
Committing changefile
jadahiya-MSFT Apr 5, 2024
bc16dbd
Merge branch 'main' of https://github.com/OfficeDev/microsoft-teams-l…
jadahiya-MSFT Apr 5, 2024
22d79fb
Merge branch 'jadahiya/message-ids' of https://github.com/OfficeDev/m…
jadahiya-MSFT Apr 5, 2024
da23fb9
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT Apr 5, 2024
0561252
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT Apr 8, 2024
fa624f6
Merge branch 'main' of https://github.com/OfficeDev/microsoft-teams-l…
jadahiya-MSFT Apr 9, 2024
3936b05
Merge branch 'jadahiya/message-ids' of https://github.com/OfficeDev/m…
jadahiya-MSFT Apr 9, 2024
f4dec6b
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT Apr 11, 2024
493cbcf
Merge branch 'main' of https://github.com/OfficeDev/microsoft-teams-l…
jadahiya-MSFT Apr 11, 2024
0bbefda
Merge branch 'main' of https://github.com/OfficeDev/microsoft-teams-l…
jadahiya-MSFT Apr 12, 2024
810e152
Added in MessageID and MessageUUID types, added in testing for UUID c…
jadahiya-MSFT Apr 12, 2024
c4e41e5
Changing waitForResponse to have input of type MessageUUID
jadahiya-MSFT Apr 12, 2024
2cc94da
Updated references to use MessageID and MessageUUID
jadahiya-MSFT Apr 12, 2024
cfd4061
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT Apr 16, 2024
6d76fdf
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT Apr 16, 2024
c2c6e81
Fixed lint error
jadahiya-MSFT Apr 16, 2024
daed3b9
Created BaseUUID type
jadahiya-MSFT Apr 16, 2024
90484a6
Merge branch 'main' of https://github.com/OfficeDev/microsoft-teams-l…
jadahiya-MSFT Apr 17, 2024
973518e
Added validation for uuid to handleParentMessage
jadahiya-MSFT Apr 17, 2024
743a896
Only validate UUIDs if there is one
jadahiya-MSFT Apr 17, 2024
c811c70
Merge branch 'main' of https://github.com/OfficeDev/microsoft-teams-l…
jadahiya-MSFT Apr 19, 2024
6566d6b
Merge branch 'main' of https://github.com/OfficeDev/microsoft-teams-l…
jadahiya-MSFT Apr 22, 2024
1951d2d
Merge branch 'main' of https://github.com/OfficeDev/microsoft-teams-l…
jadahiya-MSFT Apr 24, 2024
09506d5
Merge branch 'main' of https://github.com/OfficeDev/microsoft-teams-l…
jadahiya-MSFT Apr 24, 2024
600e0ec
Merge branch 'main' of https://github.com/OfficeDev/microsoft-teams-l…
jadahiya-MSFT Apr 25, 2024
db545d1
Added in MessageUUID object
jadahiya-MSFT Apr 25, 2024
0a20ad3
Testing new changes to UUID
jadahiya-MSFT Apr 26, 2024
14c367a
Added in serialization of objects
jadahiya-MSFT Apr 26, 2024
588a8c7
Merge branch 'main' of https://github.com/OfficeDev/microsoft-teams-l…
jadahiya-MSFT Apr 26, 2024
dfbdc87
Updated to address PR feedback
jadahiya-MSFT Apr 26, 2024
1e8cdc9
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT Apr 29, 2024
d3c0472
Added comment describing MessageID vs MessageUUID
jadahiya-MSFT Apr 29, 2024
59865dc
Merge branch 'main' of https://github.com/OfficeDev/microsoft-teams-l…
jadahiya-MSFT Apr 29, 2024
fd61898
Added in helper function
jadahiya-MSFT Apr 29, 2024
6ac09bc
Merge branch 'main' into jadahiya/message-ids
TrevorJoelHarris Apr 30, 2024
1d971a3
Removing comment since map.delete was verified to work correctly
jadahiya-MSFT Apr 30, 2024
fd5e2ea
Merge branch 'jadahiya/message-ids' of https://github.com/OfficeDev/m…
jadahiya-MSFT Apr 30, 2024
8514bdf
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT May 1, 2024
eca774f
Moved uuid object to interfaces.ts for more general use
jadahiya-MSFT May 1, 2024
f69feeb
Merge branch 'jadahiya/message-ids' of https://github.com/OfficeDev/m…
jadahiya-MSFT May 1, 2024
b6a1e35
Replaced Function in Map declarations
jadahiya-MSFT May 1, 2024
a1f907c
Updated to use serialized and deserialized Message Response objects
jadahiya-MSFT May 1, 2024
5376b3d
Merge branch 'main' into jadahiya/message-ids
TrevorJoelHarris May 3, 2024
3ca103f
Added in unit tests for UUID class
jadahiya-MSFT May 4, 2024
ba69288
Fixed lint error
jadahiya-MSFT May 4, 2024
257b3e8
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT May 6, 2024
62c9759
Updating tests
jadahiya-MSFT May 7, 2024
61dd60f
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT May 7, 2024
960259e
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT May 8, 2024
16192cb
Moved uuid object to new file uuidObject.ts, edited changefile verbage
jadahiya-MSFT May 8, 2024
8b4e3ef
Merge branch 'main' of https://github.com/OfficeDev/microsoft-teams-l…
jadahiya-MSFT May 8, 2024
7ee266a
Added in unit tests for testing callback map deletion and functionality
jadahiya-MSFT May 8, 2024
6e81322
Removed unnused import
jadahiya-MSFT May 8, 2024
391c42a
Added in logging for when a callbackID fails to be generated
jadahiya-MSFT May 8, 2024
c90a59c
Fixed a typo in communication spec
jadahiya-MSFT May 8, 2024
427b356
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT May 9, 2024
466cd17
Updated serialization and deserialization and uuid toString function
jadahiya-MSFT May 10, 2024
cf723f1
Merge branch 'jadahiya/message-ids' of https://github.com/OfficeDev/m…
jadahiya-MSFT May 10, 2024
401945b
Reverted toString() change due to compatibility issues
jadahiya-MSFT May 10, 2024
e06dde9
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT May 10, 2024
ede7f6c
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT May 10, 2024
2cb196c
Removing unnecessary map clear due to already clearing in uninitializ…
jadahiya-MSFT May 10, 2024
2b41e03
Merge branch 'jadahiya/message-ids' of https://github.com/OfficeDev/m…
jadahiya-MSFT May 10, 2024
7491372
Fixed an issue with removing message ids
jadahiya-MSFT May 10, 2024
a7da461
Merge branch 'main' into jadahiya/message-ids
AE-MS May 13, 2024
cb49af1
Merge branch 'main' of https://github.com/OfficeDev/microsoft-teams-l…
jadahiya-MSFT May 13, 2024
b88fbba
Reverting uuid back to private
jadahiya-MSFT May 13, 2024
ce5504e
Merge branch 'jadahiya/message-ids' of https://github.com/OfficeDev/m…
jadahiya-MSFT May 13, 2024
959047a
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT May 13, 2024
b757441
Merge branch 'main' into jadahiya/message-ids
jadahiya-MSFT May 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Added uuid parameter to MessageRequest interface and enabled MessageResponse ids to also be uuids",
jadahiya-MSFT marked this conversation as resolved.
Show resolved Hide resolved
"packageName": "@microsoft/teams-js",
"email": "jadahiya@microsoft.com",
"dependentChangeType": "patch"
}
91 changes: 58 additions & 33 deletions packages/teams-js/src/internal/communication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ import { version } from '../public/version';
import { GlobalVars } from './globalVars';
import { callHandler } from './handlers';
import { DOMMessageEvent, ExtendedWindow } from './interfaces';
import { MessageRequest, MessageRequestWithRequiredProperties, MessageResponse } from './messageObjects';
import {
MessageID,
MessageRequest,
MessageRequestWithRequiredProperties,
MessageResponse,
MessageUUID,
} from './messageObjects';
import {
NestedAppAuthMessageEventNames,
NestedAppAuthRequest,
ParsedNestedAppAuthMessageData,
tryPolyfillWithNestedAppAuthBridge,
} from './nestedAppAuthUtils';
import { getLogger, isFollowingApiVersionTagFormat } from './telemetry';
import { ssrSafeWindow } from './utils';
import { generateGUID, ssrSafeWindow } from './utils';
import { validateOrigin } from './validOrigins';

const communicationLogger = getLogger('communication');
Expand Down Expand Up @@ -47,15 +53,18 @@ class CommunicationPrivate {
public static topMessageQueue: MessageRequest[] = [];
public static nextMessageId = 0;
public static callbacks: {
[id: number]: Function; // (arg1, arg2, ...etc) => void
[id: MessageID]: Function; // (arg1, arg2, ...etc) => void
Copy link
Contributor

@AE-MS AE-MS Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MessageID

It looks like these maps are still using a string (which is the serialized format for the UUID) rather than an actual UUID type. Can we use an actual UUID type for our maps, rather than relying on the implementation detail of how a UUID is serialized? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm a bit confused by this question. The ids are using the type MessageID. Unfortunately, I can't use an object as an index and have to use either a template literal, number or string.

Copy link
Contributor

@AE-MS AE-MS Apr 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you are restricted to using this data structure to store the callbacks? You could consider using a JavaScript Map (although I'm guessing that won't work because you probably want custom comparison semantics on your keys). It seems like using the Map structure in the immutable-js library would suit this application if you need value equality on your keys.

} = {};
public static promiseCallbacks: {
[id: number]: Function; // (args[]) => void
[id: MessageID]: Function; // (args[]) => void
} = {};
public static portCallbacks: {
[id: number]: (port?: MessagePort, args?: unknown[]) => void;
[id: MessageID]: (port?: MessagePort, args?: unknown[]) => void;
} = {};
public static messageListener: Function;
public static legacyMessageIdsToUuidMap: {
[legacyId: number]: MessageUUID;
} = {};
jadahiya-MSFT marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down Expand Up @@ -147,6 +156,7 @@ export function uninitializeCommunication(): void {
CommunicationPrivate.callbacks = {};
CommunicationPrivate.promiseCallbacks = {};
CommunicationPrivate.portCallbacks = {};
CommunicationPrivate.legacyMessageIdsToUuidMap = {};
}

/**
Expand Down Expand Up @@ -242,7 +252,7 @@ export function sendMessageToParentAsync<T>(

return new Promise((resolve) => {
const request = sendMessageToParentHelper(apiVersionTag, actionName, args);
resolve(waitForResponse<T>(request.id));
resolve(waitForResponse<T>(request.uuid));
});
}

Expand All @@ -263,14 +273,14 @@ export function requestPortFromParentWithVersion(
);
}
const request = sendMessageToParentHelper(apiVersionTag, actionName, args);
return waitForPort(request.id);
return waitForPort(request.uuid);
}

/**
* @internal
* Limited to Microsoft-internal use
*/
function waitForPort(requestId: number): Promise<MessagePort> {
function waitForPort(requestId: MessageUUID): Promise<MessagePort> {
return new Promise<MessagePort>((resolve, reject) => {
CommunicationPrivate.portCallbacks[requestId] = (port: MessagePort | undefined, args?: unknown[]) => {
if (port instanceof MessagePort) {
Expand All @@ -287,7 +297,7 @@ function waitForPort(requestId: number): Promise<MessagePort> {
* @internal
* Limited to Microsoft-internal use
*/
function waitForResponse<T>(requestId: number): Promise<T> {
function waitForResponse<T>(requestId: MessageUUID): Promise<T> {
jadahiya-MSFT marked this conversation as resolved.
Show resolved Hide resolved
return new Promise<T>((resolve) => {
CommunicationPrivate.promiseCallbacks[requestId] = resolve;
});
Expand Down Expand Up @@ -343,7 +353,7 @@ export function sendMessageToParent(
if (callback) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
jadahiya-MSFT marked this conversation as resolved.
Show resolved Hide resolved
CommunicationPrivate.callbacks[request.id] = callback;
CommunicationPrivate.callbacks[request.uuid] = callback;
}
}

Expand All @@ -359,7 +369,7 @@ export function sendNestedAuthRequestToTopWindow(message: string): NestedAppAuth
const targetWindow = Communication.topWindow;
const request = createNestedAppAuthRequest(message);

logger('Message %i information: %o', request.id, { actionName: request.func });
logger('Message %i information: %o', request.uuid, { actionName: request.func });

return sendRequestToTargetWindowHelper(targetWindow, request) as NestedAppAuthRequest;
}
Expand All @@ -379,7 +389,7 @@ function sendRequestToTargetWindowHelper(

if (GlobalVars.isFramelessWindow) {
if (Communication.currentWindow && Communication.currentWindow.nativeInterface) {
logger(`Sending message %i to ${targetWindowName} via framelessPostMessage interface`, request.id);
logger(`Sending message %i to ${targetWindowName} via framelessPostMessage interface`, request.uuid);
(Communication.currentWindow as ExtendedWindow).nativeInterface.framelessPostMessage(JSON.stringify(request));
}
} else {
Expand All @@ -388,10 +398,10 @@ function sendRequestToTargetWindowHelper(
// If the target window isn't closed and we already know its origin, send the message right away; otherwise,
// queue the message and send it after the origin is established
if (targetWindow && targetOrigin) {
logger(`Sending message %i to ${targetWindowName} via postMessage`, request.id);
logger(`Sending message %i to ${targetWindowName} via postMessage`, request.uuid);
targetWindow.postMessage(request, targetOrigin);
} else {
logger(`Adding message %i to ${targetWindowName} message queue`, request.id);
logger(`Adding message %i to ${targetWindowName} message queue`, request.uuid);
getTargetMessageQueue(targetWindow).push(request);
}
}
Expand All @@ -415,7 +425,7 @@ function sendMessageToParentHelper(
const request = createMessageRequest(apiVersionTag, actionName, args);

/* eslint-disable-next-line strict-null-checks/all */ /* Fix tracked by 5730662 */
logger('Message %i information: %o', request.id, { actionName, args });
logger('Message %i information: %o', request.uuid, { actionName, args });

return sendRequestToTargetWindowHelper(targetWindow, request);
}
Expand Down Expand Up @@ -611,42 +621,49 @@ const handleParentMessageLogger = communicationLogger.extend('handleParentMessag
function handleParentMessage(evt: DOMMessageEvent): void {
const logger = handleParentMessageLogger;

if ('id' in evt.data && typeof evt.data.id === 'number') {
if ('id' in evt.data && (typeof evt.data.id === 'number' || typeof evt.data.id === 'string')) {
jadahiya-MSFT marked this conversation as resolved.
Show resolved Hide resolved
jadahiya-MSFT marked this conversation as resolved.
Show resolved Hide resolved
// Call any associated Communication.callbacks
const message = evt.data as MessageResponse;
jadahiya-MSFT marked this conversation as resolved.
Show resolved Hide resolved
const callback = CommunicationPrivate.callbacks[message.id];
logger('Received a response from parent for message %i', message.id);
const callbackId =
typeof message.id === 'string' ? message.id : CommunicationPrivate.legacyMessageIdsToUuidMap[message.id];
Copy link
Contributor

@AE-MS AE-MS Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typeof message.id === 'string'

I think you are trying to determine whether the id is a UUID or a number here. If this code "knows" that a UUID is just a string format, then there really isn't any value in using the custom type aliases you defined in messageObjects.ts (MessageUUID and BaseUUID) since other parts of the code are ignoring that alias and just going to the underlying data. #Closed

const callback = CommunicationPrivate.callbacks[callbackId];
logger('Received a response from parent for message %i', callbackId);
if (callback) {
logger('Invoking the registered callback for message %i with arguments %o', message.id, message.args);
logger('Invoking the registered callback for message %i with arguments %o', callbackId, message.args);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
callback.apply(null, [...message.args, message.isPartialResponse]);

// Remove the callback to ensure that the callback is called only once and to free up memory if response is a complete response
if (!isPartialResponse(evt)) {
logger('Removing registered callback for message %i', message.id);
delete CommunicationPrivate.callbacks[message.id];
logger('Removing registered callback for message %i', callbackId);
if (typeof message.id === 'number') {
delete CommunicationPrivate.legacyMessageIdsToUuidMap[message.id];
} else {
CommunicationPrivate.legacyMessageIdsToUuidMap = {};
}
delete CommunicationPrivate.callbacks[callbackId];
}
}
const promiseCallback = CommunicationPrivate.promiseCallbacks[message.id];
const promiseCallback = CommunicationPrivate.promiseCallbacks[callbackId];
if (promiseCallback) {
logger('Invoking the registered promise callback for message %i with arguments %o', message.id, message.args);
logger('Invoking the registered promise callback for message %i with arguments %o', callbackId, message.args);
promiseCallback(message.args);

logger('Removing registered promise callback for message %i', message.id);
delete CommunicationPrivate.promiseCallbacks[message.id];
logger('Removing registered promise callback for message %i', callbackId);
delete CommunicationPrivate.promiseCallbacks[callbackId];
}
const portCallback = CommunicationPrivate.portCallbacks[message.id];
const portCallback = CommunicationPrivate.portCallbacks[callbackId];
if (portCallback) {
logger('Invoking the registered port callback for message %i with arguments %o', message.id, message.args);
logger('Invoking the registered port callback for message %i with arguments %o', callbackId, message.args);
let port: MessagePort | undefined;
if (evt.ports && evt.ports[0] instanceof MessagePort) {
port = evt.ports[0];
}
portCallback(port, message.args);

logger('Removing registered port callback for message %i', message.id);
delete CommunicationPrivate.portCallbacks[message.id];
logger('Removing registered port callback for message %i', callbackId);
delete CommunicationPrivate.portCallbacks[callbackId];
}
} else if ('func' in evt.data && typeof evt.data.func === 'string') {
// Delegate the request to the proper handler
Expand Down Expand Up @@ -800,7 +817,7 @@ export function waitForMessageQueue(targetWindow: Window, callback: () => void):
* @internal
* Limited to Microsoft-internal use
*/
function sendMessageResponseToChild(id: number, args?: any[], isPartialResponse?: boolean): void {
function sendMessageResponseToChild(id: MessageID, args?: any[], isPartialResponse?: boolean): void {
const targetWindow = Communication.childWindow;
const response = createMessageResponse(id, args, isPartialResponse);
const targetOrigin = getTargetOrigin(targetWindow);
Expand Down Expand Up @@ -841,8 +858,12 @@ function createMessageRequest(
func: string,
args: any[] | undefined,
): MessageRequestWithRequiredProperties {
const messageId: MessageID = CommunicationPrivate.nextMessageId++;
jadahiya-MSFT marked this conversation as resolved.
Show resolved Hide resolved
const messageUuid: MessageUUID = generateGUID();
CommunicationPrivate.legacyMessageIdsToUuidMap[messageId] = messageUuid;
return {
id: CommunicationPrivate.nextMessageId++,
id: messageId,
uuid: messageUuid,
func: func,
timestamp: Date.now(),
args: args || [],
Expand All @@ -862,8 +883,12 @@ function createMessageRequest(
* @returns {NestedAppAuthRequest} Returns a NestedAppAuthRequest object with a unique id, the function name set to 'nestedAppAuthRequest', the current timestamp, an empty args array, and the provided message as data.
*/
function createNestedAppAuthRequest(message: string): NestedAppAuthRequest {
const messageId: MessageID = CommunicationPrivate.nextMessageId++;
jadahiya-MSFT marked this conversation as resolved.
Show resolved Hide resolved
const messageUuid: MessageUUID = generateGUID();
CommunicationPrivate.legacyMessageIdsToUuidMap[messageId] = messageUuid;
return {
id: CommunicationPrivate.nextMessageId++,
id: messageId,
uuid: messageUuid,
func: 'nestedAppAuth.execute',
timestamp: Date.now(),
// Since this is a nested app auth request, we don't need to send any args.
Expand All @@ -877,7 +902,7 @@ function createNestedAppAuthRequest(message: string): NestedAppAuthRequest {
* @internal
* Limited to Microsoft-internal use
*/
function createMessageResponse(id: number, args: any[] | undefined, isPartialResponse?: boolean): MessageResponse {
function createMessageResponse(id: MessageID, args: any[] | undefined, isPartialResponse?: boolean): MessageResponse {
return {
id: id,
args: args || [],
Expand Down
26 changes: 23 additions & 3 deletions packages/teams-js/src/internal/messageObjects.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
/**
* @internal
* Limited to Microsoft-internal use
*/
export type BaseUUID = string;

/**
* @internal
* Limited to Microsoft-internal use
*/
export type MessageUUID = BaseUUID;

/**
* @internal
* Limited to Microsoft-internal use
*/
export type MessageID = number | MessageUUID;

/**
* @internal
* Limited to Microsoft-internal use
*/
export interface MessageRequest {
id?: number;
id?: MessageID;
uuid?: MessageUUID;
Copy link
Contributor

@AE-MS AE-MS Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment describing the difference between and proper usage of these two properties? #Closed

func: string;
timestamp?: number;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -16,7 +35,7 @@ export interface MessageRequest {
* Limited to Microsoft-internal use
*/
export interface MessageResponse {
jadahiya-MSFT marked this conversation as resolved.
Show resolved Hide resolved
id: number;
id: MessageID;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
args?: any[];
isPartialResponse?: boolean; // If the message is partial, then there will be more future responses for the given message ID.
Expand All @@ -34,6 +53,7 @@ export interface MessageResponse {
* merged. However, it's a journey.
*/
export interface MessageRequestWithRequiredProperties extends MessageRequest {
id: number;
id: MessageID;
uuid: MessageUUID;
timestamp: number;
}
2 changes: 0 additions & 2 deletions packages/teams-js/test/private/teams.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ describe('Testing teams capabillity', () => {
});

describe('joinedTeams.isSupported function', () => {
const utils = new Utils();
jadahiya-MSFT marked this conversation as resolved.
Show resolved Hide resolved
it('joinedTeams.isSupported should return false if the runtime says joinedTeams is not supported', async () => {
await utils.initializeWithContext(FrameContexts.content);
utils.setRuntimeConfig({ apiVersion: 1, supports: {} });
Expand Down Expand Up @@ -281,7 +280,6 @@ describe('Testing teams capabillity', () => {
});

describe('teams.fullTrust.isSupported function', () => {
const utils = new Utils();
it('teams.fullTrust.isSupported should return false if the runtime says fullTrust is not supported', async () => {
await utils.initializeWithContext(FrameContexts.content);
utils.setRuntimeConfig({ apiVersion: 1, supports: {} });
Expand Down
2 changes: 2 additions & 0 deletions packages/teams-js/test/public/people.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ describe('people', () => {
});

describe('Testing people.isSupported function', () => {
let utils: Utils = new Utils();
jadahiya-MSFT marked this conversation as resolved.
Show resolved Hide resolved
afterEach(() => {
utils = new Utils();
app._uninitialize();
});
it('people.isSupported should return false if the runtime says people is not supported', async () => {
Expand Down
9 changes: 7 additions & 2 deletions packages/teams-js/test/public/sharing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ describe('sharing_v2', () => {
});

describe('Testing sharing.isSupported function', () => {
const utils = new Utils();
it('sharing.isSupported should return false if the runtime says sharing is not supported', async () => {
await utils.initializeWithContext(FrameContexts.content);
utils.setRuntimeConfig({ apiVersion: 1, supports: {} });
Expand Down Expand Up @@ -817,7 +816,13 @@ describe('sharing_v2', () => {
});

describe('Testing sharing.history.isSupported function', () => {
const utils = new Utils();
let utils: Utils = new Utils();
beforeEach(() => {
utils = new Utils();
});
afterEach(() => {
app._uninitialize();
});
it('sharing.history.isSupported should return false if the runtime says sharing.history is not supported', async () => {
await utils.initializeWithContext(FrameContexts.content);
utils.setRuntimeConfig({ apiVersion: 1, supports: { sharing: {} } });
Expand Down