2020-09-13 21:39:44 +02:00
|
|
|
from selenium.webdriver.support import expected_conditions as EC
|
|
|
|
from selenium.webdriver.support.ui import Select, WebDriverWait
|
|
|
|
|
|
|
|
from .utils import TEST_URL, register_valid_user
|
|
|
|
|
|
|
|
|
2021-01-10 11:39:48 +01:00
|
|
|
class TestWorkout:
|
|
|
|
def test_user_can_add_workout_without_gpx(self, selenium):
|
2020-09-13 21:39:44 +02:00
|
|
|
register_valid_user(selenium)
|
|
|
|
nav_items = selenium.find_elements_by_class_name('nav-item')
|
|
|
|
|
|
|
|
nav_items[3].click()
|
|
|
|
selenium.implicitly_wait(1)
|
|
|
|
radio_buttons = selenium.find_elements_by_class_name(
|
2021-01-10 11:39:48 +01:00
|
|
|
'add-workout-radio'
|
2020-09-13 21:39:44 +02:00
|
|
|
)
|
|
|
|
radio_buttons[1].click()
|
|
|
|
|
2021-01-10 11:39:48 +01:00
|
|
|
selenium.find_element_by_name('title').send_keys('Workout title')
|
2020-09-13 21:39:44 +02:00
|
|
|
select = Select(selenium.find_element_by_name('sport_id'))
|
|
|
|
select.select_by_index(1)
|
2021-01-10 11:39:48 +01:00
|
|
|
selenium.find_element_by_name('workout_date').send_keys('2018-12-20')
|
|
|
|
selenium.find_element_by_name('workout_time').send_keys('14:05')
|
2020-09-13 21:39:44 +02:00
|
|
|
selenium.find_element_by_name('duration').send_keys('01:00:00')
|
|
|
|
selenium.find_element_by_name('distance').send_keys('10')
|
|
|
|
selenium.find_element_by_class_name('btn-primary').click()
|
|
|
|
|
|
|
|
WebDriverWait(selenium, 10).until(
|
2021-01-10 11:39:48 +01:00
|
|
|
EC.url_changes(f"{TEST_URL}/workouts/add")
|
2020-09-13 21:39:44 +02:00
|
|
|
)
|
|
|
|
|
2021-01-10 11:39:48 +01:00
|
|
|
workout_details = selenium.find_element_by_class_name(
|
|
|
|
'workout-details'
|
2020-09-13 21:39:44 +02:00
|
|
|
).text
|
2021-01-10 11:39:48 +01:00
|
|
|
assert 'Duration: 1:00:00' in workout_details
|
|
|
|
assert 'Distance: 10 km' in workout_details
|
|
|
|
assert 'Average speed: 10 km/h' in workout_details
|
|
|
|
assert 'Max. speed: 10 km/h' in workout_details
|