diff --git a/RIGS/tests/pages.py b/RIGS/tests/pages.py index 4fa8534e..161d43bb 100644 --- a/RIGS/tests/pages.py +++ b/RIGS/tests/pages.py @@ -304,3 +304,43 @@ class UserPage(BasePage): def generate_key(self): self.find_element(*self._generation_button_selector).click() + + +class CalendarPage(BasePage): + URL_TEMPLATE = 'rigboard/calendar' + + _go_locator = (By.ID, 'go-to-date-button') + + _today_selector = (By.ID, 'today-button') + + _prev_selector = (By.ID, 'prev-button') + _next_selector = (By.ID, 'next-button') + + _month_selector = (By.ID, 'month-button') + _week_selector = (By.ID, 'week-button') + _day_selector = (By.ID, 'day-button') + + def go(self): + return self.find_element(*self._go_locator).click() + + @property + def target_date(self): + return regions.DatePicker(self, self.find_element(By.ID, 'go-to-date-input')) + + def today(self): + return self.find_element(*self._today_selector).click() + + def prev(self): + return self.find_element(*self._prev_selector).click() + + def next(self): + return self.find_element(*self._next_selector).click() + + def month(self): + return self.find_element(*self._month_selector).click() + + def week(self): + return self.find_element(*self._week_selector).click() + + def day(self): + return self.find_element(*self._day_selector).click() diff --git a/RIGS/tests/test_interaction.py b/RIGS/tests/test_interaction.py index 6167ab82..b7855a12 100644 --- a/RIGS/tests/test_interaction.py +++ b/RIGS/tests/test_interaction.py @@ -645,7 +645,18 @@ class TestCalendar(BaseRigboardTest): else: self.assertNotContains(response, "TE E" + str(test) + " ") - # Wow - that was a lot of tests + def test_calendar_buttons(self): # If FullCalendar fails to load for whatever reason, the buttons don't work + self.page = pages.CalendarPage(self.driver, self.live_server_url).open() + self.assertIn(timezone.now().strftime("%Y-%m"), self.driver.current_url) + + target_date = datetime.date(2020, 1, 1) + self.page.target_date.set_value(target_date) + self.page.go() + self.assertIn(self.page.target_date.value.strftime("%Y-%m"), self.driver.current_url) + + self.page.next() + target_date += datetime.timedelta(days=32) + self.assertIn(target_date.strftime("%m"), self.driver.current_url) @screenshot_failure_cls