Skip to content

ZCU-PUB/Partial word match API#1259

Open
Paurikova2 wants to merge 1 commit intocustomer/zcu-pubfrom
zcu-pub/partial-word-match-browsing-using-api
Open

ZCU-PUB/Partial word match API#1259
Paurikova2 wants to merge 1 commit intocustomer/zcu-pubfrom
zcu-pub/partial-word-match-browsing-using-api

Conversation

@Paurikova2
Copy link
Collaborator

Problem description

Analysis

(Write here, if there is needed describe some specific problem. Erase it, when it is not needed.)

Problems

(Write here, if some unexpected problems occur during solving issues. Erase it, when it is not needed.)

Sync verification

If en.json5 or cs.json5 translation files were updated:

  • Run yarn run sync-i18n -t src/assets/i18n/cs.json5 -i to synchronize messages, and changes are included in this PR.

Manual Testing (if applicable)

Copilot review

  • Requested review from Copilot

@Paurikova2 Paurikova2 requested a review from Copilot March 19, 2026 12:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the DSO selector search behavior to support prefix/partial-word matching for communities/collections by translating user input into a backend startsWith filter, keeping Solr-specific syntax out of the Angular UI.

Changes:

  • Add query normalization (trim/empty handling) and conditional f.dc.title + startsWith filtering for COMMUNITY/COLLECTION searches in DSOSelectorComponent.search.
  • Extend unit tests to cover the new query/filter behavior (but the current PR includes unresolved merge-conflict markers).
  • Minor formatting cleanup in AuthorizedCollectionSelectorComponent and small test refactor attempt.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/app/shared/dso-selector/dso-selector/dso-selector.component.ts Implements trimmed-query handling and conditional startsWith filter for community/collection searches.
src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts Attempts to add test coverage for query processing; currently contains merge-conflict markers and an unused import.
src/app/shared/dso-selector/dso-selector/authorized-collection-selector/authorized-collection-selector.component.ts Formatting-only change in mapping/payload construction.
src/app/shared/dso-selector/dso-selector/authorized-collection-selector/authorized-collection-selector.component.spec.ts Adds helper/fixture values, but currently leaves unused declarations that likely fail linting.

Comment on lines +162 to +248
<<<<<<< Updated upstream
=======
describe('query processing', () => {
beforeEach(() => {
spyOn(searchService, 'search').and.callThrough();
});

describe('for COMMUNITY/COLLECTION types', () => {
beforeEach(() => {
component.types = [DSpaceObjectType.COMMUNITY];
});

it('should use a title startsWith filter for community/collection searches', () => {
component.search('test query', 1);

expect(searchService.search).toHaveBeenCalledWith(
jasmine.objectContaining({
query: '',
filters: [jasmine.objectContaining({
key: 'f.dc.title',
values: ['test query'],
operator: 'startsWith'
})]
}),
null,
true
);
});

it('should pass through internal resource ID queries unchanged', () => {
const resourceIdQuery = component.getCurrentDSOQuery();
component.search(resourceIdQuery, 1);

expect(searchService.search).toHaveBeenCalledWith(
jasmine.objectContaining({
query: resourceIdQuery
}),
null,
true
);
});
});

describe('for ITEM types', () => {
beforeEach(() => {
component.types = [DSpaceObjectType.ITEM];
});

it('should pass through queries unchanged', () => {
component.search('test query', 1);

expect(searchService.search).toHaveBeenCalledWith(
jasmine.objectContaining({
query: 'test query'
}),
null,
true
);
});
});

describe('edge cases', () => {
beforeEach(() => {
component.types = [DSpaceObjectType.COMMUNITY];
});

it('should treat whitespace-only query as empty and apply default sort', () => {
component.sort = new SortOptions('dc.title', SortDirection.ASC);
component.search(' ', 1);

expect(searchService.search).toHaveBeenCalledWith(
jasmine.objectContaining({
query: '',
filters: undefined,
sort: jasmine.objectContaining({
field: 'dc.title',
direction: SortDirection.ASC,
}),
}),
null,
true
);
});
});
});

>>>>>>> Stashed changes
import { createPaginatedList } from '../../testing/utils.test';
import { NotificationsService } from '../../notifications/notifications.service';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
import { SearchFilter } from '../../search/models/search-filter.model';
Comment on lines +24 to +29
function createCollection(id: string, name: string): Collection {
return Object.assign(new Collection(), { id, name });
}

const collectionTest = createCollection('col-test', 'test');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants