Convex tests w/ ents with action identity issue.
Basically the recent updates seemed to mess with our tests. And seeing the docs were also expanded upon, and offering a bit more control so we refactored a bit, merging the ideas from the tests page on the main page and what we had working before with ents and auth.
We changed some code to use actions for the first time with a test, so the test was now breaking, and I verified the action that has a identity created - so asSarah.action(): that function then calls a ctx.runMutation() where ctx.viewerId is null within that.
However the actions ctx.auth.getIdentity() does return a value.
Just ctx.viewerId is empty in the child mutations, when its not in normal convex use. I understand that ctx on actions is not designed to get "middleware". Wondering if this is likely a setup issue or a bug.? Wishlist: It's happened a couple of times but when you accidently call a t.mutation and its a action on the other side it would be nice if the error was more specific. I know I should work naming functions differently if they are been changed to action 🙃 . Its especially easy to mix up as most actions have ctx.runMutation inside..
Just ctx.viewerId is empty in the child mutations, when its not in normal convex use. I understand that ctx on actions is not designed to get "middleware". Wondering if this is likely a setup issue or a bug.? Wishlist: It's happened a couple of times but when you accidently call a t.mutation and its a action on the other side it would be nice if the error was more specific. I know I should work naming functions differently if they are been changed to action 🙃 . Its especially easy to mix up as most actions have ctx.runMutation inside..
2 Replies
Hey @ampp please upgrade to latest version of convex-test
It's happened a couple of times but when you accidently call a t.mutation and its a action on the other side it would be nice if the error was more specificI'm curious, do you use JavaScript without any intellisense? TypeScript should warn about passing the wrong function reference to t.mutation / t.action. I'll also look into a better runtime error.
convex-test@0.0.19
has a better runtime error for passing in the wrong type of function.Thanks, both things seem to work right/better now 🙂