From 8ad93491e1339ffd667e54b9974d7faec166e103 Mon Sep 17 00:00:00 2001 From: Priyanka Terala <104053200+Terala-Priyanka@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:01:51 +0530 Subject: [PATCH] UIU-3184 - Use keywords CQL field for keyword user search. (#2737) (#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 --- .github/workflows/build-npm-release.yml | 6 +++--- .github/workflows/build-npm.yml | 6 +++--- CHANGELOG.md | 5 +++++ package.json | 2 +- src/routes/UserSearchContainer.js | 5 ++++- src/routes/UserSearchContainer.test.js | 10 +++++++--- 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-npm-release.yml b/.github/workflows/build-npm-release.yml index ecdd59d24..928dbafce 100644 --- a/.github/workflows/build-npm-release.yml +++ b/.github/workflows/build-npm-release.yml @@ -147,7 +147,7 @@ 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 }} @@ -155,14 +155,14 @@ jobs: - 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 diff --git a/.github/workflows/build-npm.yml b/.github/workflows/build-npm.yml index 10eaca128..81a8c2b0d 100644 --- a/.github/workflows/build-npm.yml +++ b/.github/workflows/build-npm.yml @@ -87,7 +87,7 @@ 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 }} @@ -95,14 +95,14 @@ jobs: - 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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 53a3e6f10..045970053 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/package.json b/package.json index ce05d8fcb..49aa335be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@folio/users", - "version": "10.1.1", + "version": "10.1.2", "description": "User management", "repository": "folio-org/ui-users", "publishConfig": { diff --git a/src/routes/UserSearchContainer.js b/src/routes/UserSearchContainer.js index 2019a33e4..7e98b6e4d 100644 --- a/src/routes/UserSearchContainer.js +++ b/src/routes/UserSearchContainer.js @@ -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 "", \, *, ? @@ -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 diff --git a/src/routes/UserSearchContainer.test.js b/src/routes/UserSearchContainer.test.js index bfe40c9ee..49775a009 100644 --- a/src/routes/UserSearchContainer.test.js +++ b/src/routes/UserSearchContainer.test.js @@ -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, @@ -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*"')); + }); });