Conversation
There was a problem hiding this comment.
Pull request overview
Adds a centralized UI service method for triggering an applications refresh and refactors the Applications view to use it instead of calling axios directly.
Changes:
- Added
Application.refreshApplications()to POST to theapplicationsendpoint. - Refactored
views/applications/index.vuerefresh handler to use the new service method and wrap it intry/catch. - Removed the now-unneeded direct
axiosimport from the view.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| spring-boot-admin-server-ui/src/main/frontend/views/applications/index.vue | Refactors the “refresh applications” action to call Application.refreshApplications() and adds a try/catch. |
| spring-boot-admin-server-ui/src/main/frontend/services/application.ts | Introduces refreshApplications() as a shared service method for the POST refresh call. |
spring-boot-admin-server-ui/src/main/frontend/views/applications/index.vue
Show resolved
Hide resolved
spring-boot-admin-server-ui/src/main/frontend/views/applications/index.vue
Outdated
Show resolved
Hide resolved
spring-boot-admin-server-ui/src/main/frontend/views/applications/index.vue
Show resolved
Hide resolved
…ns/index.vue Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…uccess/error states
d83cae0 to
7d060a1
Compare
| it('clicking the refresh button invokes Application.refreshApplications', async () => { | ||
| const refreshSpy = vi.spyOn(Application, 'refreshApplications'); | ||
|
|
||
| const refreshButton = screen.getByTitle('Refresh applications'); | ||
| // First click - enters confirm mode | ||
| await userEvent.click(refreshButton); | ||
|
|
||
| // Second click - confirms and executes | ||
| const confirmButton = await screen.findByText('Confirm'); | ||
| await userEvent.click(confirmButton); | ||
|
|
||
| await waitFor(() => { | ||
| expect(refreshSpy).toHaveBeenCalled(); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
This test spies on Application.refreshApplications but doesn’t mock its implementation, so it will execute the real axios POST. With MSW configured to error on unhandled requests, this will fail unless you add a POST /applications handler or mock the method to resolve (like the next test does).
c7a4bf3 to
f399080
Compare
| it('calls refreshApplications and handles success without errors', async () => { | ||
| const refreshSpy = vi.spyOn(Application, 'refreshApplications'); | ||
|
|
||
| const refreshButton = screen.getByTitle('Refresh applications'); | ||
| // First click - enters confirm mode | ||
| await userEvent.click(refreshButton); | ||
|
|
||
| // Second click - confirms and executes | ||
| const confirmButton = await screen.findByText('Confirm'); | ||
| await userEvent.click(confirmButton); | ||
|
|
||
| await waitFor(() => { | ||
| expect(refreshSpy).toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
|
|
There was a problem hiding this comment.
The first two refresh-button tests exercise the same behavior (click refresh -> confirm -> expect refreshApplications called). Consider removing one of them or changing one to assert a different outcome (e.g., that the success notification is shown) to avoid redundant coverage.
| it('calls refreshApplications and handles success without errors', async () => { | |
| const refreshSpy = vi.spyOn(Application, 'refreshApplications'); | |
| const refreshButton = screen.getByTitle('Refresh applications'); | |
| // First click - enters confirm mode | |
| await userEvent.click(refreshButton); | |
| // Second click - confirms and executes | |
| const confirmButton = await screen.findByText('Confirm'); | |
| await userEvent.click(confirmButton); | |
| await waitFor(() => { | |
| expect(refreshSpy).toHaveBeenCalled(); | |
| }); | |
| }); |
spring-boot-admin-server-ui/src/main/frontend/views/applications/applications.spec.ts
Show resolved
Hide resolved
f399080 to
1652d87
Compare
This pull request introduces a new method for refreshing the list of applications and refactors the refresh logic to use this new method, improving code organization and error handling. The main changes are grouped into two themes: feature addition and refactoring.
Feature Addition:
refreshApplicationsmethod to theApplicationclass, which sends a POST request to theapplicationsendpoint.Refactoring and Error Handling:
refreshContextfunction inindex.vueto use the newApplication.refreshApplicationsmethod, added error handling with a try/catch block, and improved user feedback via notifications.axiosfromindex.vuesince requests are now handled through theApplicationservice.