My team would like to be able to write some unit tests around levels of access granted to users or specific groups in our apps, but I'm struggling to find a way to properly mock the current_user
object to put it in various states & assert proper levels of access to each kind of user. Is this possible today or is there any plan for it in the future?
I think you would have to set up a bunch of users/roles in a database, or set of temp variables and simply assign a value to test against....
you could mock it as the input to a workfkow or as input to a module.... or make a workflow to just return mock data? not real sure where yall need access to ut, cause there is a like compamy wide preloaded js i think where u could define a prototype that all webbapps have access to (as opposed to proloaded js for just 1 project or a workflow w access control that returns ur test data)
If I'm following right, you're both suggesting some sort of proxy for the data exposed by the current_user
object which should work in theory.
A secondary issue I'm running into here is the most natural way to proxy objects like this seems to be to create a transformer, but it doesn't appear I can mock the results of those during integration tests either. I'm unclear on how I could mock a global JS function in tests yet have it return real values in production.