No, it passes ./test.sh to bash on the remote machine.
But argument file.txt is put on the ssh command; put it on the script instead:
ssh user@hostname 'bash -s file.txt'< ./test.sh
Here you definitely need the -s option, otherwise bash would read its commands from file.txt
NB: file.txt must be present on the remote machine. A simple ssh command can only pass one stream that is ./test.sh