As stated in the Dockerfile documentation:
If
<src>is any other kind of file, it is copied individually along with its metadata. In this case, if<dest>ends with a trailing slash/, it will be considered a directory and the contents of<src>will be written at<dest>/base(<src>).If
<dest>does not end with a trailing slash, it will be considered a regular file and the contents of<src>will be written at<dest>.
Thus, you have to write COPY test.txt /usr/src/app/ with a trailing /.