diff --git a/modules/test/dns/python/src/dns_module.py b/modules/test/dns/python/src/dns_module.py index fc735d002..5c23919f1 100644 --- a/modules/test/dns/python/src/dns_module.py +++ b/modules/test/dns/python/src/dns_module.py @@ -55,7 +55,6 @@ def generate_module_report(self): page_max_height = 850 header_height = 48 summary_height = 135 - row_height = 44 loader=FileSystemLoader(self._report_template_folder) template = Environment( loader=loader, @@ -120,26 +119,62 @@ def generate_module_report(self): 'dat': dat, 'count': count, }) - # Handling the possible table split - table_height = (len(module_data) + 1) * row_height + + col_limits = { + 'res_ip': 16, + 'dat': 40, + } + + pixels_per_extra_line = 18 + base_row_height = 44 + page_useful_space = page_max_height - header_height - summary_height - pages = table_height // (page_useful_space) - rows_on_page = (page_useful_space) // row_height - start = 0 + + pages_content = [] + current_page_rows = [] + current_page_height = 0 + + for row in module_data: + max_lines_in_row = 1 + + for field, char_limit in col_limits.items(): + text = str(row.get(field, '') or '') + if not text: + continue + + lines = (len(text) + char_limit - 1) // char_limit + max_lines_in_row = max(max_lines_in_row, lines) + + estimated_row_height = ( + base_row_height + (max_lines_in_row - 1) * pixels_per_extra_line + ) + + if (current_page_height + estimated_row_height) > page_useful_space: + pages_content.append(current_page_rows) + current_page_rows = [] + current_page_height = 0 + + current_page_rows.append(row) + current_page_height += estimated_row_height + + if current_page_rows: + pages_content.append(current_page_rows) + report_html = '' - for page in range(pages+1): - end = start + min(len(module_data), rows_on_page) - module_header_repr = module_header if page == 0 else None + if not pages_content: + pages_content = [[]] + + for i, page_rows in enumerate(pages_content): + module_header_repr = module_header if i == 0 else None page_html = template.render( - base_template=self._base_template_file, - module_header=module_header_repr, - summary_headers=summary_headers, - summary_data=summary_data, - module_data_headers=module_data_headers, - module_data=module_data[start:end] - ) + base_template=self._base_template_file, + module_header=module_header_repr, + summary_headers=summary_headers, + summary_data=summary_data, + module_data_headers=module_data_headers, + module_data=page_rows + ) report_html += page_html - start = end LOGGER.debug('Module report:\n' + report_html) diff --git a/modules/test/tls/python/src/tls_util.py b/modules/test/tls/python/src/tls_util.py index f8346f523..aa5cd577e 100644 --- a/modules/test/tls/python/src/tls_util.py +++ b/modules/test/tls/python/src/tls_util.py @@ -475,7 +475,7 @@ def validate_tls_server(self, return cert_valid, details else: LOGGER.info('Failed to resolve public certificate') - return None, 'Failed to resolve public certificate' + return None, ['Failed to resolve public certificate'] def write_cert_to_file(self, cert_name, cert): try: diff --git a/modules/ui/src/app/components/list-item/list-item.component.spec.ts b/modules/ui/src/app/components/list-item/list-item.component.spec.ts index f671c57c7..ac144e572 100644 --- a/modules/ui/src/app/components/list-item/list-item.component.spec.ts +++ b/modules/ui/src/app/components/list-item/list-item.component.spec.ts @@ -41,6 +41,8 @@ describe('ListItemComponent', () => { { action: 'Delete', icon: 'delete_icon' }, ]; + const testEntity: Entity = { id: 1, name: 'test' }; + beforeEach(async () => { await TestBed.configureTestingModule({ imports: [ @@ -55,14 +57,15 @@ describe('ListItemComponent', () => { fixture = TestBed.createComponent(ListItemComponent); component = fixture.componentInstance; fixture.componentRef.setInput('actions', testActions); - fixture.componentRef.setInput('entity', { id: 1, name: 'test' } as Entity); + fixture.componentRef.setInput('entity', testEntity); + compiled = fixture.nativeElement as HTMLElement; loader = TestbedHarnessEnvironment.loader(fixture); fixture.detectChanges(); }); describe('menu', () => { - let menu; + let menu: MatMenuHarness; let items: MatMenuItemHarness[]; beforeEach(async () => { @@ -104,4 +107,67 @@ describe('ListItemComponent', () => { expect(button).toBeTruthy(); expect(button?.textContent).toContain('more_vert'); }); + + it('should call hide on outEvent', () => { + const hideSpy = spyOn(component.tooltip, 'hide'); + component.outEvent(); + + expect(hideSpy).toHaveBeenCalled(); + }); + + describe('tooltip logic', () => { + let mockTooltipElement: HTMLElement; + + beforeEach(() => { + mockTooltipElement = document.createElement('div'); + }); + + it('should show tooltip and query container on mouseenter (onEvent)', () => { + const messageFn = (e: Entity) => `Info: ${e.name}`; + fixture.componentRef.setInput('tooltipMessage', messageFn); + + const showSpy = spyOn(component.tooltip, 'show'); + + const querySpy = spyOn(document, 'querySelector').and.returnValue( + mockTooltipElement + ); + + const event = new MouseEvent('mouseenter', { + clientX: 100, + clientY: 200, + }); + component.onEvent(event); + + expect(component.tooltip.message).toBe('Info: test'); + expect(showSpy).toHaveBeenCalledWith(0, { x: 100, y: 200 }); + expect(querySpy).toHaveBeenCalledWith( + '.mat-mdc-tooltip-panel:has(.list-item-tooltip)' + ); + }); + + it('should update container position on mousemove (onMoveEvent)', () => { + component.tooltip.message = 'Already set message'; + + spyOn(document, 'querySelector').and.returnValue(mockTooltipElement); + + const x = 150; + const y = 250; + const event = new MouseEvent('mousemove', { clientX: x, clientY: y }); + + component.onMoveEvent(event); + + expect(mockTooltipElement.style.top).toBe(`${y}px`); + expect(mockTooltipElement.style.left).toBe(`${x}px`); + }); + + it('should NOT update styles if tooltip message is missing', () => { + component.tooltip.message = ''; + const querySpy = spyOn(document, 'querySelector'); + + const event = new MouseEvent('mousemove'); + component.onMoveEvent(event); + + expect(querySpy).not.toHaveBeenCalled(); + }); + }); });