Skip to content

Commit 11ed648

Browse files
committed
Fix browse-by pages sending unnecessary request to author index
1 parent 3d3615a commit 11ed648

5 files changed

Lines changed: 10 additions & 16 deletions

File tree

src/app/browse-by/browse-by-date/browse-by-date.component.spec.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ describe('BrowseByDateComponent', () => {
9696
findById: () => createSuccessfulRemoteDataObject$(mockCommunity),
9797
};
9898

99-
const activatedRouteStub = Object.assign(new ActivatedRouteStub(), {
100-
params: of({}),
99+
const activatedRouteStub = Object.assign(new ActivatedRouteStub({ id: 'dateissued' }), {
100+
params: of({ id: 'dateissued' }),
101101
queryParams: of({}),
102102
data: of({ metadata: 'dateissued', metadataField: 'dc.date.issued' }),
103103
});
@@ -152,9 +152,8 @@ describe('BrowseByDateComponent', () => {
152152
fixture = TestBed.createComponent(BrowseByDateComponent);
153153
const browseService = fixture.debugElement.injector.get(BrowseService);
154154
spyOn(browseService, 'getFirstItemFor')
155-
// ok to expect the default browse as first param since we just need the mock items obtained via sort direction.
156-
.withArgs('author', undefined, SortDirection.ASC).and.returnValue(createSuccessfulRemoteDataObject$(firstItem))
157-
.withArgs('author', undefined, SortDirection.DESC).and.returnValue(createSuccessfulRemoteDataObject$(lastItem));
155+
.withArgs('dateissued', undefined, SortDirection.ASC).and.returnValue(createSuccessfulRemoteDataObject$(firstItem))
156+
.withArgs('dateissued', undefined, SortDirection.DESC).and.returnValue(createSuccessfulRemoteDataObject$(lastItem));
158157
comp = fixture.componentInstance;
159158
route = (comp as any).route;
160159
fixture.detectChanges();

src/app/browse-by/browse-by-date/browse-by-date.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class BrowseByDateComponent extends BrowseByMetadataComponent implements
110110
})).subscribe(({ params, scope, currentPage, currentSort }) => {
111111
const metadataKeys = params.browseDefinition ? params.browseDefinition.metadataKeys : this.defaultMetadataKeys;
112112
this.startsWith = +params.startsWith || params.startsWith;
113-
this.browseId = params.id || this.defaultBrowseId;
113+
this.browseId = params.id;
114114
const searchOptions = browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, this.fetchThumbnails);
115115
this.updatePageWithItems(searchOptions, this.value, undefined);
116116
this.updateStartsWithOptions(this.browseId, metadataKeys, params.scope);

src/app/browse-by/browse-by-metadata/browse-by-metadata.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ describe('BrowseByMetadataComponent', () => {
124124
findById: () => createSuccessfulRemoteDataObject$(mockCommunity),
125125
};
126126

127-
const activatedRouteStub = Object.assign(new ActivatedRouteStub(), {
128-
params: of({}),
127+
const activatedRouteStub = Object.assign(new ActivatedRouteStub({ id: 'author' }), {
128+
params: of({ id: 'author' }),
129129
});
130130

131131
paginationService = new PaginationServiceStub();

src/app/browse-by/browse-by-metadata/browse-by-metadata.component.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,10 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
137137
*/
138138
subs: Subscription[] = [];
139139

140-
/**
141-
* The default browse id to resort to when none is provided
142-
*/
143-
defaultBrowseId = 'author';
144-
145140
/**
146141
* The current browse id
147142
*/
148-
browseId = this.defaultBrowseId;
143+
browseId: string;
149144

150145
/**
151146
* The type of StartsWith options to render

src/app/browse-by/browse-by-title/browse-by-title.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ describe('BrowseByTitleComponent', () => {
8484
findById: () => createSuccessfulRemoteDataObject$(mockCommunity),
8585
};
8686

87-
const activatedRouteStub = Object.assign(new ActivatedRouteStub(), {
88-
params: of({}),
87+
const activatedRouteStub = Object.assign(new ActivatedRouteStub({ id: 'title' }), {
88+
params: of({ id: 'title' }),
8989
queryParams: of({}),
9090
data: of({ metadata: 'title' }),
9191
});

0 commit comments

Comments
 (0)