From a28862610592853167ebeed744591f28cce3e114 Mon Sep 17 00:00:00 2001 From: Pratik Prajapati <33730817+ppratikcr7@users.noreply.github.com> Date: Thu, 21 Nov 2024 21:49:23 +0530 Subject: [PATCH] resolved typecheck issues (#2121) Co-authored-by: danoswaltCL <97542869+danoswaltCL@users.noreply.github.com> --- .../Upgrade/.env.docker.local.example | 2 +- .../Upgrade/src/api/DTO/ExperimentDTO.ts | 2 +- .../ExperimentExperimentEnrollmentCode.ts | 4 +- .../GroupExperimentExclusionCode.ts | 2 +- .../WithinSubjectExperimentExclusionCode.ts | 2 +- .../ExperimentStats/IndividualEnrollment.ts | 2 +- .../WithinSubjectEnrollment.ts | 2 +- .../integration/ExperimentUser/Scenario1A.ts | 4 +- .../integration/ExperimentUser/Scenario1B.ts | 4 +- .../integration/ExperimentUser/Scenario1C.ts | 4 +- .../integration/ExperimentUser/Scenario2A.ts | 4 +- .../integration/ExperimentUser/Scenario2B.ts | 4 +- .../integration/ExperimentUser/Scenario2C.ts | 4 +- .../integration/ExperimentUser/Scenario3A.ts | 4 +- .../integration/ExperimentUser/Scenario3B.ts | 4 +- .../ExperimentUser/WorkingGroupChangeTest1.ts | 2 +- .../ExperimentUser/WorkingGroupChangeTest2.ts | 2 +- .../integration/mockData/experiment/index.ts | 42 ++++++++++++++++- .../integration/mockData/experiment/raw.ts | 47 +++++++++++++++---- .../Upgrade/test/integration/utils/index.ts | 4 +- 20 files changed, 107 insertions(+), 38 deletions(-) diff --git a/backend/packages/Upgrade/.env.docker.local.example b/backend/packages/Upgrade/.env.docker.local.example index 21891e1741..10b2673d35 100644 --- a/backend/packages/Upgrade/.env.docker.local.example +++ b/backend/packages/Upgrade/.env.docker.local.example @@ -82,4 +82,4 @@ CLIENT_API_SECRET=secret CLIENT_API_KEY=key CONTEXT_METADATA={"context_identifier_1":{"CONDITIONS":["potential-condition-1","potential-condition-2"],"GROUP_TYPES":["client_group_identifier_1","client_group_identifier_2","client_group_identifier_3"],"EXP_IDS":["decision_point_target_identifier_1","decision_point_target_identifier_2"],"EXP_POINTS":["decision_point_site_identifier_1","decision_point_site_identifier_2"]}} -METRICS=[{"metrics":[{"metric": "totalTimeSeconds","datatype": "continuous"}, {"groupClass":"masteryWorkspace","allowedKeys":["calculating_area_various_figures","Compare_functions_diff_reps_quadratic"],"attributes":[{"metric":"timeSeconds","datatype":"continuous"}]}],"contexts": ["context_identifier_1"]}] \ No newline at end of file +METRICS=[{"metrics":[{"metric": "totalTimeSeconds","datatype": "continuous"}, {"groupClass":"masteryWorkspace","allowedKeys":["calculating_area_various_figures","Compare_functions_diff_reps_quadratic"],"attributes":[{"metric":"timeSeconds","datatype":"continuous"}]}],"contexts": ["context_identifier_1"]}] diff --git a/backend/packages/Upgrade/src/api/DTO/ExperimentDTO.ts b/backend/packages/Upgrade/src/api/DTO/ExperimentDTO.ts index 91c5c822e5..1e310e5522 100644 --- a/backend/packages/Upgrade/src/api/DTO/ExperimentDTO.ts +++ b/backend/packages/Upgrade/src/api/DTO/ExperimentDTO.ts @@ -149,7 +149,7 @@ export class ConditionValidator { @IsOptional() @ValidateNested({ each: true }) @Type(() => LevelCombinationElementValidator) - public levelCombinationElements: LevelCombinationElementValidator[]; + public levelCombinationElements?: LevelCombinationElementValidator[]; } export class PartitionValidator { @IsNotEmpty() diff --git a/backend/packages/Upgrade/test/integration/Experiment/enrollmentCode/ExperimentExperimentEnrollmentCode.ts b/backend/packages/Upgrade/test/integration/Experiment/enrollmentCode/ExperimentExperimentEnrollmentCode.ts index 8bf113c4e6..e05671a086 100644 --- a/backend/packages/Upgrade/test/integration/Experiment/enrollmentCode/ExperimentExperimentEnrollmentCode.ts +++ b/backend/packages/Upgrade/test/integration/Experiment/enrollmentCode/ExperimentExperimentEnrollmentCode.ts @@ -9,7 +9,7 @@ import { checkExperimentAssignedIsNotDefault, } from '../../utils/index'; import { experimentUsers } from '../../mockData/experimentUsers/index'; -import { EXPERIMENT_STATE, ENROLLMENT_CODE } from 'upgrade_types'; +import { EXPERIMENT_STATE, ENROLLMENT_CODE, ASSIGNMENT_UNIT } from 'upgrade_types'; import { UpgradeLogger } from '../../../../src/lib/logger/UpgradeLogger'; import { CheckService } from '../../../../src/api/services/CheckService'; @@ -150,7 +150,7 @@ export default async function testCase(): Promise { ]) ); - experimentObject.assignmentUnit = "group"; + experimentObject.assignmentUnit = ASSIGNMENT_UNIT.GROUP; await experimentService.update(experimentObject as any, user, new UpgradeLogger()); // change experiment status to Enrolling diff --git a/backend/packages/Upgrade/test/integration/Experiment/exclusionCode/GroupExperimentExclusionCode.ts b/backend/packages/Upgrade/test/integration/Experiment/exclusionCode/GroupExperimentExclusionCode.ts index a529a83c71..d745155df7 100644 --- a/backend/packages/Upgrade/test/integration/Experiment/exclusionCode/GroupExperimentExclusionCode.ts +++ b/backend/packages/Upgrade/test/integration/Experiment/exclusionCode/GroupExperimentExclusionCode.ts @@ -88,7 +88,7 @@ export default async function testCase(): Promise { let individualExclusions = await checkService.getAllIndividualExclusion(); expect(individualExclusions.length).toEqual(1); // EXCLUDED_DUE_TO_GROUP_LOGIC - experimentObject.state = 'enrolling'; + experimentObject.state = EXPERIMENT_STATE.ENROLLING; experimentObject.experimentSegmentExclusion = { "segment": { "id": "1b0c0200-7a15-4e19-8688-f9ac283f18aa", diff --git a/backend/packages/Upgrade/test/integration/Experiment/exclusionCode/WithinSubjectExperimentExclusionCode.ts b/backend/packages/Upgrade/test/integration/Experiment/exclusionCode/WithinSubjectExperimentExclusionCode.ts index ff7050dddc..48947bcd1d 100644 --- a/backend/packages/Upgrade/test/integration/Experiment/exclusionCode/WithinSubjectExperimentExclusionCode.ts +++ b/backend/packages/Upgrade/test/integration/Experiment/exclusionCode/WithinSubjectExperimentExclusionCode.ts @@ -87,7 +87,7 @@ export default async function testCase(): Promise { let individualExclusions = await checkService.getAllIndividualExclusion(); expect(individualExclusions.length).toEqual(1); - experimentObject.state = 'enrolling'; + experimentObject.state = EXPERIMENT_STATE.ENROLLING; experimentObject.experimentSegmentExclusion = { "segment": { "id": "1b0c0200-7a15-4e19-8688-f9ac283f18aa", diff --git a/backend/packages/Upgrade/test/integration/ExperimentStats/IndividualEnrollment.ts b/backend/packages/Upgrade/test/integration/ExperimentStats/IndividualEnrollment.ts index b40a56081b..d36b5c7495 100644 --- a/backend/packages/Upgrade/test/integration/ExperimentStats/IndividualEnrollment.ts +++ b/backend/packages/Upgrade/test/integration/ExperimentStats/IndividualEnrollment.ts @@ -28,7 +28,7 @@ export default async function testCase(): Promise { experimentObject.partitions = updateExcludeIfReachedFlag(experimentObject.partitions); // create experiment - await experimentService.create(experimentObject as any, user, new UpgradeLogger()); + await experimentService.create(experimentObject, user, new UpgradeLogger()); const experiments = await experimentService.find(new UpgradeLogger()); expect(experiments).toEqual( expect.arrayContaining([ diff --git a/backend/packages/Upgrade/test/integration/ExperimentStats/WithinSubjectEnrollment.ts b/backend/packages/Upgrade/test/integration/ExperimentStats/WithinSubjectEnrollment.ts index dffd0711a2..9c9e3890cc 100644 --- a/backend/packages/Upgrade/test/integration/ExperimentStats/WithinSubjectEnrollment.ts +++ b/backend/packages/Upgrade/test/integration/ExperimentStats/WithinSubjectEnrollment.ts @@ -28,7 +28,7 @@ export default async function testCase(): Promise { experimentObject.partitions = updateExcludeIfReachedFlag(experimentObject.partitions); // create experiment - await experimentService.create(experimentObject as any, user, new UpgradeLogger()); + await experimentService.create(experimentObject, user, new UpgradeLogger()); const experiments = await experimentService.find(new UpgradeLogger()); expect(experiments).toEqual( expect.arrayContaining([ diff --git a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario1A.ts b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario1A.ts index b5dc9009f3..a1411dbfe9 100644 --- a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario1A.ts +++ b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario1A.ts @@ -46,7 +46,7 @@ export default async function ExcludeGroupsA(): Promise { experimentObject.partitions = updateExcludeIfReachedFlag(experimentObject.partitions); // create experiment - await experimentService.create(experimentObject as any, user, new UpgradeLogger()); + await experimentService.create(experimentObject, user, new UpgradeLogger()); const experiments = await experimentService.find(new UpgradeLogger()); expect(experiments).toEqual( expect.arrayContaining([ @@ -141,7 +141,7 @@ export default async function ExcludeGroupsA(): Promise { }, }, }; - await experimentService.update(experimentObject as any, user, new UpgradeLogger()); + await experimentService.update(experimentObject, user, new UpgradeLogger()); // check stats stats = await analyticsService.getDetailEnrollment(experimentId); diff --git a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario1B.ts b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario1B.ts index 3d20d25a32..f1f58f7603 100644 --- a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario1B.ts +++ b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario1B.ts @@ -46,7 +46,7 @@ export default async function ExcludeGroupsB(): Promise { experimentObject.partitions = updateExcludeIfReachedFlag(experimentObject.partitions); // create experiment - await experimentService.create(experimentObject as any, user, new UpgradeLogger()); + await experimentService.create(experimentObject, user, new UpgradeLogger()); const experiments = await experimentService.find(new UpgradeLogger()); expect(experiments).toEqual( expect.arrayContaining([ @@ -142,7 +142,7 @@ export default async function ExcludeGroupsB(): Promise { }, }, }; - await experimentService.update(experimentObject as any, user, new UpgradeLogger()); + await experimentService.update(experimentObject, user, new UpgradeLogger()); // check stats stats = await analyticsService.getDetailEnrollment(experimentId); diff --git a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario1C.ts b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario1C.ts index 9fcad7d41d..ddaf5c986f 100644 --- a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario1C.ts +++ b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario1C.ts @@ -46,7 +46,7 @@ export default async function ExcludeGroupsC(): Promise { experimentObject.partitions = updateExcludeIfReachedFlag(experimentObject.partitions); // create experiment - await experimentService.create(experimentObject as any, user, new UpgradeLogger()); + await experimentService.create(experimentObject, user, new UpgradeLogger()); const experiments = await experimentService.find(new UpgradeLogger()); expect(experiments).toEqual( expect.arrayContaining([ @@ -142,7 +142,7 @@ export default async function ExcludeGroupsC(): Promise { }, }, }; - await experimentService.update(experimentObject as any, user, new UpgradeLogger()); + await experimentService.update(experimentObject, user, new UpgradeLogger()); // check stats stats = await analyticsService.getDetailEnrollment(experimentId); diff --git a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario2A.ts b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario2A.ts index a5f7577731..2d1fc8b6a8 100644 --- a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario2A.ts +++ b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario2A.ts @@ -45,7 +45,7 @@ export default async function ExcludeIndividualsA(): Promise { experimentObject.partitions = updateExcludeIfReachedFlag(experimentObject.partitions); // create experiment - await experimentService.create(experimentObject as any, user, new UpgradeLogger()); + await experimentService.create(experimentObject, user, new UpgradeLogger()); const experiments = await experimentService.find(new UpgradeLogger()); expect(experiments).toEqual( expect.arrayContaining([ @@ -140,7 +140,7 @@ export default async function ExcludeIndividualsA(): Promise { }, }, }; - await experimentService.update(experimentObject as any, user, new UpgradeLogger()); + await experimentService.update(experimentObject, user, new UpgradeLogger()); // check stats stats = await analyticsService.getDetailEnrollment(experimentId); diff --git a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario2B.ts b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario2B.ts index be1e31d7f7..fc53682a68 100644 --- a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario2B.ts +++ b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario2B.ts @@ -46,7 +46,7 @@ export default async function ExcludeIndividualsB(): Promise { experimentObject.partitions = updateExcludeIfReachedFlag(experimentObject.partitions); // create experiment - await experimentService.create(experimentObject as any, user, new UpgradeLogger()); + await experimentService.create(experimentObject, user, new UpgradeLogger()); const experiments = await experimentService.find(new UpgradeLogger()); expect(experiments).toEqual( expect.arrayContaining([ @@ -142,7 +142,7 @@ export default async function ExcludeIndividualsB(): Promise { }, }, }; - await experimentService.update(experimentObject as any, user, new UpgradeLogger()); + await experimentService.update(experimentObject, user, new UpgradeLogger()); // check stats stats = await analyticsService.getDetailEnrollment(experimentId); diff --git a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario2C.ts b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario2C.ts index 47b454f939..e5e1153747 100644 --- a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario2C.ts +++ b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario2C.ts @@ -43,7 +43,7 @@ export default async function ExcludeIndividualsC(): Promise { experimentObject.partitions = updateExcludeIfReachedFlag(experimentObject.partitions); // create experiment - await experimentService.create(experimentObject as any, user, new UpgradeLogger()); + await experimentService.create(experimentObject, user, new UpgradeLogger()); const experiments = await experimentService.find(new UpgradeLogger()); expect(experiments).toEqual( expect.arrayContaining([ @@ -139,7 +139,7 @@ export default async function ExcludeIndividualsC(): Promise { }, }, }; - await experimentService.update(experimentObject as any, user, new UpgradeLogger()); + await experimentService.update(experimentObject, user, new UpgradeLogger()); // check stats stats = await analyticsService.getDetailEnrollment(experimentId); diff --git a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario3A.ts b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario3A.ts index 1cdd1100e4..a2164ecfcb 100644 --- a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario3A.ts +++ b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario3A.ts @@ -43,7 +43,7 @@ export default async function ExcludeGroupsC(): Promise { experimentObject.partitions = updateExcludeIfReachedFlag(experimentObject.partitions); // create experiment - await experimentService.create(experimentObject as any, user, new UpgradeLogger()); + await experimentService.create(experimentObject, user, new UpgradeLogger()); const experiments = await experimentService.find(new UpgradeLogger()); expect(experiments).toEqual( expect.arrayContaining([ @@ -139,7 +139,7 @@ export default async function ExcludeGroupsC(): Promise { }, }, }; - await experimentService.update(experimentObject as any, user, new UpgradeLogger()); + await experimentService.update(experimentObject, user, new UpgradeLogger()); // check stats stats = await analyticsService.getDetailEnrollment(experimentId); diff --git a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario3B.ts b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario3B.ts index 35f7cf6948..f7915a585d 100644 --- a/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario3B.ts +++ b/backend/packages/Upgrade/test/integration/ExperimentUser/Scenario3B.ts @@ -43,7 +43,7 @@ export default async function ExcludeGroupsB(): Promise { experimentObject.partitions = updateExcludeIfReachedFlag(experimentObject.partitions); // create experiment - await experimentService.create(experimentObject as any, user, new UpgradeLogger()); + await experimentService.create(experimentObject, user, new UpgradeLogger()); const experiments = await experimentService.find(new UpgradeLogger()); expect(experiments).toEqual( expect.arrayContaining([ @@ -139,7 +139,7 @@ export default async function ExcludeGroupsB(): Promise { }, }, }; - await experimentService.update(experimentObject as any, user, new UpgradeLogger()); + await experimentService.update(experimentObject, user, new UpgradeLogger()); // check stats stats = await analyticsService.getDetailEnrollment(experimentId); diff --git a/backend/packages/Upgrade/test/integration/ExperimentUser/WorkingGroupChangeTest1.ts b/backend/packages/Upgrade/test/integration/ExperimentUser/WorkingGroupChangeTest1.ts index 600deb3a53..56ec31e9f7 100644 --- a/backend/packages/Upgrade/test/integration/ExperimentUser/WorkingGroupChangeTest1.ts +++ b/backend/packages/Upgrade/test/integration/ExperimentUser/WorkingGroupChangeTest1.ts @@ -29,7 +29,7 @@ export default async function testCase(): Promise { experimentObject.partitions = updateExcludeIfReachedFlag(experimentObject.partitions); // create experiment - await experimentService.create(experimentObject as any, user, new UpgradeLogger()); + await experimentService.create(experimentObject, user, new UpgradeLogger()); const experiments = await experimentService.find(new UpgradeLogger()); expect(experiments).toEqual( expect.arrayContaining([ diff --git a/backend/packages/Upgrade/test/integration/ExperimentUser/WorkingGroupChangeTest2.ts b/backend/packages/Upgrade/test/integration/ExperimentUser/WorkingGroupChangeTest2.ts index d58c4929cd..c377c7988a 100644 --- a/backend/packages/Upgrade/test/integration/ExperimentUser/WorkingGroupChangeTest2.ts +++ b/backend/packages/Upgrade/test/integration/ExperimentUser/WorkingGroupChangeTest2.ts @@ -29,7 +29,7 @@ export default async function testCase(): Promise { experimentObject.partitions = updateExcludeIfReachedFlag(experimentObject.partitions); // create experiment - await experimentService.create(experimentObject as any, user, new UpgradeLogger()); + await experimentService.create(experimentObject, user, new UpgradeLogger()); const experiments = await experimentService.find(new UpgradeLogger()); expect(experiments).toEqual( expect.arrayContaining([ diff --git a/backend/packages/Upgrade/test/integration/mockData/experiment/index.ts b/backend/packages/Upgrade/test/integration/mockData/experiment/index.ts index 8355b1497b..b1725cbabd 100644 --- a/backend/packages/Upgrade/test/integration/mockData/experiment/index.ts +++ b/backend/packages/Upgrade/test/integration/mockData/experiment/index.ts @@ -15,6 +15,8 @@ import { POST_EXPERIMENT_RULE, EXPERIMENT_STATE, CONDITION_ORDER, + EXPERIMENT_TYPE, + ASSIGNMENT_ALGORITHM, } from 'upgrade_types'; function clone(data: T): T { @@ -27,6 +29,8 @@ export const individualAssignmentExperiment = clone({ assignmentUnit: ASSIGNMENT_UNIT.INDIVIDUAL, postExperimentRule: POST_EXPERIMENT_RULE.CONTINUE, state: EXPERIMENT_STATE.INACTIVE, + logging: false, + type: EXPERIMENT_TYPE.SIMPLE, }); export const individualAssignmentGroupConsistencyExperiment = clone({ @@ -35,6 +39,8 @@ export const individualAssignmentGroupConsistencyExperiment = clone({ assignmentUnit: ASSIGNMENT_UNIT.INDIVIDUAL, postExperimentRule: POST_EXPERIMENT_RULE.CONTINUE, state: EXPERIMENT_STATE.INACTIVE, + logging: false, + type: EXPERIMENT_TYPE.SIMPLE, }); export const individualAssignmentExperimentConsistencyRuleRevertToExperiment = clone({ @@ -48,6 +54,8 @@ export const individualAssignmentExperimentConsistencyRuleExperiment = clone({ postExperimentRule: POST_EXPERIMENT_RULE.ASSIGN, revertTo: getExperiment().conditions[0].id, state: EXPERIMENT_STATE.INACTIVE, + logging: false, + type: EXPERIMENT_TYPE.SIMPLE, }); export const groupAssignmentWithGroupConsistencyExperiment = clone({ @@ -56,6 +64,8 @@ export const groupAssignmentWithGroupConsistencyExperiment = clone({ assignmentUnit: ASSIGNMENT_UNIT.GROUP, postExperimentRule: POST_EXPERIMENT_RULE.CONTINUE, state: EXPERIMENT_STATE.INACTIVE, + logging: false, + type: EXPERIMENT_TYPE.SIMPLE, }); export const groupAssignmentWithGroupConsistencyExperiment2 = clone({ @@ -64,6 +74,8 @@ export const groupAssignmentWithGroupConsistencyExperiment2 = clone({ assignmentUnit: ASSIGNMENT_UNIT.GROUP, postExperimentRule: POST_EXPERIMENT_RULE.CONTINUE, state: EXPERIMENT_STATE.INACTIVE, + logging: false, + type: EXPERIMENT_TYPE.SIMPLE, }); export const groupAssignmentWithIndividualConsistencyExperiment = clone({ @@ -72,6 +84,8 @@ export const groupAssignmentWithIndividualConsistencyExperiment = clone({ assignmentUnit: ASSIGNMENT_UNIT.GROUP, postExperimentRule: POST_EXPERIMENT_RULE.CONTINUE, state: EXPERIMENT_STATE.INACTIVE, + logging: false, + type: EXPERIMENT_TYPE.SIMPLE, }); export const groupAssignmentWithExperimentConsistencyExperiment = clone({ @@ -80,6 +94,8 @@ export const groupAssignmentWithExperimentConsistencyExperiment = clone({ assignmentUnit: ASSIGNMENT_UNIT.GROUP, postExperimentRule: POST_EXPERIMENT_RULE.CONTINUE, state: EXPERIMENT_STATE.INACTIVE, + logging: false, + type: EXPERIMENT_TYPE.SIMPLE, }); export const groupAssignmentWithGroupConsistencyExperimentSwitchBeforeAssignment = clone({ @@ -88,6 +104,8 @@ export const groupAssignmentWithGroupConsistencyExperimentSwitchBeforeAssignment assignmentUnit: ASSIGNMENT_UNIT.GROUP, postExperimentRule: POST_EXPERIMENT_RULE.CONTINUE, state: EXPERIMENT_STATE.INACTIVE, + logging: false, + type: EXPERIMENT_TYPE.SIMPLE, }); export const groupAssignmentWithGroupConsistencyExperimentSwitchAfterAssignment = clone({ @@ -96,6 +114,8 @@ export const groupAssignmentWithGroupConsistencyExperimentSwitchAfterAssignment assignmentUnit: ASSIGNMENT_UNIT.GROUP, postExperimentRule: POST_EXPERIMENT_RULE.CONTINUE, state: EXPERIMENT_STATE.INACTIVE, + logging: false, + type: EXPERIMENT_TYPE.SIMPLE, }); export const groupAssignmentWithIndividualConsistencyExperimentSwitchAfterAssignment = clone({ @@ -104,6 +124,8 @@ export const groupAssignmentWithIndividualConsistencyExperimentSwitchAfterAssign assignmentUnit: ASSIGNMENT_UNIT.GROUP, postExperimentRule: POST_EXPERIMENT_RULE.CONTINUE, state: EXPERIMENT_STATE.INACTIVE, + logging: false, + type: EXPERIMENT_TYPE.SIMPLE, }); export const groupAssignmentWithExperimentConsistencyExperimentSwitchAfterAssignment = clone({ @@ -112,6 +134,8 @@ export const groupAssignmentWithExperimentConsistencyExperimentSwitchAfterAssign assignmentUnit: ASSIGNMENT_UNIT.GROUP, postExperimentRule: POST_EXPERIMENT_RULE.CONTINUE, state: EXPERIMENT_STATE.INACTIVE, + logging: false, + type: EXPERIMENT_TYPE.SIMPLE, }); export const firstFactorialExperiment = clone({ @@ -120,6 +144,8 @@ export const firstFactorialExperiment = clone({ assignmentUnit: ASSIGNMENT_UNIT.INDIVIDUAL, postExperimentRule: POST_EXPERIMENT_RULE.CONTINUE, state: EXPERIMENT_STATE.INACTIVE, + logging: false, + type: EXPERIMENT_TYPE.FACTORIAL, }); export const secondFactorialExperiment = clone({ @@ -128,6 +154,8 @@ export const secondFactorialExperiment = clone({ assignmentUnit: ASSIGNMENT_UNIT.INDIVIDUAL, postExperimentRule: POST_EXPERIMENT_RULE.CONTINUE, state: EXPERIMENT_STATE.INACTIVE, + logging: false, + type: EXPERIMENT_TYPE.FACTORIAL, }); export const withinSubjectExperiment = clone({ @@ -140,6 +168,7 @@ export const withinSubjectExperiment = clone({ assignmentWeight: 50, conditionCode: 'Abstract', twoCharacterId: 'AB', + order: 1 }, { id: 'd2702d3c-5e04-41a7-8766-1da8a95b72ce', @@ -148,11 +177,14 @@ export const withinSubjectExperiment = clone({ assignmentWeight: 50, conditionCode: 'Concrete', twoCharacterId: 'CN', + order: 2 }, ], assignmentUnit: ASSIGNMENT_UNIT.WITHIN_SUBJECTS, conditionOrder: CONDITION_ORDER.RANDOM, consistencyRule: null, + logging: false, + type: EXPERIMENT_TYPE.SIMPLE, }); // exclusion code experiments: @@ -537,6 +569,7 @@ export const stratificationSRSExperimentAssignmentExperiment1 = clone({ assignmentWeight: 50, conditionCode: 'Abstract', twoCharacterId: 'AB', + order: 1 }, { id: 'd2702d3c-5e04-41a7-8766-1da8a95b72ce', @@ -545,11 +578,14 @@ export const stratificationSRSExperimentAssignmentExperiment1 = clone({ assignmentWeight: 50, conditionCode: 'Concrete', twoCharacterId: 'CN', + order: 2 }, ], conditionOrder: CONDITION_ORDER.RANDOM, consistencyRule: null, - assignmentAlgorithm: 'stratified random sampling', + assignmentAlgorithm: ASSIGNMENT_ALGORITHM.STRATIFIED_RANDOM_SAMPLING, + logging: false, + type: EXPERIMENT_TYPE.SIMPLE, }); export const stratificationRandomExperimentAssignmentExperiment2 = clone({ @@ -562,6 +598,7 @@ export const stratificationRandomExperimentAssignmentExperiment2 = clone({ assignmentWeight: 50, conditionCode: 'Abstract', twoCharacterId: 'AB', + order: 1 }, { id: 'd2702d3c-5e04-41a7-8766-1da8a95b72ce', @@ -570,8 +607,11 @@ export const stratificationRandomExperimentAssignmentExperiment2 = clone({ assignmentWeight: 50, conditionCode: 'Concrete', twoCharacterId: 'CN', + order: 2 }, ], conditionOrder: CONDITION_ORDER.RANDOM, consistencyRule: null, + logging: false, + type: EXPERIMENT_TYPE.SIMPLE, }); diff --git a/backend/packages/Upgrade/test/integration/mockData/experiment/raw.ts b/backend/packages/Upgrade/test/integration/mockData/experiment/raw.ts index e52dc89ae1..b80068bca2 100644 --- a/backend/packages/Upgrade/test/integration/mockData/experiment/raw.ts +++ b/backend/packages/Upgrade/test/integration/mockData/experiment/raw.ts @@ -1,5 +1,5 @@ import { METRICS_JOIN_TEXT } from '../../../../src/api/services/MetricService'; -import { EXPERIMENT_TYPE, FILTER_MODE, OPERATION_TYPES, REPEATED_MEASURE } from 'upgrade_types'; +import { ASSIGNMENT_ALGORITHM, ASSIGNMENT_UNIT, EXPERIMENT_STATE, EXPERIMENT_TYPE, FILTER_MODE, OPERATION_TYPES, REPEATED_MEASURE, CONSISTENCY_RULE, POST_EXPERIMENT_RULE, SEGMENT_TYPE } from 'upgrade_types'; export const revertToExperiment = { id: 'be3ae74f-370a-4015-93f3-7761d16f8b11', @@ -80,18 +80,18 @@ export const experiment = { id: 'be3ae74f-370a-4015-93f3-7761d16f8b17', name: 'Test Experiment', description: 'Test Experiment Description', - consistencyRule: 'individual', - assignmentUnit: 'individual', - postExperimentRule: 'continue', - state: 'scheduled', - startOn: new Date().toISOString(), + consistencyRule: CONSISTENCY_RULE.INDIVIDUAL, + assignmentUnit: ASSIGNMENT_UNIT.INDIVIDUAL, + postExperimentRule: POST_EXPERIMENT_RULE.CONTINUE, + state: EXPERIMENT_STATE.SCHEDULED, + startOn: new Date(), group: 'teacher', context: ['home'], tags: [], queries: [], filterMode: FILTER_MODE.INCLUDE_ALL, - experimentSegmentInclusion: { segment: { individualForSegment: [], groupForSegment: [{"groupId": "All", "type": "All"}], subSegments: [] } }, - experimentSegmentExclusion: { segment: { individualForSegment: [], groupForSegment: [], subSegments: [] } }, + experimentSegmentInclusion: { segment: { individualForSegment: [], groupForSegment: [{"groupId": "All", "type": "All"}], type: SEGMENT_TYPE.PRIVATE, subSegments: []} }, + experimentSegmentExclusion: { segment: { individualForSegment: [], groupForSegment: [], type: SEGMENT_TYPE.PRIVATE, subSegments: [] } }, conditions: [ { id: 'c22467b1-f0e9-4444-9517-cc03037bc079', @@ -100,6 +100,7 @@ export const experiment = { assignmentWeight: 40, conditionCode: 'ConditionA', twoCharacterId: 'CA', + order: 1, }, { id: 'd2702d3c-5e04-41a7-8766-1da8a95b72ce', @@ -108,34 +109,41 @@ export const experiment = { assignmentWeight: 60, conditionCode: 'ConditionB', twoCharacterId: 'CB', + order: 2, }, ], partitions: [ { + id: 'd2702d3c-5e04-41a7-8766-1da8a95b72de', site: 'CurriculumSequence', target: 'W1', description: 'Decision Point on Workspace 1', twoCharacterId: 'W1', excludeIfReached: false, + order: 1, }, { + id: 'd2702d3c-5e04-41a7-8766-1da8a95b72fe', site: 'CurriculumSequence', target: 'W2', description: 'Decision Point on Workspace 2', twoCharacterId: 'W2', excludeIfReached: false, + order: 2, }, { + id: 'd2702d3c-5e04-41a7-8766-1da8a95b72ae', site: 'CurriculumSequence', description: 'No Decision Point', twoCharacterId: 'NP', excludeIfReached: false, + order: 3, }, ], conditionPayloads: [], backendVersion: '1.0.0', groupSatisfied: 0, - assignmentAlgorithm: 'random', + assignmentAlgorithm: ASSIGNMENT_ALGORITHM.RANDOM, }; export const experimentSecond = { @@ -162,6 +170,7 @@ export const experimentSecond = { assignmentWeight: 40, conditionCode: 'ConditionA', twoCharacterId: 'BA', + order: 1, }, { id: '439a6fef-901d-4f0c-bca8-25f06e9e6262', @@ -170,6 +179,7 @@ export const experimentSecond = { assignmentWeight: 60, conditionCode: 'ConditionB', twoCharacterId: 'BB', + order: 2, }, ], partitions: [ @@ -179,6 +189,7 @@ export const experimentSecond = { description: 'Decision Point on Workspace 1', twoCharacterId: 'X1', excludeIfReached: false, + order: 1, }, { site: 'CurriculumSequence2', @@ -186,6 +197,7 @@ export const experimentSecond = { description: 'Decision Point on Workspace 2', twoCharacterId: 'X2', excludeIfReached: false, + order: 2, }, ], conditionPayloads: [], @@ -218,6 +230,7 @@ export const experimentThird = { assignmentWeight: 40, conditionCode: 'ConditionA', twoCharacterId: 'AA', + order: 1, }, { id: '8c7b2951-f9a7-4d2e-a1ed-0572e1ede879', @@ -226,6 +239,7 @@ export const experimentThird = { assignmentWeight: 60, conditionCode: 'ConditionB', twoCharacterId: 'AB', + order: 2, }, ], partitions: [ @@ -235,6 +249,7 @@ export const experimentThird = { description: 'Decision Point on Workspace 1', twoCharacterId: 'Y1', excludeIfReached: false, + order: 1, }, { site: 'CurriculumSequence3', @@ -242,6 +257,7 @@ export const experimentThird = { description: 'Decision Point on Workspace 2', twoCharacterId: 'Y2', excludeIfReached: false, + order: 2, }, ], conditionPayloads: [], @@ -274,6 +290,7 @@ export const experimentFourth = { assignmentWeight: 55.5, conditionCode: 'ConditionA', twoCharacterId: 'AA', + order: 1, }, { id: '8c7b2951-f9a7-4d2e-a1ed-0572e1ede878', @@ -282,6 +299,7 @@ export const experimentFourth = { assignmentWeight: 44.5, conditionCode: 'ConditionB', twoCharacterId: 'AB', + order: 2, }, ], partitions: [ @@ -291,6 +309,7 @@ export const experimentFourth = { description: 'Decision Point on Workspace 1', twoCharacterId: 'Y1', excludeIfReached: false, + order: 1, }, { site: 'CurriculumSequence3', @@ -298,6 +317,7 @@ export const experimentFourth = { description: 'Decision Point on Workspace 2', twoCharacterId: 'Y2', excludeIfReached: false, + order: 2, }, ], conditionPayloads: [], @@ -331,6 +351,7 @@ export const experimentFifth = { assignmentWeight: 40, conditionCode: 'ConditionA', twoCharacterId: 'CA', + order: 1, }, { id: 'd2702d3c-5e04-41a7-8766-1da8a95b72ce', @@ -339,6 +360,7 @@ export const experimentFifth = { assignmentWeight: 60, conditionCode: 'ConditionB', twoCharacterId: 'CB', + order: 2, }, ], partitions: [ @@ -349,6 +371,7 @@ export const experimentFifth = { description: 'Decision Point on Workspace 1', twoCharacterId: 'W1', excludeIfReached: false, + order: 1, }, { id: 'e22467b1-f0e9-4444-9517-cc03037bc079', @@ -357,6 +380,7 @@ export const experimentFifth = { description: 'Decision Point on Workspace 2', twoCharacterId: 'W2', excludeIfReached: false, + order: 2, }, { id: 'f22467b1-f0e9-4444-9517-cc03037bc079', @@ -364,6 +388,7 @@ export const experimentFifth = { description: 'No Decision Point', twoCharacterId: 'NP', excludeIfReached: false, + order: 3, }, ], conditionPayloads: [ @@ -415,6 +440,7 @@ export const experimentSixth = { assignmentWeight: 40, conditionCode: 'ConditionA', twoCharacterId: 'CA', + order: 1, }, { id: 'd2702d3c-5e04-41a7-8766-1da8a95b72ce', @@ -423,6 +449,7 @@ export const experimentSixth = { assignmentWeight: 60, conditionCode: 'ConditionB', twoCharacterId: 'CB', + order: 2, }, ], partitions: [ @@ -433,6 +460,7 @@ export const experimentSixth = { description: 'Decision Point on Workspace 1', twoCharacterId: 'W1', excludeIfReached: false, + order: 1, }, { id: 'e22467b1-f0e9-4444-9517-cc03037bc079', @@ -441,6 +469,7 @@ export const experimentSixth = { description: 'Decision Point on Workspace 2', twoCharacterId: 'W2', excludeIfReached: false, + order: 2, }, ], conditionPayloads: [], diff --git a/backend/packages/Upgrade/test/integration/utils/index.ts b/backend/packages/Upgrade/test/integration/utils/index.ts index 7736445cc1..ebaca7b6e5 100644 --- a/backend/packages/Upgrade/test/integration/utils/index.ts +++ b/backend/packages/Upgrade/test/integration/utils/index.ts @@ -13,11 +13,11 @@ import { UpgradeLogger } from '../../../src/lib/logger/UpgradeLogger'; import { ExperimentUserService } from '../../../src/api/services/ExperimentUserService'; import { DecisionPoint } from 'src/api/models/DecisionPoint'; -export function updateExcludeIfReachedFlag(partitions: DecisionPoint[]): DecisionPoint[] { +export function updateExcludeIfReachedFlag(partitions: Array>>): DecisionPoint[] { partitions.forEach((partition) => { partition.excludeIfReached = true; }); - return partitions; + return partitions as DecisionPoint[]; } import { IndividualExclusionRepository } from '../../../src/api/repositories/IndividualExclusionRepository';