Skip to content

Commit ffe3250

Browse files
ulischulteSteKoe
authored andcommitted
#5352: Re-fetch the (server-cached) group list on every instance change
1 parent 95f761b commit ffe3250

2 files changed

Lines changed: 11 additions & 14 deletions

File tree

spring-boot-admin-server-ui/src/main/frontend/views/instances/details/details-health.spec.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ describe('DetailsHealth', () => {
105105
});
106106

107107
describe('SSE reactive updates', () => {
108-
it('should call fetchCachedHealthGroups once on mount, not on SSE version changes', async () => {
108+
it('should re-fetch cached health groups on SSE version changes', async () => {
109109
const baseApp = applications[0];
110110
const instance1 = new Application(baseApp).instances[0];
111111
instance1.fetchCachedHealthGroups = vi
@@ -119,7 +119,8 @@ describe('DetailsHealth', () => {
119119
await screen.findAllByRole('status');
120120
expect(instance1.fetchCachedHealthGroups).toHaveBeenCalledTimes(1);
121121

122-
// Same instance, different version (SSE update) — should NOT call fetchCachedHealthGroups again
122+
// Same instance, different version (SSE update) — should re-fetch the
123+
// (server-cached) group list so it self-corrects when groups change.
123124
const instance2 = new Application({
124125
...baseApp,
125126
instances: [
@@ -132,15 +133,17 @@ describe('DetailsHealth', () => {
132133
}).instances[0];
133134
instance2.fetchCachedHealthGroups = vi
134135
.fn()
135-
.mockResolvedValue({ data: [] });
136+
.mockResolvedValue({ data: ['liveness', 'readiness'] });
136137

137138
await rerender({ instance: instance2 });
138139

139-
// Original instance's mock should still be 1 (no additional calls)
140-
expect(instance1.fetchCachedHealthGroups).toHaveBeenCalledTimes(1);
140+
// The new instance's cached groups should have been fetched on the SSE update.
141+
await waitFor(() => {
142+
expect(instance2.fetchCachedHealthGroups).toHaveBeenCalledTimes(1);
143+
});
141144
});
142145

143-
it('should reactively update through multiple SSE status changes without extra HTTP calls', async () => {
146+
it('should reactively update health status and details through SSE status changes', async () => {
144147
const baseApp = applications[0];
145148

146149
const instance1 = new Application(baseApp).instances[0];

spring-boot-admin-server-ui/src/main/frontend/views/instances/details/details-health.vue

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,9 @@ export default defineComponent({
175175
this.healthGroupOpenStatus = {};
176176
this.healthGroupLoadingMap = {};
177177
this.healthGroupsError = null;
178-
this.fetchHealthGroups();
179-
} else {
180-
// Same instance, SSE update (e.g. status change) — collapse groups and clear stale data
181-
for (const group of this.healthGroups) {
182-
group.data = null;
183-
}
184-
this.healthGroupOpenStatus = {};
185-
this.healthGroupLoadingMap = {};
186178
}
179+
// Re-fetch the (server-cached) group list on every instance change
180+
this.fetchHealthGroups();
187181
},
188182
isHealthGroupOpen(groupName: string) {
189183
return this.healthGroupOpenStatus[groupName]?.isOpen ?? false;

0 commit comments

Comments
 (0)