Skip to content

Item 10437: Aliquot Field Inheritance #872

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 45 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f1fc6bc
Item 10437: Aliquot Field Inheritance
XingY Jun 20, 2022
1dedec0
lint
XingY Jun 20, 2022
923e389
ui fixes
XingY Jun 21, 2022
89f971d
fix sample creation with all fields
XingY Jun 21, 2022
e1d29b7
fix editable export for insert cases
XingY Jun 21, 2022
2461e84
Merge branch 'develop' into fb_aliquotOptions
XingY Jun 22, 2022
778efea
jest
XingY Jun 22, 2022
4697fe7
lint
XingY Jun 22, 2022
c319248
fix jest
XingY Jun 22, 2022
3b53833
lint
XingY Jun 22, 2022
ea01153
fix release note
XingY Jun 22, 2022
ca68acf
v2.189.0-fb-aliquotOptions.1
XingY Jun 22, 2022
5c32b70
Merge branch 'develop' into fb_aliquotOptions
XingY Jun 23, 2022
7524d21
code review changes
XingY Jun 23, 2022
17780fe
v2.189.0-fb-aliquotOptions.2
XingY Jun 23, 2022
8af65d9
code review changes
XingY Jun 23, 2022
4505e8f
lint
XingY Jun 23, 2022
696f8c3
lint
XingY Jun 23, 2022
b4af75b
extract comments
XingY Jun 23, 2022
c7d883e
v2.189.0-fb-aliquotOptions.4
XingY Jun 23, 2022
0a7fdf0
don't show options for barcode fields
XingY Jun 23, 2022
6ffb8b1
lint
XingY Jun 23, 2022
e1052a4
v2.189.0-fb-aliquotOptions.5
XingY Jun 23, 2022
ed28988
code review changes
XingY Jun 23, 2022
e237466
fix comment
XingY Jun 24, 2022
91ef27c
update snapshot
XingY Jun 24, 2022
e13aa40
Merge branch 'develop' into fb_aliquotOptions
XingY Jun 29, 2022
b0e7e4c
v2.192.0-fb-aliquotOptions.1
XingY Jun 29, 2022
a655f06
set explicit default value for aliquot options
XingY Jun 30, 2022
19dddc6
Merge branch 'develop' into fb_aliquotOptions
XingY Jun 30, 2022
e6e4b2a
v2.193.0-fb-aliquotOptions.1
XingY Jun 30, 2022
5c54353
Merge branch 'develop' into fb_aliquotOptions
XingY Jul 3, 2022
0ca2eba
v2.193.0-fb-aliquotOptions.2
XingY Jul 3, 2022
3024097
Fix editable grid update with no aliquot selection
XingY Jul 5, 2022
34860f4
Merge branch 'develop' into fb_aliquotOptions
XingY Jul 5, 2022
f31de98
v2.195.0-fb-aliquotOptions.1
XingY Jul 5, 2022
fe201a3
fix independent field
XingY Jul 6, 2022
3540ed0
v2.195.0-fb-aliquotOptions.2
XingY Jul 6, 2022
e8b9eaf
fix aliquot reset
XingY Jul 6, 2022
6c4d5fe
v2.195.0-fb-aliquotOptions.3
XingY Jul 6, 2022
4abd527
Merge branch 'develop' into fb_aliquotOptions
XingY Jul 7, 2022
c9f6a5f
v2.196.0-fb-aliquotOptions.2
XingY Jul 7, 2022
f98e84d
update snapshot
XingY Jul 7, 2022
9684e05
update release note
XingY Jul 7, 2022
f51590c
v2.196.0
XingY Jul 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@labkey/components",
"version": "2.195.1",
"version": "2.196.0",
"description": "Components, models, actions, and utility functions for LabKey applications and pages",
"main": "dist/components.js",
"module": "dist/components.js",
Expand Down
5 changes: 5 additions & 0 deletions packages/components/releaseNotes/components.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# @labkey/components
Components, models, actions, and utility functions for LabKey applications and pages.

### version 2.196.0
*Released*: 7 July 2022
* Item 10437: Aliquot Field Inheritance
* Update DerivationDataScopeFieldOptions, SampleTypeDesigner, EntityInsertPanel and SamplesBulkUpdateForm to support aliquot & sample options

### version 2.195.1
*Released*: 7 July 2022
* Issue 44599: Field editor PHI Level doesn't show correct value for a field if the admin user does not have that level of PHI access
Expand Down
Original file line number Diff line number Diff line change
@@ -1,65 +1,258 @@
import { mount } from 'enzyme';
import React, { ReactNode } from 'react';
import React from 'react';

import { createFormInputId } from './actions';
import { DOMAIN_FIELD_DERIVATION_DATA_SCOPE, DOMAIN_FIELD_NOT_LOCKED } from './constants';
import { Radio } from 'react-bootstrap';

import { Alert } from '../base/Alert';

import { DERIVATION_DATA_SCOPES, DOMAIN_FIELD_NOT_LOCKED } from './constants';
import { DerivationDataScopeFieldOptions } from './DerivationDataScopeFieldOptions';
import { PropDescType, TEXT_TYPE, UNIQUE_ID_TYPE } from './PropDescType';

describe('DerivationDataScopeFieldOptions', () => {
test('Derivation Data Scope Field Options', () => {
const label = 'Aliquot properties';
test('Default config, new field', () => {
const props = {
index: 1,
domainIndex: 1,
label: null,
onChange: jest.fn(),
lockType: DOMAIN_FIELD_NOT_LOCKED,
isExistingField: false,
};

const wrapper = mount(<DerivationDataScopeFieldOptions {...props} />);

const sectionLabel = wrapper.find({ className: 'domain-field-section-heading domain-field-section-hdr' });
expect(sectionLabel.length).toEqual(1);
expect(sectionLabel.text()).toEqual('Derivation Data Scope');

const radios = wrapper.find(Radio);
expect(radios).toHaveLength(3);
expect(radios.at(0).prop('checked')).toBeTruthy();
expect(radios.at(0).prop('disabled')).toBeFalsy();
expect(radios.at(0).text()).toBe('Editable for parent data only (default)');
expect(radios.at(1).prop('checked')).toBeFalsy();
expect(radios.at(1).prop('disabled')).toBeFalsy();
expect(radios.at(1).text()).toBe('Editable for child data only');
expect(radios.at(2).prop('checked')).toBeFalsy();
expect(radios.at(2).prop('disabled')).toBeFalsy();
expect(radios.at(2).text()).toBe('Editable for parent and child data independently');
expect(wrapper.find(Alert)).toHaveLength(0);

wrapper.unmount();
});

test('Existing field, value = ParentOnly', () => {
const props = {
index: 1,
domainIndex: 1,
label: null,
onChange: jest.fn(),
lockType: DOMAIN_FIELD_NOT_LOCKED,
isExistingField: true,
value: DERIVATION_DATA_SCOPES.PARENT_ONLY,
};

const wrapper = mount(<DerivationDataScopeFieldOptions {...props} />);

const radios = wrapper.find(Radio);
expect(radios).toHaveLength(3);
expect(radios.at(0).prop('checked')).toBeTruthy();
expect(radios.at(0).prop('disabled')).toBeFalsy();
expect(radios.at(1).prop('checked')).toBeFalsy();
expect(radios.at(1).prop('disabled')).toBeTruthy();
expect(radios.at(2).prop('checked')).toBeFalsy();
expect(radios.at(2).prop('disabled')).toBeFalsy();
expect(wrapper.find(Alert)).toHaveLength(0);

wrapper.unmount();
});

test('Existing field, value is empty', () => {
const props = {
index: 1,
domainIndex: 1,
label: null,
onChange: jest.fn(),
lockType: DOMAIN_FIELD_NOT_LOCKED,
isExistingField: true,
value: '',
};

const wrapper = mount(<DerivationDataScopeFieldOptions {...props} />);

const radios = wrapper.find(Radio);
expect(radios).toHaveLength(3);
expect(radios.at(0).prop('checked')).toBeTruthy();
expect(radios.at(0).prop('disabled')).toBeFalsy();
expect(radios.at(1).prop('checked')).toBeFalsy();
expect(radios.at(1).prop('disabled')).toBeTruthy();
expect(radios.at(2).prop('checked')).toBeFalsy();
expect(radios.at(2).prop('disabled')).toBeFalsy();
expect(wrapper.find(Alert)).toHaveLength(0);

wrapper.unmount();
});

test('Existing field, value = ChildOnly', () => {
const props = {
index: 1,
domainIndex: 1,
label: null,
onChange: jest.fn(),
lockType: DOMAIN_FIELD_NOT_LOCKED,
isExistingField: true,
value: DERIVATION_DATA_SCOPES.CHILD_ONLY,
};

const wrapper = mount(<DerivationDataScopeFieldOptions {...props} />);

const radios = wrapper.find(Radio);
expect(radios).toHaveLength(3);
expect(radios.at(0).prop('checked')).toBeFalsy();
expect(radios.at(0).prop('disabled')).toBeTruthy();
expect(radios.at(0).text()).toBe('Editable for parent data only (default)');
expect(radios.at(1).prop('checked')).toBeTruthy();
expect(radios.at(1).prop('disabled')).toBeFalsy();
expect(radios.at(1).text()).toBe('Editable for child data only');
expect(radios.at(2).prop('checked')).toBeFalsy();
expect(radios.at(2).prop('disabled')).toBeFalsy();
expect(radios.at(2).text()).toBe('Editable for parent and child data independently');
expect(wrapper.find(Alert)).toHaveLength(0);

wrapper.unmount();
});

test('Existing field, value = All', () => {
const props = {
index: 1,
domainIndex: 1,
label: null,
onChange: jest.fn(),
lockType: DOMAIN_FIELD_NOT_LOCKED,
isExistingField: true,
value: DERIVATION_DATA_SCOPES.ALL,
};

const wrapper = mount(<DerivationDataScopeFieldOptions {...props} />);

const radios = wrapper.find(Radio);
expect(radios).toHaveLength(3);
expect(radios.at(0).prop('checked')).toBeFalsy();
expect(radios.at(0).prop('disabled')).toBeTruthy();
expect(radios.at(1).prop('checked')).toBeFalsy();
expect(radios.at(1).prop('disabled')).toBeTruthy();
expect(radios.at(2).prop('checked')).toBeTruthy();
expect(radios.at(2).prop('disabled')).toBeFalsy();
expect(wrapper.find(Alert)).toHaveLength(0);

wrapper.unmount();
});

test('With config, show = true', () => {
const label = 'Sample/Aliquot Options';
const warning =
"Updating a 'Samples Only' field to be 'Samples and Aliquots' will blank out the field values for all aliquots. This action cannot be undone.";
const props = {
index: 1,
domainIndex: 1,
label,
onChange: jest.fn(),
lockType: DOMAIN_FIELD_NOT_LOCKED,
config: {
show: true,
sectionTitle: 'Sample/Aliquot Options',
labelAll: 'Separately editable for samples and aliquots',
labelChild: 'Editable for aliquots only',
labelParent: 'Editable for samples only (default)',
helpLinkNode: <>help</>,
scopeChangeWarning: warning,
},
isExistingField: true,
value: DERIVATION_DATA_SCOPES.PARENT_ONLY,
};

const aliquot = mount(<DerivationDataScopeFieldOptions {...props} />);
const wrapper = mount(<DerivationDataScopeFieldOptions {...props} />);

// Verify label
const sectionLabel = aliquot.find({ className: 'domain-field-section-heading domain-field-section-hdr' });
const sectionLabel = wrapper.find({ className: 'domain-field-section-heading domain-field-section-hdr' });
expect(sectionLabel.length).toEqual(1);
expect(sectionLabel.text()).toEqual(label);

const fieldName = createFormInputId(DOMAIN_FIELD_DERIVATION_DATA_SCOPE, 1, 1);
// Test format field initial value
let checkbox = aliquot.find({ id: fieldName, bsClass: 'checkbox' });
expect(checkbox.length).toEqual(1);
expect(checkbox.props().checked).toEqual(false);
const radios = wrapper.find(Radio);
expect(radios).toHaveLength(3);
expect(radios.at(0).prop('checked')).toBeTruthy();
expect(radios.at(0).text()).toBe('Editable for samples only (default)');
expect(radios.at(1).prop('checked')).toBeFalsy();
expect(radios.at(1).text()).toBe('Editable for aliquots only');
expect(radios.at(2).prop('checked')).toBeFalsy();
expect(radios.at(2).text()).toBe('Separately editable for samples and aliquots');
expect(wrapper.find(Alert)).toHaveLength(0);

// Verify format value changes with props
aliquot.setProps({ value: 'ChildOnly' });
checkbox = aliquot.find({ id: fieldName, bsClass: 'checkbox' });
expect(checkbox.props().checked).toEqual(true);
wrapper.unmount();
});

aliquot.unmount();
test('With config, show = false', () => {
const label = 'Sample/Aliquot Options';
const props = {
index: 1,
domainIndex: 1,
label,
onChange: jest.fn(),
lockType: DOMAIN_FIELD_NOT_LOCKED,
config: {
show: false,
},
};

const wrapper = mount(<DerivationDataScopeFieldOptions {...props} />);
expect(wrapper).toEqual({});
wrapper.unmount();
});

test('With config', () => {
const label = 'Aliquot field';
test('With config, isExistingField is not applicable', () => {
const props = {
index: 1,
domainIndex: 1,
label: null,
onChange: jest.fn(),
lockType: DOMAIN_FIELD_NOT_LOCKED,
isExistingField: true,
value: DERIVATION_DATA_SCOPES.ALL,
config: {
show: true,
dataTypeFilter: (dataType: PropDescType) => !dataType.isUniqueId(),
},
fieldDataType: UNIQUE_ID_TYPE,
};

const wrapper = mount(<DerivationDataScopeFieldOptions {...props} />);

expect(wrapper).toEqual({});

wrapper.unmount();
});

test('With config, isExistingField is applicable', () => {
const props = {
index: 1,
domainIndex: 1,
label,
label: null,
onChange: jest.fn(),
lockType: DOMAIN_FIELD_NOT_LOCKED,
isExistingField: true,
value: DERIVATION_DATA_SCOPES.ALL,
config: {
show: true,
disable: true,
sectionTitle: 'Aliquot field',
fieldLabel: 'Aliquot Only',
dataTypeFilter: (dataType: PropDescType) => !dataType.isUniqueId(),
},
fieldDataType: TEXT_TYPE,
};

const aliquot = mount(<DerivationDataScopeFieldOptions {...props} />);
const fieldName = createFormInputId(DOMAIN_FIELD_DERIVATION_DATA_SCOPE, 1, 1);
const wrapper = mount(<DerivationDataScopeFieldOptions {...props} />);

const radios = wrapper.find(Radio);
expect(radios).toHaveLength(3);

const checkbox = aliquot.find({ id: fieldName, bsClass: 'checkbox' });
expect(checkbox.props().disabled).toEqual(true);
aliquot.unmount();
wrapper.unmount();
});
});
Loading