mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 04:08:25 -04:00
Merge pull request #2167 from alphagov/fix_services_finding_user_info
Fix displaying of services on User Information page
This commit is contained in:
@@ -30,7 +30,9 @@ def find_users_by_email():
|
|||||||
@user_is_platform_admin
|
@user_is_platform_admin
|
||||||
def user_information(user_id):
|
def user_information(user_id):
|
||||||
user = user_api_client.get_user(user_id)
|
user = user_api_client.get_user(user_id)
|
||||||
|
services = user_api_client.get_organisations_and_services_for_user(user)
|
||||||
return render_template(
|
return render_template(
|
||||||
'views/find-users/user-information.html',
|
'views/find-users/user-information.html',
|
||||||
user=user
|
user=user,
|
||||||
|
services=services['services_without_organisations'],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
<h2 class="heading-medium">Services</h2>
|
<h2 class="heading-medium">Services</h2>
|
||||||
<nav class="browse-list">
|
<nav class="browse-list">
|
||||||
<ul>
|
<ul>
|
||||||
{% for service in user.services %}
|
{% for service in services %}
|
||||||
<li class="browse-list-item">
|
<li class="browse-list-item">
|
||||||
<p class="browse-list-sub-item">{{ service.name }}</p>
|
<a class="browse-list-hint" href={{url_for('.service_dashboard', service_id=service.id)}}>{{ service.name }}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -93,11 +93,17 @@ def test_user_information_page_shows_information_about_user(
|
|||||||
):
|
):
|
||||||
mocker.patch('app.user_api_client.get_user', side_effect=[
|
mocker.patch('app.user_api_client.get_user', side_effect=[
|
||||||
platform_admin_user,
|
platform_admin_user,
|
||||||
User(user_json(name="Apple Bloom", services=[
|
User(user_json(name="Apple Bloom", services=[1, 2]))
|
||||||
|
], autospec=True)
|
||||||
|
|
||||||
|
mocker.patch(
|
||||||
|
'app.user_api_client.get_organisations_and_services_for_user',
|
||||||
|
return_value={'organisations': [], 'services_without_organisations': [
|
||||||
{"id": 1, "name": "Fresh Orchard Juice"},
|
{"id": 1, "name": "Fresh Orchard Juice"},
|
||||||
{"id": 2, "name": "Nature Therapy"},
|
{"id": 2, "name": "Nature Therapy"},
|
||||||
]))
|
]},
|
||||||
], autospec=True)
|
autospec=True
|
||||||
|
)
|
||||||
client.login(platform_admin_user)
|
client.login(platform_admin_user)
|
||||||
response = client.get(url_for('main.user_information', user_id=345))
|
response = client.get(url_for('main.user_information', user_id=345))
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
@@ -109,8 +115,8 @@ def test_user_information_page_shows_information_about_user(
|
|||||||
assert document.xpath("//p/text()[normalize-space()='+447700900986']")
|
assert document.xpath("//p/text()[normalize-space()='+447700900986']")
|
||||||
|
|
||||||
assert document.xpath("//h2/text()[normalize-space()='Services']")
|
assert document.xpath("//h2/text()[normalize-space()='Services']")
|
||||||
assert document.xpath("//p/text()[normalize-space()='Fresh Orchard Juice']")
|
assert document.xpath("//a/text()[normalize-space()='Fresh Orchard Juice']")
|
||||||
assert document.xpath("//p/text()[normalize-space()='Nature Therapy']")
|
assert document.xpath("//a/text()[normalize-space()='Nature Therapy']")
|
||||||
|
|
||||||
assert document.xpath("//h2/text()[normalize-space()='Last login']")
|
assert document.xpath("//h2/text()[normalize-space()='Last login']")
|
||||||
assert not document.xpath("//p/text()[normalize-space()='0 failed login attempts']")
|
assert not document.xpath("//p/text()[normalize-space()='0 failed login attempts']")
|
||||||
@@ -125,6 +131,15 @@ def test_user_information_page_displays_if_there_are_failed_login_attempts(
|
|||||||
platform_admin_user,
|
platform_admin_user,
|
||||||
User(user_json(name="Apple Bloom", failed_login_count=2))
|
User(user_json(name="Apple Bloom", failed_login_count=2))
|
||||||
], autospec=True)
|
], autospec=True)
|
||||||
|
|
||||||
|
mocker.patch(
|
||||||
|
'app.user_api_client.get_organisations_and_services_for_user',
|
||||||
|
return_value={'organisations': [], 'services_without_organisations': [
|
||||||
|
{"id": 1, "name": "Fresh Orchard Juice"},
|
||||||
|
{"id": 2, "name": "Nature Therapy"},
|
||||||
|
]},
|
||||||
|
autospec=True
|
||||||
|
)
|
||||||
client.login(platform_admin_user)
|
client.login(platform_admin_user)
|
||||||
response = client.get(url_for('main.user_information', user_id=345))
|
response = client.get(url_for('main.user_information', user_id=345))
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|||||||
Reference in New Issue
Block a user