Skip to content

Commit

Permalink
Add ability to wait for element in specific table in E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
treiher committed Dec 23, 2024
1 parent 4da3add commit 893d693
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 65 deletions.
4 changes: 2 additions & 2 deletions tests/e2e/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,12 @@ def click_delete(self, index: int) -> None:
buttons[index].click()
self.wait_for_dialog()

def wait_for_table_value(self, row: int, column: int, text: str) -> None:
def wait_for_table_value(self, table: int, row: int, column: int, text: str) -> None:
wait(self._driver).until(
EC.text_to_be_present_in_element(
(
By.XPATH,
f"//table[contains(@class, 'is-hoverable')]/tbody/tr[{row}]/td[{column}]",
f"(//table[contains(@class, 'is-hoverable')])[{table}]/tbody/tr[{row}]/td[{column}]",
),
text,
)
Expand Down
126 changes: 63 additions & 63 deletions tests/e2e/web_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def test_body_weight_add(driver: webdriver.Chrome) -> None:

page.body_weight_dialog.click_save()

page.wait_for_table_value(1, 1, date)
page.wait_for_table_value(1, 2, weight)
page.wait_for_table_value(1, 1, 1, date)
page.wait_for_table_value(1, 1, 2, weight)


def test_body_weight_edit(driver: webdriver.Chrome) -> None:
Expand All @@ -157,22 +157,22 @@ def test_body_weight_edit(driver: webdriver.Chrome) -> None:
page = BodyWeightPage(driver)
page.load()

page.wait_for_table_value(1, 1, date)
page.wait_for_table_value(1, 2, weight)
page.wait_for_table_value(1, 1, 1, date)
page.wait_for_table_value(1, 1, 2, weight)

page.click_edit(0)
page.body_weight_dialog.set_weight(new_weight)
page.body_weight_dialog.click_cancel()

page.wait_for_table_value(1, 1, date)
page.wait_for_table_value(1, 2, weight)
page.wait_for_table_value(1, 1, 1, date)
page.wait_for_table_value(1, 1, 2, weight)

page.click_edit(0)
page.body_weight_dialog.set_weight(new_weight)
page.body_weight_dialog.click_save()

page.wait_for_table_value(1, 1, date)
page.wait_for_table_value(1, 2, new_weight)
page.wait_for_table_value(1, 1, 1, date)
page.wait_for_table_value(1, 1, 2, new_weight)


def test_body_weight_delete(driver: webdriver.Chrome) -> None:
Expand All @@ -184,19 +184,19 @@ def test_body_weight_delete(driver: webdriver.Chrome) -> None:
page = BodyWeightPage(driver)
page.load()

page.wait_for_table_value(1, 1, date_1)
page.wait_for_table_value(1, 2, weight)
page.wait_for_table_value(1, 1, 1, date_1)
page.wait_for_table_value(1, 1, 2, weight)

page.click_delete(0)
page.delete_dialog.click_no()

page.wait_for_table_value(1, 1, date_1)
page.wait_for_table_value(1, 2, weight)
page.wait_for_table_value(1, 1, 1, date_1)
page.wait_for_table_value(1, 1, 2, weight)

page.click_delete(0)
page.delete_dialog.click_yes()

page.wait_for_table_value(1, 1, date_2)
page.wait_for_table_value(1, 1, 1, date_2)


def test_body_fat_add(driver: webdriver.Chrome) -> None:
Expand Down Expand Up @@ -228,9 +228,9 @@ def test_body_fat_add(driver: webdriver.Chrome) -> None:

page.body_fat_dialog.click_save()

page.wait_for_table_value(1, 1, date)
page.wait_for_table_value(1, 1, 1, date)
for i, v in enumerate(values, start=4):
page.wait_for_table_value(1, i, v)
page.wait_for_table_value(1, 1, i, v)


def test_body_fat_edit(driver: webdriver.Chrome) -> None:
Expand All @@ -251,25 +251,25 @@ def test_body_fat_edit(driver: webdriver.Chrome) -> None:
page = BodyFatPage(driver)
page.load()

page.wait_for_table_value(1, 1, date)
page.wait_for_table_value(1, 1, 1, date)
for i, v in enumerate(values, start=4):
page.wait_for_table_value(1, i, v)
page.wait_for_table_value(1, 1, i, v)

page.click_edit(0)
page.body_fat_dialog.set_jp7(new_values)
page.body_fat_dialog.click_cancel()

page.wait_for_table_value(1, 1, date)
page.wait_for_table_value(1, 1, 1, date)
for i, v in enumerate(values, start=4):
page.wait_for_table_value(1, i, v)
page.wait_for_table_value(1, 1, i, v)

page.click_edit(0)
page.body_fat_dialog.set_jp7(new_values)
page.body_fat_dialog.click_save()

page.wait_for_table_value(1, 1, date)
page.wait_for_table_value(1, 1, 1, date)
for i, v in enumerate(new_values, start=4):
page.wait_for_table_value(1, i, v)
page.wait_for_table_value(1, 1, i, v)


def test_body_fat_delete(driver: webdriver.Chrome) -> None:
Expand All @@ -280,17 +280,17 @@ def test_body_fat_delete(driver: webdriver.Chrome) -> None:
page = BodyFatPage(driver)
page.load()

page.wait_for_table_value(1, 1, date_1)
page.wait_for_table_value(1, 1, 1, date_1)

page.click_delete(0)
page.delete_dialog.click_no()

page.wait_for_table_value(1, 1, date_1)
page.wait_for_table_value(1, 1, 1, date_1)

page.click_delete(0)
page.delete_dialog.click_yes()

page.wait_for_table_value(1, 1, date_2)
page.wait_for_table_value(1, 1, 1, date_2)


def test_menstrual_cycle_add(driver: webdriver.Chrome) -> None:
Expand Down Expand Up @@ -320,8 +320,8 @@ def test_menstrual_cycle_add(driver: webdriver.Chrome) -> None:

page.period_dialog.click_save()

page.wait_for_table_value(1, 1, date)
page.wait_for_table_value(1, 2, intensity)
page.wait_for_table_value(1, 1, 1, date)
page.wait_for_table_value(1, 1, 2, intensity)


def test_menstrual_cycle_edit(driver: webdriver.Chrome) -> None:
Expand All @@ -336,22 +336,22 @@ def test_menstrual_cycle_edit(driver: webdriver.Chrome) -> None:
page = MenstrualCyclePage(driver)
page.load()

page.wait_for_table_value(1, 1, date)
page.wait_for_table_value(1, 2, intensity)
page.wait_for_table_value(1, 1, 1, date)
page.wait_for_table_value(1, 1, 2, intensity)

page.click_edit(0)
page.period_dialog.set_period(new_intensity)
page.period_dialog.click_cancel()

page.wait_for_table_value(1, 1, date)
page.wait_for_table_value(1, 2, intensity)
page.wait_for_table_value(1, 1, 1, date)
page.wait_for_table_value(1, 1, 2, intensity)

page.click_edit(0)
page.period_dialog.set_period(new_intensity)
page.period_dialog.click_save()

page.wait_for_table_value(1, 1, date)
page.wait_for_table_value(1, 2, new_intensity)
page.wait_for_table_value(1, 1, 1, date)
page.wait_for_table_value(1, 1, 2, new_intensity)


def test_menstrual_cycle_delete(driver: webdriver.Chrome) -> None:
Expand All @@ -364,19 +364,19 @@ def test_menstrual_cycle_delete(driver: webdriver.Chrome) -> None:
page = MenstrualCyclePage(driver)
page.load()

page.wait_for_table_value(1, 1, date_1)
page.wait_for_table_value(1, 2, intensity)
page.wait_for_table_value(1, 1, 1, date_1)
page.wait_for_table_value(1, 1, 2, intensity)

page.click_delete(0)
page.delete_dialog.click_no()

page.wait_for_table_value(1, 1, date_1)
page.wait_for_table_value(1, 2, intensity)
page.wait_for_table_value(1, 1, 1, date_1)
page.wait_for_table_value(1, 1, 2, intensity)

page.click_delete(0)
page.delete_dialog.click_yes()

page.wait_for_table_value(1, 1, date_2)
page.wait_for_table_value(1, 1, 1, date_2)


def test_training_links(driver: webdriver.Chrome) -> None:
Expand Down Expand Up @@ -452,19 +452,19 @@ def test_training_delete(driver: webdriver.Chrome) -> None:
page = TrainingPage(driver)
page.load()

page.wait_for_table_value(1, 1, date_1)
page.wait_for_table_value(1, 2, routine)
page.wait_for_table_value(1, 1, 1, date_1)
page.wait_for_table_value(1, 1, 2, routine)

page.click_delete(0)
page.delete_dialog.click_no()

page.wait_for_table_value(1, 1, date_1)
page.wait_for_table_value(1, 2, routine)
page.wait_for_table_value(1, 1, 1, date_1)
page.wait_for_table_value(1, 1, 2, routine)

page.click_delete(0)
page.delete_dialog.click_yes()

page.wait_for_table_value(1, 1, date_2)
page.wait_for_table_value(1, 1, 1, date_2)


def test_training_session(driver: webdriver.Chrome) -> None:
Expand Down Expand Up @@ -606,7 +606,7 @@ def test_routines_add(driver: webdriver.Chrome) -> None:

page.routines_dialog.click_cancel()

page.wait_for_table_value(2, 1, name)
page.wait_for_table_value(1, 2, 1, name)

page.click_fab()

Expand All @@ -615,7 +615,7 @@ def test_routines_add(driver: webdriver.Chrome) -> None:
page.routines_dialog.set_name(new_name)
page.routines_dialog.click_save()

page.wait_for_table_value(2, 1, new_name)
page.wait_for_table_value(1, 2, 1, new_name)


def test_routines_edit(driver: webdriver.Chrome) -> None:
Expand All @@ -628,19 +628,19 @@ def test_routines_edit(driver: webdriver.Chrome) -> None:
page = RoutinesPage(driver)
page.load()

page.wait_for_table_value(1, 1, name)
page.wait_for_table_value(1, 1, 1, name)

page.click_edit(0)
page.routines_dialog.set_name(new_name)
page.routines_dialog.click_cancel()

page.wait_for_table_value(1, 1, name)
page.wait_for_table_value(1, 1, 1, name)

page.click_edit(0)
page.routines_dialog.set_name(new_name)
page.routines_dialog.click_save()

page.wait_for_table_value(1, 1, new_name)
page.wait_for_table_value(1, 1, 1, new_name)


def test_routines_delete(driver: webdriver.Chrome) -> None:
Expand All @@ -651,19 +651,19 @@ def test_routines_delete(driver: webdriver.Chrome) -> None:
page = RoutinesPage(driver)
page.load()

page.wait_for_table_value(1, 1, name_2)
page.wait_for_table_value(2, 1, name_1)
page.wait_for_table_value(1, 1, 1, name_2)
page.wait_for_table_value(1, 2, 1, name_1)

page.click_delete(0)
page.delete_dialog.click_no()

page.wait_for_table_value(1, 1, name_2)
page.wait_for_table_value(2, 1, name_1)
page.wait_for_table_value(1, 1, 1, name_2)
page.wait_for_table_value(1, 2, 1, name_1)

page.click_delete(0)
page.delete_dialog.click_yes()

page.wait_for_table_value(1, 1, name_1)
page.wait_for_table_value(1, 1, 1, name_1)


def test_routine_edit_save(driver: webdriver.Chrome) -> None:
Expand Down Expand Up @@ -1302,7 +1302,7 @@ def test_exercises_add(driver: webdriver.Chrome) -> None:

page.exercises_dialog.click_cancel()

page.wait_for_table_value(1, 1, name)
page.wait_for_table_value(1, 1, 1, name)

page.click_fab()

Expand All @@ -1311,7 +1311,7 @@ def test_exercises_add(driver: webdriver.Chrome) -> None:
page.exercises_dialog.set_name(new_name)
page.exercises_dialog.click_save()

page.wait_for_table_value(1, 1, new_name)
page.wait_for_table_value(1, 1, 1, new_name)


def test_exercises_edit(driver: webdriver.Chrome) -> None:
Expand All @@ -1325,19 +1325,19 @@ def test_exercises_edit(driver: webdriver.Chrome) -> None:
page = ExercisesPage(driver)
page.load()

page.wait_for_table_value(1, 1, name)
page.wait_for_table_value(1, 1, 1, name)

page.click_edit(0)
page.exercises_dialog.set_name(new_name)
page.exercises_dialog.click_cancel()

page.wait_for_table_value(1, 1, name)
page.wait_for_table_value(1, 1, 1, name)

page.click_edit(0)
page.exercises_dialog.set_name(new_name)
page.exercises_dialog.click_save()

page.wait_for_table_value(1, 1, new_name)
page.wait_for_table_value(1, 1, 1, new_name)


def test_exercises_delete(driver: webdriver.Chrome) -> None:
Expand All @@ -1349,17 +1349,17 @@ def test_exercises_delete(driver: webdriver.Chrome) -> None:
page = ExercisesPage(driver)
page.load()

page.wait_for_table_value(1, 1, name_1)
page.wait_for_table_value(1, 1, 1, name_1)

page.click_delete(0)
page.delete_dialog.click_no()

page.wait_for_table_value(1, 1, name_1)
page.wait_for_table_value(1, 1, 1, name_1)

page.click_delete(0)
page.delete_dialog.click_yes()

page.wait_for_table_value(1, 1, name_2)
page.wait_for_table_value(1, 1, 1, name_2)


def test_exercise_delete_workout(driver: webdriver.Chrome) -> None:
Expand All @@ -1372,14 +1372,14 @@ def test_exercise_delete_workout(driver: webdriver.Chrome) -> None:
page = ExercisePage(driver, exercise.id)
page.load()

page.wait_for_table_value(1, 1, workout_1)
page.wait_for_table_value(1, 1, 1, workout_1)

page.click_delete(0)
page.delete_dialog.click_no()

page.wait_for_table_value(1, 1, workout_1)
page.wait_for_table_value(1, 1, 1, workout_1)

page.click_delete(0)
page.delete_dialog.click_yes()

page.wait_for_table_value(1, 1, workout_2)
page.wait_for_table_value(1, 1, 1, workout_2)

0 comments on commit 893d693

Please sign in to comment.