Skip to content

Commit 7763c59

Browse files
authored
fix(indexes): show the in-progress index in the list again COMPASS-7789 (#5609)
* show the in-progress index in the list again * add a unit test
1 parent 234337f commit 7763c59

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

packages/compass-indexes/src/stores/store.spec.ts

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,11 @@ describe('IndexesStore [Store]', function () {
3535
localAppRegistry: localAppRegistry,
3636
instance: fakeInstance as any,
3737
dataService: {
38-
indexes: (
39-
ns: string,
40-
options: unknown,
41-
callback: (...args: any[]) => void
42-
) => {
43-
callback('err', []);
38+
indexes: () => {
39+
return Promise.resolve([]);
4440
},
4541
isConnected: () => true,
46-
} as IndexesDataService,
42+
} as unknown as IndexesDataService,
4743
logger: createNoopLoggerAndTelemetry(),
4844
},
4945
createActivateHelpers()
@@ -102,4 +98,32 @@ describe('IndexesStore [Store]', function () {
10298
expect(store.getState().regularIndexes.indexes).to.deep.equal([]);
10399
});
104100
});
101+
102+
context('in-progress-indexes-added', function () {
103+
it('dispatches the load indexes action', function (done) {
104+
// so it will actually merge
105+
store.getState().isReadonlyView = false;
106+
107+
const newIndex = {
108+
id: 'my-new-index',
109+
key: { description: 'text' },
110+
fields: [{ field: 'description', value: 'text' }],
111+
name: 'description_text',
112+
ns: 'my_collection',
113+
size: 1,
114+
relativeSize: 2,
115+
usageCount: 3,
116+
extra: {
117+
status: 'inprogress',
118+
},
119+
};
120+
121+
localAppRegistry.once('indexes-changed', (allIndexes) => {
122+
expect(allIndexes).to.deep.equal([newIndex]);
123+
done();
124+
});
125+
126+
localAppRegistry.emit('in-progress-indexes-added', newIndex);
127+
});
128+
});
105129
});

packages/compass-indexes/src/stores/store.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ export function activateIndexesPlugin(
101101
'in-progress-indexes-added',
102102
(index: InProgressIndex) => {
103103
store.dispatch(inProgressIndexAdded(index));
104+
// we have to merge the in-progress indexes with the regular indexes, so
105+
// just fetch them again which will perform the merge
106+
void store.dispatch(fetchIndexes());
104107
store.dispatch(switchToRegularIndexes());
105108
}
106109
);

0 commit comments

Comments
 (0)