I suspect you may not have given people enough information on what you are trying to achieve to help you. I’m not familiar with but one obvious one is your indentation is screwy and ESPHome gets a bit upset when not properly formatted.
I’d also look at your path to your test.js script and compare to how it is defined in the docs, yours doesn’t see to have the path defined.
I downloaded www.js and added my functions to the end and uploaded them to a web server. So as long as that server is up, my interface works.
I tried putting my HTML after my functions in www.js and setting local: true. This failed by not updating the innerHTML. I will keep trying to get this to work local.