I am creating some integration tests for a ColdBox REST API that generates static HTML files processed by wkhtmltopdf to convert them to PDFs. Everything works in production, but the tests fail to create PDF files because TestBox appends “/root/” to the value returned by
event.getHTMLBaseURL(). I need to make sure
event.getHTMLBaseURL() always returns the URL for the web root, even from within TestBox.
http://127.0.0.1:60830/root/temp/myFile.html <- TestBox: Returns 404
http://127.0.0.1:60830/temp/myFile.html <- Production: returns 200 success!
Is there a way, within an integration test, to not append “/root/” to the path?
If you create a mapping in the regular application for /root does that resolve the issue?
Although, this interaction isn’t what I would expect.
I always thought we should have a convention for this, so it’s mirrored in the app and in testing. Sometimes its root, sometimes its cbapp.
I do have a /root mapping in the regular application. I believe this is from the boilerplate app template. It looks like this:
COLDBOX_APP_ROOT_PATH = getDirectoryFromPath( getCurrentTemplatePath() );
this.mappings[ "/root" ] = COLDBOX_APP_ROOT_PATH;
Even with that mapping, I get 404s when /root/ is appended to the URL. For example:
http://127.0.0.1:60830/root/api/v1/echo/ <- 404 Not Found
http://127.0.0.1:60830/api/v1/echo/ <- 200 Success
Or with static files:
http://127.0.0.1:60830/root/resources/img/logo.png <- 404 Not found
http://127.0.0.1:60830/resources/img/logo.png <- 200 Success