Skip to content

Commit

Permalink
Add extra tests from elastic#128769
Browse files Browse the repository at this point in the history
  • Loading branch information
gsoldevila committed Apr 5, 2022
1 parent 78088c9 commit b57701f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/core/server/status/plugins_status.test.ts
Original file line number Diff line number Diff line change
@@ -285,6 +285,32 @@ describe('PluginStatusService', () => {
]);
});

it('updates when a plugin status observable emits with the same level but a different summary', async () => {
const service = new PluginsStatusService({
core$: coreAllAvailable$,
pluginDependencies: new Map([['a', []]]),
});
const statusUpdates: Array<Record<PluginName, ServiceStatus>> = [];
const subscription = service
.getAll$()
// the first emission happens right after core services emit (see explanation above)
.pipe(skip(1))
.subscribe((pluginStatuses) => statusUpdates.push(pluginStatuses));

const aStatus$ = new BehaviorSubject<ServiceStatus>({
level: ServiceStatusLevels.available,
summary: 'summary initial',
});
service.set('a', aStatus$);
aStatus$.next({ level: ServiceStatusLevels.available, summary: 'summary updated' });
subscription.unsubscribe();

expect(statusUpdates).toEqual([
{ a: { level: ServiceStatusLevels.available, summary: 'summary initial' } },
{ a: { level: ServiceStatusLevels.available, summary: 'summary updated' } },
]);
});

it('emits an unavailable status if first emission times out, then continues future emissions', async () => {
const service = new PluginsStatusService(
{

0 comments on commit b57701f

Please sign in to comment.