 
   describe "when tool-panel:unfocus is triggered on the tree view", ->
     it "surrenders focus to the root view but remains open", ->
-      atom.workspaceView.openSync() # When we trigger 'tool-panel:unfocus' below, we want an editor to become focused
-      atom.workspaceView.attachToDom()
-      treeView.focus()
-      expect(treeView.list).toMatchSelector(':focus')
-      treeView.trigger 'tool-panel:unfocus'
-      expect(treeView).toBeVisible()
-      expect(treeView.list).not.toMatchSelector(':focus')
-      expect(atom.workspaceView.getActiveView().isFocused).toBeTruthy()
+      waitsForPromise ->
+        atom.workspace.open() # When we trigger 'tool-panel:unfocus' below, we want an editor to become focused
+
+      runs ->
+        atom.workspaceView.attachToDom()
+        treeView.focus()
+        expect(treeView.list).toMatchSelector(':focus')
+        treeView.trigger 'tool-panel:unfocus'
+        expect(treeView).toBeVisible()
+        expect(treeView.list).not.toMatchSelector(':focus')
+        expect(atom.workspaceView.getActiveView().isFocused).toBeTruthy()
 
   describe "copy path commands", ->
     [pathToSelect, relativizedPath] = []

          sampleJs.click()

        runs ->
          atom.workspaceView.getActivePane().showItem($$ -> @div('hello'))
          expect(atom.workspaceView.find('.selected')).not.toExist()

  describe "when a different editor becomes active", ->


    describe "if the current file has a path", ->
      it "shows and focuses the tree view and selects the file", ->
        waitsForPromise ->
          atom.workspace.open(path.join('dir1', 'file1'))

        runs ->
          atom.workspaceView.trigger 'tree-view:reveal-active-file'
          expect(treeView.hasParent()).toBeTruthy()
          expect(treeView.focus).toHaveBeenCalled()
          expect(treeView.selectedEntry().getPath()).toMatch new RegExp("dir1#{_.escapeRegExp(path.sep)}file1$")

    describe "if the current file has no path", ->
      it "shows and focuses the tree view, but does not attempt to select a specific file", ->
        waitsForPromise ->
          atom.workspace.open()

        runs ->
          expect(atom.workspace.getActivePaneItem().getPath()).toBeUndefined()
          atom.workspaceView.trigger 'tree-view:reveal-active-file'
          expect(treeView.hasParent()).toBeTruthy()
          expect(treeView.focus).toHaveBeenCalled()

    describe "if there is no editor open", ->
      it "shows and focuses the tree view, but does not attempt to select a specific file", ->
