There are 2 errors:
Firstly:
RewriteCond %{HTTP_USER_AGENT} ^Test Agent/(.*)$
You need to avoid the space and slash in the regex pattern.
RewriteCond %{HTTP_USER_AGENT} ^Test\ Agent\/(.*)$
Secondly:
RewriteRule ^(.*)$ https://test.domain.com/$1 [L,302]
302 is the HTTP redirect status code, but you did not indicate that you are redirecting.
RewriteRule ^(.*)$ https://test.domain.com/$1 [L,R=302]
source share