From a1f23ac4947995c0c12a75e7d88082bb59522e53 Mon Sep 17 00:00:00 2001 From: Artem_Blazhko Date: Fri, 13 Sep 2024 13:23:11 +0300 Subject: [PATCH] Release 9.1.2 --- .github/workflows/build-npm-release.yml | 26 +++--------------------- .github/workflows/build-npm.yml | 26 +++--------------------- CHANGELOG.md | 11 ++++++++-- package.json | 2 +- src/RequestForm.js | 27 +++++++++++++------------ src/RequestForm.test.js | 10 +++++++++ src/utils.js | 8 ++++++++ src/utils.test.js | 19 +++++++++++++++++ 8 files changed, 67 insertions(+), 62 deletions(-) diff --git a/.github/workflows/build-npm-release.yml b/.github/workflows/build-npm-release.yml index 5df875997..e8fdd4acd 100644 --- a/.github/workflows/build-npm-release.yml +++ b/.github/workflows/build-npm-release.yml @@ -31,11 +31,9 @@ jobs: NODEJS_VERSION: '18' JEST_JUNIT_OUTPUT_DIR: 'artifacts/jest-junit' JEST_COVERAGE_REPORT_DIR: 'artifacts/coverage-jest/lcov-report/' - BIGTEST_JUNIT_OUTPUT_DIR: 'artifacts/runTest' - BIGTEST_COVERAGE_REPORT_DIR: 'artifacts/coverage/lcov-report/' OKAPI_PULL: '{ "urls" : [ "https://folio-registry.dev.folio.org" ] }' SQ_LCOV_REPORT: 'artifacts/coverage-jest/lcov.info' - SQ_EXCLUSIONS: '**/platform/alias-service.js,**/docs/**,**/node_modules/**,**/examples/**,**/artifacts/**,**/ci/**,Jenkinsfile,**/LICENSE,**/*.css,**/*.md,**/*.json,**/tests/**,**/stories/*.js,**/test/**,**/.stories.js,**/resources/bigtest/interactors/**,**/resources/bigtest/network/**,**/*-test.js,**/*.test.js,**/*-spec.js,**/karma.conf.js,**/jest.config.js' + SQ_EXCLUSIONS: '**/platform/alias-service.js,**/docs/**,**/node_modules/**,**/examples/**,**/artifacts/**,**/ci/**,Jenkinsfile,**/LICENSE,**/*.css,**/*.md,**/*.json,**/tests/**,**/stories/*.js,**/test/**,**/.stories.js,**/*-test.js,**/*.test.js,**/*-spec.js,**/karma.conf.js,**/jest.config.js' runs-on: ubuntu-latest steps: @@ -152,33 +150,15 @@ jobs: comment_title: Jest Unit Test Statistics - name: Publish Jest coverage report - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: always() with: name: jest-coverage-report path: ${{ env.JEST_COVERAGE_REPORT_DIR }} retention-days: 30 - - name: Publish BigTest unit test results - uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1 - if: always() - with: - github_token: ${{ github.token }} - files: "${{ env.BIGTEST_JUNIT_OUTPUT_DIR }}/*.xml" - check_name: BigTest Unit Test Results - comment_mode: update last - comment_title: BigTest Unit Test Statistics - - - name: Publish BigTest coverage report - uses: actions/upload-artifact@v2 - if: always() - with: - name: bigtest-coverage-report - path: ${{ env.BIGTEST_COVERAGE_REPORT_DIR }} - retention-days: 30 - - name: Publish yarn.lock - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: yarn.lock diff --git a/.github/workflows/build-npm.yml b/.github/workflows/build-npm.yml index 8997a5e7e..b529c196d 100644 --- a/.github/workflows/build-npm.yml +++ b/.github/workflows/build-npm.yml @@ -28,10 +28,8 @@ jobs: NODEJS_VERSION: '18' JEST_JUNIT_OUTPUT_DIR: 'artifacts/jest-junit' JEST_COVERAGE_REPORT_DIR: 'artifacts/coverage-jest/lcov-report/' - BIGTEST_JUNIT_OUTPUT_DIR: 'artifacts/runTest' - BIGTEST_COVERAGE_REPORT_DIR: 'artifacts/coverage/lcov-report/' SQ_LCOV_REPORT: 'artifacts/coverage-jest/lcov.info' - SQ_EXCLUSIONS: '**/platform/alias-service.js,**/docs/**,**/node_modules/**,**/examples/**,**/artifacts/**,**/ci/**,Jenkinsfile,**/LICENSE,**/*.css,**/*.md,**/*.json,**/tests/**,**/stories/*.js,**/test/**,**/.stories.js,**/resources/bigtest/interactors/**,**/resources/bigtest/network/**,**/*-test.js,**/*.test.js,**/*-spec.js,**/karma.conf.js,**/jest.config.js' + SQ_EXCLUSIONS: '**/platform/alias-service.js,**/docs/**,**/node_modules/**,**/examples/**,**/artifacts/**,**/ci/**,Jenkinsfile,**/LICENSE,**/*.css,**/*.md,**/*.json,**/tests/**,**/stories/*.js,**/test/**,**/.stories.js,**/*-test.js,**/*.test.js,**/*-spec.js,**/karma.conf.js,**/jest.config.js' runs-on: ubuntu-latest steps: @@ -95,33 +93,15 @@ jobs: comment_title: Jest Unit Test Statistics - name: Publish Jest coverage report - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: always() with: name: jest-coverage-report path: ${{ env.JEST_COVERAGE_REPORT_DIR }} retention-days: 30 - - name: Publish BigTest unit test results - uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1 - if: always() - with: - github_token: ${{ github.token }} - files: "${{ env.BIGTEST_JUNIT_OUTPUT_DIR }}/*.xml" - check_name: BigTest Unit Test Results - comment_mode: update last - comment_title: BigTest Unit Test Statistics - - - name: Publish BigTest coverage report - uses: actions/upload-artifact@v2 - if: always() - with: - name: bigtest-coverage-report - path: ${{ env.BIGTEST_COVERAGE_REPORT_DIR }} - retention-days: 30 - - name: Publish yarn.lock - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: yarn.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e1892351..e02678370 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,14 @@ # Change history for ui-requests -## [9.1.1] (https://github.com/folio-org/ui-checkin/tree/v9.1.1) (2024-03-27) -[Full Changelog](https://github.com/folio-org/ui-checkin/compare/v9.1.0...v9.1.1) +## [9.1.2] (https://github.com/folio-org/ui-requests/tree/v9.1.2) (2024-09-13) +[Full Changelog](https://github.com/folio-org/ui-requests/compare/v9.1.1...v9.1.2) + +* Remove bigtests from github actions. Refs UIREQ-1099. +* Fix issue with Proxy's patron group and delivery address that shown instead of Sponsor's when creating request. Refs UIREQ-1132, UIREQ-1133. +* Update upload-artifact actions from v1 and v2 to v4. Refs UIREQ-1150. + +## [9.1.1] (https://github.com/folio-org/ui-requests/tree/v9.1.1) (2024-03-27) +[Full Changelog](https://github.com/folio-org/ui-requests/compare/v9.1.0...v9.1.1) * Add support for Barcode tag with sanitize. Refs UIREQ-1080, UIREQ-1082. diff --git a/package.json b/package.json index 4ccec3d25..f849fdf04 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@folio/requests", - "version": "9.1.1", + "version": "9.1.2", "description": "Requests manager", "repository": "folio-org/ui-requests", "publishConfig": { diff --git a/src/RequestForm.js b/src/RequestForm.js index b26887d37..9e9807e4d 100644 --- a/src/RequestForm.js +++ b/src/RequestForm.js @@ -78,6 +78,7 @@ import { isSubmittingButtonDisabled, isFormEditing, resetFieldState, + getRequester, } from './utils'; import css from './requests.css'; @@ -186,7 +187,7 @@ class RequestForm extends React.Component { const { titleLevelRequestsFeatureEnabled } = this.getTlrSettings(); this.state = { - proxy: {}, + proxy: null, selectedLoan: loan, ...getDefaultRequestPreferences(request, initialValues), isAwaitingForProxySelection: false, @@ -452,17 +453,13 @@ class RequestForm extends React.Component { const { form, selectedUser, - onSetSelectedUser, } = this.props; if (selectedUser.id === proxy.id) { - onSetSelectedUser(selectedUser); this.setState({ proxy: selectedUser, }); - form.change(REQUEST_FORM_FIELD_NAMES.REQUESTER_ID, selectedUser.id); } else { - onSetSelectedUser(selectedUser); this.setState({ proxy, requestTypes: {}, @@ -767,6 +764,7 @@ class RequestForm extends React.Component { onSetSelectedItem, selectedUser, } = this.props; + const { proxy } = this.state; this.setState({ isItemOrInstanceLoading: true, @@ -816,7 +814,8 @@ class RequestForm extends React.Component { }) .then(item => { if (item && selectedUser?.id) { - this.findRequestTypes(item.id, selectedUser.id, ID_TYPE_MAP.ITEM_ID); + const requester = getRequester(proxy, selectedUser); + this.findRequestTypes(item.id, requester.id, ID_TYPE_MAP.ITEM_ID); } return item; @@ -849,6 +848,7 @@ class RequestForm extends React.Component { onSetSelectedInstance, selectedUser, } = this.props; + const { proxy } = this.state; this.setState({ isItemOrInstanceLoading: true, @@ -897,7 +897,8 @@ class RequestForm extends React.Component { }) .then(instance => { if (instance && selectedUser?.id) { - this.findRequestTypes(instance.id, selectedUser.id, ID_TYPE_MAP.INSTANCE_ID); + const requester = getRequester(proxy, selectedUser); + this.findRequestTypes(instance.id, requester.id, ID_TYPE_MAP.INSTANCE_ID); } return instance; @@ -1137,26 +1138,26 @@ class RequestForm extends React.Component { const patronBlocks = onGetPatronManualBlocks(parentResources); const automatedPatronBlocks = onGetAutomatedPatronBlocks(parentResources); const isEditForm = isFormEditing(request); - + const selectedProxy = getProxy(request, proxy); + const requester = getRequester(selectedProxy, selectedUser); let deliveryLocations; let deliveryLocationsDetail = []; let addressDetail; - if (selectedUser && selectedUser.personal && selectedUser.personal.addresses) { - deliveryLocations = selectedUser.personal.addresses.map((a) => { + if (requester?.personal?.addresses) { + deliveryLocations = requester.personal.addresses.map((a) => { const typeName = find(addressTypes, { id: a.addressTypeId }).addressType; return { label: typeName, value: a.addressTypeId }; }); deliveryLocations = sortBy(deliveryLocations, ['label']); - deliveryLocationsDetail = keyBy(selectedUser.personal.addresses, a => a.addressTypeId); + deliveryLocationsDetail = keyBy(requester.personal.addresses, a => a.addressTypeId); } if (selectedAddressTypeId) { addressDetail = toUserAddress(deliveryLocationsDetail[selectedAddressTypeId]); } - const patronGroup = getPatronGroup(selectedUser, patronGroups); + const patronGroup = getPatronGroup(requester, patronGroups); const fulfillmentTypeOptions = getFulfillmentTypeOptions(hasDelivery, optionLists?.fulfillmentTypes || []); - const selectedProxy = getProxy(request, proxy); const isSubmittingDisabled = isSubmittingButtonDisabled(pristine, submitting); const isTitleLevelRequest = createTitleLevelRequest || request?.requestLevel === REQUEST_LEVEL_TYPES.TITLE; const getPatronBlockModalOpenStatus = () => { diff --git a/src/RequestForm.test.js b/src/RequestForm.test.js index fafdb8ad9..2a723abaa 100644 --- a/src/RequestForm.test.js +++ b/src/RequestForm.test.js @@ -35,6 +35,7 @@ import { isFormEditing, getFulfillmentPreference, resetFieldState, + getRequester, } from './utils'; const testIds = { @@ -70,6 +71,7 @@ jest.mock('./utils', () => ({ getDefaultRequestPreferences: jest.fn(), isFormEditing: jest.fn(), getFulfillmentPreference: jest.fn(), + getRequester: jest.fn((proxy, selectedUser) => selectedUser), })); jest.mock('./components/FulfilmentPreference', () => jest.fn(({ changeDeliveryAddress, @@ -1323,6 +1325,10 @@ describe('RequestForm', () => { expect(resetFieldState).toHaveBeenCalledWith(...expectedArgs); }); + it('should get requester information', () => { + expect(getRequester).toHaveBeenCalled(); + }); + it('should get information about loans', () => { const expectedArgs = [ 'loan', @@ -1632,6 +1638,10 @@ describe('RequestForm', () => { expect(resetFieldState).toHaveBeenCalledWith(...expectedArgs); }); + it('should get requester information', () => { + expect(getRequester).toHaveBeenCalled(); + }); + it('should get information about open instance requests', () => { const expectedArgs = [ 'requestsForInstance', diff --git a/src/utils.js b/src/utils.js index 421d0a3a8..86de23fc1 100644 --- a/src/utils.js +++ b/src/utils.js @@ -456,3 +456,11 @@ export function resetFieldState(form, fieldName) { form.resetFieldState(fieldName); } } + +export const getRequester = (proxy, selectedUser) => { + if (proxy && proxy.id !== selectedUser?.id) { + return proxy; + } + + return selectedUser; +}; diff --git a/src/utils.test.js b/src/utils.test.js index 9331a24ad..43d40e618 100644 --- a/src/utils.test.js +++ b/src/utils.test.js @@ -29,6 +29,7 @@ import { resetFieldState, getRequestTypeOptions, isVirtualItem, + getRequester, } from './utils'; import { @@ -859,3 +860,21 @@ describe('getRequestTypeOptions', () => { expect(getRequestTypeOptions(requestTypes)).toEqual(expectedResult); }); }); + +describe('getRequester', () => { + const selectedUser = { + id: 'selectedUserId', + }; + + it('should return proxy user', () => { + const proxy = { + id: 'proxyId', + }; + + expect(getRequester(proxy, selectedUser)).toEqual(proxy); + }); + + it('should return selected user', () => { + expect(getRequester(null, selectedUser)).toEqual(selectedUser); + }); +});