Skip to content
Open
Show file tree
Hide file tree
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
11 changes: 5 additions & 6 deletions packages/@webex/webex-core/src/lib/services-v2/services-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,16 +501,15 @@ const Services = WebexPlugin.extend({
switchActiveClusterIds(newActiveClusters: ActiveServices): Promise<void> {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Loading