From 8978e24c798c68e71f6957fbc2a5786b240937a6 Mon Sep 17 00:00:00 2001 From: Alex Molodyh <140214274+amolodyh-hyland@users.noreply.github.com> Date: Wed, 30 Jul 2025 15:00:12 -0700 Subject: [PATCH] [AAE-36983] Updated translation keys in search-text-input.component.html (#11083) --- lib/core/src/lib/i18n/en.json | 14 ++++++- .../search-text-input.component.html | 8 ++-- .../search-text-input.component.spec.ts | 37 ++++++++++++++++++- 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/lib/core/src/lib/i18n/en.json b/lib/core/src/lib/i18n/en.json index 06550092a1..aaba8782e1 100644 --- a/lib/core/src/lib/i18n/en.json +++ b/lib/core/src/lib/i18n/en.json @@ -292,7 +292,19 @@ }, "SEARCH": { "TOGGLE_ASC_DESC_ORDER": "Toggle results between ascending and descending order", - "SORT_BY": "Sort by" + "SORT_BY": "Sort by", + "BUTTON": { + "TOOLTIP": "Search", + "ARIA-LABEL": "Search button" + }, + "INPUT": { + "ARIA-LABEL": "Search input" + }, + "FILTER": { + "BUTTONS": { + "CLOSE": "Close" + } + } }, "FEATURE-FLAGS": { "OVERRIDES": "Feature flag overrides", diff --git a/lib/core/src/lib/search-text/search-text-input.component.html b/lib/core/src/lib/search-text/search-text-input.component.html index f948dad6cb..b53f8602a1 100644 --- a/lib/core/src/lib/search-text/search-text-input.component.html +++ b/lib/core/src/lib/search-text/search-text-input.component.html @@ -7,16 +7,16 @@ id="adf-search-button" class="adf-search-button" [ngClass]="{'adf-search-button-inactive': subscriptAnimationState.value === 'inactive'}" - [title]="'SEARCH.BUTTON.TOOLTIP' | translate" + [title]="'CORE.SEARCH.BUTTON.TOOLTIP' | translate" (click)="toggleSearchBar()" (keyup.enter)="toggleSearchBar()"> - search + search {{label}} close diff --git a/lib/core/src/lib/search-text/search-text-input.component.spec.ts b/lib/core/src/lib/search-text/search-text-input.component.spec.ts index 82088aa2fb..0109389f9f 100644 --- a/lib/core/src/lib/search-text/search-text-input.component.spec.ts +++ b/lib/core/src/lib/search-text/search-text-input.component.spec.ts @@ -21,6 +21,8 @@ import { DebugElement } from '@angular/core'; import { Subject } from 'rxjs'; import { UserPreferencesService } from '../common/services/user-preferences.service'; import { UnitTestingUtils } from '../testing/unit-testing-utils'; +import { NoopTranslateModule } from '../testing'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; describe('SearchTextInputComponent', () => { let fixture: ComponentFixture; @@ -31,7 +33,7 @@ describe('SearchTextInputComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [SearchTextInputComponent] + imports: [NoopAnimationsModule, SearchTextInputComponent, NoopTranslateModule] }); fixture = TestBed.createComponent(SearchTextInputComponent); component = fixture.componentInstance; @@ -356,4 +358,37 @@ describe('SearchTextInputComponent', () => { }); }); }); + + describe('Translations', () => { + beforeEach(fakeAsync(() => { + component.expandable = true; + component.showClearButton = true; + fixture.detectChanges(); + component.subscriptAnimationState.value = 'active'; + fixture.detectChanges(); + tick(200); + })); + + it('should contain correct translation key for search button tooltip', () => { + const searchButton = testingUtils.getByCSS('#adf-search-button'); + expect(searchButton.nativeElement.getAttribute('title')).toBe('CORE.SEARCH.BUTTON.TOOLTIP'); + }); + + it('should contain correct translation key for search button aria-label', () => { + const searchButton = testingUtils.getByCSS('#adf-search-button'); + // eslint-disable-next-line @alfresco/eslint-angular/no-angular-material-selectors + const searchIcon = searchButton.nativeElement.querySelector('mat-icon'); + expect(searchIcon.getAttribute('aria-label')).toBe('CORE.SEARCH.BUTTON.ARIA-LABEL'); + }); + + it('should contain correct translation key for search input aria-label', () => { + const searchInput = testingUtils.getByCSS('#adf-control-input'); + expect(searchInput.nativeElement.getAttribute('aria-label')).toBe('CORE.SEARCH.INPUT.ARIA-LABEL'); + }); + + it('should contain correct translation key for clear button title', () => { + const clearButton = testingUtils.getByDataAutomationId('adf-clear-search-button'); + expect(clearButton.nativeElement.getAttribute('title')).toBe('CORE.SEARCH.FILTER.BUTTONS.CLOSE'); + }); + }); });