diff --git a/app/templates/components/copy-to-clipboard.html b/app/templates/components/copy-to-clipboard.html
index 8f67c1cfa..08e2f4a31 100644
--- a/app/templates/components/copy-to-clipboard.html
+++ b/app/templates/components/copy-to-clipboard.html
@@ -6,7 +6,7 @@
{% endif %}
- {% if name|lower != thing|lower %}{{ thing }}: {% endif %}{{ value }}
+ {%- if name|lower != thing|lower %}{{ thing }}: {% endif %}{{ value -}}
diff --git a/tests/app/main/views/test_api_integration.py b/tests/app/main/views/test_api_integration.py
index 7857d199f..2dbe7ed5a 100644
--- a/tests/app/main/views/test_api_integration.py
+++ b/tests/app/main/views/test_api_integration.py
@@ -281,8 +281,9 @@ def test_should_create_api_key_with_type_normal(
_expected_status=200,
)
- assert page.select_one('span.copy-to-clipboard__value').text.strip() == (
- 'some_default_key_name_12-{}-{}'.format(SERVICE_ONE_ID, fake_uuid)
+ assert page.select_one('span.copy-to-clipboard__value').text == (
+ # The text should be exactly this, with no leading or trailing whitespace
+ f'some_default_key_name_12-{SERVICE_ONE_ID}-{fake_uuid}'
)
post.assert_called_once_with(url='/service/{}/api-key'.format(SERVICE_ONE_ID), data={