Skip to content

Commit

Permalink
Adding test
Browse files Browse the repository at this point in the history
  • Loading branch information
ndangudubiyyam committed Dec 10, 2024
1 parent 1da3333 commit f19f872
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
33 changes: 28 additions & 5 deletions apps/teams-test-app/src/components/privateApis/CopilotAPIs.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { copilot } from '@microsoft/teams-js';
import React, { ReactElement } from 'react';

import { ApiWithoutInput } from '../utils';
import { ApiWithoutInput, ApiWithTextInput } from '../utils';
import { ModuleWrapper } from '../utils/ModuleWrapper';

const CopilotAPIs = (): ReactElement => {
Expand All @@ -23,11 +23,34 @@ const CopilotAPIs = (): ReactElement => {
},
});

const SendCustomTelemetryData = (): ReactElement =>
ApiWithTextInput<{
name: copilot.Stage;
timestamp: number;
}>({
name: 'sendCustomTelemetryData',
title: 'sendCustomTelemetryData',
onClick: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
validateInput: (_input) => {},
submit: async (input) => {
const result = await copilot.customTelemetry.sendCustomTelemetryData(input.name, input.timestamp);
return JSON.stringify(result);
},
},
defaultInput: JSON.stringify({ name: copilot.Stage.STAGE_E, timestamp: Date.now() }),
});

return (
<ModuleWrapper title="Copilot.Eligibility">
<CheckCopilotEligibilityCapability />
<GetEligibilityInfo />
</ModuleWrapper>
<>
<ModuleWrapper title="Copilot.Eligibility">
<CheckCopilotEligibilityCapability />
<GetEligibilityInfo />
</ModuleWrapper>
<ModuleWrapper title="Copilot.CustomTelemetry">
<SendCustomTelemetryData />
</ModuleWrapper>
</>
);
};

Expand Down
3 changes: 2 additions & 1 deletion packages/teams-js/src/private/copilot/copilot.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as customTelemetry from './customTelemetry';
import { Stage } from './customTelemetry';
import * as eligibility from './eligibility';

export { customTelemetry, eligibility };
export { customTelemetry, Stage, eligibility };
2 changes: 1 addition & 1 deletion packages/teams-js/src/private/copilot/customTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { runtime } from '../../public/runtime';
const copilotTelemetryVersionNumber: ApiVersionNumber = ApiVersionNumber.V_2;
const copilotLogger = getLogger('copilot');

enum Stage {
export enum Stage {
STAGE_E = 'E',
}
/**
Expand Down
1 change: 1 addition & 0 deletions packages/teams-js/src/public/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ interface IRuntimeV4 extends IBaseRuntime {
readonly conversations?: {};
readonly copilot?: {
readonly eligibility?: {};
readonly customTelemetry?: {};
};
readonly dialog?: {
readonly card?: {
Expand Down
2 changes: 1 addition & 1 deletion packages/teams-js/test/private/copilot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ describe('copilot', () => {
});
it('sendCustomTelemetryData should throw if called before initialization', async () => {
expect.assertions(1);
copilot.customTelemetry.sendCustomTelemetryData();
copilot.customTelemetry.sendCustomTelemetryData(copilot.Stage.STAGE_E);
const message = utils.findMessageByFunc('copilot.customTelemetry.sendCustomTelemetryData');
expect(message).not.toBeNull();
});
Expand Down

0 comments on commit f19f872

Please sign in to comment.