Skip to content

Commit

Permalink
Merged branch feature/tests-for-time-plans into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
horia141 committed Jul 4, 2024
1 parent 071d509 commit 2126afb
Show file tree
Hide file tree
Showing 22 changed files with 2,077 additions and 135 deletions.
1,852 changes: 1,852 additions & 0 deletions itests/entities/test_time_plans.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion itests/entities/test_vacations.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_vacation_create_note(page: Page, create_vacation) -> None:

page.locator('#editorjs div[contenteditable="true"]').first.fill("This is a note.")

page.wait_for_url("/workspace/vacations/*")
page.wait_for_url(re.compile(r"/workspace/vacations/\d+"))

expect(page.locator('#editorjs div[contenteditable="true"]').first).to_contain_text(
"This is a note."
Expand Down
3 changes: 3 additions & 0 deletions scripts/run-itests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ dev_mode() {
esac
done

echo $webapi_url
echo $webui_url

if [[ -z "$webapi_url" ]]; then
webapi_url="http://0.0.0.0:$STANDARD_WEBAPI_PORT"
fi
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""A inbox task collection."""

from jupiter.core.domain.inbox_tasks.inbox_task import InboxTask
from jupiter.core.framework.base.entity_id import EntityId
from jupiter.core.framework.context import DomainContext
from jupiter.core.framework.entity import (
ContainsMany,
IsRefId,
ParentLink,
TrunkEntity,
create_entity_action,
Expand All @@ -16,6 +19,8 @@ class InboxTaskCollection(TrunkEntity):

workspace: ParentLink

inbox_tasks = ContainsMany(InboxTask, inbox_task_collection_ref_id=IsRefId())

@staticmethod
@create_entity_action
def new_inbox_task_collection(
Expand Down
12 changes: 10 additions & 2 deletions src/core/jupiter/core/domain/infra/generic_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ async def generic_loader( # type: ignore[no-untyped-def]
entity_link1.the_type
).find_all_generic(
parent_ref_id=None,
allow_archived=allow_subentity_archived,
allow_archived=allow_archived or allow_subentity_archived,
**entity_link1.get_for_entity(entity),
)

Expand All @@ -305,6 +305,10 @@ async def generic_loader( # type: ignore[no-untyped-def]
final_first_linked_entities = (
first_linked_entities[0] if len(first_linked_entities) > 0 else None
)
elif not allow_subentity_archived:
final_first_linked_entities = [
f for f in first_linked_entities if not f.archived
]
else:
final_first_linked_entities = first_linked_entities

Expand All @@ -322,7 +326,7 @@ async def generic_loader( # type: ignore[no-untyped-def]
entity_link2.the_type
).find_all_generic(
parent_ref_id=None,
allow_archived=allow_subentity_archived,
allow_archived=allow_archived or allow_subentity_archived,
**entity_link2.get_for_entity(entity),
)

Expand Down Expand Up @@ -355,6 +359,10 @@ async def generic_loader( # type: ignore[no-untyped-def]
if len(second_linked_entities) > 0
else None
)
elif not allow_subentity_archived:
final_second_linked_entities = [
f for f in second_linked_entities if not f.archived
]
else:
final_second_linked_entities = second_linked_entities

Expand Down
2 changes: 2 additions & 0 deletions src/core/jupiter/core/domain/named_entity_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
class NamedEntityTag(EnumValue):
"""A tag for all known entities."""

SCORE_LOG_ENTRY = "ScoreLogEntry" # ScoreLogEntry.__name__

INBOX_TASK = "InboxTask" # InboxTask.__name__
WORKING_MEM = "WorkingMem" # WorkingMem.__name__
TIME_PLAN = "TimePlan" # TimePlan.__name__
Expand Down
5 changes: 5 additions & 0 deletions src/core/jupiter/core/domain/persons/person_collection.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""The person collection."""

from jupiter.core.domain.persons.person import Person
from jupiter.core.framework.base.entity_id import EntityId
from jupiter.core.framework.context import DomainContext
from jupiter.core.framework.entity import (
ContainsMany,
IsRefId,
ParentLink,
TrunkEntity,
create_entity_action,
Expand All @@ -18,6 +21,8 @@ class PersonCollection(TrunkEntity):
workspace: ParentLink
catch_up_project_ref_id: EntityId

persons = ContainsMany(Person, person_collection_ref_id=IsRefId())

@staticmethod
@create_entity_action
def new_person_collection(
Expand Down
10 changes: 7 additions & 3 deletions src/core/jupiter/core/domain/time_plans/time_plan_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def new_activity_from_existing(
existing_activity_kind: TimePlanActivityKind,
existing_activity_feasability: TimePlanActivityFeasability,
) -> "TimePlanActivity":
"""Create a new actvity from an existing one."""
return TimePlanActivity._create(
ctx,
name=existing_activity_name,
Expand All @@ -82,9 +83,10 @@ def new_activity_for_inbox_task(
kind: TimePlanActivityKind,
feasability: TimePlanActivityFeasability,
) -> "TimePlanActivity":
"""Create a new activity from an inbox task."""
return TimePlanActivity._create(
ctx,
name=TimePlanActivity.build_name(
name=TimePlanActivity._build_name(
TimePlanActivityTarget.INBOX_TASK, inbox_task_ref_id
),
time_plan=ParentLink(time_plan_ref_id),
Expand All @@ -103,9 +105,10 @@ def new_activity_for_big_plan(
kind: TimePlanActivityKind,
feasability: TimePlanActivityFeasability,
) -> "TimePlanActivity":
"""Create a new activity from a big plan."""
return TimePlanActivity._create(
ctx,
name=TimePlanActivity.build_name(
name=TimePlanActivity._build_name(
TimePlanActivityTarget.INBOX_TASK, big_plan_ref_id
),
time_plan=ParentLink(time_plan_ref_id),
Expand All @@ -122,14 +125,15 @@ def update(
kind: UpdateAction[TimePlanActivityKind],
feasability: UpdateAction[TimePlanActivityFeasability],
) -> "TimePlanActivity":
"""Update the details of an activity."""
return self._new_version(
ctx,
kind=kind.or_else(self.kind),
feasability=feasability.or_else(self.feasability),
)

@staticmethod
def build_name(target: TimePlanActivityTarget, entity_id: EntityId) -> EntityName:
def _build_name(target: TimePlanActivityTarget, entity_id: EntityId) -> EntityName:
return EntityName(f"Work on {target.value!s} {entity_id}")


Expand Down
2 changes: 1 addition & 1 deletion src/core/jupiter/core/framework/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def save(self, record: RecordT) -> RecordT:
"""Save a record."""

@abc.abstractmethod
async def remove(self, record: RecordT) -> RecordT:
async def remove(self, record: RecordT) -> None:
"""Hard remove a record - an irreversible operation."""

@abc.abstractmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def find_completed_in_range(
filter_end_completed_date: ADate,
filter_exclude_ref_ids: Iterable[EntityId] | None = None,
) -> list[BigPlan]:
"""find all completed big plans in a time range."""
"""Find all completed big plans in a time range."""
query_stmt = select(self._table).where(
self._table.c.big_plan_collection_ref_id == parent_ref_id.as_int(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async def save(self, record: ScoreStats) -> ScoreStats:
)
return record

async def remove(self, record: ScoreStats) -> ScoreStats:
async def remove(self, record: ScoreStats) -> None:
"""Remove a score stats."""
result = await self._connection.execute(
delete(self._score_stats_table)
Expand All @@ -176,7 +176,6 @@ async def remove(self, record: ScoreStats) -> ScoreStats:
raise RecordNotFoundError(
f"The score stats {record.key[0]}:{record.key[1]}:{record.key[2]} does not exist"
)
return self._row_to_entity(result)

async def load_by_key_optional(
self, key: tuple[EntityId, RecurringTaskPeriod | None, str]
Expand Down Expand Up @@ -317,7 +316,7 @@ async def save(self, record: ScorePeriodBest) -> ScorePeriodBest:
)
return record

async def remove(self, record: ScorePeriodBest) -> ScorePeriodBest:
async def remove(self, record: ScorePeriodBest) -> None:
"""Remove a score period best."""
result = await self._connection.execute(
delete(self._score_period_best_table)
Expand All @@ -337,7 +336,6 @@ async def remove(self, record: ScorePeriodBest) -> ScorePeriodBest:
raise RecordNotFoundError(
f"The score period best {record.key[0]}:{record.key[1]}:{record.key[2]}:{record.key[3]} does not exist"
)
return self._row_to_entity(result)

async def load_by_key_optional(
self, key: tuple[EntityId, RecurringTaskPeriod | None, str, RecurringTaskPeriod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async def find_completed_in_range(
filter_include_sources: Iterable[InboxTaskSource],
filter_exclude_ref_ids: Iterable[EntityId] | None = None,
) -> list[InboxTask]:
"""find all completed inbox tasks in a time range."""
"""Find all completed inbox tasks in a time range."""
query_stmt = select(self._table).where(
self._table.c.inbox_task_collection_ref_id == parent_ref_id.as_int(),
)
Expand Down
2 changes: 1 addition & 1 deletion src/core/jupiter/core/use_cases/time_plans/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async def _perform_transactional_read(
],
)

if args.include_completed_nontarget and target_big_plans:
if args.include_completed_nontarget and target_big_plans is not None:
completed_nontarget_big_plans = await uow.get(
BigPlanRepository
).find_completed_in_range(
Expand Down
5 changes: 4 additions & 1 deletion src/webui/app/components/big-plan-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export function BigPlanCard(props: BigPlanCardProps) {
: undefined
}
>
<EntityLink to={`/workspace/big-plans/${props.bigPlan.ref_id}`}>
<EntityLink
to={`/workspace/big-plans/${props.bigPlan.ref_id}`}
block={props.onClick !== undefined}
>
<EntityNameComponent
compact={props.compact}
name={props.bigPlan.name}
Expand Down
2 changes: 1 addition & 1 deletion src/webui/app/components/infra/layout/branch-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export function BranchPanel(props: PropsWithChildren<BranchPanelProps>) {

{props.showArchiveButton && (
<IconButton
id="leaf-entity-archive"
id="branch-entity-archive"
sx={{ marginLeft: "auto" }}
disabled={!props.enableArchiveButton}
type="submit"
Expand Down
25 changes: 13 additions & 12 deletions src/webui/app/components/infra/section-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,22 @@ export function NavSingle(desc: Omit<NavSingleDesc, "kind">): NavSingleDesc {
}

export function NavMultipleSpread(
...navs: Array<NavSingleDesc>
desc: Omit<Omit<NavMultipleDesc, "kind">, "approach">
): NavMultipleDesc {
return {
kind: "nav-multiple",
approach: "spread",
navs: navs,
...desc,
};
}

export function NavMultipleCompact(
desc: Omit<Omit<NavMultipleDesc, "kind">, "approach">
): NavMultipleDesc {
return {
kind: "nav-multiple",
approach: "compact",
...desc,
};
}

Expand All @@ -132,16 +142,6 @@ export function ActionMultipleSpread(
};
}

export function NavMultipleCompact(
...navs: Array<NavSingleDesc>
): NavMultipleDesc {
return {
kind: "nav-multiple",
approach: "compact",
navs: navs,
};
}

export function FilterFewOptions<K>(
defaultOption: K,
options: Array<FilterOption<K>>,
Expand Down Expand Up @@ -483,6 +483,7 @@ function NavMultipleCompactView(props: NavMultipleViewProps) {
{realActions[selectedIndex].text}
</Button>
<Button
id="section-action-nav-multiple-compact-button"
size="small"
disabled={!props.inputsEnabled}
onClick={() => setOpen((prevOpen) => !prevOpen)}
Expand Down
5 changes: 3 additions & 2 deletions src/webui/app/components/infra/section-card-new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { Card, CardContent, Chip, styled } from "@mui/material";
import type { PropsWithChildren } from "react";

interface SectionCardNewProps {
id?: string;
title: string;
actions: JSX.Element;
actions?: JSX.Element;
}

export function SectionCardNew(props: PropsWithChildren<SectionCardNewProps>) {
return (
<StyledCard>
<StyledCard id={props.id}>
<SectionHeader>
<SectionTitle label={props.title} />
{props.actions}
Expand Down
Loading

0 comments on commit 2126afb

Please sign in to comment.