'Clicks the preview toggling button and waits for the previews to appear or disappear.'

def toggle_previews(self):

    toggle = (not self.are_previews_showing())
    self.q(css='.toggle-preview-button').click()
    EmptyPromise((lambda : (self.are_previews_showing() == toggle)), ('Preview    is    visible:    %s' % toggle), timeout=30).fulfill()
    self.wait_until_ready()
