-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UIPFU-77 - Add 'User assignment status' filter group #249
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0024421
UIPFU-77 - Add 'User assignment status' filter group
Terala-Priyanka b2d41d4
UIPFU-77 - Update change log
Terala-Priyanka 5b390ff
UIPFU-77 - yarn.lock
Terala-Priyanka a309cc4
UIPFU-77 - update test script
Terala-Priyanka e5287a2
UIPFU-77 - refine complexity
Terala-Priyanka a7bba68
UIPFU-77 - cleanup
Terala-Priyanka 5ad35b6
UIPFU-77 - add comments
Terala-Priyanka a016d97
UIPFU-77 - fix review comments
Terala-Priyanka a3adb92
UIPFU-77 - fix review comments
Terala-Priyanka 16e11ee
UIPFU-fix review comments
Terala-Priyanka 4bd8c31
Update src/UserSearchContainer.js
Terala-Priyanka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,27 @@ | ||
{ | ||
"parser": "@babel/eslint-parser", | ||
"extends": "@folio/eslint-config-stripes" | ||
"extends": "@folio/eslint-config-stripes", | ||
"overrides": [ | ||
{ | ||
"files": [ "src/**/tests/*", "*.test.js", "test/**/*" ], | ||
"rules": { | ||
"react/prop-types": "off", | ||
"import/prefer-default-export": "off" | ||
} | ||
} | ||
], | ||
"env": { | ||
"jest": true | ||
}, | ||
"settings": { | ||
"import/resolver": { | ||
"alias": { | ||
"map": [ | ||
["__mock__", "./test/jest/__mock__"], | ||
["fixtures", "./test/jest/fixtures"], | ||
["helpers", "./test/jest/helpers"] | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
artifacts | ||
artifacts | ||
junit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const path = require('path'); | ||
const config = require('@folio/jest-config-stripes'); | ||
|
||
module.exports = { | ||
...config, | ||
setupFiles: [ | ||
...config.setupFiles, | ||
path.join(__dirname, './test/jest/setupFiles.js'), | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
export const UAS = 'uas'; | ||
export const ASSIGNED_FILTER_KEY = 'uas.Assigned'; | ||
export const UNASSIGNED_FILTER_KEY = 'uas.Unassigned'; | ||
export const ASSIGNED = 'Assigned'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import cloneDeep from 'lodash/cloneDeep'; | ||
import { | ||
ASSIGNED_FILTER_KEY, | ||
UNASSIGNED_FILTER_KEY, | ||
UAS, | ||
} from './constants'; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export const updateResourceData = (rData) => { | ||
const filterString = rData?.query?.filters; | ||
const newRData = cloneDeep(rData); | ||
if (filterString === UNASSIGNED_FILTER_KEY || filterString === `${ASSIGNED_FILTER_KEY},${UNASSIGNED_FILTER_KEY}` || filterString === `${UNASSIGNED_FILTER_KEY},${ASSIGNED_FILTER_KEY}`) { | ||
/* | ||
* When Unassigned filter is selected on 'User assignment Status' filter group, with no other filter from other groups, | ||
* fetch all the user records. The filter string is adjusted to include both active and inactive status filters. This will result in (cql.allRecords=1) | ||
* | ||
* The same applies when both Assigned and Unassigned are selected in any sequential order. | ||
*/ | ||
const alteredfilters = 'active.active,active.inactive'; | ||
newRData.query.filters = alteredfilters; | ||
} else { | ||
const alteredfilters = newRData.query.filters.split(',').filter(str => !str.startsWith(UAS)).join(','); | ||
newRData.query.filters = alteredfilters; | ||
} | ||
return newRData; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { updateResourceData } from './utils'; | ||
import { UNASSIGNED_FILTER_KEY, ASSIGNED_FILTER_KEY } from './constants'; | ||
|
||
describe('updatedResourceData', () => { | ||
describe('when only UnAssigned filter is selected', () => { | ||
[UNASSIGNED_FILTER_KEY, `${ASSIGNED_FILTER_KEY},${UNASSIGNED_FILTER_KEY}`, `${UNASSIGNED_FILTER_KEY},${ASSIGNED_FILTER_KEY}`].forEach(filterStr => ( | ||
it(`should remove ${filterStr} from filter string and add active and inactive filter strings`, () => { | ||
const resourceData = { | ||
query: { | ||
filters: filterStr, | ||
} | ||
}; | ||
const expectedResourceData = { | ||
query: { | ||
...resourceData.query, | ||
filters: 'active.active,active.inactive', | ||
}, | ||
}; | ||
expect(updateResourceData(resourceData)).toMatchObject(expectedResourceData); | ||
}) | ||
)); | ||
}); | ||
|
||
describe('when Unassigned filter is selected along with filters from other filter groups', () => { | ||
it('should remove Unassigned filter and return the rest', () => { | ||
const resourceData = { | ||
query: { | ||
filters: `${UNASSIGNED_FILTER_KEY},active.active`, | ||
} | ||
}; | ||
const expectedResourceData = { | ||
query: { | ||
...resourceData.query, | ||
filters: 'active.active', | ||
}, | ||
}; | ||
expect(updateResourceData(resourceData)).toMatchObject(expectedResourceData); | ||
}); | ||
}); | ||
|
||
describe('when Assigned filter is selected with or without combination of filters from other filter groups', () => { | ||
it('should remove assigned filter string', () => { | ||
const resourceData = { | ||
query: { | ||
filters: `${ASSIGNED_FILTER_KEY},active.active`, | ||
} | ||
}; | ||
const expectedResourceData = { | ||
query: { | ||
...resourceData.query, | ||
filters: 'active.active', | ||
}, | ||
}; | ||
expect(updateResourceData(resourceData)).toMatchObject(expectedResourceData); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// See https://github.com/facebook/jest/issues/335#issuecomment-703691592 | ||
// import './__mock__'; | ||
|
||
import 'regenerator-runtime/runtime'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to move this function outside the component. I will much easier to test all
if...else
conditions.But it is up to you.