-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The pagination links in various pages were using `url_for('programs_page')`, which builds a URL to a route on the global `app` object. Since #6052 we don't have a global app object anymore. Instead, we use a global Blueprint called `app` instead. In this PR, make all `url_for` calls in the same `app.py` file Blueprint-relative by prepending a period: `url_for('.programs_page')`, and make the `url_for` in the teachers page that points to a user's programs page (probably legacy and unused?) absolute by prepending the full Blueprint name: `url_for('app.programs_page')`. Add tests to make sure that the page renders successfully. **How to test** Automatic tests have been added, so if they pass we should be good.
- Loading branch information
Showing
7 changed files
with
111 additions
and
15 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# https://werkzeug.palletsprojects.com/en/stable/test/ | ||
from .fixtures.given import Given | ||
from .fixtures.flask import Client | ||
import bs4 | ||
|
||
|
||
def test_explore_page_loads_with_lots_of_programs(client: Client, given: Given): | ||
"""Smoke test of the explore page, if there are enough programs for pagination.""" | ||
# GIVEN | ||
user = given.logged_in_as_student() | ||
for _ in range(50): | ||
given.some_saved_program(user['username'], public=1) | ||
|
||
# WHEN | ||
response = client.get('/explore') | ||
|
||
# THEN - it succeeds, renders a lot of adventures and a next button | ||
soup = bs4.BeautifulSoup(response.data, 'html.parser') | ||
adventures = soup.find_all('div', class_='adventure') | ||
assert len(adventures) > 40 | ||
|
||
next_page_link = soup.find('a', {'aria-label': 'Next page'}) | ||
assert next_page_link |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# https://werkzeug.palletsprojects.com/en/stable/test/ | ||
from .fixtures.given import Given | ||
from .fixtures.flask import Client | ||
|
||
|
||
def test_programs_page_loads_with_lots_of_programs(client: Client, given: Given): | ||
"""Smoke test of the programs page, if there are enough programs for pagination.""" | ||
# GIVEN | ||
user = given.logged_in_as_student() | ||
for _ in range(20): | ||
given.some_saved_program(user['username']) | ||
|
||
# WHEN | ||
client.get('/programs') | ||
|
||
# THEN - it succeeds |
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