Skip to content

Commit

Permalink
[ACA-4310] - Show the breadcrumb even for invalid selections in searc… (
Browse files Browse the repository at this point in the history
#7241)

* [ACA-4310] - Show the breadcrumb even for invalid selections in search results

* Empty commit

Co-authored-by: Ardit Domi <arditdomi@apl-c02g64vpmd6t.home>
  • Loading branch information
arditdomi and Ardit Domi committed Sep 8, 2021
1 parent 20f1ca1 commit cb79b21
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ describe('ContentNodeSelectorPanelComponent', () => {

});

it('should show the breadcrumb for the selected node when search results are displayed', async () => {
it('should show the breadcrumb in search results for a valid node selection', async () => {
searchQueryBuilderService.userQuery = 'mock-search-term';
searchQueryBuilderService.update();
triggerSearchResults(fakeResultSetPaging);
Expand All @@ -283,6 +283,21 @@ describe('ContentNodeSelectorPanelComponent', () => {
expect(breadcrumb.componentInstance.folderNode.path).toBe(chosenNode.path);
});

it('should show the breadcrumb in search results even for an invalid node selection', async () => {
component.isSelectionValid = (node: Node) => node.isFile;
searchQueryBuilderService.userQuery = 'mock-search-term';
searchQueryBuilderService.update();
triggerSearchResults(fakeResultSetPaging);

const chosenNode = new Node({ path: { elements: ['fake-path'] }, isFile: false, isFolder: true });
component.onCurrentSelection([{ entry: chosenNode }]);
fixture.detectChanges();

const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
expect(breadcrumb).not.toBeNull();
expect(breadcrumb.componentInstance.folderNode.path).toBe(chosenNode.path);
});

it('should NOT show the breadcrumb for the selected node when not on search results list', async () => {
triggerSearchResults(fakeResultSetPaging);
fixture.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
showingSearchResults: boolean = false;
loadingSearchResults: boolean = false;
inDialog: boolean = false;
_chosenNode: Node [] = null;
_chosenNode: Node[] = null;
selectionWithoutValidation: Node[] = null;
folderIdToShow: string | null = null;
breadcrumbFolderTitle: string | null = null;
startSiteGuid: string | null = null;
Expand Down Expand Up @@ -454,8 +455,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
get breadcrumbFolderNode(): Node | null {
let folderNode: Node;

if (this.showingSearchResults && this.chosenNode) {
folderNode = this.chosenNode[0];
if (this.showingSearchResults && this.selectionWithoutValidation?.length) {
folderNode = this.selectionWithoutValidation[0];
} else {
folderNode = this.documentList.folderNode;
}
Expand Down Expand Up @@ -629,6 +630,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
onCurrentSelection(nodesEntries: NodeEntry[]): void {
const validNodesEntity = nodesEntries.filter((node) => this.isSelectionValid(node.entry));
this.chosenNode = validNodesEntity.map((node) => node.entry);
this.selectionWithoutValidation = nodesEntries.map(node => node.entry);
}

setTitleIfCustomSite(site: SiteEntry) {
Expand Down

0 comments on commit cb79b21

Please sign in to comment.