Skip to content

Commit

Permalink
test(internal-plugin-dss): revert test and fix with an empty catch (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mkesavan13 authored Apr 25, 2024
1 parent b81ca4a commit 9c5224b
Showing 1 changed file with 59 additions and 51 deletions.
110 changes: 59 additions & 51 deletions packages/@webex/internal-plugin-dss/test/unit/spec/dss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,22 +620,24 @@ describe('plugin-dss', () => {
});

it('fails with default timeout when mercury does not respond', async () => {
return testMakeRequest({
const {promise} = await testMakeRequest({
method: 'lookup',
resource: '/lookup/orgid/userOrgId/identities',
params: {id: 'id1', shouldBatch: false},
bodyParams: {lookupValues: ['id1']},
}).then(async ({promise}) => {
promise.catch((err) => {
expect(err.toString()).equal(
'DssTimeoutError: The DSS did not respond within 6000 ms.' +
'\n Request Id: randomid' +
'\n Resource: /lookup/orgid/userOrgId/identities' +
'\n Params: {"lookupValues":["id1"]}'
);
});
await clock.tickAsync(6000);
});

promise.catch(() => {}); // to prevent the test from failing due to unhandled promise rejection

await clock.tickAsync(6000);

return assert.isRejected(
promise,
'The DSS did not respond within 6000 ms.' +
'\n Request Id: randomid' +
'\n Resource: /lookup/orgid/userOrgId/identities' +
'\n Params: {"lookupValues":["id1"]}'
);
});

it('does not fail with timeout when mercury response in time', async () => {
Expand Down Expand Up @@ -719,22 +721,24 @@ describe('plugin-dss', () => {
});

it('fails with default timeout when mercury does not respond', async () => {
return testMakeRequest({
const {promise} = await testMakeRequest({
method: 'lookupByEmail',
resource: '/lookup/orgid/userOrgId/emails',
params: {email: 'email1'},
bodyParams: {lookupValues: ['email1']},
}).then(async ({promise}) => {
promise.catch((err) => {
expect(err.toString()).equal(
'DssTimeoutError: The DSS did not respond within 6000 ms.' +
'\n Request Id: randomid' +
'\n Resource: /lookup/orgid/userOrgId/emails' +
'\n Params: {"lookupValues":["email1"]}'
);
});
await clock.tickAsync(6000);
});

promise.catch(() => {}); // to prevent the test from failing due to unhandled promise rejection

await clock.tickAsync(6000);

return assert.isRejected(
promise,
'The DSS did not respond within 6000 ms.' +
'\n Request Id: randomid' +
'\n Resource: /lookup/orgid/userOrgId/emails' +
'\n Params: {"lookupValues":["email1"]}'
);
});

it('does not fail with timeout when mercury response in time', async () => {
Expand Down Expand Up @@ -813,7 +817,7 @@ describe('plugin-dss', () => {
});

it('fails with default timeout when mercury does not respond', async () => {
return testMakeRequest({
const {promise} = await testMakeRequest({
method: 'search',
resource: '/search/orgid/userOrgId/entities',
params: {
Expand All @@ -826,17 +830,19 @@ describe('plugin-dss', () => {
resultSize: 100,
queryString: 'query',
},
}).then(async ({promise}) => {
promise.catch((err) => {
expect(err.toString()).equal(
'DssTimeoutError: The DSS did not respond within 6000 ms.' +
'\n Request Id: randomid' +
'\n Resource: /search/orgid/userOrgId/entities' +
'\n Params: {"queryString":"query","resultSize":100,"requestedTypes":["PERSON","ROBOT"]}'
);
});
await clock.tickAsync(6000);
});

promise.catch(() => {}); // to prevent the test from failing due to unhandled promise rejection

await clock.tickAsync(6000);

return assert.isRejected(
promise,
'The DSS did not respond within 6000 ms.' +
'\n Request Id: randomid' +
'\n Resource: /search/orgid/userOrgId/entities' +
'\n Params: {"queryString":"query","resultSize":100,"requestedTypes":["PERSON","ROBOT"]}'
);
});

it('does not fail with timeout when mercury response in time', async () => {
Expand Down Expand Up @@ -871,7 +877,7 @@ describe('plugin-dss', () => {
});

it('fails with timeout when request only partially resolved', async () => {
return testMakeRequest({
const {requestId, promise} = await testMakeRequest({
method: 'search',
resource: '/search/orgid/userOrgId/entities',
params: {
Expand All @@ -884,24 +890,26 @@ describe('plugin-dss', () => {
resultSize: 100,
queryString: 'query',
},
}).then(async ({requestId, promise}) => {
mercuryCallbacks['event:directory.search'](
createData(requestId, 2, true, 'directoryEntities', ['data2'])
);
mercuryCallbacks['event:directory.search'](
createData(requestId, 0, false, 'directoryEntities', ['data0'])
);

promise.catch((err) => {
expect(err.toString()).equal(
'DssTimeoutError: The DSS did not respond within 6000 ms.' +
'\n Request Id: randomid' +
'\n Resource: /search/orgid/userOrgId/entities' +
'\n Params: {"queryString":"query","resultSize":100,"requestedTypes":["PERSON","ROBOT"]}'
);
});
await clock.tickAsync(6000);
});

mercuryCallbacks['event:directory.search'](
createData(requestId, 2, true, 'directoryEntities', ['data2'])
);
mercuryCallbacks['event:directory.search'](
createData(requestId, 0, false, 'directoryEntities', ['data0'])
);

promise.catch(() => {}); // to prevent the test from failing due to unhandled promise rejection

await clock.tickAsync(6000);

return assert.isRejected(
promise,
'The DSS did not respond within 6000 ms.' +
'\n Request Id: randomid' +
'\n Resource: /search/orgid/userOrgId/entities' +
'\n Params: {"queryString":"query","resultSize":100,"requestedTypes":["PERSON","ROBOT"]}'
);
});
});

Expand Down

0 comments on commit 9c5224b

Please sign in to comment.