From 58157fbc63ad486dd5b13f085608314db477ac7b Mon Sep 17 00:00:00 2001 From: Timon Borter Date: Fri, 17 Nov 2023 15:47:56 +0100 Subject: [PATCH] feat(simulator-ui): visual improvements * configurable page-size per table * refresh button on results (landing page) * possibility to reset test-results (landing page) --- simulator-samples/pom.xml | 8 +-- .../simulator/model/TestResult.java | 3 +- .../simulator/service/TestResultService.java | 5 ++ .../service/impl/TestResultServiceImpl.java | 8 ++- .../web/rest/TestResultResource.java | 13 ++++ .../impl/TestResultServiceImplTest.java | 21 ++++-- .../web/rest/TestResultResourceIT.java | 36 ++++++++-- .../config/user-preference.service.spec.ts | 60 ++++++++++++++++ .../core/config/user-preference.service.ts | 20 ++++++ .../message-header-detail.component.spec.ts | 2 +- .../message-header-table.component.spec.ts | 2 +- .../list/message-header.component.spec.ts | 2 +- .../service/message-header.service.spec.ts | 8 +-- .../detail/message-detail.component.spec.ts | 2 +- .../message/list/message.component.spec.ts | 4 +- .../message/service/message.service.spec.ts | 8 +-- .../scenario-action-detail.component.spec.ts | 2 +- .../list/scenario-action.component.spec.ts | 4 +- .../service/scenario-action.service.spec.ts | 8 +-- ...cenario-execution-detail.component.spec.ts | 2 +- .../list/scenario-execution.component.spec.ts | 4 +- .../scenario-execution.service.spec.ts | 8 +-- ...cenario-parameter-detail.component.spec.ts | 2 +- .../list/scenario-parameter.component.spec.ts | 4 +- .../scenario-parameter.service.spec.ts | 8 +-- .../test-parameter-detail.component.spec.ts | 2 +- .../list/test-parameter.component.spec.ts | 4 +- .../service/test-parameter.service.spec.ts | 8 +-- .../test-result-detail.component.spec.ts | 2 +- .../list/test-result.component.spec.ts | 4 +- .../service/test-result.service.spec.ts | 8 +-- .../service/test-result.service.ts | 4 ++ .../test-result-delete-dialog.component.html | 26 +++++++ ...est-result-delete-dialog.component.spec.ts | 61 ++++++++++++++++ .../test-result-delete-dialog.component.ts | 31 ++++++++ .../home/test-result-summary.component.html | 13 ++++ .../app/home/test-result-summary.component.ts | 40 ++++++++--- .../layouts/navbar/navbar.component.spec.ts | 2 +- .../profiles/page-ribbon.component.spec.ts | 2 +- .../scenario-result.component.html | 5 ++ .../scenario-result.component.spec.ts | 72 +++++++++++++++++++ .../scenario-result.component.ts | 20 +++++- .../detail/scenario-detail.component.spec.ts | 2 +- .../app/scenario/list/scenario.component.html | 5 ++ .../scenario/list/scenario.component.spec.ts | 65 +++++++++-------- .../app/scenario/list/scenario.component.ts | 16 ++++- .../scenario/service/scenario.service.spec.ts | 8 +-- .../alert/alert-error.component.spec.ts | 16 ++--- .../app/shared/alert/alert.component.spec.ts | 4 +- .../webapp/app/shared/pagination/index.ts | 1 + .../select-page-size.component.html | 19 +++++ .../pagination/select-page-size.component.ts | 41 +++++++++++ .../main/webapp/app/shared/shared.module.ts | 10 +-- .../src/main/webapp/i18n/en/global.json | 3 +- .../main/webapp/i18n/en/testParameter.json | 4 ++ 55 files changed, 609 insertions(+), 133 deletions(-) create mode 100644 simulator-ui/src/main/webapp/app/core/config/user-preference.service.spec.ts create mode 100644 simulator-ui/src/main/webapp/app/core/config/user-preference.service.ts create mode 100644 simulator-ui/src/main/webapp/app/home/delete/test-result-delete-dialog.component.html create mode 100644 simulator-ui/src/main/webapp/app/home/delete/test-result-delete-dialog.component.spec.ts create mode 100644 simulator-ui/src/main/webapp/app/home/delete/test-result-delete-dialog.component.ts create mode 100644 simulator-ui/src/main/webapp/app/scenario-result/scenario-result.component.spec.ts create mode 100644 simulator-ui/src/main/webapp/app/shared/pagination/select-page-size.component.html create mode 100644 simulator-ui/src/main/webapp/app/shared/pagination/select-page-size.component.ts diff --git a/simulator-samples/pom.xml b/simulator-samples/pom.xml index ac53a6c0c..9923e8b2d 100644 --- a/simulator-samples/pom.xml +++ b/simulator-samples/pom.xml @@ -24,15 +24,15 @@ sample-bank-service + sample-combined + sample-jms + sample-jms-fax + sample-mail sample-rest sample-swagger sample-ws sample-ws-client sample-wsdl - sample-mail - sample-combined - sample-jms - sample-jms-fax diff --git a/simulator-starter/src/main/java/org/citrusframework/simulator/model/TestResult.java b/simulator-starter/src/main/java/org/citrusframework/simulator/model/TestResult.java index 9607f7380..f1ad9a613 100644 --- a/simulator-starter/src/main/java/org/citrusframework/simulator/model/TestResult.java +++ b/simulator-starter/src/main/java/org/citrusframework/simulator/model/TestResult.java @@ -17,6 +17,7 @@ package org.citrusframework.simulator.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; @@ -81,7 +82,7 @@ public class TestResult extends AbstractAuditingEntity impleme /** * Optional test parameters */ - @OneToMany(fetch = FetchType.LAZY, mappedBy = "testResult") + @OneToMany(fetch = FetchType.LAZY, mappedBy = "testResult", cascade = {CascadeType.REMOVE}) @JsonIgnoreProperties(value = { "testResult" }, allowSetters = true) private final Set testParameters = new HashSet<>(); diff --git a/simulator-starter/src/main/java/org/citrusframework/simulator/service/TestResultService.java b/simulator-starter/src/main/java/org/citrusframework/simulator/service/TestResultService.java index 4d4232c97..9c2669f06 100644 --- a/simulator-starter/src/main/java/org/citrusframework/simulator/service/TestResultService.java +++ b/simulator-starter/src/main/java/org/citrusframework/simulator/service/TestResultService.java @@ -67,4 +67,9 @@ public interface TestResultService { * @return the TestResult count. */ TestResultByStatus countByStatus(); + + /** + * Delete all testResults + */ + void deleteAll(); } diff --git a/simulator-starter/src/main/java/org/citrusframework/simulator/service/impl/TestResultServiceImpl.java b/simulator-starter/src/main/java/org/citrusframework/simulator/service/impl/TestResultServiceImpl.java index 6c5e5711e..4c8c426b4 100644 --- a/simulator-starter/src/main/java/org/citrusframework/simulator/service/impl/TestResultServiceImpl.java +++ b/simulator-starter/src/main/java/org/citrusframework/simulator/service/impl/TestResultServiceImpl.java @@ -73,7 +73,13 @@ public Optional findOne(Long id) { @Override @Transactional(readOnly = true) public TestResultByStatus countByStatus() { - logger.debug("count total by status"); + logger.debug("Request to count TestResults by status"); return testResultRepository.countByStatus(); } + + @Override + public void deleteAll() { + logger.debug("Request to delete all TestResults"); + testResultRepository.deleteAll(); + } } diff --git a/simulator-starter/src/main/java/org/citrusframework/simulator/web/rest/TestResultResource.java b/simulator-starter/src/main/java/org/citrusframework/simulator/web/rest/TestResultResource.java index 5f16b1d93..91c24c5e6 100644 --- a/simulator-starter/src/main/java/org/citrusframework/simulator/web/rest/TestResultResource.java +++ b/simulator-starter/src/main/java/org/citrusframework/simulator/web/rest/TestResultResource.java @@ -29,6 +29,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -75,6 +76,18 @@ public ResponseEntity> getAllTestResults( return ResponseEntity.ok().headers(headers).body(page.getContent()); } + /** + * {@code DELETE /test-results} : delete all the testResults. + * + * @return the {@link ResponseEntity} with status {@code 201 (NO CONTENT)}. + */ + @DeleteMapping("/test-results") + public ResponseEntity deleteAllTestResults() { + logger.debug("REST request to delete all TestResults"); + testResultService.deleteAll(); + return ResponseEntity.noContent().build(); + } + /** * {@code GET /test-results/count} : count all the testResults. * diff --git a/simulator-starter/src/test/java/org/citrusframework/simulator/service/impl/TestResultServiceImplTest.java b/simulator-starter/src/test/java/org/citrusframework/simulator/service/impl/TestResultServiceImplTest.java index 704283a85..9f6719a6f 100644 --- a/simulator-starter/src/test/java/org/citrusframework/simulator/service/impl/TestResultServiceImplTest.java +++ b/simulator-starter/src/test/java/org/citrusframework/simulator/service/impl/TestResultServiceImplTest.java @@ -18,18 +18,19 @@ import static org.mockito.Mockito.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) class TestResultServiceImplTest { @Mock - private TestResultRepository testResultRepository; + private TestResultRepository testResultRepositoryMock; private TestResultServiceImpl fixture; @BeforeEach void beforeEachSetup() { - fixture = new TestResultServiceImpl(testResultRepository); + fixture = new TestResultServiceImpl(testResultRepositoryMock); } @Test @@ -37,7 +38,7 @@ void testTransformAndSave() { org.citrusframework.TestResult citrusTestResult = org.citrusframework.TestResult.success("TestResult", TestResultServiceImpl.class.getSimpleName()); TestResult testResult = new TestResult(citrusTestResult); - doReturn(testResult).when(testResultRepository).save(any(TestResult.class)); + doReturn(testResult).when(testResultRepositoryMock).save(any(TestResult.class)); TestResult result = fixture.transformAndSave(citrusTestResult); @@ -47,7 +48,7 @@ void testTransformAndSave() { @Test void testSave() { TestResult testResult = new TestResult(); - doReturn(testResult).when(testResultRepository).save(testResult); + doReturn(testResult).when(testResultRepositoryMock).save(testResult); TestResult result = fixture.save(testResult); @@ -58,7 +59,7 @@ void testSave() { void testFindAll() { Pageable pageable = mock(Pageable.class); Page mockPage = mock(Page.class); - doReturn(mockPage).when(testResultRepository).findAll(pageable); + doReturn(mockPage).when(testResultRepositoryMock).findAll(pageable); Page result = fixture.findAll(pageable); @@ -71,7 +72,7 @@ void testFindOne() { TestResult testResult = new TestResult(); Optional optionalTestResult = Optional.of(testResult); - doReturn(optionalTestResult).when(testResultRepository).findById(id); + doReturn(optionalTestResult).when(testResultRepositoryMock).findById(id); Optional maybeTestResult = fixture.findOne(id); @@ -82,9 +83,15 @@ void testFindOne() { @Test void testCountByStatus() { TestResultByStatus testResultByStatus = new TestResultByStatus(1L, 1L); - doReturn(testResultByStatus).when(testResultRepository).countByStatus(); + doReturn(testResultByStatus).when(testResultRepositoryMock).countByStatus(); TestResultByStatus result = fixture.countByStatus(); assertEquals(testResultByStatus, result); } + + @Test + void delete() { + fixture.deleteAll(); + verify(testResultRepositoryMock).deleteAll(); + } } diff --git a/simulator-starter/src/test/java/org/citrusframework/simulator/web/rest/TestResultResourceIT.java b/simulator-starter/src/test/java/org/citrusframework/simulator/web/rest/TestResultResourceIT.java index 187551b38..1ca9acd91 100644 --- a/simulator-starter/src/test/java/org/citrusframework/simulator/web/rest/TestResultResourceIT.java +++ b/simulator-starter/src/test/java/org/citrusframework/simulator/web/rest/TestResultResourceIT.java @@ -17,9 +17,12 @@ import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; +import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; import static org.citrusframework.simulator.web.rest.TestUtil.sameInstant; import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; @@ -726,6 +729,32 @@ void getAllTestResultsByLastModifiedDateIsGreaterThanSomething() throws Exceptio @Test @Transactional void getAllTestResultsByTestParameterIsEqualToSomething() throws Exception { + TestParameter testParameter = getOrCreateTestParameterWithTestResult(); + + String testParameterKey = testParameter.getKey(); + // Get all the testResultList where testParameter equals to testParameterKey + defaultTestResultShouldBeFound("testParameterKey.equals=" + testParameterKey); + + // Get all the testResultList where testParameter equals to (testParameterKey + 1) + defaultTestResultShouldNotBeFound("testParameterKey.equals=" + (testParameterKey + 1)); + } + + @Test + @Transactional + void deleteAllTestResults() throws Exception { + TestParameter testParameter = getOrCreateTestParameterWithTestResult(); + + int databaseSizeBeforeDelete = testResultRepository.findAll().size(); + + mockMvc + .perform(delete(ENTITY_API_URL).accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + List eventList = testResultRepository.findAll(); + assertThat(eventList).hasSize(databaseSizeBeforeDelete - 1); + } + + private TestParameter getOrCreateTestParameterWithTestResult() { TestParameter testParameter; if (TestUtil.findAll(entityManager, TestParameter.class).isEmpty()) { testResultRepository.saveAndFlush(testResult); @@ -737,12 +766,7 @@ void getAllTestResultsByTestParameterIsEqualToSomething() throws Exception { entityManager.flush(); testResult.addTestParameter(testParameter); testResultRepository.saveAndFlush(testResult); - String testParameterKey = testParameter.getKey(); - // Get all the testResultList where testParameter equals to testParameterKey - defaultTestResultShouldBeFound("testParameterKey.equals=" + testParameterKey); - - // Get all the testResultList where testParameter equals to (testParameterKey + 1) - defaultTestResultShouldNotBeFound("testParameterKey.equals=" + (testParameterKey + 1)); + return testParameter; } /** diff --git a/simulator-ui/src/main/webapp/app/core/config/user-preference.service.spec.ts b/simulator-ui/src/main/webapp/app/core/config/user-preference.service.spec.ts new file mode 100644 index 000000000..c0ddde5c2 --- /dev/null +++ b/simulator-ui/src/main/webapp/app/core/config/user-preference.service.spec.ts @@ -0,0 +1,60 @@ +import { TestBed } from '@angular/core/testing'; + +import { ITEMS_PER_PAGE } from 'app/config/pagination.constants'; + +import { UserPreferenceService } from './user-preference.service'; + +type Mock = jest.Mock; + +describe('UserPreferenceService', () => { + let service: UserPreferenceService; + let mockLocalStorage: Partial & { + setItem: Mock; + getItem: Mock; + removeItem: Mock; + }; + + beforeEach(() => { + mockLocalStorage = { + setItem: jest.fn(), + getItem: jest.fn(), + removeItem: jest.fn(), + }; + + Object.defineProperty(window, 'localStorage', { value: mockLocalStorage, writable: true }); + + TestBed.configureTestingModule({ + providers: [UserPreferenceService], + }); + + service = TestBed.inject(UserPreferenceService); + }); + + describe('setPreferredPageSize', () => { + it('should return known item from localStorage', () => { + mockLocalStorage.getItem.mockReturnValueOnce('1234'); + + const preferredPageSize = service.getPreferredPageSize('key'); + + expect(preferredPageSize).toEqual(1234); + expect(mockLocalStorage.getItem).toHaveBeenCalledWith('psize-key'); + }); + + it('should return default page size if item is not in localStorage', () => { + mockLocalStorage.getItem.mockReturnValueOnce(null); + + const preferredPageSize = service.getPreferredPageSize('key'); + + expect(preferredPageSize).toEqual(ITEMS_PER_PAGE); + expect(mockLocalStorage.getItem).toHaveBeenCalledWith('psize-key'); + }); + }); + + describe('setPreferredPageSize', () => { + it('should save item in localStorage', () => { + service.setPreferredPageSize('key', 1234); + + expect(mockLocalStorage.setItem).toHaveBeenCalledWith('psize-key', '1234'); + }); + }); +}); diff --git a/simulator-ui/src/main/webapp/app/core/config/user-preference.service.ts b/simulator-ui/src/main/webapp/app/core/config/user-preference.service.ts new file mode 100644 index 000000000..89e219508 --- /dev/null +++ b/simulator-ui/src/main/webapp/app/core/config/user-preference.service.ts @@ -0,0 +1,20 @@ +import { Injectable } from '@angular/core'; + +import { ITEMS_PER_PAGE } from 'app/config/pagination.constants'; + +@Injectable({ providedIn: 'root' }) +export class UserPreferenceService { + private paginationPrefix = 'psize'; + + public getPreferredPageSize(key: string): number { + return Number(localStorage.getItem(this.paginationId(key)) ?? ITEMS_PER_PAGE); + } + + public setPreferredPageSize(key: string, size: number): void { + localStorage.setItem(this.paginationId(key), size.toString()); + } + + private paginationId(key: string): string { + return `${this.paginationPrefix}-${key}`; + } +} diff --git a/simulator-ui/src/main/webapp/app/entities/message-header/detail/message-header-detail.component.spec.ts b/simulator-ui/src/main/webapp/app/entities/message-header/detail/message-header-detail.component.spec.ts index b705846f9..c4c97e8c2 100644 --- a/simulator-ui/src/main/webapp/app/entities/message-header/detail/message-header-detail.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/message-header/detail/message-header-detail.component.spec.ts @@ -27,7 +27,7 @@ describe('MessageHeader Management Detail Component', () => { }); describe('OnInit', () => { - it('Should load messageHeader on init', async () => { + it('should load messageHeader on init', async () => { const harness = await RouterTestingHarness.create(); const instance = await harness.navigateByUrl('/', MessageHeaderDetailComponent); diff --git a/simulator-ui/src/main/webapp/app/entities/message-header/list/message-header-table.component.spec.ts b/simulator-ui/src/main/webapp/app/entities/message-header/list/message-header-table.component.spec.ts index 9aa28758d..3af2238d9 100644 --- a/simulator-ui/src/main/webapp/app/entities/message-header/list/message-header-table.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/message-header/list/message-header-table.component.spec.ts @@ -63,7 +63,7 @@ describe('MessageHeader Table Component', () => { }); describe('trackId', () => { - it('Should forward to messageHeaderService', () => { + it('should forward to messageHeaderService', () => { const entity = { headerId: 123 }; jest.spyOn(service, 'getMessageHeaderIdentifier'); const headerId = component.trackId(0, entity); diff --git a/simulator-ui/src/main/webapp/app/entities/message-header/list/message-header.component.spec.ts b/simulator-ui/src/main/webapp/app/entities/message-header/list/message-header.component.spec.ts index 2f370cbb4..77520e7e2 100644 --- a/simulator-ui/src/main/webapp/app/entities/message-header/list/message-header.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/message-header/list/message-header.component.spec.ts @@ -64,7 +64,7 @@ describe('MessageHeader Management Component', () => { ); }); - it('Should call load all on init', () => { + it('should call load all on init', () => { // WHEN component.ngOnInit(); diff --git a/simulator-ui/src/main/webapp/app/entities/message-header/service/message-header.service.spec.ts b/simulator-ui/src/main/webapp/app/entities/message-header/service/message-header.service.spec.ts index 279f15c21..875cf72c6 100644 --- a/simulator-ui/src/main/webapp/app/entities/message-header/service/message-header.service.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/message-header/service/message-header.service.spec.ts @@ -110,7 +110,7 @@ describe('MessageHeader Service', () => { }); describe('compareMessageHeader', () => { - it('Should return true if both entities are null', () => { + it('should return true if both entities are null', () => { const entity1 = null; const entity2 = null; @@ -119,7 +119,7 @@ describe('MessageHeader Service', () => { expect(compareResult).toEqual(true); }); - it('Should return false if one entity is null', () => { + it('should return false if one entity is null', () => { const entity1 = { headerId: 123 }; const entity2 = null; @@ -130,7 +130,7 @@ describe('MessageHeader Service', () => { expect(compareResult2).toEqual(false); }); - it('Should return false if primaryKey differs', () => { + it('should return false if primaryKey differs', () => { const entity1 = { headerId: 123 }; const entity2 = { headerId: 456 }; @@ -141,7 +141,7 @@ describe('MessageHeader Service', () => { expect(compareResult2).toEqual(false); }); - it('Should return false if primaryKey matches', () => { + it('should return false if primaryKey matches', () => { const entity1 = { headerId: 123 }; const entity2 = { headerId: 123 }; diff --git a/simulator-ui/src/main/webapp/app/entities/message/detail/message-detail.component.spec.ts b/simulator-ui/src/main/webapp/app/entities/message/detail/message-detail.component.spec.ts index 5a85774b8..d69780eb7 100644 --- a/simulator-ui/src/main/webapp/app/entities/message/detail/message-detail.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/message/detail/message-detail.component.spec.ts @@ -27,7 +27,7 @@ describe('Message Management Detail Component', () => { }); describe('OnInit', () => { - it('Should load message on init', async () => { + it('should load message on init', async () => { const harness = await RouterTestingHarness.create(); const instance = await harness.navigateByUrl('/', MessageDetailComponent); diff --git a/simulator-ui/src/main/webapp/app/entities/message/list/message.component.spec.ts b/simulator-ui/src/main/webapp/app/entities/message/list/message.component.spec.ts index 3d9778624..c1040d1f6 100644 --- a/simulator-ui/src/main/webapp/app/entities/message/list/message.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/message/list/message.component.spec.ts @@ -62,7 +62,7 @@ describe('Message Management Component', () => { ); }); - it('Should call load all on init', () => { + it('should call load all on init', () => { // WHEN comp.ngOnInit(); @@ -72,7 +72,7 @@ describe('Message Management Component', () => { }); describe('trackId', () => { - it('Should forward to messageService', () => { + it('should forward to messageService', () => { const entity = { messageId: 123 }; jest.spyOn(service, 'getMessageIdentifier'); const messageId = comp.trackId(0, entity); diff --git a/simulator-ui/src/main/webapp/app/entities/message/service/message.service.spec.ts b/simulator-ui/src/main/webapp/app/entities/message/service/message.service.spec.ts index 83393f722..155e12d60 100644 --- a/simulator-ui/src/main/webapp/app/entities/message/service/message.service.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/message/service/message.service.spec.ts @@ -110,7 +110,7 @@ describe('Message Service', () => { }); describe('compareMessage', () => { - it('Should return true if both entities are null', () => { + it('should return true if both entities are null', () => { const entity1 = null; const entity2 = null; @@ -119,7 +119,7 @@ describe('Message Service', () => { expect(compareResult).toEqual(true); }); - it('Should return false if one entity is null', () => { + it('should return false if one entity is null', () => { const entity1 = { messageId: 123 }; const entity2 = null; @@ -130,7 +130,7 @@ describe('Message Service', () => { expect(compareResult2).toEqual(false); }); - it('Should return false if primaryKey differs', () => { + it('should return false if primaryKey differs', () => { const entity1 = { messageId: 123 }; const entity2 = { messageId: 456 }; @@ -141,7 +141,7 @@ describe('Message Service', () => { expect(compareResult2).toEqual(false); }); - it('Should return false if primaryKey matches', () => { + it('should return false if primaryKey matches', () => { const entity1 = { messageId: 123 }; const entity2 = { messageId: 123 }; diff --git a/simulator-ui/src/main/webapp/app/entities/scenario-action/detail/scenario-action-detail.component.spec.ts b/simulator-ui/src/main/webapp/app/entities/scenario-action/detail/scenario-action-detail.component.spec.ts index 05095d426..b1a02c90a 100644 --- a/simulator-ui/src/main/webapp/app/entities/scenario-action/detail/scenario-action-detail.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/scenario-action/detail/scenario-action-detail.component.spec.ts @@ -27,7 +27,7 @@ describe('ScenarioAction Management Detail Component', () => { }); describe('OnInit', () => { - it('Should load scenarioAction on init', async () => { + it('should load scenarioAction on init', async () => { const harness = await RouterTestingHarness.create(); const instance = await harness.navigateByUrl('/', ScenarioActionDetailComponent); diff --git a/simulator-ui/src/main/webapp/app/entities/scenario-action/list/scenario-action.component.spec.ts b/simulator-ui/src/main/webapp/app/entities/scenario-action/list/scenario-action.component.spec.ts index 27df6967e..0c63ee4b0 100644 --- a/simulator-ui/src/main/webapp/app/entities/scenario-action/list/scenario-action.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/scenario-action/list/scenario-action.component.spec.ts @@ -62,7 +62,7 @@ describe('ScenarioAction Management Component', () => { ); }); - it('Should call load all on init', () => { + it('should call load all on init', () => { // WHEN comp.ngOnInit(); @@ -72,7 +72,7 @@ describe('ScenarioAction Management Component', () => { }); describe('trackId', () => { - it('Should forward to scenarioActionService', () => { + it('should forward to scenarioActionService', () => { const entity = { actionId: 123 }; jest.spyOn(service, 'getScenarioActionIdentifier'); const actionId = comp.trackId(0, entity); diff --git a/simulator-ui/src/main/webapp/app/entities/scenario-action/service/scenario-action.service.spec.ts b/simulator-ui/src/main/webapp/app/entities/scenario-action/service/scenario-action.service.spec.ts index fbc6fb466..1db6b2880 100644 --- a/simulator-ui/src/main/webapp/app/entities/scenario-action/service/scenario-action.service.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/scenario-action/service/scenario-action.service.spec.ts @@ -110,7 +110,7 @@ describe('ScenarioAction Service', () => { }); describe('compareScenarioAction', () => { - it('Should return true if both entities are null', () => { + it('should return true if both entities are null', () => { const entity1 = null; const entity2 = null; @@ -119,7 +119,7 @@ describe('ScenarioAction Service', () => { expect(compareResult).toEqual(true); }); - it('Should return false if one entity is null', () => { + it('should return false if one entity is null', () => { const entity1 = { actionId: 123 }; const entity2 = null; @@ -130,7 +130,7 @@ describe('ScenarioAction Service', () => { expect(compareResult2).toEqual(false); }); - it('Should return false if primaryKey differs', () => { + it('should return false if primaryKey differs', () => { const entity1 = { actionId: 123 }; const entity2 = { actionId: 456 }; @@ -141,7 +141,7 @@ describe('ScenarioAction Service', () => { expect(compareResult2).toEqual(false); }); - it('Should return false if primaryKey matches', () => { + it('should return false if primaryKey matches', () => { const entity1 = { actionId: 123 }; const entity2 = { actionId: 123 }; diff --git a/simulator-ui/src/main/webapp/app/entities/scenario-execution/detail/scenario-execution-detail.component.spec.ts b/simulator-ui/src/main/webapp/app/entities/scenario-execution/detail/scenario-execution-detail.component.spec.ts index 4a49415db..2612ff83d 100644 --- a/simulator-ui/src/main/webapp/app/entities/scenario-execution/detail/scenario-execution-detail.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/scenario-execution/detail/scenario-execution-detail.component.spec.ts @@ -27,7 +27,7 @@ describe('ScenarioExecution Management Detail Component', () => { }); describe('OnInit', () => { - it('Should load scenarioExecution on init', async () => { + it('should load scenarioExecution on init', async () => { const harness = await RouterTestingHarness.create(); const instance = await harness.navigateByUrl('/', ScenarioExecutionDetailComponent); diff --git a/simulator-ui/src/main/webapp/app/entities/scenario-execution/list/scenario-execution.component.spec.ts b/simulator-ui/src/main/webapp/app/entities/scenario-execution/list/scenario-execution.component.spec.ts index 584b0d420..85232a7a5 100644 --- a/simulator-ui/src/main/webapp/app/entities/scenario-execution/list/scenario-execution.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/scenario-execution/list/scenario-execution.component.spec.ts @@ -62,7 +62,7 @@ describe('ScenarioExecution Management Component', () => { ); }); - it('Should call load all on init', () => { + it('should call load all on init', () => { // WHEN comp.ngOnInit(); @@ -72,7 +72,7 @@ describe('ScenarioExecution Management Component', () => { }); describe('trackId', () => { - it('Should forward to scenarioExecutionService', () => { + it('should forward to scenarioExecutionService', () => { const entity = { executionId: 123 }; jest.spyOn(service, 'getScenarioExecutionIdentifier'); const executionId = comp.trackId(0, entity); diff --git a/simulator-ui/src/main/webapp/app/entities/scenario-execution/service/scenario-execution.service.spec.ts b/simulator-ui/src/main/webapp/app/entities/scenario-execution/service/scenario-execution.service.spec.ts index 8b4e4c437..b17420e39 100644 --- a/simulator-ui/src/main/webapp/app/entities/scenario-execution/service/scenario-execution.service.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/scenario-execution/service/scenario-execution.service.spec.ts @@ -110,7 +110,7 @@ describe('ScenarioExecution Service', () => { }); describe('compareScenarioExecution', () => { - it('Should return true if both entities are null', () => { + it('should return true if both entities are null', () => { const entity1 = null; const entity2 = null; @@ -119,7 +119,7 @@ describe('ScenarioExecution Service', () => { expect(compareResult).toEqual(true); }); - it('Should return false if one entity is null', () => { + it('should return false if one entity is null', () => { const entity1 = { executionId: 123 }; const entity2 = null; @@ -130,7 +130,7 @@ describe('ScenarioExecution Service', () => { expect(compareResult2).toEqual(false); }); - it('Should return false if primaryKey differs', () => { + it('should return false if primaryKey differs', () => { const entity1 = { executionId: 123 }; const entity2 = { executionId: 456 }; @@ -141,7 +141,7 @@ describe('ScenarioExecution Service', () => { expect(compareResult2).toEqual(false); }); - it('Should return false if primaryKey matches', () => { + it('should return false if primaryKey matches', () => { const entity1 = { executionId: 123 }; const entity2 = { executionId: 123 }; diff --git a/simulator-ui/src/main/webapp/app/entities/scenario-parameter/detail/scenario-parameter-detail.component.spec.ts b/simulator-ui/src/main/webapp/app/entities/scenario-parameter/detail/scenario-parameter-detail.component.spec.ts index 06f29051a..db594eebc 100644 --- a/simulator-ui/src/main/webapp/app/entities/scenario-parameter/detail/scenario-parameter-detail.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/scenario-parameter/detail/scenario-parameter-detail.component.spec.ts @@ -27,7 +27,7 @@ describe('ScenarioParameter Management Detail Component', () => { }); describe('OnInit', () => { - it('Should load scenarioParameter on init', async () => { + it('should load scenarioParameter on init', async () => { const harness = await RouterTestingHarness.create(); const instance = await harness.navigateByUrl('/', ScenarioParameterDetailComponent); diff --git a/simulator-ui/src/main/webapp/app/entities/scenario-parameter/list/scenario-parameter.component.spec.ts b/simulator-ui/src/main/webapp/app/entities/scenario-parameter/list/scenario-parameter.component.spec.ts index 3aa6ea32f..8b1f86ae8 100644 --- a/simulator-ui/src/main/webapp/app/entities/scenario-parameter/list/scenario-parameter.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/scenario-parameter/list/scenario-parameter.component.spec.ts @@ -62,7 +62,7 @@ describe('ScenarioParameter Management Component', () => { ); }); - it('Should call load all on init', () => { + it('should call load all on init', () => { // WHEN comp.ngOnInit(); @@ -72,7 +72,7 @@ describe('ScenarioParameter Management Component', () => { }); describe('trackId', () => { - it('Should forward to scenarioParameterService', () => { + it('should forward to scenarioParameterService', () => { const entity = { parameterId: 123 }; jest.spyOn(service, 'getScenarioParameterIdentifier'); const parameterId = comp.trackId(0, entity); diff --git a/simulator-ui/src/main/webapp/app/entities/scenario-parameter/service/scenario-parameter.service.spec.ts b/simulator-ui/src/main/webapp/app/entities/scenario-parameter/service/scenario-parameter.service.spec.ts index 81ca53c18..33dea8a84 100644 --- a/simulator-ui/src/main/webapp/app/entities/scenario-parameter/service/scenario-parameter.service.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/scenario-parameter/service/scenario-parameter.service.spec.ts @@ -109,7 +109,7 @@ describe('ScenarioParameter Service', () => { }); describe('compareScenarioParameter', () => { - it('Should return true if both entities are null', () => { + it('should return true if both entities are null', () => { const entity1 = null; const entity2 = null; @@ -118,7 +118,7 @@ describe('ScenarioParameter Service', () => { expect(compareResult).toEqual(true); }); - it('Should return false if one entity is null', () => { + it('should return false if one entity is null', () => { const entity1 = { parameterId: 123 }; const entity2 = null; @@ -129,7 +129,7 @@ describe('ScenarioParameter Service', () => { expect(compareResult2).toEqual(false); }); - it('Should return false if primaryKey differs', () => { + it('should return false if primaryKey differs', () => { const entity1 = { parameterId: 123 }; const entity2 = { parameterId: 456 }; @@ -140,7 +140,7 @@ describe('ScenarioParameter Service', () => { expect(compareResult2).toEqual(false); }); - it('Should return false if primaryKey matches', () => { + it('should return false if primaryKey matches', () => { const entity1 = { parameterId: 123 }; const entity2 = { parameterId: 123 }; diff --git a/simulator-ui/src/main/webapp/app/entities/test-parameter/detail/test-parameter-detail.component.spec.ts b/simulator-ui/src/main/webapp/app/entities/test-parameter/detail/test-parameter-detail.component.spec.ts index 3e4057e8b..3c4d5cd30 100644 --- a/simulator-ui/src/main/webapp/app/entities/test-parameter/detail/test-parameter-detail.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/test-parameter/detail/test-parameter-detail.component.spec.ts @@ -27,7 +27,7 @@ describe('TestParameter Management Detail Component', () => { }); describe('OnInit', () => { - it('Should load testParameter on init', async () => { + it('should load testParameter on init', async () => { const harness = await RouterTestingHarness.create(); const instance = await harness.navigateByUrl('/', TestParameterDetailComponent); diff --git a/simulator-ui/src/main/webapp/app/entities/test-parameter/list/test-parameter.component.spec.ts b/simulator-ui/src/main/webapp/app/entities/test-parameter/list/test-parameter.component.spec.ts index b0fb437ef..008daaf5d 100644 --- a/simulator-ui/src/main/webapp/app/entities/test-parameter/list/test-parameter.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/test-parameter/list/test-parameter.component.spec.ts @@ -62,7 +62,7 @@ describe('TestParameter Management Component', () => { ); }); - it('Should call load all on init', () => { + it('should call load all on init', () => { // WHEN comp.ngOnInit(); @@ -72,7 +72,7 @@ describe('TestParameter Management Component', () => { }); describe('trackId', () => { - it('Should forward to testParameterService', () => { + it('should forward to testParameterService', () => { const entity = { key: 'key', testResult: { id: 123 } }; jest.spyOn(service, 'getTestParameterIdentifier'); const id = comp.trackId(0, entity); diff --git a/simulator-ui/src/main/webapp/app/entities/test-parameter/service/test-parameter.service.spec.ts b/simulator-ui/src/main/webapp/app/entities/test-parameter/service/test-parameter.service.spec.ts index 200f748e9..9124b3c42 100644 --- a/simulator-ui/src/main/webapp/app/entities/test-parameter/service/test-parameter.service.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/test-parameter/service/test-parameter.service.spec.ts @@ -110,7 +110,7 @@ describe('TestParameter Service', () => { }); describe('compareTestParameter', () => { - it('Should return true if both entities are null', () => { + it('should return true if both entities are null', () => { const entity1 = null; const entity2 = null; @@ -119,7 +119,7 @@ describe('TestParameter Service', () => { expect(compareResult).toEqual(true); }); - it('Should return false if one entity is null', () => { + it('should return false if one entity is null', () => { const entity1 = { key: 'key', testResult: { id: 123 } }; const entity2 = null; @@ -130,7 +130,7 @@ describe('TestParameter Service', () => { expect(compareResult2).toEqual(false); }); - it('Should return false if primaryKey differs', () => { + it('should return false if primaryKey differs', () => { const entity1 = { key: 'key', testResult: { id: 123 } }; const entity2 = { key: 'another key', testResult: { id: 123 } }; const entity3 = { key: 'key', testResult: { id: 234 } }; @@ -146,7 +146,7 @@ describe('TestParameter Service', () => { expect(compareResult4).toEqual(false); }); - it('Should return true if primaryKey matches', () => { + it('should return true if primaryKey matches', () => { const entity1 = { key: 'key', testResult: { id: 123 } }; const entity2 = { key: 'key', testResult: { id: 123 } }; diff --git a/simulator-ui/src/main/webapp/app/entities/test-result/detail/test-result-detail.component.spec.ts b/simulator-ui/src/main/webapp/app/entities/test-result/detail/test-result-detail.component.spec.ts index 94364f117..84b5bf7f7 100644 --- a/simulator-ui/src/main/webapp/app/entities/test-result/detail/test-result-detail.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/test-result/detail/test-result-detail.component.spec.ts @@ -27,7 +27,7 @@ describe('TestResult Management Detail Component', () => { }); describe('OnInit', () => { - it('Should load testResult on init', async () => { + it('should load testResult on init', async () => { const harness = await RouterTestingHarness.create(); const instance = await harness.navigateByUrl('/', TestResultDetailComponent); diff --git a/simulator-ui/src/main/webapp/app/entities/test-result/list/test-result.component.spec.ts b/simulator-ui/src/main/webapp/app/entities/test-result/list/test-result.component.spec.ts index 87b2a6172..f4aed426a 100644 --- a/simulator-ui/src/main/webapp/app/entities/test-result/list/test-result.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/test-result/list/test-result.component.spec.ts @@ -62,7 +62,7 @@ describe('TestResult Management Component', () => { ); }); - it('Should call load all on init', () => { + it('should call load all on init', () => { // WHEN comp.ngOnInit(); @@ -72,7 +72,7 @@ describe('TestResult Management Component', () => { }); describe('trackId', () => { - it('Should forward to testResultService', () => { + it('should forward to testResultService', () => { const entity = { id: 123 }; jest.spyOn(service, 'getTestResultIdentifier'); const id = comp.trackId(0, entity); diff --git a/simulator-ui/src/main/webapp/app/entities/test-result/service/test-result.service.spec.ts b/simulator-ui/src/main/webapp/app/entities/test-result/service/test-result.service.spec.ts index 15336203e..3dc4423ea 100644 --- a/simulator-ui/src/main/webapp/app/entities/test-result/service/test-result.service.spec.ts +++ b/simulator-ui/src/main/webapp/app/entities/test-result/service/test-result.service.spec.ts @@ -124,7 +124,7 @@ describe('TestResult Service', () => { }); describe('compareTestResult', () => { - it('Should return true if both entities are null', () => { + it('should return true if both entities are null', () => { const entity1 = null; const entity2 = null; @@ -133,7 +133,7 @@ describe('TestResult Service', () => { expect(compareResult).toEqual(true); }); - it('Should return false if one entity is null', () => { + it('should return false if one entity is null', () => { const entity1 = { id: 123 }; const entity2 = null; @@ -144,7 +144,7 @@ describe('TestResult Service', () => { expect(compareResult2).toEqual(false); }); - it('Should return false if primaryKey differs', () => { + it('should return false if primaryKey differs', () => { const entity1 = { id: 123 }; const entity2 = { id: 456 }; @@ -155,7 +155,7 @@ describe('TestResult Service', () => { expect(compareResult2).toEqual(false); }); - it('Should return true if primaryKey matches', () => { + it('should return true if primaryKey matches', () => { const entity1 = { id: 123 }; const entity2 = { id: 123 }; diff --git a/simulator-ui/src/main/webapp/app/entities/test-result/service/test-result.service.ts b/simulator-ui/src/main/webapp/app/entities/test-result/service/test-result.service.ts index 488d793cb..07ff3c8ee 100644 --- a/simulator-ui/src/main/webapp/app/entities/test-result/service/test-result.service.ts +++ b/simulator-ui/src/main/webapp/app/entities/test-result/service/test-result.service.ts @@ -53,6 +53,10 @@ export class TestResultService { return this.http.get(`${this.resourceUrl}/count-by-status`, { observe: 'response' }); } + deleteAll(): Observable> { + return this.http.delete(this.resourceUrl, { observe: 'response' }); + } + getTestResultIdentifier(testResult: Pick): number { return testResult.id; } diff --git a/simulator-ui/src/main/webapp/app/home/delete/test-result-delete-dialog.component.html b/simulator-ui/src/main/webapp/app/home/delete/test-result-delete-dialog.component.html new file mode 100644 index 000000000..ef8b16d23 --- /dev/null +++ b/simulator-ui/src/main/webapp/app/home/delete/test-result-delete-dialog.component.html @@ -0,0 +1,26 @@ +
+ + + + + +
diff --git a/simulator-ui/src/main/webapp/app/home/delete/test-result-delete-dialog.component.spec.ts b/simulator-ui/src/main/webapp/app/home/delete/test-result-delete-dialog.component.spec.ts new file mode 100644 index 000000000..bc5bf9fa4 --- /dev/null +++ b/simulator-ui/src/main/webapp/app/home/delete/test-result-delete-dialog.component.spec.ts @@ -0,0 +1,61 @@ +jest.mock('@ng-bootstrap/ng-bootstrap'); + +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; + +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; + +import { of } from 'rxjs'; + +import { TestResultService } from 'app/entities/test-result/service/test-result.service'; + +import TestResultDeleteDialogComponent from './test-result-delete-dialog.component'; + +describe('Test Result Delete Component', () => { + let service: TestResultService; + let mockActiveModal: NgbActiveModal; + + let fixture: ComponentFixture; + let component: TestResultDeleteDialogComponent; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule, TestResultDeleteDialogComponent], + providers: [NgbActiveModal], + }) + .overrideTemplate(TestResultDeleteDialogComponent, '') + .compileComponents(); + + service = TestBed.inject(TestResultService); + mockActiveModal = TestBed.inject(NgbActiveModal); + + fixture = TestBed.createComponent(TestResultDeleteDialogComponent); + component = fixture.componentInstance; + }); + + describe('confirmDelete', () => { + it('should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + jest.spyOn(service, 'deleteAll').mockReturnValue(of(new HttpResponse())); + + component.confirmDelete(); + tick(); + + expect(service.deleteAll).toHaveBeenCalled(); + expect(mockActiveModal.close).toHaveBeenCalledWith('deleted'); + }), + )); + + it('should not call delete service on clear', () => { + jest.spyOn(service, 'deleteAll'); + + component.cancel(); + + expect(service.deleteAll).not.toHaveBeenCalled(); + expect(mockActiveModal.close).not.toHaveBeenCalled(); + expect(mockActiveModal.dismiss).toHaveBeenCalled(); + }); + }); +}); diff --git a/simulator-ui/src/main/webapp/app/home/delete/test-result-delete-dialog.component.ts b/simulator-ui/src/main/webapp/app/home/delete/test-result-delete-dialog.component.ts new file mode 100644 index 000000000..6b257e290 --- /dev/null +++ b/simulator-ui/src/main/webapp/app/home/delete/test-result-delete-dialog.component.ts @@ -0,0 +1,31 @@ +import { Component } from '@angular/core'; +import { FormsModule } from '@angular/forms'; + +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; + +import { ITEM_DELETED_EVENT } from 'app/config/navigation.constants'; + +import SharedModule from 'app/shared/shared.module'; +import { TestResultService } from 'app/entities/test-result/service/test-result.service'; + +@Component({ + standalone: true, + templateUrl: './test-result-delete-dialog.component.html', + imports: [SharedModule, FormsModule], +}) +export default class TestResultDeleteDialogComponent { + constructor( + protected activeModal: NgbActiveModal, + protected testResultService: TestResultService, + ) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmDelete(): void { + this.testResultService.deleteAll().subscribe(() => { + this.activeModal.close(ITEM_DELETED_EVENT); + }); + } +} diff --git a/simulator-ui/src/main/webapp/app/home/test-result-summary.component.html b/simulator-ui/src/main/webapp/app/home/test-result-summary.component.html index c310fce85..25840af88 100644 --- a/simulator-ui/src/main/webapp/app/home/test-result-summary.component.html +++ b/simulator-ui/src/main/webapp/app/home/test-result-summary.component.html @@ -2,6 +2,19 @@

Test Results + +
+
+ + +
+

diff --git a/simulator-ui/src/main/webapp/app/home/test-result-summary.component.ts b/simulator-ui/src/main/webapp/app/home/test-result-summary.component.ts index e8e0b9c61..9d3eca23c 100644 --- a/simulator-ui/src/main/webapp/app/home/test-result-summary.component.ts +++ b/simulator-ui/src/main/webapp/app/home/test-result-summary.component.ts @@ -1,11 +1,16 @@ import { Component, OnInit } from '@angular/core'; import { RouterModule } from '@angular/router'; -import { map } from 'rxjs/operators'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; + +import { filter, map } from 'rxjs/operators'; import { STATUS_FAILED, STATUS_SUCCESS } from 'app/entities/scenario-execution/scenario-execution.model'; import { TestResultsByStatus, TestResultService } from 'app/entities/test-result/service/test-result.service'; import SharedModule from 'app/shared/shared.module'; +import TestResultDeleteDialogComponent from './delete/test-result-delete-dialog.component'; +import { switchMap } from 'rxjs'; +import { ITEM_DELETED_EVENT } from '../config/navigation.constants'; @Component({ standalone: true, @@ -14,6 +19,7 @@ import SharedModule from 'app/shared/shared.module'; imports: [RouterModule, SharedModule], }) export default class TestResultSummaryComponent implements OnInit { + isLoading = false; testResults: TestResultsByStatus | null = null; successfulPercentage = '0'; @@ -22,25 +28,41 @@ export default class TestResultSummaryComponent implements OnInit { statusSuccess = STATUS_SUCCESS; statusFailed = STATUS_FAILED; - constructor(private testResultService: TestResultService) {} + constructor( + private modalService: NgbModal, + private testResultService: TestResultService, + ) {} ngOnInit(): void { this.load(); } - private load(): void { + protected load(): void { + this.isLoading = true; this.testResultService .countByStatus() .pipe(map(response => response.body ?? { total: 0, successful: 0, failed: 0 })) - .subscribe((testResults: TestResultsByStatus) => { - this.testResults = testResults; + .subscribe({ + next: (testResults: TestResultsByStatus) => { + this.testResults = testResults; - if (testResults.total > 0) { - this.successfulPercentage = this.toFixedDecimalIfNotMatching((testResults.successful / testResults.total) * 100); - this.failedPercentage = this.toFixedDecimalIfNotMatching((testResults.failed / testResults.total) * 100); - } + if (testResults.total > 0) { + this.successfulPercentage = this.toFixedDecimalIfNotMatching((testResults.successful / testResults.total) * 100); + this.failedPercentage = this.toFixedDecimalIfNotMatching((testResults.failed / testResults.total) * 100); + } + }, + complete: () => (this.isLoading = false), }); } + protected reset(): void { + const modalRef = this.modalService.open(TestResultDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); + // unsubscribe not needed because closed completes on modal close + modalRef.closed.pipe(filter(reason => reason === ITEM_DELETED_EVENT)).subscribe({ + next: () => { + this.load(); + }, + }); + } private toFixedDecimalIfNotMatching(percentage: number): string { const fixed = percentage.toFixed(2); diff --git a/simulator-ui/src/main/webapp/app/layouts/navbar/navbar.component.spec.ts b/simulator-ui/src/main/webapp/app/layouts/navbar/navbar.component.spec.ts index d026a77eb..30e30a8fe 100644 --- a/simulator-ui/src/main/webapp/app/layouts/navbar/navbar.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/layouts/navbar/navbar.component.spec.ts @@ -28,7 +28,7 @@ describe('Navbar Component', () => { profileService = TestBed.inject(ProfileService); }); - it('Should call profileService.getProfileInfo on init', () => { + it('should call profileService.getProfileInfo on init', () => { // GIVEN jest.spyOn(profileService, 'getProfileInfo').mockReturnValue(of(new ProfileInfo())); diff --git a/simulator-ui/src/main/webapp/app/layouts/profiles/page-ribbon.component.spec.ts b/simulator-ui/src/main/webapp/app/layouts/profiles/page-ribbon.component.spec.ts index 4d5176cda..741018761 100644 --- a/simulator-ui/src/main/webapp/app/layouts/profiles/page-ribbon.component.spec.ts +++ b/simulator-ui/src/main/webapp/app/layouts/profiles/page-ribbon.component.spec.ts @@ -26,7 +26,7 @@ describe('Page Ribbon Component', () => { profileService = TestBed.inject(ProfileService); }); - it('Should call profileService.getProfileInfo on init', () => { + it('should call profileService.getProfileInfo on init', () => { // GIVEN jest.spyOn(profileService, 'getProfileInfo').mockReturnValue(of(new ProfileInfo())); diff --git a/simulator-ui/src/main/webapp/app/scenario-result/scenario-result.component.html b/simulator-ui/src/main/webapp/app/scenario-result/scenario-result.component.html index d8cfc195d..00e590603 100644 --- a/simulator-ui/src/main/webapp/app/scenario-result/scenario-result.component.html +++ b/simulator-ui/src/main/webapp/app/scenario-result/scenario-result.component.html @@ -3,6 +3,11 @@

Scenario Executions
+