Commit 20647618 authored by Esther Vogt's avatar Esther Vogt
Browse files

Merge branch 'development' into 'master'

Deploy final version

See merge request !11
parents d8736029 6e5f73a2
Pipeline #171591 passed with stage
in 30 seconds
......@@ -6,4 +6,5 @@ node_modules/
# Generated by Cordova
#/plugins/
platforms/browser/www/
/chromedriver.exe
/.pytest_cache/
......@@ -57,13 +57,13 @@
</div>
<div class="col-lg-6"></div>
</div>
</div>
<div class="row">
<div>Update a team</div>
<input id="update-id" type="text" placeholder="Id of team">
<input id="update-name" type="text" placeholder="Name of team">
<input id="update-athlete" type="text" placeholder="Athlete">
<input id="update-id" type="text" placeholder="Id of team">
<input type="button" id="update-button">
<input type="button" id="update-button" value="Submit">
</div>
<div class="row">
<div id="all_teams">Here's your teams:</div>
......@@ -113,7 +113,7 @@
<template id="template-teams">
<!-- I need a drop down list with the athletes of the coach -->
<div class="team">
<div class="name"></div>
<div class="coach"></div>
......@@ -153,7 +153,7 @@
<template id="template-file">
<a class="me-2 link-block" href="#"></a>
</template>
</div>
<script src="scripts/defaults.js"></script>
<script src="scripts/scripts.js"></script>
<script src="scripts/myathletes.js"></script>
......
......@@ -318,7 +318,9 @@ async function printTeam(){
let coach = teamTeam.querySelector(".coach")
name.innerText = "Team Name & id: " + teamName + "; " + id + "."
coach.innerText = "Coach: " + teamCoach
athleteContainer.innerText = teamMembers
if (teamMembers!=null) {
athleteContainer.innerText = "My Athletes: "+ teamMembers
}
teamContainers.appendChild(teamTeam)
}
}
......@@ -378,6 +380,7 @@ async function addAthletes(){
// arr.append(athlete.username)
// }
let response = await sendRequest("PUT", url, body);
if (response.ok){location.reload();}
}
......
......@@ -2,6 +2,13 @@
}
*/
.hide {
display: none !important;
}
......@@ -121,4 +128,9 @@
.fade-in {
opacity: 0;
animation: fadeIn 0.5s ease-in 1 forwards ;
}
.team{
margin: 10px;
border: 1px solid #ced4da;
border-radius: 0.25rem;
}
\ No newline at end of file
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
import pytest
from selenium import webdriver
from selenium.webdriver import Remote, DesiredCapabilities
from tests.utils import *
import yaml
def pytest_addoption(parser):
""" Parse pytest --option variables from shell """
parser.addoption('--browser', help='Which test browser?', default='chrome')
parser.addoption('--local', help='local or CI?', choices=['true', 'false'], default='true')
parser.addoption('--perform_setup', help='w/ or w/o setup?', choices=['true', 'false'], default='true')
@pytest.fixture(scope='session')
def test_browser(request):
""" :returns Browser.NAME from --browser option """
return request.config.getoption('--browser')
@pytest.fixture(scope='session')
def local(request):
""" :returns true or false from --local option """
return request.config.getoption('--local')
@pytest.fixture(scope='session')
def perform_setup(request):
""" :returns true or false from --perform_setup option """
return request.config.getoption('--perform_setup')
@pytest.fixture(scope='session')
def load_users():
# load the yaml file containing the user details
with open("tests/data/user.yml") as f:
users = yaml.load(f, Loader=yaml.FullLoader)
return users
@pytest.fixture(scope='session')
def load_workouts():
# load the yaml file containing the user details
with open("tests/data/workouts.yml") as f:
workouts = yaml.load(f, Loader=yaml.FullLoader)
return workouts
@pytest.fixture(scope='session', autouse=True)
def setUp(perform_setup, load_users, load_workouts, remote_browser, base_url):
"""
Note: this setup will only be called once per session
"""
# create the users
if perform_setup == 'true':
for userid, user_data in load_users.items():
create_account(remote_browser, base_url, user_data)
print(f'User Account for "{userid}" created.')
# create corresponding workouts
user_workouts = {k: v for k, v in load_workouts.items() if k.startswith(user_data['username'])}
for workoutid, workout_data in user_workouts.items():
create_workout(remote_browser, base_url, workout_data)
print(f'Workout "{workoutid}" created.')
# create comments on workouts
# retrieve all comments
workout_comments = {v['name']: list(v['comments'].values()) for k, v in load_workouts.items() if 'comments' in v.keys()}
for workout_name, comments in workout_comments.items():
# loop over all comments per workout
for comment in comments:
# login the comment owner #TODO: group comments first to reduce logins
owner = comment['owner_username']
login(remote_browser, base_url, load_users[owner]['username'], load_users[owner]['password'])
# redirect comment owner to workouts page (default tab "All Workouts" should display the given workout)
remote_browser.get(urljoin(base_url, 'workouts.html'))
# get list of displayed workouts and corresponding hrefs
workouts_displayed, hrefs = get_displayed_workouts(remote_browser, base_url, '//*[@id="list-all-workouts-list"]')
# click on given workout
for w, h in dict(zip(workouts_displayed, hrefs)).items():
if w == workout_name:
# follow link to workout details page
remote_browser.get(h)
# find comment text area
remote_browser.find_element(by=By.ID, value='comment-area').send_keys(comment['content'])
# submit
click_element(remote_browser, '//*[@id="post-comment"]')
# check if click was successful
# create_comments(remote_browser, base_url, workout_data['comments'])
@pytest.fixture(scope='session')
def base_url(request):
""" :returns base_url based on --local option """
local = request.config.getoption('--local')
if request.config.getoption('--local') == 'true':
# note: don't use localhost:9090 since this cannot be found from inside the selenium container
base_url = 'http://host.docker.internal:9090'
elif request.config.getoption('--local') == 'false':
# TODO: replace by .env vars
base_url = 'https://secfit-group32-frontend-dev.herokuapp.com'
else:
raise ValueError(f'--local={local}". Base_url could not be determined.')
return base_url
@pytest.fixture(scope='session')
def remote_browser(test_browser, local) -> Remote:
""" Select configuration depends on browser and host """
if local != 'true' and local != 'false':
raise ValueError(f'--local={local}". Driver could not be setup.\n'
'pass "true" if local execute\n'
'pass "false" if use CI service')
cmd_executor = {
'true': 'http://localhost:4444',
'false': f'http://selenium__standalone-{test_browser}:4444'
}
if test_browser == 'firefox':
driver = webdriver.Remote(
options=webdriver.FirefoxOptions(),
command_executor=cmd_executor[local])
elif test_browser == 'chrome':
options = webdriver.ChromeOptions()
if local == 'true':
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(options=options)
else:
driver = webdriver.Remote(
options=options,
command_executor=cmd_executor[local])
else:
raise ValueError(
f'--browser="{test_browser}" is not chrome or firefox')
yield driver
driver.quit()
[pytest]
;python_files = test_exercises_bva.py
python_files = tests.py test_*.py *_tests.py
junit_logging = system-out
addopts = --perform_setup false --verbose --junitxml=report.xml
;addopts = --perform_setup false --verbose --html=report.html
\ No newline at end of file
pytest
pytest-dependency
selenium
urllib3
pyyaml
pytest-html
coach1:
username: 'coach1'
email: 'coach1@domain.com'
password: 'coach1pw'
password1: 'coach1pw'
role: 'Coach'
coach: ''
athlete1:
username: 'athlete1'
email: 'athlete1@domain.com'
password: 'athlete1pw'
password1: 'athlete1pw'
role: 'Athlete'
coach: 'coach1'
athlete2:
username: 'athlete2'
email: 'athlete2@domain.com'
password: 'athlete2pw'
password1: 'athlete2pw'
role: 'Athlete'
coach: 'coach1'
\ No newline at end of file
athlete1workout1:
name: 'workout1a1'
owner_username: 'athlete1'
visibility: 'Public'
notes: 'workout1a1'
files:
workoutfile1: 'tests\data\workout-file.jpg'
comments:
comment1:
owner_username: 'athlete1'
content: 'some comment'
athlete1workout2:
name: 'workout2a1'
owner_username: 'athlete1'
visibility: 'Coach'
notes: 'workout2a1'
athlete1workout3:
name: 'workout3a1'
owner_username: 'athlete1'
visibility: 'Private'
notes: 'workout3a1'
coach1workout1:
name: 'workout1c1'
owner_username: 'coach1'
visibility: 'Public'
notes: 'workout1c1'
coach1workout2:
name: 'workout2c1'
owner_username: 'coach1'
visibility: 'Coach'
notes: 'workout2c1'
coach1workout3:
name: 'workout3c1'
owner_username: 'coach1'
visibility: 'Private'
notes: 'workout3c1'
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment