Tests - add missing e2e test (add a workout w/ gpx)

This commit is contained in:
Sam 2023-07-14 17:43:39 +02:00
parent f6b867f076
commit bc15421b39
3 changed files with 138 additions and 0 deletions

View File

@ -87,6 +87,7 @@ jobs:
run: pytest fittrackee -p no:warnings --cov fittrackee --cov-report term-missing
end2end:
name: e2e tests
runs-on: ubuntu-latest
needs: ["python"]
container: python:3.10
@ -131,6 +132,7 @@ jobs:
pytest e2e --driver Remote --capability browserName firefox --selenium-host selenium --selenium-port 4444
end2end_package:
name: e2e tests with package
runs-on: ubuntu-latest
needs: ["python"]
container: python:3.10

109
e2e/test.gpx Normal file
View File

@ -0,0 +1,109 @@
<?xml version='1.0' encoding='UTF-8'?>
<gpx xmlns:gpxdata="http://www.cluetrust.com/XML/GPXDATA/1/0" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:gpxext="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns="http://www.topografix.com/GPX/1/1">'
<metadata/>
<trk>
<name>just a workout</name>
<trkseg>
<trkpt lat="44.68095" lon="6.07367">
<ele>998</ele>
<time>2018-03-13T12:44:45Z</time>
</trkpt>
<trkpt lat="44.68091" lon="6.07367">
<ele>998</ele>
<time>2018-03-13T12:44:50Z</time>
</trkpt>
<trkpt lat="44.6808" lon="6.07364">
<ele>994</ele>
<time>2018-03-13T12:45:00Z</time>
</trkpt>
<trkpt lat="44.68075" lon="6.07364">
<ele>994</ele>
<time>2018-03-13T12:45:05Z</time>
</trkpt>
<trkpt lat="44.68071" lon="6.07364">
<ele>994</ele>
<time>2018-03-13T12:45:10Z</time>
</trkpt>
<trkpt lat="44.68049" lon="6.07361">
<ele>993</ele>
<time>2018-03-13T12:45:30Z</time>
</trkpt>
<trkpt lat="44.68019" lon="6.07356">
<ele>992</ele>
<time>2018-03-13T12:45:55Z</time>
</trkpt>
<trkpt lat="44.68014" lon="6.07355">
<ele>992</ele>
<time>2018-03-13T12:46:00Z</time>
</trkpt>
<trkpt lat="44.67995" lon="6.07358">
<ele>987</ele>
<time>2018-03-13T12:46:15Z</time>
</trkpt>
<trkpt lat="44.67977" lon="6.07364">
<ele>987</ele>
<time>2018-03-13T12:46:30Z</time>
</trkpt>
<trkpt lat="44.67972" lon="6.07367">
<ele>987</ele>
<time>2018-03-13T12:46:35Z</time>
</trkpt>
<trkpt lat="44.67966" lon="6.07368">
<ele>987</ele>
<time>2018-03-13T12:46:40Z</time>
</trkpt>
<trkpt lat="44.67961" lon="6.0737">
<ele>986</ele>
<time>2018-03-13T12:46:45Z</time>
</trkpt>
<trkpt lat="44.67938" lon="6.07377">
<ele>986</ele>
<time>2018-03-13T12:47:05Z</time>
</trkpt>
<trkpt lat="44.67933" lon="6.07381">
<ele>986</ele>
<time>2018-03-13T12:47:10Z</time>
</trkpt>
<trkpt lat="44.67922" lon="6.07385">
<ele>985</ele>
<time>2018-03-13T12:47:20Z</time>
</trkpt>
<trkpt lat="44.67911" lon="6.0739">
<ele>980</ele>
<time>2018-03-13T12:47:30Z</time>
</trkpt>
<trkpt lat="44.679" lon="6.07399">
<ele>980</ele>
<time>2018-03-13T12:47:40Z</time>
</trkpt>
<trkpt lat="44.67896" lon="6.07402">
<ele>980</ele>
<time>2018-03-13T12:47:45Z</time>
</trkpt>
<trkpt lat="44.67884" lon="6.07408">
<ele>979</ele>
<time>2018-03-13T12:47:55Z</time>
</trkpt>
<trkpt lat="44.67863" lon="6.07423">
<ele>981</ele>
<time>2018-03-13T12:48:15Z</time>
</trkpt>
<trkpt lat="44.67858" lon="6.07425">
<ele>980</ele>
<time>2018-03-13T12:48:20Z</time>
</trkpt>
<trkpt lat="44.67842" lon="6.07434">
<ele>979</ele>
<time>2018-03-13T12:48:35Z</time>
</trkpt>
<trkpt lat="44.67837" lon="6.07435">
<ele>979</ele>
<time>2018-03-13T12:48:40Z</time>
</trkpt>
<trkpt lat="44.67822" lon="6.07442">
<ele>975</ele>
<time>2018-03-13T12:48:55Z</time>
</trkpt>
</trkseg>
</trk>
</gpx>

View File

@ -1,3 +1,5 @@
import os
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait
@ -42,3 +44,28 @@ class TestWorkout:
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
def test_user_can_add_workout_with_gpx(self, selenium):
register_valid_user(selenium)
app_menu = selenium.find_element(By.CLASS_NAME, 'nav-items-app-menu')
add_workout_link = app_menu.find_elements(By.CLASS_NAME, 'nav-item')[3]
add_workout_link.click()
selenium.implicitly_wait(1)
select = Select(selenium.find_element(By.ID, 'sport'))
select.select_by_index(1)
gpx_input = selenium.find_element(By.XPATH, "//input[@type='file']")
gpx_input.send_keys(os.getcwd() + "/e2e/test.gpx")
confirm_button = selenium.find_elements(By.CLASS_NAME, 'confirm')[-1]
confirm_button.click()
WebDriverWait(selenium, 30).until(
EC.url_changes(f"{TEST_URL}/workouts/add")
)
workout_details = selenium.find_element(By.ID, 'workout-info').text
assert 'Duration: 0:04:10' in workout_details
assert 'Distance: 0.32 km' in workout_details
assert 'Average Speed: 4.61 km/h' in workout_details