trustification / trustify

Apache License 2.0
8 stars 15 forks source link

Ignoring embedded UI test #440

Closed jcrossley3 closed 2 weeks ago

jcrossley3 commented 2 weeks ago

This test has problems:

I recommend it be moved beneath server/ and refactored to use TestRequest.

helio-frota commented 2 weeks ago
helio-frota commented 2 weeks ago

I recommend it be moved beneath server/ and refactored to use TestRequest.

Updated: That is a mock server https://github.com/helio-frota/trustify/blob/dea876a7f0d838ea121a4e112156bd7de29ea5ee/modules/ui/src/endpoints.rs#L28

I think I'm not using TestRequest correctly then, because it says /foobar returns status-code 200 https://github.com/trustification/trustify/pull/429/files#r1644637254

jcrossley3 commented 2 weeks ago
  • it leaves .trustify dirs behind -- 🤦‍♂️ probably needs another delete at the end

No. You must ensure it leaves no turds behind, whether it fails or passes, which is harder to do than it sounds. Better to design your tests so that no filesystem is required, if possible.

  • it makes requests of URL's that don't exist -- I'm not following that part

Try it with curl/wget/httpie in a shell. Try all the URL's in your tests:

You'll see that all of those url's all return the exact same thing: a blob of javascript.

But if you try these, you'll get different results:

And this is due to the way we configure our routes, which is critically important knowledge for you as this test's author.

I'm pretty sure #426 fell out of #422, but you can confirm that with @ctron

jcrossley3 commented 2 weeks ago

Updated: ~That is a mock server~ https://github.com/helio-frota/trustify/blob/dea876a7f0d838ea121a4e112156bd7de29ea5ee/modules/ui/src/endpoints.rs#L28

I know. And it grok's Actix route configuration. You should be able to affirm our configuration with it.

I think I'm not using TestRequest correctly then, because it says /foobar returns status-code 200 https://github.com/trustification/trustify/pull/429/files#r1644637254

See my above comment to understand why that is.

Do this: create a failing test with TestRequest. Revert #423 in your local environment and convince yourself that the bug exists, both by manually trying it in a browser and a shell, and then automatically with a unit test using TestRequest. Once you have that failing, restore the fix (#423) in your local environment. Your test should now pass. If it doesn't, you did something wrong.

helio-frota commented 2 weeks ago
You'll see that all of those url's all return the exact same thing: a blob of javascript.

But if you try these, you'll get different results:

http://localhost:8080/api/v1/advisory
http://localhost:8080/graphql/
And this is due to the way we [configure our routes](https://github.com/trustification/trustify/blob/773e957153100ddfea186a1b2e00b7be47054749/server/src/lib.rs#L264-L301), which is critically important knowledge for you as this test's author.

When I started the test I was thinking (and continued) on the literal part embedded UI works the ui-crate.

thanks for the extra info :+1: