Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions packages/components/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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": "7.22.0",
"version": "7.22.1",
"description": "Components, models, actions, and utility functions for LabKey applications and pages",
"sideEffects": false,
"files": [
Expand Down
4 changes: 4 additions & 0 deletions packages/components/releaseNotes/components.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# @labkey/components
Components, models, actions, and utility functions for LabKey applications and pages

### version 7.22.1
*Released*: 6 March 2026
- GitHub Issue 897: Study dataset should not allow multivalue text choice as a third key

### version 7.22.0
*Released*: 4 March 2026
- Remove styles for `.app-page`
Expand Down
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' });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function getAdditionalKeyFields(domain: DomainDesign, timepointType: stri
}

domain.fields
.filter(field => !field.isCalculatedField())
.filter(field => !field.isCalculatedField() && !field.isMultiChoiceField())
Copy link
Contributor

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.

.map(field => {
additionalKeyFields = additionalKeyFields.push({ value: field.name, label: field.name });
});
Expand Down