Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/openchs-android/package.json
  • Loading branch information
himeshr committed Jan 16, 2024
2 parents 9ac0686 + 704e388 commit 9d86468
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 5 deletions.
4 changes: 3 additions & 1 deletion packages/openchs-android/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ dependencies {
implementation project(':@react-native-firebase_analytics')
implementation project(':react-native-immediate-phone-call')
implementation project(':amazon-cognito-identity-js')
implementation project(':rn-fetch-blob')
implementation (project(':rn-fetch-blob')) {
exclude group: 'com.squareup.okhttp3'
}
implementation project(':react-native-image-picker')
implementation project(':react-native-fs')
implementation(project(':react-native-video')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import TestSubjectFactory from "../test/model/txn/TestSubjectFactory";
import TestObsFactory from "../test/model/TestObsFactory";
import TestKeyValueFactory from "../test/model/TestKeyValueFactory";
import TestMetadataService from "./service/TestMetadataService";
import {clearTestState} from "realm";
import General from "../src/utility/General";

const rule = `({params, imports}) => {
const workLists = params.workLists;
Expand All @@ -52,6 +54,12 @@ const rule = `({params, imports}) => {
return workLists;
};`;

const formElementRule = `'use strict';
({params, imports}) => {
return new imports.rulesConfig.FormElementStatus(params.formElement.uuid, true, "20", [], []);
};
`;

class PersonRegisterActionsIntegrationTest extends BaseIntegrationTest {
concept; addressLevel; gender;

Expand Down Expand Up @@ -104,7 +112,7 @@ class PersonRegisterActionsIntegrationTest extends BaseIntegrationTest {
keyValues: [TestKeyValueFactory.create({key: "unique", value: "true"})]
}));
db.create(FormMapping, TestFormMappingFactory.createWithDefaults({subjectType: subjectType, form: form}));
db.create(OrganisationConfig, TestOrganisationConfigFactory.createWithDefaults({worklistUpdationRule: rule}));
db.create(OrganisationConfig, TestOrganisationConfigFactory.createWithDefaults({}));

db.create(Individual, TestSubjectFactory.createWithDefaults({subjectType: subjectType, address: this.addressLevel, firstName: "foo", lastName: "bar", observations: [TestObsFactory.create({concept: this.concept, valueJSON: JSON.stringify(this.concept.getValueWrapperFor("ABC"))})]}));
});
Expand Down Expand Up @@ -136,6 +144,44 @@ class PersonRegisterActionsIntegrationTest extends BaseIntegrationTest {
this.dispatch({type: Actions.NEXT, completed: () => {}});
assert.equal(this.getState(Reducers.reducerKeys.personRegister).validationResults.length, 0);
}

rule_generated_field_edited_by_user() {
function getValue(test) {
return test.getState(Reducers.reducerKeys.personRegister).individual.observations[0].valueJSON.value;
}

let subjectType, formElement;
this.executeInWrite((db) => {
subjectType = db.create(SubjectType, TestSubjectTypeFactory.createWithDefaults({type: SubjectType.types.Person, name: 'Beneficiary'}));
const form = db.create(Form, TestFormFactory.createWithDefaults({formType: Form.formTypes.IndividualProfile}));
const formElementGroup = db.create(FormElementGroup, TestFormElementGroupFactory.create({form: form}));
formElement = db.create(FormElement, TestFormElementFactory.create({
uuid: "FOO",
concept: this.concept,
displayOrder: 1,
formElementGroup: formElementGroup,
rule: formElementRule
}));
db.create(FormMapping, TestFormMappingFactory.createWithDefaults({subjectType: subjectType, form: form}));
db.create(OrganisationConfig, TestOrganisationConfigFactory.createWithDefaults({}));

db.create(Individual, TestSubjectFactory.createWithDefaults({subjectType: subjectType, address: this.addressLevel, firstName: "foo", lastName: "bar", observations: [TestObsFactory.create({concept: this.concept, valueJSON: JSON.stringify(this.concept.getValueWrapperFor("ABC"))})]}));
});

this.initialDataSetupComplete();

const workLists = new WorkLists(new WorkList(subjectType.name).withRegistration(subjectType.name));
this.dispatch({type: Actions.ON_LOAD, isDraftEntity: false, workLists: workLists});
this.dispatch({type: Actions.REGISTRATION_ENTER_FIRST_NAME, value: "baz"});
this.dispatch({type: Actions.REGISTRATION_ENTER_LAST_NAME, value: "kal"});
this.dispatch({type: Actions.REGISTRATION_ENTER_GENDER, value: this.gender});
this.dispatch({type: Actions.REGISTRATION_ENTER_DOB, value: new Date()});
this.dispatch({type: Actions.REGISTRATION_ENTER_ADDRESS_LEVEL, value: this.addressLevel});
this.dispatch({type: Actions.NEXT, completed: () => {}});
this.dispatch({type: Actions.PRIMITIVE_VALUE_CHANGE, formElement: formElement, value: ""});
General.logDebugTempJson("", getValue(this));
// assert.equal(this.getState(Reducers.reducerKeys.personRegister), 0);
}
}

export default PersonRegisterActionsIntegrationTest;
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class IndividualIntegrationTest extends BaseIntegrationTest {
this.subject.addEnrolment(program2Enrolment);
});
const entities = this.subject.getMemberEntitiesWithLatestStatus(this.metadata.approvedStatus.status);
assert.equal(entities.length, 3);
assert.equal(entities.length, 4);
assert.equal(true, _.some(entities, (x) => x.uuid === enrolment1Id));
assert.equal(true, _.some(entities, (x) => x.uuid === program2Enrolment.uuid));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/openchs-android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"lodash": "4.17.21",
"moment": "2.29.4",
"native-base": "3.4.9",
"openchs-models": "1.31.20",
"openchs-models": "1.31.21",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-native": "0.72.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import {FormElement} from 'openchs-models';
import General from "../../../src/utility/General";

class TestFormElementFactory {
static create({uuid = General.randomUUID(), name = General.randomUUID(), displayOrder, concept, formElementGroup, mandatory = true, keyValues = []}) {
static create({uuid = General.randomUUID(), name = General.randomUUID(), displayOrder, concept, formElementGroup, mandatory = true, keyValues = [], rule}) {
const entity = new FormElement();
entity.uuid = uuid;
entity.name = name;
entity.concept = concept;
entity.displayOrder = displayOrder;
entity.mandatory = mandatory;
entity.keyValues = keyValues;
entity.rule = rule;
formElementGroup.addFormElement(entity);
return entity;
}
Expand Down

0 comments on commit 9d86468

Please sign in to comment.