Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: MI Assign home screen (M2-7405) #530

Merged
merged 9 commits into from
Sep 5, 2024
51 changes: 20 additions & 31 deletions src/abstract/lib/GroupBuilder/ActivityGroupsBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const getActivity = (): Entity => {
order: 0,
type: ActivityType.NotDefined,
image: null,
autoAssign: true,
};
return result;
};
Expand Down Expand Up @@ -98,6 +99,7 @@ const getExpectedItem = (): ActivityListItem => {
timeLeftToComplete: null,
isInActivityFlow: false,
image: null,
targetSubject: null,
};
return expectedItem;
};
Expand Down Expand Up @@ -152,6 +154,7 @@ const getScheduledEventEntity = (settings: {
timer: null,
},
},
targetSubject: null,
};
return result;
};
Expand All @@ -175,6 +178,7 @@ const getAlwaysAvailableEventEntity = (settings: { scheduledAt: Date }): EventEn
timer: null,
},
},
targetSubject: null,
};

return result;
Expand Down Expand Up @@ -903,8 +907,6 @@ describe('ActivityGroupsBuilder', () => {
progress,
};

let builder = createActivityGroupsBuilder(input);

const eventEntity: EventEntity = getScheduledEventEntity({
scheduledAt,
startDate: subDays(startOfDay(scheduledAt), 2),
Expand All @@ -929,7 +931,7 @@ describe('ActivityGroupsBuilder', () => {
progress,
};

builder = createActivityGroupsBuilder(input);
const builder = createActivityGroupsBuilder(input);

const now = addMinutes(scheduledAt, 10);

Expand All @@ -939,18 +941,9 @@ describe('ActivityGroupsBuilder', () => {
expect(result).toEqual(expectedResult);
});

it('5Should not return group-item for scheduled event and periodicity is Weekly and allowAccessBeforeFromTime is false when started yesterday, but not completed yet', () => {
it('Should not return group-item for scheduled event and periodicity is Weekly and allowAccessBeforeFromTime is false when started yesterday, but not completed yet', () => {
const scheduledAt = new Date(2023, 8, 1, 15, 0, 0);

let progress: GroupProgressState = getEmptyProgress();

let input: GroupsBuildContext = {
allAppletActivities: [],
progress,
};

let builder = createActivityGroupsBuilder(input);

const eventEntity: EventEntity = getScheduledEventEntity({
scheduledAt,
startDate: subDays(startOfDay(scheduledAt), 2),
Expand All @@ -968,14 +961,14 @@ describe('ActivityGroupsBuilder', () => {
activities: [],
};

progress = getProgress(subDays(scheduledAt, 1), null);
const progress = getProgress(subDays(scheduledAt, 1), null);

input = {
const input = {
allAppletActivities: [],
progress,
};

builder = createActivityGroupsBuilder(input);
const builder = createActivityGroupsBuilder(input);

const now = addMinutes(scheduledAt, 10);

Expand Down Expand Up @@ -1108,8 +1101,6 @@ describe('ActivityGroupsBuilder', () => {
eventEntity.event.availability.startDate = subMonths(now, 3);
eventEntity.event.availability.endDate = subMonths(now, 2);

let result = builder.buildAvailable([eventEntity]);

const expectedItem = getExpectedAvailableItem();
expectedItem.availableTo = new Date(startOfDay(scheduledAt));
expectedItem.availableTo.setHours(16);
Expand All @@ -1121,7 +1112,7 @@ describe('ActivityGroupsBuilder', () => {
activities: [],
};

result = builder.buildAvailable([eventEntity]);
const result = builder.buildAvailable([eventEntity]);
expect(result).toEqual(expectedEmptyResult);
});

Expand Down Expand Up @@ -1154,8 +1145,6 @@ describe('ActivityGroupsBuilder', () => {
eventEntity.event.availability.startDate = subMonths(now, 2);
eventEntity.event.availability.endDate = addMonths(now, 2);

let result = builder.buildAvailable([eventEntity]);

const expectedItem = getExpectedAvailableItem();
expectedItem.availableTo = new Date(startOfDay(scheduledAt));
expectedItem.availableTo.setHours(16);
Expand All @@ -1170,7 +1159,7 @@ describe('ActivityGroupsBuilder', () => {
activities: [expectedItem],
};

result = builder.buildAvailable([eventEntity]);
const result = builder.buildAvailable([eventEntity]);

expect(result).toEqual(expectedResult);
});
Expand Down Expand Up @@ -1375,8 +1364,6 @@ describe('ActivityGroupsBuilder', () => {
eventEntity.event.availability.startDate = addMonths(now, 2);
eventEntity.event.availability.endDate = addMonths(now, 3);

let result = builder.buildScheduled([eventEntity]);

const expectedItem: ActivityListItem = getExpectedScheduledItem();
expectedItem.availableFrom = startOfDay(scheduledAt);
expectedItem.availableFrom.setHours(15);
Expand All @@ -1390,7 +1377,7 @@ describe('ActivityGroupsBuilder', () => {
activities: [expectedItem],
};

result = builder.buildScheduled([eventEntity]);
const result = builder.buildScheduled([eventEntity]);

expect(result).toEqual(expectedEmptyResult);
});
Expand Down Expand Up @@ -1424,8 +1411,6 @@ describe('ActivityGroupsBuilder', () => {
eventEntity.event.availability.startDate = subMonths(now, 3);
eventEntity.event.availability.endDate = subMonths(now, 2);

let result = builder.buildScheduled([eventEntity]);

const expectedItem: ActivityListItem = getExpectedScheduledItem();
expectedItem.availableFrom = startOfDay(scheduledAt);
expectedItem.availableFrom.setHours(15);
Expand All @@ -1439,7 +1424,7 @@ describe('ActivityGroupsBuilder', () => {
activities: [expectedItem],
};

result = builder.buildScheduled([eventEntity]);
const result = builder.buildScheduled([eventEntity]);

expect(result).toEqual(expectedEmptyResult);
});
Expand Down Expand Up @@ -1471,8 +1456,6 @@ describe('ActivityGroupsBuilder', () => {
eventEntity.event.availability.timeFrom = { hours: 15, minutes: 0 };
eventEntity.event.availability.timeTo = { hours: 16, minutes: 30 };

let result = builder.buildScheduled([eventEntity]);

const expectedItem: ActivityListItem = getExpectedScheduledItem();
expectedItem.availableFrom = startOfDay(scheduledAt);
expectedItem.availableFrom.setHours(15);
Expand Down Expand Up @@ -1500,7 +1483,7 @@ describe('ActivityGroupsBuilder', () => {
eventEntity.event.availability.startDate = subMonths(now, 2);
eventEntity.event.availability.endDate = addMonths(now, 2);

result = builder.buildScheduled([eventEntity]);
const result = builder.buildScheduled([eventEntity]);
expect(result).toEqual(expectedResult);
});

Expand Down Expand Up @@ -1611,6 +1594,7 @@ describe('ActivityGroupsBuilder', () => {
type: ActivityType.NotDefined,
order: 0,
image: null,
autoAssign: true,
},
{
description: 'test-description-2',
Expand All @@ -1621,6 +1605,7 @@ describe('ActivityGroupsBuilder', () => {
type: ActivityType.NotDefined,
order: 1,
image: null,
autoAssign: true,
},
],
progress,
Expand All @@ -1638,6 +1623,7 @@ describe('ActivityGroupsBuilder', () => {
isHidden: false,
order: 0,
image: null,
autoAssign: true,
};

const eventEntity: EventEntity = {
Expand All @@ -1656,6 +1642,7 @@ describe('ActivityGroupsBuilder', () => {
timer: null,
},
},
targetSubject: null,
};

let result = builder.buildInProgress([eventEntity]);
Expand Down Expand Up @@ -1684,6 +1671,7 @@ describe('ActivityGroupsBuilder', () => {
numberOfActivitiesInFlow: 2,
activityPositionInFlow: 1,
},
targetSubject: null,
},
],
name: 'additional.in_progress',
Expand Down Expand Up @@ -1725,6 +1713,7 @@ describe('ActivityGroupsBuilder', () => {
numberOfActivitiesInFlow: 2,
activityPositionInFlow: 2,
},
targetSubject: null,
},
],
name: 'additional.in_progress',
Expand Down
24 changes: 12 additions & 12 deletions src/abstract/lib/GroupBuilder/ActivityGroupsBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ export class ActivityGroupsBuilder implements IActivityGroupsBuilder {
this.utility = new GroupUtility(inputParams);
}

public buildInProgress(eventsActivities: Array<EventEntity>): ActivityListGroup {
const filtered = eventsActivities.filter((x) => this.utility.isInProgress(x));
public buildInProgress(eventEntities: Array<EventEntity>): ActivityListGroup {
const filtered = eventEntities.filter((x) => this.utility.isInProgress(x));

const activityItems: Array<ActivityListItem> = [];

for (const eventActivity of filtered) {
const item = this.itemsFactory.createProgressItem(eventActivity);
for (const eventEntity of filtered) {
const item = this.itemsFactory.createProgressItem(eventEntity);

activityItems.push(item);
}
Expand All @@ -52,13 +52,13 @@ export class ActivityGroupsBuilder implements IActivityGroupsBuilder {
return result;
}

public buildAvailable(eventsEntities: Array<EventEntity>): ActivityListGroup {
const filtered = this.availableEvaluator.evaluate(eventsEntities);
public buildAvailable(eventEntities: Array<EventEntity>): ActivityListGroup {
const filtered = this.availableEvaluator.evaluate(eventEntities);

const activityItems: Array<ActivityListItem> = [];

for (const eventActivity of filtered) {
const item = this.itemsFactory.createAvailableItem(eventActivity);
for (const eventEntity of filtered) {
const item = this.itemsFactory.createAvailableItem(eventEntity);

activityItems.push(item);
}
Expand All @@ -72,13 +72,13 @@ export class ActivityGroupsBuilder implements IActivityGroupsBuilder {
return result;
}

public buildScheduled(eventsEntities: Array<EventEntity>): ActivityListGroup {
const filtered = this.scheduledEvaluator.evaluate(eventsEntities);
public buildScheduled(eventEntities: Array<EventEntity>): ActivityListGroup {
const filtered = this.scheduledEvaluator.evaluate(eventEntities);

const activityItems: Array<ActivityListItem> = [];

for (const eventActivity of filtered) {
const item = this.itemsFactory.createScheduledItem(eventActivity);
for (const eventEntity of filtered) {
const item = this.itemsFactory.createScheduledItem(eventEntity);

activityItems.push(item);
}
Expand Down
2 changes: 2 additions & 0 deletions src/abstract/lib/GroupBuilder/AvailableGroupBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const getActivity = (): Entity => {
order: 0,
type: ActivityType.NotDefined,
image: null,
autoAssign: true,
};
return result;
};
Expand Down Expand Up @@ -104,6 +105,7 @@ const getScheduledEventEntity = (settings: {
timer: null,
},
},
targetSubject: null,
};

return result;
Expand Down
Loading
Loading