Can the defined TEST be parsed correctly if positioned right after \n?
@startuml
!define TEST something
a[#red]->b: test:\nTEST
note right: The test is wrong:\nTEST
a-[#green]>b: test:\n TEST
note left: The test is correct:\n TEST
@enduml
Currently you need to add an extra space to get it parsed