Skip to content

Commit

Permalink
Merge pull request #55 from itsallcode/#54_set_remainder_for_first_ac…
Browse files Browse the repository at this point in the history
…tivity

#54: Set remainder flag for first activity
  • Loading branch information
kaklakariada authored Dec 5, 2020
2 parents a988279 + 378ad46 commit 4726b71
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ See [Release](https://github.com/itsallcode/white-rabbit/releases/tag/v1.2.0) /
### Added

* [#52](https://github.com/itsallcode/white-rabbit/issues/52): Improve keyboard usage for autocomplete text fields, immediately show proposals.
* [#54](https://github.com/itsallcode/white-rabbit/issues/54): First added activity has the remainder flag set.

## [1.1.0] 2020-11-29

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ void toggleRemainderDurationUpdatedAtMinuteTick()
}

@Test
void addActivitySelectRemainder()
void addActivityDeselectRemainder()
{
addActivity();

final JavaFxTable<ActivityPropertyAdapter> activitiesTable = app().activitiesTable().table();
robot.clickOn(activitiesTable.getTableCell(0, "remainder"));
activitiesTable.assertRowContent(0, ActivitiesTableExpectedRow.defaultRow().withRemainder(true).build());
activitiesTable.assertRowContent(0, ActivitiesTableExpectedRow.defaultRow().withRemainder(false).build());
}

@Test
Expand All @@ -249,7 +249,8 @@ void addActivitySelectProject()
final Node projectCell = activitiesTable.getTableCell(0, "project");

robot.doubleClickOn(projectCell).clickOn(projectCell).type(KeyCode.ENTER);
activitiesTable.assertRowContent(0, ActivitiesTableExpectedRow.defaultRow().withProject(PROJECT1).build());
activitiesTable.assertRowContent(0,
ActivitiesTableExpectedRow.defaultRow().withRemainder(true).withProject(PROJECT1).build());
}

@Test
Expand Down Expand Up @@ -321,12 +322,14 @@ private void addActivity()
time().tickMinute();
final ActivitiesTable activities = app().activitiesTable();

final JavaFxTable<ActivityPropertyAdapter> table = activities.table();
final boolean isFirstActivity = table.getRowCount() == 0;
activities.addActivity();

final Builder expectedRowContent = ActivitiesTableExpectedRow.defaultRow();
final Builder expectedRowContent = ActivitiesTableExpectedRow.defaultRow().withRemainder(isFirstActivity);

assertAll(() -> activities.table().assertRowCount(1),
() -> activities.table().assertRowContent(0, expectedRowContent.build()));
assertAll(() -> table.assertRowCount(1),
() -> table.assertRowContent(0, expectedRowContent.build()));
}

private void selectCurrentDay()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ public void addRemainderActivity(Project project, String comment)
final Node projectCell = table.getTableCell(rowIndex, "project");
robot.doubleClickOn(projectCell).clickOn(projectCell).clickOn(project.getLabel());
}
robot.clickOn(table.getTableCell(rowIndex, "remainder"));
final TableCell<?, ?> remainderCell = table.getTableCell(rowIndex, "remainder");
if (!(Boolean) remainderCell.getItem())
{
robot.clickOn(remainderCell);
}
robot.doubleClickOn(table.getTableCell(rowIndex, "comment")).write(comment).type(KeyCode.ENTER);
}

Expand All @@ -54,6 +58,12 @@ public void addActivity(Project project, Duration duration, String comment)
{
final int rowIndex = addActivity();

final TableCell<?, ?> remainderCell = table.getTableCell(rowIndex, "remainder");
if ((Boolean) remainderCell.getItem())
{
robot.clickOn(remainderCell);
}

if (project != null)
{
final Node projectCell = table.getTableCell(rowIndex, "project");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ public Activity add()
{
day.setActivities(new ArrayList<>());
}
final boolean isFirstActivity = getActivities().findAny().isEmpty();

final JsonActivity jsonActivity = new JsonActivity();
jsonActivity.setProjectId("");
jsonActivity.setDuration(Duration.ZERO);
final int newRowIndex = day.getActivities().size();
day.getActivities().add(jsonActivity);

return wrapActivity(jsonActivity, newRowIndex);
final Activity wrappedActivity = wrapActivity(jsonActivity, newRowIndex);
wrappedActivity.setRemainderActivity(isFirstActivity);
return wrappedActivity;
}

public List<Activity> getAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,29 @@ void addWhenActivitiesAreNull()
assertThat(jsonDay.getActivities()).hasSize(1);
}

@Test
void firstAddedActivityHasRemainderFlag()
{
final DayActivities activities = create();
jsonDay.setActivities(new ArrayList<>());

final Activity newActivity = activities.add();

assertThat(newActivity.isRemainderActivity()).as("remainder").isTrue();
}

@Test
void secondAddedActivityDoesNotHaveRemainderFlag()
{
final DayActivities activities = create();
jsonDay.setActivities(new ArrayList<>());

activities.add();
final Activity newActivity = activities.add();

assertThat(newActivity.isRemainderActivity()).as("remainder").isFalse();
}

@Test
void addIncrementsRowIndex()
{
Expand Down

0 comments on commit 4726b71

Please sign in to comment.