I would say that problem is in timing.
If you toggle left sidebar, this command (.toggleLeft()) will not wait for a sidebar to open before proceeding further. Thus .isOpen() will always return false; side menu is still not fully opened.
We’re talking about asynchronous process here.