From 5459a662f604a6f623d16ddeedab785bf975633c Mon Sep 17 00:00:00 2001 From: Shivangi Shree Date: Tue, 8 Sep 2026 10:05:30 +0530 Subject: [PATCH] =?UTF-8?q?[ACS-10262]=20Add=20key=20for=20screen=20reader?= =?UTF-8?q?=20users=20so=20that=20search=20process=20is=E2=80=A6=20(#5350)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [ACS-10262] Add key for screen reader users so that search process is announced * [ACS-10262] Add unit test * [ACS-10262] CR Fixes * [ACS-10262] CR fixes * [ACS-10262] Remove repetition --- projects/aca-content/assets/i18n/en.json | 1 + .../search-results.component.html | 15 ++++++- .../search-results.component.spec.ts | 42 ++++++++++++++++++- 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/projects/aca-content/assets/i18n/en.json b/projects/aca-content/assets/i18n/en.json index e1ce84a11..3c2626acb 100644 --- a/projects/aca-content/assets/i18n/en.json +++ b/projects/aca-content/assets/i18n/en.json @@ -225,6 +225,7 @@ "EFFECTIVITY": "Effectivity", "TITLE": "Search Results", "FILTER_SET": "Filter Set:", + "LOADING": "Loading search results, please wait.", "ADVANCED_FILTERS": "Advanced Filters:", "RESET": "Reset", "RESET_ACTION": "Reset search filters", diff --git a/projects/aca-content/src/lib/components/search/search-results/search-results.component.html b/projects/aca-content/src/lib/components/search/search-results/search-results.component.html index 509e6a177..4d6a11872 100644 --- a/projects/aca-content/src/lib/components/search/search-results/search-results.component.html +++ b/projects/aca-content/src/lib/components/search/search-results/search-results.component.html @@ -11,7 +11,20 @@
- + @if (isLoading) { + + } + + @if (isLoading) { + {{ 'APP.BROWSE.SEARCH.LOADING' | translate }} + } @else { + @if (totalResults > 0) { + {{ (totalResults === 1 ? 'APP.BROWSE.SEARCH.FOUND_ONE_RESULT' : 'APP.BROWSE.SEARCH.FOUND_RESULTS') | translate: { number: totalResults } }} + } @else { + {{ 'APP.BROWSE.SEARCH.NO_RESULTS' | translate }} + } + } +

{{ 'APP.BROWSE.SEARCH.FILTER_SET' | translate }}

diff --git a/projects/aca-content/src/lib/components/search/search-results/search-results.component.spec.ts b/projects/aca-content/src/lib/components/search/search-results/search-results.component.spec.ts index d0b14c68f..260adc1e0 100644 --- a/projects/aca-content/src/lib/components/search/search-results/search-results.component.spec.ts +++ b/projects/aca-content/src/lib/components/search/search-results/search-results.component.spec.ts @@ -24,7 +24,7 @@ import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing'; import { SearchResultsComponent } from './search-results.component'; -import { AppConfigService, NotificationService, TranslationService } from '@alfresco/adf-core'; +import { AppConfigService, NotificationService, TranslationService, UnitTestingUtils } from '@alfresco/adf-core'; import { Store } from '@ngrx/store'; import { NavigateToFolder } from '@alfresco/aca-shared/store'; import { Pagination, SearchRequest } from '@alfresco/js-api'; @@ -62,12 +62,14 @@ describe('SearchComponent', () => { let showErrorSpy: jasmine.Spy<(message: string, action?: string, interpolateArgs?: any, showAction?: boolean) => MatSnackBarRef>; let showInfoSpy: jasmine.Spy<(message: string, action?: string, interpolateArgs?: any, showAction?: boolean) => MatSnackBarRef>; let loader: HarnessLoader; + let unitTestingUtils: UnitTestingUtils; const editSavedSearchesSpy = jasmine.createSpy('editSavedSearch'); const getSavedSearchButton = (): HTMLButtonElement => fixture.nativeElement.querySelector('.aca-content__save-search-action'); const getResetSearchButton = (): HTMLButtonElement => fixture.nativeElement.querySelector('.aca-content__reset-action'); const getDividerHarness = () => loader.getHarness(MatDividerHarness); const getProgressBarHarnesses = () => loader.getAllHarnesses(MatProgressBarHarness); + const getStatusText = (): string => unitTestingUtils.getByCSS('.cdk-visually-hidden').nativeElement.textContent.trim(); const encodeQuery = (query: any): string => { return Buffer.from(JSON.stringify(query)).toString('base64'); @@ -141,6 +143,7 @@ describe('SearchComponent', () => { fixture.detectChanges(); loader = TestbedHarnessEnvironment.loader(fixture); + unitTestingUtils = new UnitTestingUtils(fixture.debugElement); }); afterEach(() => { @@ -472,6 +475,43 @@ describe('SearchComponent', () => { expect(await divider.getOrientation()).toBe('vertical'); }); + describe('search process status', () => { + it('should have loading status when search is loading', () => { + component.isLoading = true; + fixture.detectChanges(); + + expect(getStatusText()).toBe('APP.BROWSE.SEARCH.LOADING'); + }); + + it('should not have loading status when search is not loading', () => { + component.isLoading = false; + fixture.detectChanges(); + + expect(getStatusText()).not.toBe('APP.BROWSE.SEARCH.LOADING'); + }); + + it('should have the correct result status when search is complete and results are present', () => { + component.isLoading = false; + component.totalResults = 1; + fixture.detectChanges(); + + expect(getStatusText()).toBe('APP.BROWSE.SEARCH.FOUND_ONE_RESULT'); + + component.totalResults = 5; + fixture.detectChanges(); + + expect(getStatusText()).toBe('APP.BROWSE.SEARCH.FOUND_RESULTS'); + }); + + it('should have no results status when search is complete and no results are present', () => { + component.isLoading = false; + component.totalResults = 0; + fixture.detectChanges(); + + expect(getStatusText()).toBe('APP.BROWSE.SEARCH.NO_RESULTS'); + }); + }); + describe('reset button', () => { it('should enable the reset button when there are queryFragments', fakeAsync(() => { queryBuilder.queryFragmentsUpdate.next({ test: 'test-value' });