Skip to content

Commit

Permalink
#177: Add ui-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kaklakariada committed Jul 19, 2021
1 parent 974f8b1 commit 02aaa01
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.itsallcode.whiterabbit.jfxui.testutil.TestUtil;
import org.itsallcode.whiterabbit.jfxui.testutil.model.DayTable;
import org.itsallcode.whiterabbit.jfxui.testutil.model.JavaFxTable;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testfx.api.FxRobot;
Expand Down Expand Up @@ -273,7 +272,6 @@ void higlightedWeekends()
}

@Test
@Disabled("Test is instable")
void higlightedWeekendsUpdatedWhenMonthChanges()
{
final DayTable dayTable = app().dayTable();
Expand All @@ -297,6 +295,22 @@ void higlightedWeekendsUpdatedWhenMonthChanges()
25, 26, 27, 30);
}

@Test
void nextButtonSelectsNextMonth()
{
assertThat(app().getSelectedMonth()).isEqualTo(YearMonth.of(2007, Month.DECEMBER));
app().gotoNextMonth();
assertThat(app().getSelectedMonth()).isEqualTo(YearMonth.of(2008, Month.JANUARY));
}

@Test
void prevButtonSelectsPrevMonth()
{
assertThat(app().getSelectedMonth()).isEqualTo(YearMonth.of(2007, Month.DECEMBER));
app().gotoPreviousMonth();
assertThat(app().getSelectedMonth()).isEqualTo(YearMonth.of(2007, Month.NOVEMBER));
}

@Test
void typingF5UpdatesData()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ public void setSelectedMonth(YearMonth month)
JavaFxUtil.runOnFxApplicationThread(() -> getSelectedMonthComboBox().setValue(month));
}

public void gotoNextMonth()
{
clickButton("#next-month-button");
}

public void gotoPreviousMonth()
{
clickButton("#previous-month-button");
}

private void clickButton(String query)
{
final Button button = robot.lookup(query).queryButton();
robot.clickOn(button);
}

private ComboBox<YearMonth> getSelectedMonthComboBox()
{
return robot.lookup("#selected-month-combobox").queryComboBox();
Expand Down

0 comments on commit 02aaa01

Please sign in to comment.