Skip to content

Commit

Permalink
fix(test): unit test failures (#3368)
Browse files Browse the repository at this point in the history
Co-authored-by: Shreyas Sharma <shreysh2@cisco.com>
  • Loading branch information
mkesavan13 and ShreyasSharma28 authored Feb 21, 2024
1 parent 51786c5 commit 0a8ee00
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/@webex/common/test/unit/spec/browser-detection.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {browserDetection} from '@webex/common/src/constants.js';
describe('getBowserSerial()', () => {
const originalWindowNavigator = {...window.navigator};

after('restore window.navigator', () => {
afterEach(() => {
window.navigator = originalWindowNavigator;
});

Expand Down
1 change: 1 addition & 0 deletions packages/@webex/http-core/src/request/request.shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import {defaults, isArray, pick} from 'lodash';
import qs from 'qs';

import {Blob} from 'buffer';
import xhr from '../lib/xhr';
import detect from '../lib/detect';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Request shim', () => {

window.XMLHttpRequest = DummyXMLHttpRequest;

const options = {upload: new EventEmitter(), headers: [], method: 'post', ...options, auth: {user: 'test', pass: 'pw'}};
const options = {upload: new EventEmitter(), headers: [], method: 'post', ...options, auth: {user: 'test', pass: 'pw'}, logger: {warn: () => {}}};

request(options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ describe('internal-plugin-calendar', () => {
uri: "kms://kms-us-int.wbx2.com/keys/xxxx-xxxx-xxxx-xxxx"
}])
},
encryptText: sinon.stub().resolves("encryptedText")
encryptText: sinon.stub().resolves("encryptedText"),
getKey: sinon.stub().resolves(undefined),
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import CONFIG from '../../../../src/config';

//@ts-ignore
global.window = {location: {hostname: 'whatever'}};
process.env.NODE_ENV = 'test';

const {getOSName, getOSVersion, getBrowserName, getBrowserVersion} = BrowserDetection();
const userAgent = `webex-js-sdk/test-webex-version client=Cantina; (os=${getOSName()}/${
Expand Down Expand Up @@ -78,6 +79,11 @@ describe('internal-plugin-metrics', () => {
orgId: 'orgId',
},
},
config: {
metrics: {
...CONFIG.metrics,
},
},
meetings: {
config: {
metrics: {
Expand Down Expand Up @@ -539,7 +545,7 @@ describe('internal-plugin-metrics', () => {
});
});

describe.skip('#submitClientEvent', () => {
describe('#submitClientEvent', () => {
it('should submit client event successfully with meetingId', () => {
const prepareDiagnosticEventSpy = sinon.spy(cd, 'prepareDiagnosticEvent');
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
Expand Down Expand Up @@ -716,7 +722,7 @@ describe('internal-plugin-metrics', () => {
]);
});

it('should submit client event successfully with correlationId, webexConferenceIdStr and globalMeetingId', () => {
it('should submit client event successfully with correlationId, webexConferenceIdStr and globalMeetingId', async () => {
const prepareDiagnosticEventSpy = sinon.spy(cd, 'prepareDiagnosticEvent');
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
const generateClientEventErrorPayloadSpy = sinon.spy(cd, 'generateClientEventErrorPayload');
Expand Down Expand Up @@ -1031,8 +1037,6 @@ describe('internal-plugin-metrics', () => {
options,
});

console.log(submitToCallDiagnosticsSpy.getCalls()[0].args[0].event.errors);

assert.calledWith(submitToCallDiagnosticsSpy, {
event: {
canProceed: true,
Expand Down Expand Up @@ -1357,7 +1361,7 @@ describe('internal-plugin-metrics', () => {
});

describe('#submitMQE', () => {
it.skip('submits the event correctly', () => {
it('submits the event correctly', () => {
const prepareDiagnosticEventSpy = sinon.spy(cd, 'prepareDiagnosticEvent');
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
const getErrorPayloadForClientErrorCodeSpy = sinon.spy(
Expand Down Expand Up @@ -1940,7 +1944,7 @@ describe('internal-plugin-metrics', () => {
});
});

describe.skip('#buildClientEventFetchRequestOptions', () => {
describe('#buildClientEventFetchRequestOptions', () => {
[undefined, 'myPreLoginId'].forEach((preLoginId) => {
it('returns expected options without preLoginId', async () => {
const options = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('internal-plugin-metrics', () => {
},
};
clearEmptyKeysRecursively(obj);
console.log(obj);
assert.deepEqual(obj, {nested: {arr: ['test']}});
});

Expand Down Expand Up @@ -369,7 +368,7 @@ describe('internal-plugin-metrics', () => {
})
});

describe('setMetricTimings', async () => {
describe('setMetricTimings', () => {
let webex: any;

const check = (options: any, expectedOptions: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {BrowserDetection} from '@webex/common';

const {getOSVersion} = BrowserDetection();

//@ts-ignore
global.window = {location: {hostname: 'whatever'}};
function promiseTick(count) {
let promise = Promise.resolve();

Expand Down

0 comments on commit 0a8ee00

Please sign in to comment.