Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Interface Tests #354

Merged
merged 2 commits into from
Nov 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
bandit
coverage
coveralls
flake8
mock
selenium
52 changes: 52 additions & 0 deletions .github/selenium-tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env python3

import sys

from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.common.by import By


BASE_URL = 'http://admin:opencast@127.0.0.1:5000'

driver = None


def navigate(path):
driver.get(f'{BASE_URL}{path}')


def wait_for(driver, element, timeout=20):
return WebDriverWait(driver, timeout).until(
expected_conditions.presence_of_element_located(element))


def check_pyca():
print('%-30s' % 'Testing pyCA header…', end='')
navigate('/')
elem = driver.find_element(By.TAG_NAME, 'header')
assert 'pyCA' == elem.text
print('✓')

print('%-30s' % 'Testing FontAwesome…', end='')
wait_for(driver, (By.CSS_SELECTOR, 'span.action'), timeout=0.2)
elem = driver.find_elements(By.CSS_SELECTOR, 'span.action svg')[0]
assert elem.get_attribute('role') == 'img'
print('✓')

print('%-30s' % 'Testing recordings table…', end='')
selector = '#recordings tbody tr'
wait_for(driver, (By.CSS_SELECTOR, selector), timeout=0.2)
recording_rows = driver.find_elements(By.CSS_SELECTOR, selector)
assert len(recording_rows) == 4
print('✓')


if __name__ == '__main__':
options = webdriver.FirefoxOptions()
if sys.argv[-1] != 'gui':
options.headless = True
driver = webdriver.Firefox(options=options)
check_pyca()
driver.close()
Binary file added .github/test.db.gz
Binary file not shown.
24 changes: 19 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- 3.7
- 3.8
- 3.9
- '3.10'

steps:
- name: install libgnutls28-dev
Expand All @@ -30,18 +31,31 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: install dependencies
run: |
pip install flake8 bandit mock coverage coveralls
pip install -r requirements.txt
npm ci
- name: install Python dependencies
run: pip install -r requirements.txt

- name: install JavaScript dependencies
run: npm ci

- name: install test dependencies
run: pip install -r .github/requirements.txt

- name: lint code
run: make lint

- name: run test
run: make test

- name: start user interface
run: |
gunzip .github/test.db.gz
mv .github/test.db pyca.db
./start.sh ui &
sleep 2

- name: run user interface integration tests
run: ./.github/selenium-tests

- name: upload test coverage to coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ all: lint test
export DOCKER_BUILDKIT=1

lint:
@flake8 $$(find pyca tests -name '*.py')
@flake8 $$(find pyca tests -name '*.py') .github/selenium-tests
@bandit pyca tests
@npm run eslint

Expand Down
3 changes: 2 additions & 1 deletion ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ <h1>
<div>Processed</div>
<div class=inactive>{{ processed }}</div>
</div>
</div>
</summary>

<main class=center>
Expand All @@ -57,7 +58,7 @@ <h2>Preview Images</h2>
<div v-else>No preview image</div>
</section>

<section>
<section id=recordings>
<h2>Recordings</h2>

<table>
Expand Down