Testing interface that with different "loggedInUsers"

My interface hides or shows buttons based on the users role, determined by "loggedInUser()".   I would like to test the interface mocking different logged in users.   Is there a way to achieve that?

  Discussion posts and replies are publicly visible

Parents
  • I always recommend storing the loggedInUser() to a local variable, and using the local variable throughout the interface.  This way, you can test all interface differences based on the user by temporarily updating the local!user variable in one place:

    a!localVariables(
      /*local!user: loggedInUser(),*/
      local!user: touser("user.name"),
      
      ...
    )

    Further preferred on my end, by using something such as a constant on each server holding the name of your server, this code is safer by preventing unwanted functionality if you forget to change the commenting back prior to deployment (happens..):

    a!localVariables(
      local!user: if(
        cons!SERVER_NAME="DEV",
        touser("user.name"),
        loggedInUser()
      ),
      
      ...
    )

  • Thank you Chris - that is what I am doing, however I want to be able to pass in user as logged in User so I can test the interface through different scenarios without having to touch the code itself.

Reply Children