From fdf2a987a1bb25dc40471604173d724ae2606f48 Mon Sep 17 00:00:00 2001 From: Ulrich Schulte Date: Sat, 20 Jul 2024 20:07:36 +0200 Subject: [PATCH] Conditions evaluation report (#3474) --- spring-boot-admin-server-ui/package.json | 2 +- .../src/main/frontend/services/instance.ts | 4 + .../conditions-list-details.spec.ts | 75 ++++++ .../conditions/conditions-list-details.vue | 72 ++++++ .../instances/conditions/conditions-list.vue | 112 +++++++++ .../views/instances/conditions/i18n.de.json | 13 ++ .../views/instances/conditions/i18n.en.json | 13 ++ .../views/instances/conditions/index.vue | 218 ++++++++++++++++++ 8 files changed, 508 insertions(+), 1 deletion(-) create mode 100644 spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/conditions-list-details.spec.ts create mode 100644 spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/conditions-list-details.vue create mode 100644 spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/conditions-list.vue create mode 100644 spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/i18n.de.json create mode 100644 spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/i18n.en.json create mode 100644 spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/index.vue diff --git a/spring-boot-admin-server-ui/package.json b/spring-boot-admin-server-ui/package.json index b300c382884..de9bbff86f3 100644 --- a/spring-boot-admin-server-ui/package.json +++ b/spring-boot-admin-server-ui/package.json @@ -5,7 +5,7 @@ "scripts": { "build": "vite build --emptyOutDir --sourcemap", "build:dev": "NODE_ENV=development vite build --emptyOutDir --sourcemap --mode development", - "build:watch": "NODE_ENV=development vite build --emptyOutDir --watch --mode development", + "build:watch": "NODE_ENV=development vite build --emptyOutDir --sourcemap --watch --mode development", "dev": "vite", "test": "vitest run --silent", "test:watch": "vitest", diff --git a/spring-boot-admin-server-ui/src/main/frontend/services/instance.ts b/spring-boot-admin-server-ui/src/main/frontend/services/instance.ts index d20106780d7..9f537913791 100644 --- a/spring-boot-admin-server-ui/src/main/frontend/services/instance.ts +++ b/spring-boot-admin-server-ui/src/main/frontend/services/instance.ts @@ -280,6 +280,10 @@ class Instance { return this.axios.get(uri`actuator/beans`); } + async fetchConditions() { + return this.axios.get(uri`actuator/conditions`); + } + async fetchThreaddump() { return this.axios.get(uri`actuator/threaddump`); } diff --git a/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/conditions-list-details.spec.ts b/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/conditions-list-details.spec.ts new file mode 100644 index 00000000000..8724ad69a99 --- /dev/null +++ b/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/conditions-list-details.spec.ts @@ -0,0 +1,75 @@ +import { screen } from '@testing-library/vue'; +import { describe, expect, it } from 'vitest'; + +import { render } from '@/test-utils'; +import ConditionsListDetails from '@/views/instances/conditions/conditions-list-details.vue'; + +describe('ConditionsListDetails', () => { + it('should display condition', async () => { + render(ConditionsListDetails, { + props: { + condition: { + condition: 'SpringBootAdminServerEnabledCondition', + }, + }, + }); + expect( + await screen.findByLabelText('instances.conditions.condition'), + ).toHaveTextContent('SpringBootAdminServerEnabledCondition'); + }); + + it('should display message', async () => { + render(ConditionsListDetails, { + props: { + condition: { + message: 'matched', + }, + }, + }); + expect( + await screen.findByLabelText('instances.conditions.message'), + ).toHaveTextContent('matched'); + }); + + it.each` + condition + ${undefined} + ${null} + ${''} + `( + 'should not display condition if condition is $condition', + async ({ condition }) => { + render(ConditionsListDetails, { + props: { + condition: { + condition, + }, + }, + }); + expect( + screen.queryByLabelText('instances.conditions.condition'), + ).not.toBeInTheDocument(); + }, + ); + + it.each` + message + ${undefined} + ${null} + ${''} + `( + 'should not display message if message is $message', + async ({ message }) => { + render(ConditionsListDetails, { + props: { + condition: { + message, + }, + }, + }); + expect( + screen.queryByLabelText('instances.conditions.message'), + ).not.toBeInTheDocument(); + }, + ); +}); diff --git a/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/conditions-list-details.vue b/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/conditions-list-details.vue new file mode 100644 index 00000000000..ab2995128d8 --- /dev/null +++ b/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/conditions-list-details.vue @@ -0,0 +1,72 @@ + + + + + + + diff --git a/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/conditions-list.vue b/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/conditions-list.vue new file mode 100644 index 00000000000..8683db45f24 --- /dev/null +++ b/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/conditions-list.vue @@ -0,0 +1,112 @@ + + + + + diff --git a/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/i18n.de.json b/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/i18n.de.json new file mode 100644 index 00000000000..01bde66a49f --- /dev/null +++ b/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/i18n.de.json @@ -0,0 +1,13 @@ +{ + "instances": { + "conditions": { + "label": "Bedingungen", + "positive-matches": "Übereinstimmungen", + "negative-matches": "Keine Übereinstimmungen", + "condition": "Bedingung", + "message": "Hinweis", + "not-matched": "Nicht übereinstimmend", + "matched": "Übereinstimmend" + } + } +} diff --git a/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/i18n.en.json b/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/i18n.en.json new file mode 100644 index 00000000000..b8d73f36d64 --- /dev/null +++ b/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/i18n.en.json @@ -0,0 +1,13 @@ +{ + "instances": { + "conditions": { + "label": "Conditions", + "positive-matches": "Positive matches", + "negative-matches": "Negative matches", + "condition": "Condition", + "message": "Message", + "not-matched": "Not matched", + "matched": "Matched" + } + } +} diff --git a/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/index.vue b/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/index.vue new file mode 100644 index 00000000000..28392e6f421 --- /dev/null +++ b/spring-boot-admin-server-ui/src/main/frontend/views/instances/conditions/index.vue @@ -0,0 +1,218 @@ + + + + +