Add test for live-search on templates page

Includes addition of a mock for a list of
templates long enough to need a live-search.
This commit is contained in:
Tom Byers
2018-08-16 12:18:07 +01:00
parent 3b4c49a2c3
commit 3bc7c1c224
2 changed files with 36 additions and 0 deletions

View File

@@ -147,6 +147,32 @@ def test_should_not_show_template_nav_if_only_one_type_of_template(
assert not page.select('.pill')
def test_should_not_show_live_search_if_list_of_templates_fits_onscreen(
client_request,
mock_get_service_templates
):
page = client_request.get(
'main.choose_template',
service_id=SERVICE_ONE_ID,
)
assert not page.select('.live-search')
def test_should_show_live_search_if_list_of_templates_taller_than_screen(
client_request,
mock_get_more_service_templates_than_can_fit_onscreen
):
page = client_request.get(
'main.choose_template',
service_id=SERVICE_ONE_ID,
)
assert page.select('.live-search')
def test_should_show_page_for_one_template(
logged_in_client,
mock_get_service_template,

View File

@@ -987,6 +987,16 @@ def mock_get_service_templates(mocker):
side_effect=_create)
@pytest.fixture(scope='function')
def mock_get_more_service_templates_than_can_fit_onscreen(mocker):
def _create(service_id):
return create_service_templates(service_id, number_of_templates=10)
return mocker.patch(
'app.service_api_client.get_service_templates',
side_effect=_create)
@pytest.fixture(scope='function')
def mock_get_service_templates_when_no_templates_exist(mocker):