[ACS-11406] Refactored UnitTestingUtils to use inner scoped utility classes (#12052)

* [ACS-11406] Refactored UnitTestingUtils

* [ACS-11406] update affected unit tests

* empty [ci:force]

* [ACS-11406] fix process-services-cloud tests [ci:force]

* [ACS-11406] cr fixes [ci:force]
This commit is contained in:
Mykyta Maliarchuk
2026-07-21 10:38:14 +02:00
committed by GitHub
parent 62dff48260
commit 1f7722ca89
33 changed files with 612 additions and 588 deletions
@@ -351,7 +351,7 @@ describe('LibraryDialogComponent', () => {
it('should not show required error on opening dialog', async () => {
findSitesSpy.and.returnValue(Promise.resolve(findSitesResponse));
fixture.detectChanges();
const titleFormField = await unitTestingUtils.getMatFormField();
const titleFormField = await unitTestingUtils.formField.get();
const errors = await titleFormField.getTextErrors();
expect(errors.length).toBe(0);
});
@@ -371,7 +371,7 @@ describe('LibraryDialogComponent', () => {
component.form.controls.title.setValue('');
fixture.detectChanges();
const titleFormField = await unitTestingUtils.getMatFormField();
const titleFormField = await unitTestingUtils.formField.get();
const errors = await titleFormField.getTextErrors();
expect(component.form.controls.title.errors).toEqual({ required: true });
@@ -385,7 +385,7 @@ describe('LibraryDialogComponent', () => {
component.form.controls.id.markAsTouched();
fixture.detectChanges();
const idFormField = await unitTestingUtils.getMatFormFieldByCSS('.adf-library-dialog-form-field:nth-of-type(2)');
const idFormField = await unitTestingUtils.formField.getByCSS('.adf-library-dialog-form-field:nth-of-type(2)');
const errors = await idFormField.getTextErrors();
expect(component.form.controls.id.errors).toEqual({ required: true });
@@ -24,7 +24,6 @@ import { SearchFilterContainerComponent } from './search-filter-container.compon
import { SearchCategory } from '../../models/search-category.interface';
import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatMenuHarness } from '@angular/material/menu/testing';
import { MatButtonHarness } from '@angular/material/button/testing';
import { MatInputHarness } from '@angular/material/input/testing';
import { provideRouter } from '@angular/router';
@@ -93,7 +92,7 @@ describe('SearchFilterContainerComponent', () => {
});
it('should set/update the active filter after the Apply button is clicked', async () => {
const menu = await loader.getHarness(MatMenuHarness);
const menu = await unitTestingUtils.menu.get();
await menu.open();
component.widgetContainer.componentRef.instance.value = 'searchText';
@@ -118,7 +117,7 @@ describe('SearchFilterContainerComponent', () => {
it('should remove active filter after the Clear button is clicked', async () => {
queryBuilder.setActiveFilter('queryName', 'searchText');
const menu = await loader.getHarness(MatMenuHarness);
const menu = await unitTestingUtils.menu.get();
await menu.open();
component.widgetContainer.componentRef.instance.value = 'searchText';
@@ -137,7 +136,7 @@ describe('SearchFilterContainerComponent', () => {
eventRaised = true;
});
const menu = await loader.getHarness(MatMenuHarness);
const menu = await unitTestingUtils.menu.get();
await menu.open();
component.widgetContainer.componentRef.instance.value = 'searchText';
@@ -182,7 +181,7 @@ describe('SearchFilterContainerComponent', () => {
it('should set up a focus trap on the filter when the menu is opened', async () => {
expect(component.focusTrap).toBeUndefined();
const menu = await loader.getHarness(MatMenuHarness);
const menu = await unitTestingUtils.menu.get();
await menu.open();
expect(component.focusTrap).toBeDefined();
@@ -193,7 +192,7 @@ describe('SearchFilterContainerComponent', () => {
// TODO: very flaky test, need to be refactored
// eslint-disable-next-line ban/ban
xit('should focus the input element when the menu is opened', async () => {
const menu = await loader.getHarness(MatMenuHarness);
const menu = await unitTestingUtils.menu.get();
await menu.open();
const input = await menu.getHarness(MatInputHarness);
@@ -201,7 +200,7 @@ describe('SearchFilterContainerComponent', () => {
});
it('should focus the menu trigger when the menu is closed', async () => {
const menu = await loader.getHarness(MatMenuHarness);
const menu = await unitTestingUtils.menu.get();
await menu.open();
await menu.close();
@@ -209,7 +208,7 @@ describe('SearchFilterContainerComponent', () => {
});
it('should use a fieldset with aria-labelledby pointing to the legend', async () => {
const menu = await loader.getHarness(MatMenuHarness);
const menu = await unitTestingUtils.menu.get();
await menu.open();
fixture.detectChanges();
@@ -225,7 +224,7 @@ describe('SearchFilterContainerComponent', () => {
});
it('should have the legend text matching the category name', async () => {
const menu = await loader.getHarness(MatMenuHarness);
const menu = await unitTestingUtils.menu.get();
await menu.open();
fixture.detectChanges();
@@ -29,7 +29,6 @@ import { SelectionChange } from '@angular/cdk/collections';
import { DebugElement } from '@angular/core';
import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatCheckboxHarness } from '@angular/material/checkbox/testing';
import { TranslateService } from '@ngx-translate/core';
describe('TreeComponent', () => {
@@ -49,7 +48,7 @@ describe('TreeComponent', () => {
const getNodePadding = (nodeId: string) => parseInt(getComputedStyle(getNode(nodeId).nativeElement).paddingLeft, 10);
const getNodeSpinner = async (nodeId: string) => testingUtils.getMatProgressSpinnerWithAncestorByDataAutomationId(`node_${nodeId}`);
const getNodeSpinner = async (nodeId: string) => testingUtils.progressSpinner.getWithAncestorByDataAutomationId(`node_${nodeId}`);
const clickExpandCollapseBtn = (nodeId: string) => testingUtils.clickByCSS(`${composeNodeSelector(nodeId)} .adf-tree-expand-collapse-button`);
@@ -138,7 +137,7 @@ describe('TreeComponent', () => {
component.loadingRoot$ = of(true);
fixture.detectChanges();
const matSpinnerElement = await testingUtils.getMatProgressSpinnerWithAncestorByCSS('.adf-tree-loading-spinner-container');
const matSpinnerElement = await testingUtils.progressSpinner.getWithAncestorByCSS('.adf-tree-loading-spinner-container');
expect(await matSpinnerElement.getMode()).toBe('indeterminate');
});
@@ -148,7 +147,7 @@ describe('TreeComponent', () => {
component.collapseIcon = 'chevron_left';
component.treeService.collapseNode(component.treeService.treeNodes[0]);
fixture.detectChanges();
const icon = await testingUtils.getMatIconWithAncestorByCSS('.adf-tree-expand-collapse-button');
const icon = await testingUtils.icon.getWithAncestorByCSS('.adf-tree-expand-collapse-button');
expect(await icon.getName()).toContain('folder');
spyOn(component.treeService.treeControl, 'isExpanded').and.returnValue(true);
fixture.detectChanges();
@@ -324,7 +323,7 @@ describe('TreeComponent', () => {
it('selection should be disabled by default, no checkboxes should be displayed', async () => {
component.refreshTree();
fixture.detectChanges();
const nodeCheckboxes = await loader.getAllHarnesses(MatCheckboxHarness);
const nodeCheckboxes = await testingUtils.checkbox.getAll();
expect(nodeCheckboxes.length).toEqual(0);
expect(component.selectableNodes).toEqual(false);
@@ -338,7 +337,7 @@ describe('TreeComponent', () => {
it('should display checkboxes when selection is enabled', async () => {
component.refreshTree();
fixture.detectChanges();
const nodeCheckboxes = await loader.getAllHarnesses(MatCheckboxHarness);
const nodeCheckboxes = await testingUtils.checkbox.getAll();
const selectableNodes = component.treeService.treeNodes.filter((node: TreeNode) => node.nodeType !== TreeNodeType.LoadMoreNode);
expect(nodeCheckboxes.length).toEqual(selectableNodes.length);
});
@@ -577,7 +576,7 @@ describe('TreeComponent', () => {
component.contextMenuOptions = [contextMenuOption1, contextMenuOption2];
fixture.detectChanges();
const menu = await testingUtils.getMatMenuByCSS('#action_menu_right_testId1');
const menu = await testingUtils.menu.getByCSS('#action_menu_right_testId1');
await menu.open();
expect(await menu.isOpen()).toBeTrue();
expect(component.contextMenuOptions.length).toEqual(2);