Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -2223,11 +2223,9 @@ export class ExperimentAssignmentService {
const explicitGroupExclusionFilteredData: { groupId: string; type: string; id: string }[] = [];

const userGroups = [];
if (experimentUser.group) {
Object.keys(experimentUser.group).forEach((type) => {
experimentUser.group[type].forEach((groupId) => {
userGroups.push({ type, groupId });
});
if (experimentUser.workingGroup) {
Object.keys(experimentUser.workingGroup).forEach((type) => {
userGroups.push({ type, groupId: experimentUser.workingGroup[type] });
});
}
Comment on lines +2226 to 2230
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true that we need to worry about groupsForSession, but experimentUser.group and experimentUser.workingGroup are not the same type.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ describe('Experiment Assignment Service Test', () => {
expect(includedExperiment).toEqual([exp]);
});

it('[experimentLevelExclusionInclusion] should return an exclusion reason if a user or userGroup is on exclusion list', async () => {
const userDoc = { id: 'user2', group: { teacher: ['teacher1'] }, workingGroup: {} };
it('[experimentLevelExclusionInclusion] should return an exclusion reason if a user workingGroup is on exclusion list', async () => {
const userDoc = { id: 'user2', group: { teacher: ['teacher1'] }, workingGroup: { teacher: 'teacher1' } };
const exp = structuredClone(simpleIndividualAssignmentExperiment);
const [includedExperiment, exclusionReason] = await testedModule.experimentLevelExclusionInclusion([exp], userDoc);
expect(exclusionReason.length).toEqual(1);
Expand All @@ -568,6 +568,18 @@ describe('Experiment Assignment Service Test', () => {
expect(includedExperiment).toEqual([]);
});

it('[experimentLevelExclusionInclusion] should not return an exclusion reason if a user workingGroup is not on exclusion list', async () => {
const userDoc = {
id: 'user2',
group: { teacher: ['teacher1', 'teacher2'] },
workingGroup: { teacher: 'teacher2' },
};
const exp = structuredClone(simpleIndividualAssignmentExperiment);
const [includedExperiment, exclusionReason] = await testedModule.experimentLevelExclusionInclusion([exp], userDoc);
Comment on lines +571 to +578
expect(exclusionReason.length).toEqual(0);
expect(includedExperiment).toEqual([exp]);
});

it('[createExperimentPool] should return empty pool of experiments for no active experiments', async () => {
const expResult = await testedModule.createExperimentPool([]);
expect(expResult).toEqual([]);
Expand Down