Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Questionnaire loading no longer crash when a question uses a code list (or nomenclature) that does not exist anymore. It could happen when an existing question used a previous version of a nomenclature.
- nginx.conf: disable cache on remote-entry (to ensure keeping last legacy version)
- For unique choice questions (inside or outside a table) and multiple choice questions, the variable max length is now 249 instead of 1.

### Changed

Expand Down
2 changes: 1 addition & 1 deletion legacy/src/model/transformations/component.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ describe('component tranformations', () => {
Datatype: {
typeName: 'TEXT',
type: 'TextDatatypeType',
MaxLength: 1,
MaxLength: 249,
visualizationHint: 'DROPDOWN',
},
id: 'my-q-pairwise-response-id',
Expand Down
2 changes: 1 addition & 1 deletion legacy/src/model/transformations/questionnaire.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ describe('questionnaire', () => {
CodeListReference: 'jf0w3fab',
CollectedVariableReference: 'jf0vqq4j',
Datatype: {
MaxLength: 1,
MaxLength: 249,
type: 'TextDatatypeType',
typeName: 'TEXT',
visualizationHint: 'CHECKBOX',
Expand Down
128 changes: 128 additions & 0 deletions legacy/src/model/transformations/response-format-multiple.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { describe, expect, it } from 'vitest';

import {
CHOICE_TYPE,
DATATYPE_VIS_HINT,
DEFAULT_CODES_LIST_SELECTOR_PATH,
DIMENSION_FORMATS,
} from '@/constants/pogues-constants';

import { remoteToState, stateToRemote } from './response-format-multiple';

describe('response format multiple', () => {
Expand Down Expand Up @@ -239,5 +246,126 @@ describe('response format multiple', () => {
],
});
});

it('Correctly compute remote data for CODES_LIST measure type', () => {
const state = {
mandatory: true,
PRIMARY: { CodesList: { id: 'my-cl-id' } },
MEASURE: {
type: DIMENSION_FORMATS.CODES_LIST,
[DIMENSION_FORMATS.CODES_LIST]: {
[DEFAULT_CODES_LIST_SELECTOR_PATH]: { id: 'codes-list-id' },
choiceType: CHOICE_TYPE.CODE_LIST,
visHint: DATATYPE_VIS_HINT.RADIO,
},
},
};
const collectedVariables = ['my-var-id-1', 'my-var-id-2'];
const collectedVariablesStore = {
'my-var-id-2': {
BOOLEAN: {},
DATE: undefined,
DURATION: undefined,
NUMERIC: undefined,
TEXT: { maxLength: 249 },
codeListReference: 'codes-list-id',
codeListReferenceLabel: 'codes-list-label',
id: 'my-var-id-2',
isCollected: '1',
label: '2 - lib2',
mesureLevel: undefined,
name: 'QUESTIONTA2',
type: 'TEXT',
x: 2,
y: Number.NaN,
z: undefined,
},
'my-var-id-1': {
BOOLEAN: {},
DATE: undefined,
DURATION: undefined,
NUMERIC: undefined,
TEXT: { maxLength: 249 },
codeListReference: 'codes-list-id',
codeListReferenceLabel: 'codes-list-label',
id: 'my-var-id-1',
isCollected: '1',
label: '1 - lib1',
mesureLevel: undefined,
name: 'QUESTIONTA1',
type: 'TEXT',
x: 1,
y: Number.NaN,
z: undefined,
},
};
const response = [
{
CollectedVariableReference: 'my-var-id-1',
Datatype: {
typeName: 'TEXT',
type: 'TextDatatypeType',
},
id: 'my-response-id-1',
},
{
CollectedVariableReference: 'my-var-id-2',
Datatype: {
typeName: 'TEXT',
type: 'TextDatatypeType',
},
id: 'my-response-id-2',
},
];

const output = stateToRemote(
state,
collectedVariables,
collectedVariablesStore,
response,
);

expect(output).toEqual({
Attribute: [],
Dimension: [
{
CodeListReference: 'my-cl-id',
dimensionType: 'PRIMARY',
dynamic: 'NON_DYNAMIC',
},
{ dimensionType: 'MEASURE' },
],
Mapping: [
{ MappingSource: 'my-response-id-1', MappingTarget: '1' },
{ MappingSource: 'my-response-id-2', MappingTarget: '2' },
],
Response: [
{
id: 'my-response-id-1',
CollectedVariableReference: 'my-var-id-1',
Datatype: {
type: 'TextDatatypeType',
typeName: 'TEXT',
MaxLength: 249,
visualizationHint: DATATYPE_VIS_HINT.RADIO,
},
choiceType: CHOICE_TYPE.CODE_LIST,
CodeListReference: 'codes-list-id',
},
{
id: 'my-response-id-2',
CollectedVariableReference: 'my-var-id-2',
Datatype: {
type: 'TextDatatypeType',
typeName: 'TEXT',
MaxLength: 249,
visualizationHint: DATATYPE_VIS_HINT.RADIO,
},
choiceType: CHOICE_TYPE.CODE_LIST,
CodeListReference: 'codes-list-id',
},
],
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export function stateToRemote(
typeName: DATATYPE_NAME.TEXT,
visHint,
choiceType,
maxLength: 1,
maxLength: 249,
};
} else {
responseState = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('stateToRemote', () => {
CodeListReference: 'my-cl-id',
CollectedVariableReference: 'my-var-id',
Datatype: {
MaxLength: 1,
MaxLength: 249,
type: 'TextDatatypeType',
typeName: 'TEXT',
visualizationHint: 'RADIO',
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('stateToRemote', () => {
CodeListReference: 'my-cl-id',
CollectedVariableReference: 'my-var-id',
Datatype: {
MaxLength: 1,
MaxLength: 249,
type: 'TextDatatypeType',
typeName: 'TEXT',
visualizationHint: 'SUGGESTER',
Expand Down Expand Up @@ -177,7 +177,7 @@ describe('stateToRemote', () => {
VariableReference: 'my-variable-id',
CollectedVariableReference: 'my-var-id',
Datatype: {
MaxLength: 1,
MaxLength: 249,
type: 'TextDatatypeType',
typeName: 'TEXT',
visualizationHint: 'RADIO',
Expand Down
2 changes: 1 addition & 1 deletion legacy/src/model/transformations/response-format-single.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export function stateToRemote(
nomenclatureId,
variableReferenceId,
typeName: DATATYPE_NAME.TEXT,
maxLength: 1,
maxLength: 249,
collectedVariable: collectedVariables[0],
}),
],
Expand Down
2 changes: 1 addition & 1 deletion legacy/src/model/transformations/response-format-table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ function stateToResponseState(state, primaryType) {
nomenclatureId,
variableReferenceId,
typeName: TEXT,
maxLength: 1,
maxLength: 249,
visHint,
choiceType,
};
Expand Down
45 changes: 38 additions & 7 deletions legacy/src/model/transformations/response-format-table.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ describe('stateToRemote', () => {
const state = {
PRIMARY: {
type: 'CODES_LIST',
CODES_LIST: { CodesList: { id: 'jf0vbzj9' } },
CODES_LIST: { CodesList: { id: 'jf0vbzj9', label: 'my-code-list-1' } },
},
LIST_MEASURE: [
{
Expand All @@ -658,8 +658,12 @@ describe('stateToRemote', () => {
},
{
label: 'measure 2',
type: 'SIMPLE',
SIMPLE: { type: 'TEXT', TEXT: { maxLength: 249 } },
type: 'SINGLE_CHOICE',
SINGLE_CHOICE: {
CodesList: { id: 'mlz1qdq0', label: 'my-code-list-2' },
choiceType: 'CODE_LIST',
visHint: 'RADIO',
},
},
],
};
Expand Down Expand Up @@ -712,8 +716,8 @@ describe('stateToRemote', () => {
DATE: { maximum: '', minimum: '', format: '' },
BOOLEAN: {},
isCollected: '0',
codeListReference: '',
codeListReferenceLabel: '',
codeListReference: 'mlz1qdq0',
codeListReferenceLabel: 'my-code-list-2',
},
jk8h32gm: {
id: 'jk8h32gm',
Expand All @@ -728,8 +732,8 @@ describe('stateToRemote', () => {
DATE: { maximum: '', minimum: '', format: '' },
BOOLEAN: {},
isCollected: '0',
codeListReference: '',
codeListReferenceLabel: '',
codeListReference: 'mlz1qdq0',
codeListReferenceLabel: 'my-code-list-2',
},
};
const result = stateToRemote(
Expand Down Expand Up @@ -783,6 +787,7 @@ describe('stateToRemote', () => {
expect(item.conditionFilter).toBeUndefined();
});

// measure 1 : simple response
expect(outputResponse[0].Datatype).toEqual({
MaxLength: 249,
type: 'TextDatatypeType',
Expand All @@ -796,6 +801,32 @@ describe('stateToRemote', () => {
});
expect(outputMapping[0].MappingTarget).toEqual('1 1');
expect(outputMapping[1].MappingTarget).toEqual('2 1');

// measure 2 : single response (codeList, radio)
expect(outputResponse[2]).toEqual({
id: expect.anything(),
Datatype: {
typeName: 'TEXT',
type: 'TextDatatypeType',
visualizationHint: 'RADIO',
MaxLength: 249,
},
choiceType: 'CODE_LIST',
CodeListReference: 'mlz1qdq0',
CollectedVariableReference: 'jg4v561m',
});
expect(outputResponse[3]).toEqual({
id: expect.anything(),
Datatype: {
typeName: 'TEXT',
type: 'TextDatatypeType',
visualizationHint: 'RADIO',
MaxLength: 249,
},
choiceType: 'CODE_LIST',
CodeListReference: 'mlz1qdq0',
CollectedVariableReference: 'jk8h32gm',
});
});

it('works with non dynamic table, with secondary axes', () => {
Expand Down
2 changes: 1 addition & 1 deletion legacy/src/utils/variables/collected-variables-multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function getCollectedVariablesMultiple(
codeListReference: form[MEASURE][CODES_LIST].CodesList.id,
codeListReferenceLabel: form[MEASURE][CODES_LIST].CodesList.label,
type: TEXT,
[TEXT]: { maxLength: 1 },
[TEXT]: { maxLength: 249 },
};
} else {
reponseFormatValues = {
Expand Down
Loading
Loading