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

test(internal-plugin-dss): revert test and fix with an empty catch #3568

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading