Skip to content

Commit f6e3c7b

Browse files
bugclerkundsoft
andauthored
NAS-135539 / 25.04.1 / Incorrect endpoint is used to check for updates (by undsoft) (#11936)
* NAS-135539: Incorrect endpoint is used to check for updates --------- Co-authored-by: Evgeny Stepanovych <[email protected]>
1 parent 535c26d commit f6e3c7b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/app/pages/dashboard/services/widget-resources.service.spec.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { App } from 'app/interfaces/app.interface';
1616
import { CloudSyncTask } from 'app/interfaces/cloud-sync-task.interface';
1717
import { NetworkInterface } from 'app/interfaces/network-interface.interface';
1818
import { Pool } from 'app/interfaces/pool.interface';
19+
import { SystemUpdateChange } from 'app/interfaces/system-update.interface';
1920
import { WidgetResourcesService } from 'app/pages/dashboard/services/widget-resources.service';
2021

2122
const pools = [
@@ -214,7 +215,9 @@ describe('WidgetResourcesService', () => {
214215
mockCall('webui.main.dashboard.sys_info'),
215216
mockCall('app.query', apps),
216217
mockCall('pool.query', pools),
217-
mockCall('update.check_available'),
218+
mockCall('update.get_pending', [
219+
{} as SystemUpdateChange,
220+
]),
218221
mockCall('reporting.netdata_get_data', [interfaceEth0]),
219222
]),
220223
],
@@ -252,6 +255,12 @@ describe('WidgetResourcesService', () => {
252255
expect(await firstValueFrom(spectator.service.installedApps$)).toEqual(apps);
253256
});
254257

258+
describe('updateAvailable$', () => {
259+
it('returns true when api knows about available updates', async () => {
260+
expect(await firstValueFrom(spectator.service.updateAvailable$)).toBe(true);
261+
});
262+
});
263+
255264
describe('networkInterfaceLastHourStats', () => {
256265
it('returns network interface stats for the last hour', async () => {
257266
expect(

src/app/pages/dashboard/services/widget-resources.service.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
filter,
88
forkJoin, map, of, repeat, shareReplay, startWith, switchMap, throttleTime, timer,
99
} from 'rxjs';
10-
import { SystemUpdateStatus } from 'app/enums/system-update.enum';
1110
import { LoadingState, toLoadingState } from 'app/helpers/operators/to-loading-state.helper';
1211
import { ApiEvent } from 'app/interfaces/api-message.interface';
1312
import { App, AppStartQueryParams, AppStats } from 'app/interfaces/app.interface';
@@ -100,8 +99,8 @@ export class WidgetResourcesService {
10099
map((datasets) => this.parseVolumeData(datasets)),
101100
);
102101

103-
readonly updateAvailable$ = this.api.call('update.check_available').pipe(
104-
map((update) => update.status === SystemUpdateStatus.Available),
102+
readonly updateAvailable$ = this.api.call('update.get_pending').pipe(
103+
map((updates) => Boolean(updates.length)),
105104
catchError(() => of(false)),
106105
shareReplay({ refCount: false, bufferSize: 1 }),
107106
);

0 commit comments

Comments
 (0)