-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [ACS-6427] Initial commit for search highlights * [ACS-6427] Add correct highlighting config, handle highlights in search results * [ACS-6427] CR fixes * [ACS-6427] CR fix * [ACS-6427] Locator fix * [ACS-6427] E2E fix --------- Co-authored-by: swapnil.verma <[email protected]>
- Loading branch information
1 parent
60a4aba
commit 4766bfe
Showing
12 changed files
with
304 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 33 additions & 7 deletions
40
...ca-content/src/lib/components/search/search-results-row/search-results-row.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,38 @@ | ||
<div class="search-file-name"> | ||
<span tabindex="0" role="link" *ngIf="isFile" (click)="showPreview($event)" (keyup.enter)="showPreview($event)" class="aca-link"> | ||
{{ name$ | async }} | ||
</span> | ||
<span tabindex="0" role="link" *ngIf="!isFile" (click)="navigate($event)" (keyup.enter)="navigate($event)" class="bold aca-link"> | ||
{{ name$ | async }} | ||
</span> | ||
<span>{{ title$ | async }}</span> | ||
<span | ||
tabindex="0" | ||
role="link" | ||
*ngIf="isFile" | ||
(click)="showPreview($event)" | ||
(keyup.enter)="showPreview($event)" | ||
class="aca-link aca-crop-text" | ||
[title]="nameStripped" | ||
[innerHTML]="name$ | async" | ||
></span> | ||
<span | ||
tabindex="0" | ||
role="link" | ||
*ngIf="!isFile" | ||
(click)="navigate($event)" | ||
(keyup.enter)="navigate($event)" | ||
class="bold aca-link aca-crop-text" | ||
[title]="nameStripped" | ||
[innerHTML]="name$ | async" | ||
></span> | ||
<span | ||
data-automation-id="search-results-entry-title" | ||
class="aca-crop-text" | ||
[title]="titleStripped" | ||
[innerHTML]="title$ | async" | ||
></span> | ||
</div> | ||
<div | ||
data-automation-id="search-results-entry-description" | ||
class="aca-crop-text" | ||
[title]="descriptionStripped" | ||
[innerHTML]="description$ | async" | ||
></div> | ||
<div class="aca-result-location"> | ||
<aca-location-link [context]="context" [showLocation]="true"></aca-location-link> | ||
</div> | ||
<div class="aca-result-content aca-crop-text" [title]="contentStripped" [innerHTML]="content$ | async"></div> |
17 changes: 17 additions & 0 deletions
17
...ca-content/src/lib/components/search/search-results-row/search-results-row.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
...content/src/lib/components/search/search-results-row/search-results-row.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/*! | ||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. | ||
* | ||
* Alfresco Example Content Application | ||
* | ||
* This file is part of the Alfresco Example Content Application. | ||
* If the software was purchased under a paid Alfresco license, the terms of | ||
* the paid license agreement will prevail. Otherwise, the software is | ||
* provided under the following open source license terms: | ||
* | ||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The Alfresco Example Content Application is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { NodeEntry, ResultSetRowEntry } from '@alfresco/js-api'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { first } from 'rxjs/operators'; | ||
import { AppTestingModule } from '../../../testing/app-testing.module'; | ||
import { SearchResultsRowComponent } from './search-results-row.component'; | ||
|
||
describe('SearchResultsRowComponent', () => { | ||
let component: SearchResultsRowComponent; | ||
let fixture: ComponentFixture<SearchResultsRowComponent>; | ||
|
||
const nodeEntry: NodeEntry = { | ||
entry: { | ||
id: 'fake-node-entry', | ||
modifiedByUser: { displayName: 'IChangeThings' }, | ||
modifiedAt: new Date(), | ||
isFile: true, | ||
properties: { 'cm:title': 'BananaRama' } | ||
} | ||
} as NodeEntry; | ||
|
||
const resultEntry: ResultSetRowEntry = { | ||
entry: { | ||
id: 'fake-node-entry', | ||
modifiedAt: new Date(), | ||
isFile: true, | ||
name: 'Random name', | ||
properties: { 'cm:title': 'Random title', 'cm:description': 'some random description' }, | ||
search: { | ||
score: 10, | ||
highlight: [ | ||
{ | ||
field: 'cm:content', | ||
snippets: [`Interesting <span class='aca-highlight'>random</span> content`] | ||
}, | ||
{ | ||
field: 'cm:name', | ||
snippets: [`<span class='aca-highlight'>Random</span>`] | ||
}, | ||
{ | ||
field: 'cm:title', | ||
snippets: [`<span class='aca-highlight'>Random</span> title`] | ||
}, | ||
{ | ||
field: 'cm:description', | ||
snippets: [`some <span class='aca-highlight'>random</span> description`] | ||
} | ||
] | ||
} | ||
} | ||
} as ResultSetRowEntry; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [AppTestingModule, SearchResultsRowComponent] | ||
}); | ||
|
||
fixture = TestBed.createComponent(SearchResultsRowComponent); | ||
component = fixture.componentInstance; | ||
}); | ||
|
||
it('should show the current node', () => { | ||
component.context = { row: { node: nodeEntry } }; | ||
fixture.detectChanges(); | ||
|
||
const element = fixture.nativeElement.querySelector('div'); | ||
expect(element).not.toBeNull(); | ||
}); | ||
|
||
it('should correctly parse highlights', (done) => { | ||
component.context = { row: { node: resultEntry } }; | ||
component.content$ | ||
.asObservable() | ||
.pipe(first()) | ||
.subscribe(() => { | ||
fixture.detectChanges(); | ||
|
||
const nameElement: HTMLSpanElement = fixture.debugElement.query(By.css('.aca-link.aca-crop-text')).nativeElement; | ||
expect(nameElement.innerHTML).toBe('<span class="aca-highlight">Random</span>'); | ||
expect(nameElement.title).toBe('Random'); | ||
|
||
const titleElement: HTMLSpanElement = fixture.debugElement.query(By.css('[data-automation-id="search-results-entry-title"]')).nativeElement; | ||
expect(titleElement.innerHTML).toBe(' ( <span class="aca-highlight">Random</span> title )'); | ||
expect(titleElement.title).toBe('Random title'); | ||
|
||
const descriptionElement: HTMLDivElement = fixture.debugElement.query( | ||
By.css('[data-automation-id="search-results-entry-description"]') | ||
).nativeElement; | ||
expect(descriptionElement.innerHTML).toBe('some <span class="aca-highlight">random</span> description'); | ||
expect(descriptionElement.title).toBe('some random description'); | ||
|
||
const contentElement: HTMLDivElement = fixture.debugElement.query(By.css('.aca-result-content.aca-crop-text')).nativeElement; | ||
expect(contentElement.innerHTML).toBe('...Interesting <span class="aca-highlight">random</span> content...'); | ||
expect(contentElement.title).toBe('...Interesting random content...'); | ||
done(); | ||
}); | ||
fixture.detectChanges(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.