mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
fix(maps): settle failed recovery and update registry QA
This commit is contained in:
1 parent
06c73bca98
commit
8024813792
4 files changed
+145
-300
No files matched your search
@@ -124,9 +124,15 @@ export class MapSourceController {
|
||||
recovery.id !== stack.id &&
|
||||
this.isStackAvailable(recovery.id)
|
||||
) {
|
||||
await this._activate(recovery, gen);
|
||||
if (gen !== this._switchGen) return this.getState();
|
||||
this._activeId = recovery.id;
|
||||
try {
|
||||
const activation = await this._activate(recovery, gen);
|
||||
if (gen !== this._switchGen) return this.getState();
|
||||
this._activeId = activation?.effectiveStackId || recovery.id;
|
||||
} catch (recoveryError) {
|
||||
if (gen !== this._switchGen) return this.getState();
|
||||
this._lastError = recoveryError?.message || String(recoveryError);
|
||||
this._onError?.(this._lastError, recovery);
|
||||
}
|
||||
}
|
||||
if (!silent) this._emitChange('error');
|
||||
} finally {
|
||||
|
||||
@@ -349,3 +349,35 @@ for (const reactivate of [false, true]) {
|
||||
assert.equal(destroyed, 1);
|
||||
});
|
||||
}
|
||||
|
||||
test('a failed recovery reports its error and leaves switching settled', async () => {
|
||||
const errors = [];
|
||||
const env = fixture(
|
||||
{
|
||||
defaultId: 'first',
|
||||
recoveryId: 'recovery',
|
||||
sources: [
|
||||
{
|
||||
descriptor: descriptor('first'),
|
||||
imagery: async () => {
|
||||
throw new Error('first offline');
|
||||
},
|
||||
},
|
||||
{
|
||||
descriptor: descriptor('recovery'),
|
||||
imagery: async () => {
|
||||
throw new Error('recovery offline');
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{ onError: (message) => errors.push(message) },
|
||||
);
|
||||
const result = await env.controller.setStack('first');
|
||||
assert.equal(result.status, 'ready');
|
||||
assert.equal(result.lastError, 'recovery offline');
|
||||
assert.deepEqual(errors, ['first offline', 'recovery offline']);
|
||||
assert.equal(env.changes.at(-1).status, 'error');
|
||||
assert.equal(env.imagery.length, 0);
|
||||
env.controller.destroy();
|
||||
});
|
||||
Reference in new issue
Block a user