Don't throw an error is panel is added, then removed, before embeddable finishes loading (#46788) (#47818)

* Remove this error being thrown as it can be expected in certain situations

* change test after change in logic
This commit is contained in:
Stacey Gammon 2019-10-10 10:03:49 -04:00 committed by GitHub
parent 0419844ee3
commit 8ed19f2c42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View file

@ -181,11 +181,10 @@ export abstract class Container<
resolve(this.children[id] as TEmbeddable);
}
// If a panel is removed before the embeddable was loaded there is a chance this will
// never resolve.
// If we hit this, the panel was removed before the embeddable finished loading.
if (this.input.panels[id] === undefined) {
subscription.unsubscribe();
reject(new PanelNotFoundError());
resolve(undefined);
}
});
});

View file

@ -27,7 +27,6 @@ import {
} from '../lib/test_samples/embeddables/filterable_embeddable';
import { ERROR_EMBEDDABLE_TYPE } from '../lib/embeddables/error_embeddable';
import { Filter, FilterStateStore } from '@kbn/es-query';
import { PanelNotFoundError } from '../lib/errors';
import { FilterableEmbeddableFactory } from '../lib/test_samples/embeddables/filterable_embeddable_factory';
import { CONTACT_CARD_EMBEDDABLE } from '../lib/test_samples/embeddables/contact_card/contact_card_embeddable_factory';
import { SlowContactCardEmbeddableFactory } from '../lib/test_samples/embeddables/contact_card/slow_contact_card_embeddable_factory';
@ -753,7 +752,7 @@ test('untilEmbeddableLoaded() resolves if child is loaded in the container', asy
done();
});
test('untilEmbeddableLoaded rejects with an error if child is subsequently removed', async done => {
test('untilEmbeddableLoaded resolves with undefined if child is subsequently removed', async done => {
const { doStart, coreStart, uiActions } = testPlugin(
coreMock.createSetup(),
coreMock.createStart()
@ -785,8 +784,8 @@ test('untilEmbeddableLoaded rejects with an error if child is subsequently remov
}
);
container.untilEmbeddableLoaded('123').catch(error => {
expect(error).toBeInstanceOf(PanelNotFoundError);
container.untilEmbeddableLoaded('123').then(embed => {
expect(embed).toBeUndefined();
done();
});