-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25ec8d9
commit 68422e4
Showing
9 changed files
with
119 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os | ||
import pytest | ||
from xprocess import ProcessStarter | ||
|
||
@pytest.fixture(scope='session') | ||
def api(xprocess): | ||
port = '5003' | ||
|
||
class Starter(ProcessStarter): | ||
pattern = '.*Running.*' | ||
timeout = 10 | ||
args = ['python', '-m', 'flask', '--app', '../../../../mock_api.py', | ||
'run', '--port', port] | ||
|
||
# Start API | ||
xprocess.ensure('api', Starter) | ||
|
||
yield f'http://localhost:{port}' | ||
|
||
# Stop API | ||
xprocess.getinfo('api').terminate() | ||
|
||
@pytest.fixture(scope='session') | ||
def server(xprocess, api): | ||
port = '5002' | ||
|
||
class Starter(ProcessStarter): | ||
pattern = '.*Running.*' | ||
timeout = 10 | ||
args = ['python', '-m', 'flask', '--app', '../../../../songs2slides', | ||
'run', '--port', port] | ||
env = os.environ | { 'API_URL': api + '/{title}/{artist}/' } | ||
|
||
# Start server | ||
xprocess.ensure('server', Starter) | ||
|
||
yield f'http://localhost:{port}' | ||
|
||
# Stop server | ||
xprocess.getinfo('server').terminate() | ||
|
||
@pytest.fixture(scope='session') | ||
def base_url(server): | ||
return server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Run with: pytest tests/generate_screenshots.py | ||
# (not run by default due to lack of test_* filename prefix) | ||
|
||
from playwright.sync_api import Page | ||
|
||
def test_generate_screenshots(page: Page): | ||
# Set viewport size | ||
page.set_viewport_size({'width': 800, 'height': 380}) | ||
|
||
# Start on homepage | ||
page.goto('/') | ||
|
||
# Click 'Create a Slideshow' | ||
page.get_by_role('link', name='Create a Slideshow').click() | ||
|
||
# Fill in song information | ||
page.get_by_placeholder('Song title').last.fill('Song 1') | ||
page.get_by_placeholder('Song artist').last.fill('Artist A') | ||
page.get_by_role('button', name='Add Song').click() | ||
page.get_by_placeholder('Song title').last.fill('Song 4') | ||
page.get_by_placeholder('Song artist').last.fill('Artist C') | ||
page.get_by_placeholder('Song artist').last.blur() | ||
|
||
# Take step 1 screenshot | ||
page.screenshot(path='screenshots/step-1.png', full_page=True) | ||
|
||
# Click Next | ||
page.get_by_role('button', name='Next').click() | ||
|
||
# Uncollapse Song 1 | ||
page.get_by_text('Song 1 (Artist A)').click() | ||
|
||
# Shrink textareas (for a more compact screenshot) | ||
page.add_style_tag(content='textarea { height: 65px } .missing textarea { height: 40px }') | ||
|
||
# Take step 2 screenshot | ||
page.screenshot(path='screenshots/step-2.png', full_page=True) | ||
|
||
# Click Next | ||
page.get_by_role('button', name='Next').click() | ||
|
||
# Fill in slideshow settings | ||
page.get_by_role('checkbox', name='Include a title slide before each song').uncheck() | ||
|
||
# Take step 3 screenshot | ||
page.screenshot(path='screenshots/step-3.png', full_page=True) | ||
|
||
# Click create | ||
page.get_by_role('button', name='Create').click() | ||
|
||
# Hide header (for better screenshot) | ||
page.add_style_tag(content='header { display: none }') | ||
|
||
# Take slides screenshot | ||
page.screenshot(path='screenshots/slides.png', full_page=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters