diff --git a/packages/@webex/webex-core/src/lib/services-v2/services-v2.ts b/packages/@webex/webex-core/src/lib/services-v2/services-v2.ts index d6b19b5f5ab..8902a814ab9 100644 --- a/packages/@webex/webex-core/src/lib/services-v2/services-v2.ts +++ b/packages/@webex/webex-core/src/lib/services-v2/services-v2.ts @@ -501,16 +501,15 @@ const Services = WebexPlugin.extend({ switchActiveClusterIds(newActiveClusters: ActiveServices): Promise { this.logger.info('services: switching active cluster ids'); - const newActiveClusterIds = Object.values(newActiveClusters); + const invalidEntries = Object.entries(newActiveClusters).some(([serviceName, clusterId]) => { + const service = this._services.find((s) => s.id === clusterId); - const missingClusterIds = newActiveClusterIds.some((clusterId) => { - // if the clusterId does not exist in the catalog, fetch the catalog - return !this._services.find((service) => service.id === clusterId); + return !service || service.serviceName !== serviceName; }); - if (missingClusterIds) { + if (invalidEntries) { this.logger.warn( - 'services: some cluster ids do not exist in the catalog, fetching the catalog' + 'services: some cluster ids are unknown or do not match their service, fetching the catalog' ); // fetch the catalog diff --git a/packages/@webex/webex-core/test/unit/spec/services-v2/services-v2.ts b/packages/@webex/webex-core/test/unit/spec/services-v2/services-v2.ts index 1e6ba3fd7e3..b70c87c865b 100644 --- a/packages/@webex/webex-core/test/unit/spec/services-v2/services-v2.ts +++ b/packages/@webex/webex-core/test/unit/spec/services-v2/services-v2.ts @@ -607,6 +607,17 @@ describe('webex-core', () => { assert.calledOnce(services.initServiceCatalogs); }); + + it('fetches the catalog and does not update active services when id belongs to another service', async () => { + services._updateActiveServices = sinon.stub(); + + await services.switchActiveClusterIds({ + conversation: 'urn:TEAM:me-central-1_d:mercury', + }); + + assert.calledOnceWithExactly(services.initServiceCatalogs, true); + assert.notCalled(services._updateActiveServices); + }); }); describe('#updateCatalog', () => {