Skip to content

Commit

Permalink
UIU-3184 - Use keywords CQL field for keyword user search. (#2737) (#…
Browse files Browse the repository at this point in the history
…2741)

* UIU-3184 - Use keywords CQL field for keyword user search. (#2737)

* UIU-3184 - Use keywords CQL field for keyword user search.

* UIU-3184 - update/add unit test

* UIU-3184 - revert package.json change

* UIU-3184-Q-CSP4 - update change log and package.json files

* UIU-3184 - update change log file

* UIU-3184-Q-CSP4 - upgrade actions/upload-artifact to v4
  • Loading branch information
Terala-Priyanka authored Sep 9, 2024
1 parent feb4cce commit 8ad9349
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-npm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,22 +147,22 @@ jobs:
data: ${{ steps.moduleDescriptor.outputs.content }}

- name: Upload event file
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Event File
path: ${{ github.event_path }}
retention-days: 30

- name: Upload Jest results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: jest-test-results
path: ${{ env.JEST_JUNIT_OUTPUT_DIR }}/*.xml
retention-days: 30

- name: Publish Jest coverage report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: jest-coverage-report
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,22 @@ jobs:
run: cat module-descriptor.json

- name: Upload event file
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Event File
path: ${{ github.event_path }}
retention-days: 30

- name: Upload Jest results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: jest-test-results
path: ${{ env.JEST_JUNIT_OUTPUT_DIR }}/*.xml
retention-days: 30

- name: Publish Jest coverage report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: jest-coverage-report
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change history for ui-users

## [10.1.2](https://github.com/folio-org/ui-users/tree/v10.1.2) (2024-09-05)
[Full Changelog](https://github.com/folio-org/ui-users/compare/v10.1.1...v10.1.2)

* Use keywords CQL field for keyword user search. Refs UIU-3184.

## [10.1.1](https://github.com/folio-org/ui-users/tree/v10.1.1) (2024-05-07)
[Full Changelog](https://github.com/folio-org/ui-users/compare/v10.1.0...v10.1.1)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/users",
"version": "10.1.1",
"version": "10.1.2",
"description": "User management",
"repository": "folio-org/ui-users",
"publishConfig": {
Expand Down
5 changes: 4 additions & 1 deletion src/routes/UserSearchContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const searchFields = [
'externalSystemId="%{query}*"',
'customFields="%{query}*"'
];
const compileQuery = template(`(${searchFields.join(' or ')})`, { interpolate: /%{([\s\S]+?)}/g });

/*
Some of the special characters that are allowed while creating a tag are "", \, *, ?
Expand Down Expand Up @@ -69,6 +68,10 @@ export function buildQuery(queryParams, pathComponents, resourceData, logger, pr
const customFilterConfig = buildFilterConfig(queryParams.filters);
const newResourceData = escapeSpecialCharactersInTagFilters(queryParams, resourceData);

const compileQuery = props.stripes.hasInterface('users', '16.3') ?
template('keywords="%{query}*"', { interpolate: /%{([\s\S]+?)}/g }) :
template(`(${searchFields.join(' or ')})`, { interpolate: /%{([\s\S]+?)}/g });

return makeQueryFunction(
'cql.allRecords=1',
// TODO: Refactor/remove this after work on FOLIO-2066 and RMB-385 is done
Expand Down
10 changes: 7 additions & 3 deletions src/routes/UserSearchContainer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const resourceData = {
const logger = {
log: jest.fn(),
};
const mockHasInterface = jest.fn().mockReturnValue(false);
const mockHasInterface = jest.fn().mockReturnValue(0);
const props = {
stripes: {
hasInterface: mockHasInterface,
Expand All @@ -24,8 +24,12 @@ describe('buildQuery', () => {
expect(buildQuery({}, pathComponents, { query: {} }, logger, props)).toBeFalsy();
});

it('should include username when building CQL query', () => {
mockHasInterface.mockReturnValue(true);
it('should include username when building CQL query when stripes "users" interface is less than 16.3', () => {
expect(buildQuery(queryParams, pathComponents, resourceData, logger, props)).toEqual(expect.stringContaining('username="Joe*"'));
});

it('should include "keywords" when building CQL query when stripes "users" interface is 16.3', () => {
mockHasInterface.mockReturnValue(16.3);
expect(buildQuery(queryParams, pathComponents, resourceData, logger, props)).toEqual(expect.stringContaining('keywords="Joe*"'));
});
});

0 comments on commit 8ad9349

Please sign in to comment.