Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,47 @@ describe('SearchFilterAutocompleteChipsComponent', () => {
});

it('should populate LOCATION field options with sites and predefined values from config', (done) => {
Copy link
Contributor Author

@g-jaskowski g-jaskowski Oct 2, 2025

Choose a reason for hiding this comment

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

For some reason it treated an existing unit test that had one line changed as completely new code and newly added unit test as edited code

const sitesMock: SitePaging = {
list: {
pagination: {},
entries: [{ entry: { guid: 'site1', id: 'site1', title: 'Marketing', visibility: 'public' } }]
}
};
component.settings.field = AutocompleteField.LOCATION;
component.settings.autocompleteOptions = [{ value: 'Repository', query: `PATH:'somePath'` }];
spyOn(sitesService, 'getSites').and.returnValue(of(sitesMock));
component.onInputChange('mark');
component.autocompleteOptions$.subscribe((result) => {
expect(result).toEqual([
{ id: 'site1', value: 'Marketing' },
{ value: 'Repository', query: `PATH:'somePath'` }
]);
done();
});
});

it('should filter LOCATION field options', (done) => {
const sitesMock: SitePaging = {
list: {
pagination: {},
entries: [
{ entry: { guid: 'site1', id: 'site1', title: 'Marketing', visibility: 'public' } },
{ entry: { guid: 'site2', id: 'site2', title: 'Finance', visibility: 'private' } }
{ entry: { guid: 'site2', id: 'site2', title: 'Finance', visibility: 'moderated' } },
{ entry: { guid: 'site3', id: 'site3', title: 'HR', visibility: 'private' } },
{ entry: { guid: 'site4', id: 'site4', title: 'Legal', visibility: 'private', role: 'Consumer' } },
{ entry: { guid: 'site5', id: 'site5', title: 'IT', visibility: 'moderated', role: 'SiteManager' } }
]
}
};
component.settings.field = AutocompleteField.LOCATION;
component.settings.autocompleteOptions = [{ value: 'Repository', query: `PATH:'somePath'` }];
component.settings.autocompleteOptions = [];
spyOn(sitesService, 'getSites').and.returnValue(of(sitesMock));
component.onInputChange('mark');
component.autocompleteOptions$.subscribe((result) => {
expect(result).toEqual([
{ id: 'site1', value: 'Marketing' },
{ id: 'site2', value: 'Finance' },
{ value: 'Repository', query: `PATH:'somePath'` }
{ id: 'site4', value: 'Legal' },
{ id: 'site5', value: 'IT' }
]);
done();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,12 @@ export class SearchFilterAutocompleteChipsComponent implements SearchWidget, OnI
.pipe(
map((sites) => {
const predefinedOptions = this.settings?.autocompleteOptions || [];
const sitesOptions = sites.list.entries.map<AutocompleteOption>((siteEntry) => ({
id: siteEntry.entry.id,
value: siteEntry.entry.title
}));
const sitesOptions = sites.list.entries
.filter((siteEntry) => siteEntry.entry.visibility === 'public' || siteEntry.entry?.role)
.map<AutocompleteOption>((siteEntry) => ({
id: siteEntry.entry.id,
value: siteEntry.entry.title
}));
return [...sitesOptions, ...predefinedOptions];
})
)
Expand Down