-
Notifications
You must be signed in to change notification settings - Fork 2
GitHub Issue 897: Study dataset should not allow multivalue text choice as a third key #1948
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
90 changes: 90 additions & 0 deletions
90
packages/components/src/internal/components/domainproperties/dataset/actions.test.ts
This file contains hidden or 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,90 @@ | ||
| import { DomainDesign } from '../models'; | ||
| import { CALCULATED_CONCEPT_URI, MULTI_CHOICE_RANGE_URI } from '../constants'; | ||
|
|
||
| import { TIME_KEY_FIELD_DISPLAY, TIME_KEY_FIELD_KEY, VISIT_TIMEPOINT_TYPE } from './constants'; | ||
| import { getAdditionalKeyFields } from './actions'; | ||
|
|
||
| describe('getAdditionalKeyFields', () => { | ||
| test('includes time key field for date-based study', () => { | ||
| const domain = DomainDesign.create({}); | ||
| const result = getAdditionalKeyFields(domain, 'DATE'); | ||
|
|
||
| expect(result.size).toBe(1); | ||
| expect(result.get(0)).toEqual({ value: TIME_KEY_FIELD_KEY, label: TIME_KEY_FIELD_DISPLAY }); | ||
| }); | ||
|
|
||
| test('excludes time key field for visit-based study', () => { | ||
| const domain = DomainDesign.create({}); | ||
| const result = getAdditionalKeyFields(domain, VISIT_TIMEPOINT_TYPE); | ||
|
|
||
| expect(result.size).toBe(0); | ||
| }); | ||
|
|
||
| test('includes regular fields', () => { | ||
| const domain = DomainDesign.create({ | ||
| fields: [ | ||
| { name: 'Field1', rangeURI: 'int' }, | ||
| { name: 'Field2', rangeURI: 'string' }, | ||
| ], | ||
| }); | ||
| const result = getAdditionalKeyFields(domain, VISIT_TIMEPOINT_TYPE); | ||
|
|
||
| expect(result.size).toBe(2); | ||
| expect(result.get(0)).toEqual({ value: 'Field1', label: 'Field1' }); | ||
| expect(result.get(1)).toEqual({ value: 'Field2', label: 'Field2' }); | ||
| }); | ||
|
|
||
| test('excludes calculated fields', () => { | ||
| const domain = DomainDesign.create({ | ||
| fields: [ | ||
| { name: 'Regular', rangeURI: 'int' }, | ||
| { name: 'Calculated', rangeURI: 'int', conceptURI: CALCULATED_CONCEPT_URI }, | ||
| ], | ||
| }); | ||
| const result = getAdditionalKeyFields(domain, VISIT_TIMEPOINT_TYPE); | ||
|
|
||
| expect(result.size).toBe(1); | ||
| expect(result.get(0)).toEqual({ value: 'Regular', label: 'Regular' }); | ||
| }); | ||
|
|
||
| test('excludes multi-choice fields', () => { | ||
| const domain = DomainDesign.create({ | ||
| fields: [ | ||
| { name: 'Regular', rangeURI: 'int' }, | ||
| { name: 'MultiChoice', rangeURI: MULTI_CHOICE_RANGE_URI }, | ||
| ], | ||
| }); | ||
| const result = getAdditionalKeyFields(domain, VISIT_TIMEPOINT_TYPE); | ||
|
|
||
| expect(result.size).toBe(1); | ||
| expect(result.get(0)).toEqual({ value: 'Regular', label: 'Regular' }); | ||
| }); | ||
|
|
||
| test('includes time key field before domain fields for non-visit study', () => { | ||
| const domain = DomainDesign.create({ | ||
| fields: [{ name: 'Field1', rangeURI: 'int' }], | ||
| }); | ||
| const result = getAdditionalKeyFields(domain, 'Timepoints'); | ||
|
|
||
| expect(result.size).toBe(2); | ||
| expect(result.get(0)).toEqual({ value: TIME_KEY_FIELD_KEY, label: TIME_KEY_FIELD_DISPLAY }); | ||
| expect(result.get(1)).toEqual({ value: 'Field1', label: 'Field1' }); | ||
| }); | ||
|
|
||
| test('filters out both calculated and multi-choice fields while keeping regular fields', () => { | ||
| const domain = DomainDesign.create({ | ||
| fields: [ | ||
| { name: 'Regular1', rangeURI: 'int' }, | ||
| { name: 'Calculated', rangeURI: 'int', conceptURI: CALCULATED_CONCEPT_URI }, | ||
| { name: 'Regular2', rangeURI: 'string' }, | ||
| { name: 'MultiChoice', rangeURI: MULTI_CHOICE_RANGE_URI }, | ||
| ], | ||
| }); | ||
| const result = getAdditionalKeyFields(domain, 'Timepoints'); | ||
|
|
||
| expect(result.size).toBe(3); | ||
| expect(result.get(0)).toEqual({ value: TIME_KEY_FIELD_KEY, label: TIME_KEY_FIELD_DISPLAY }); | ||
| expect(result.get(1)).toEqual({ value: 'Regular1', label: 'Regular1' }); | ||
| expect(result.get(2)).toEqual({ value: 'Regular2', label: 'Regular2' }); | ||
| }); | ||
| }); |
This file contains hidden or 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
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.
since this function is more of a util than an action, it seems like it could have some jest test coverage. If you've found a place on the selenium side to easily add this coverage, that works but otherwise jest test coverage here for the filter would be good.