|
7 | 7 | TEST_POLLING_INTERVAL, |
8 | 8 | unmanageNamespace, |
9 | 9 | cancelSharding, |
| 10 | + setPluginTitleVisibility, |
10 | 11 | } from './reducer'; |
11 | 12 | import sinon from 'sinon'; |
12 | 13 | import type { |
@@ -278,6 +279,33 @@ describe('GlobalWritesStore Store', function () { |
278 | 279 | expect(confirmationStub).to.have.been.called; |
279 | 280 | }); |
280 | 281 |
|
| 282 | + it('sharding -> pause sharding -> resume sharding -> valid shard key', async function () { |
| 283 | + let mockShardKey = false; |
| 284 | + confirmationStub.resolves(true); |
| 285 | + // initial state === sharding |
| 286 | + const store = createStore({ |
| 287 | + isNamespaceManaged: () => true, |
| 288 | + hasShardKey: Sinon.fake(() => mockShardKey), |
| 289 | + }); |
| 290 | + await waitFor(() => { |
| 291 | + expect(store.getState().status).to.equal('SHARDING'); |
| 292 | + }); |
| 293 | + |
| 294 | + // user leaves the workspace |
| 295 | + store.dispatch(setPluginTitleVisibility(false)); |
| 296 | + mockShardKey = true; |
| 297 | + await wait(TEST_POLLING_INTERVAL * 2); |
| 298 | + expect(store.getState().pollingTimeout).to.be.undefined; |
| 299 | + expect(store.getState().status).to.equal('SHARDING'); // no update |
| 300 | + |
| 301 | + // user comes back |
| 302 | + store.dispatch(setPluginTitleVisibility(true)); |
| 303 | + await wait(TEST_POLLING_INTERVAL); |
| 304 | + await waitFor(() => { |
| 305 | + expect(store.getState().status).to.equal('SHARD_KEY_CORRECT'); // now there is an update |
| 306 | + }); |
| 307 | + }); |
| 308 | + |
281 | 309 | it('valid shard key', async function () { |
282 | 310 | const store = createStore({ |
283 | 311 | isNamespaceManaged: () => true, |
|
0 commit comments