 
       beforeEach ->
         waitsForPromise ->
-          atom.workspace.open('sample.txt').then (o) ->
-            editor2 = o
-            pane.activateItem(editor2)
-
-        waitsForPromise ->
           atom.packages.activatePackage('settings-view').then ->
             atom.workspace.open('atom://config').then (o) ->
               settingsView = o
-              pane.activateItem(settingsView)
+
+        waitsForPromise ->
+          atom.workspace.open('sample.txt', pending: true).then (o) ->
+            editor2 = o
 
       it 'creates a permanent tab', ->
         expect(tabBar.tabForItem(settingsView)).toExist()

          expect($(tabBar.tabForItem(editor1)).find('.title')).not.toHaveClass 'temp'

    describe 'when switching from a preview tab to a permanent tab', ->
      it "keeps the preview tab open", ->
        atom.config.set("tabs.usePreviewTabs", false)
        editor1 = null
        editor2 = null

        waitsForPromise ->
          atom.workspace.open('sample.txt').then (o) ->
            editor1 = o
            pane.activateItem(editor1)

        runs ->
          atom.config.set("tabs.usePreviewTabs", true)

        waitsForPromise ->
          atom.workspace.open('sample2.txt').then (o) ->
            editor2 = o
            pane.activateItem(editor2)

        runs ->
          pane.activateItem(editor1)
          expect(pane.getItems().length).toBe 2
          expect($(tabBar.tabForItem(editor1)).find('.title')).not.toHaveClass 'temp'
          expect($(tabBar.tabForItem(editor2)).find('.title')).toHaveClass 'temp'

    describe "when splitting a preview tab", ->
      it "makes the tab permanent in the new pane", ->

          workspaceElement.querySelector('.tree-view')

        waitsForPromise ->
          atom.workspace.open('sample.js', pending: true).then (o) -> editor1 = o

        runs ->
          expect($(tabBar.tabForItem(editor1)).find('.title')).toHaveClass 'temp'

          fileNode = workspaceElement.querySelector(".tree-view [data-path=\"#{path.join(__dirname, 'fixtures', 'sample.js')}\"]")
