2015-02-06 00:02:08 +03:00
|
|
|
# These tests are excluded by default. To run them from the command line:
|
|
|
|
#
|
|
|
|
# ATOM_INTEGRATION_TESTS_ENABLED=true apm test
|
2015-05-08 23:25:54 +03:00
|
|
|
return unless process.env.ATOM_INTEGRATION_TESTS_ENABLED
|
2015-04-16 10:52:41 +03:00
|
|
|
# Integration tests require a fast machine and, for now, we cannot afford to
|
|
|
|
# run them on Travis.
|
2015-05-08 23:25:54 +03:00
|
|
|
return if process.env.TRAVIS
|
2015-02-06 00:02:08 +03:00
|
|
|
|
2015-02-04 22:40:21 +03:00
|
|
|
fs = require "fs"
|
|
|
|
path = require "path"
|
|
|
|
temp = require("temp").track()
|
2015-05-08 23:33:30 +03:00
|
|
|
runAtom = require "./helpers/start-atom"
|
2015-08-26 00:24:11 +03:00
|
|
|
CSON = require "season"
|
2015-02-04 22:40:21 +03:00
|
|
|
|
|
|
|
describe "Starting Atom", ->
|
2015-04-15 00:14:15 +03:00
|
|
|
[tempDirPath, otherTempDirPath, atomHome] = []
|
2015-02-24 22:40:23 +03:00
|
|
|
|
2015-02-04 22:40:21 +03:00
|
|
|
beforeEach ->
|
2015-02-06 21:38:40 +03:00
|
|
|
jasmine.useRealClock()
|
2015-02-04 22:40:21 +03:00
|
|
|
|
2015-04-15 00:14:15 +03:00
|
|
|
atomHome = temp.mkdirSync('atom-home')
|
|
|
|
fs.writeFileSync(path.join(atomHome, 'config.cson'), fs.readFileSync(path.join(__dirname, 'fixtures', 'atom-home', 'config.cson')))
|
2015-02-24 22:40:23 +03:00
|
|
|
tempDirPath = temp.mkdirSync("empty-dir")
|
|
|
|
otherTempDirPath = temp.mkdirSync("another-temp-dir")
|
2015-02-04 22:40:21 +03:00
|
|
|
|
2015-02-24 22:40:23 +03:00
|
|
|
describe "opening a new file", ->
|
|
|
|
it "opens the parent directory and creates an empty text editor", ->
|
2015-04-15 00:14:15 +03:00
|
|
|
runAtom [path.join(tempDirPath, "new-file")], {ATOM_HOME: atomHome}, (client) ->
|
2015-02-11 21:53:49 +03:00
|
|
|
client
|
|
|
|
.waitForWindowCount(1, 1000)
|
2015-02-24 22:40:23 +03:00
|
|
|
.waitForExist("atom-workspace", 5000)
|
2015-02-11 21:53:49 +03:00
|
|
|
.waitForPaneItemCount(1, 1000)
|
2015-02-06 21:38:40 +03:00
|
|
|
|
2015-02-24 22:40:23 +03:00
|
|
|
.treeViewRootDirectories()
|
|
|
|
.then ({value}) -> expect(value).toEqual([tempDirPath])
|
|
|
|
|
|
|
|
.waitForExist("atom-text-editor", 5000)
|
|
|
|
.then (exists) -> expect(exists).toBe true
|
2015-02-06 21:38:40 +03:00
|
|
|
.click("atom-text-editor")
|
|
|
|
.keys("Hello!")
|
2015-02-24 22:40:23 +03:00
|
|
|
.execute -> atom.workspace.getActiveTextEditor().getText()
|
|
|
|
.then ({value}) -> expect(value).toBe "Hello!"
|
2015-04-15 00:16:39 +03:00
|
|
|
.dispatchCommand("editor:delete-line")
|
2015-02-24 22:40:23 +03:00
|
|
|
|
2015-05-08 23:24:48 +03:00
|
|
|
it "opens the file to the specified line number", ->
|
2015-05-08 23:23:28 +03:00
|
|
|
filePath = path.join(fs.realpathSync(tempDirPath), "new-file")
|
|
|
|
fs.writeFileSync filePath, """
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
"""
|
|
|
|
|
|
|
|
runAtom ["#{filePath}:3"], {ATOM_HOME: atomHome}, (client) ->
|
2015-05-08 23:04:42 +03:00
|
|
|
client
|
|
|
|
.waitForWindowCount(1, 1000)
|
|
|
|
.waitForExist("atom-workspace", 5000)
|
|
|
|
.waitForPaneItemCount(1, 1000)
|
2015-05-08 23:23:28 +03:00
|
|
|
.waitForExist("atom-text-editor", 5000)
|
|
|
|
.then (exists) -> expect(exists).toBe true
|
2015-05-08 23:04:42 +03:00
|
|
|
|
2015-05-08 23:23:28 +03:00
|
|
|
.execute -> atom.workspace.getActiveTextEditor().getPath()
|
|
|
|
.then ({value}) -> expect(value).toBe filePath
|
2015-05-08 23:04:42 +03:00
|
|
|
|
2015-05-08 23:23:28 +03:00
|
|
|
.execute -> atom.workspace.getActiveTextEditor().getCursorBufferPosition()
|
|
|
|
.then ({value}) ->
|
|
|
|
expect(value.row).toBe 2
|
|
|
|
expect(value.column).toBe 0
|
|
|
|
|
2015-05-08 23:24:48 +03:00
|
|
|
it "opens the file to the specified line number and column number", ->
|
|
|
|
filePath = path.join(fs.realpathSync(tempDirPath), "new-file")
|
|
|
|
fs.writeFileSync filePath, """
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
"""
|
|
|
|
|
|
|
|
runAtom ["#{filePath}:2:2"], {ATOM_HOME: atomHome}, (client) ->
|
|
|
|
client
|
|
|
|
.waitForWindowCount(1, 1000)
|
|
|
|
.waitForExist("atom-workspace", 5000)
|
|
|
|
.waitForPaneItemCount(1, 1000)
|
|
|
|
.waitForExist("atom-text-editor", 5000)
|
|
|
|
.then (exists) -> expect(exists).toBe true
|
|
|
|
|
|
|
|
.execute -> atom.workspace.getActiveTextEditor().getPath()
|
|
|
|
.then ({value}) -> expect(value).toBe filePath
|
|
|
|
|
|
|
|
.execute -> atom.workspace.getActiveTextEditor().getCursorBufferPosition()
|
|
|
|
.then ({value}) ->
|
|
|
|
expect(value.row).toBe 1
|
|
|
|
expect(value.column).toBe 1
|
|
|
|
|
2015-05-08 23:23:28 +03:00
|
|
|
it "removes all trailing whitespace and colons from the specified path", ->
|
|
|
|
filePath = path.join(tempDirPath, "new-file")
|
|
|
|
runAtom ["#{filePath}: "], {ATOM_HOME: atomHome}, (client) ->
|
|
|
|
client
|
|
|
|
.waitForWindowCount(1, 1000)
|
|
|
|
.waitForExist("atom-workspace", 5000)
|
|
|
|
.waitForPaneItemCount(1, 1000)
|
2015-05-08 23:04:42 +03:00
|
|
|
.waitForExist("atom-text-editor", 5000)
|
|
|
|
.then (exists) -> expect(exists).toBe true
|
2015-05-08 23:23:28 +03:00
|
|
|
|
2015-05-08 23:04:42 +03:00
|
|
|
.execute -> atom.workspace.getActiveTextEditor().getPath()
|
2015-05-08 23:23:28 +03:00
|
|
|
.then ({value}) -> expect(value).toBe filePath
|
2015-05-08 23:04:42 +03:00
|
|
|
|
2015-02-24 23:09:10 +03:00
|
|
|
describe "when there is already a window open", ->
|
|
|
|
it "reuses that window when opening files, but not when opening directories", ->
|
|
|
|
tempFilePath = path.join(temp.mkdirSync("a-third-dir"), "a-file")
|
|
|
|
fs.writeFileSync(tempFilePath, "This file was already here.")
|
|
|
|
|
2015-04-15 00:14:15 +03:00
|
|
|
runAtom [path.join(tempDirPath, "new-file")], {ATOM_HOME: atomHome}, (client) ->
|
2015-02-24 22:40:23 +03:00
|
|
|
client
|
|
|
|
.waitForWindowCount(1, 1000)
|
|
|
|
.waitForExist("atom-workspace", 5000)
|
|
|
|
.waitForPaneItemCount(1, 5000)
|
2015-02-06 21:38:40 +03:00
|
|
|
|
2015-02-24 23:09:10 +03:00
|
|
|
# Opening another file reuses the same window and does not change the
|
|
|
|
# project paths.
|
2015-04-15 00:14:15 +03:00
|
|
|
.startAnotherAtom([tempFilePath], ATOM_HOME: atomHome)
|
2015-02-11 21:53:49 +03:00
|
|
|
.waitForPaneItemCount(2, 5000)
|
|
|
|
.waitForWindowCount(1, 1000)
|
2015-02-24 22:40:23 +03:00
|
|
|
.treeViewRootDirectories()
|
|
|
|
.then ({value}) -> expect(value).toEqual([tempDirPath])
|
|
|
|
.execute -> atom.workspace.getActiveTextEditor().getText()
|
|
|
|
.then ({value: text}) -> expect(text).toBe "This file was already here."
|
2015-02-06 21:38:40 +03:00
|
|
|
|
2015-02-24 23:09:10 +03:00
|
|
|
# Opening another directory creates a second window.
|
2015-02-12 04:04:54 +03:00
|
|
|
.waitForNewWindow(->
|
2015-04-15 00:14:15 +03:00
|
|
|
@startAnotherAtom([otherTempDirPath], ATOM_HOME: atomHome)
|
2015-02-12 04:04:54 +03:00
|
|
|
, 5000)
|
2015-02-11 21:53:49 +03:00
|
|
|
.waitForExist("atom-workspace", 5000)
|
|
|
|
.waitForPaneItemCount(0, 1000)
|
2015-02-24 22:40:23 +03:00
|
|
|
.treeViewRootDirectories()
|
|
|
|
.then ({value}) -> expect(value).toEqual([otherTempDirPath])
|
2015-02-13 08:18:18 +03:00
|
|
|
|
2015-02-24 22:40:23 +03:00
|
|
|
describe "reopening a directory that was previously opened", ->
|
|
|
|
it "remembers the state of the window", ->
|
2015-04-15 00:14:15 +03:00
|
|
|
runAtom [tempDirPath], {ATOM_HOME: atomHome}, (client) ->
|
2015-02-13 08:18:18 +03:00
|
|
|
client
|
2015-02-12 07:29:17 +03:00
|
|
|
.waitForExist("atom-workspace", 5000)
|
2015-02-12 04:04:54 +03:00
|
|
|
.waitForPaneItemCount(0, 3000)
|
2015-02-24 22:40:23 +03:00
|
|
|
.execute -> atom.workspace.open()
|
2015-02-12 04:04:54 +03:00
|
|
|
.waitForPaneItemCount(1, 3000)
|
2015-02-13 08:18:18 +03:00
|
|
|
|
2015-04-15 00:14:15 +03:00
|
|
|
runAtom [tempDirPath], {ATOM_HOME: atomHome}, (client) ->
|
2015-02-24 22:40:23 +03:00
|
|
|
client
|
2015-02-12 07:29:17 +03:00
|
|
|
.waitForExist("atom-workspace", 5000)
|
2015-02-12 04:04:54 +03:00
|
|
|
.waitForPaneItemCount(1, 5000)
|
2015-02-13 08:18:18 +03:00
|
|
|
|
2015-02-24 22:40:23 +03:00
|
|
|
describe "opening multiple directories simultaneously", ->
|
|
|
|
it "shows them all in the tree-view", ->
|
2015-02-24 23:09:10 +03:00
|
|
|
nestedDir = path.join(otherTempDirPath, "nested-dir")
|
|
|
|
fs.mkdirSync(nestedDir)
|
|
|
|
|
2015-04-15 00:14:15 +03:00
|
|
|
runAtom [tempDirPath, otherTempDirPath], {ATOM_HOME: atomHome}, (client) ->
|
2015-02-13 08:18:18 +03:00
|
|
|
client
|
|
|
|
.waitForExist("atom-workspace", 5000)
|
2015-02-24 22:40:23 +03:00
|
|
|
.treeViewRootDirectories()
|
|
|
|
.then ({value}) -> expect(value).toEqual([tempDirPath, otherTempDirPath])
|
2015-02-13 08:18:18 +03:00
|
|
|
|
2015-02-24 23:09:10 +03:00
|
|
|
# Opening one of those directories again reuses the same window and
|
|
|
|
# does not change the project paths.
|
2015-04-15 00:14:15 +03:00
|
|
|
.startAnotherAtom([nestedDir], ATOM_HOME: atomHome)
|
2015-02-12 07:29:17 +03:00
|
|
|
.waitForExist("atom-workspace", 5000)
|
2015-02-24 22:40:23 +03:00
|
|
|
.treeViewRootDirectories()
|
|
|
|
.then ({value}) -> expect(value).toEqual([tempDirPath, otherTempDirPath])
|
2015-02-18 02:25:50 +03:00
|
|
|
|
2015-02-24 22:40:23 +03:00
|
|
|
describe "when there is an existing window with no project path", ->
|
2015-04-15 00:18:44 +03:00
|
|
|
it "reuses that window to open a directory", ->
|
|
|
|
runAtom [], {ATOM_HOME: atomHome}, (client) ->
|
|
|
|
client
|
|
|
|
.waitForExist("atom-workspace")
|
|
|
|
.treeViewRootDirectories()
|
|
|
|
.then ({value}) -> expect(value).toEqual([])
|
|
|
|
|
|
|
|
.startAnotherAtom([tempDirPath], ATOM_HOME: atomHome)
|
|
|
|
.waitUntil(->
|
|
|
|
@treeViewRootDirectories()
|
|
|
|
.then ({value}) -> value[0] is tempDirPath
|
|
|
|
, 5000)
|
|
|
|
.then (result) -> expect(result).toBe(true)
|
|
|
|
.waitForWindowCount(1, 5000)
|
|
|
|
|
|
|
|
describe "launching with no path", ->
|
|
|
|
it "opens a new window with a single untitled buffer", ->
|
|
|
|
runAtom [], {ATOM_HOME: atomHome}, (client) ->
|
|
|
|
client
|
|
|
|
.waitForExist("atom-workspace")
|
|
|
|
.waitForPaneItemCount(1, 5000)
|
|
|
|
|
|
|
|
# Opening with no file paths always creates a new window, even if
|
|
|
|
# existing windows have no project paths.
|
|
|
|
.waitForNewWindow(->
|
|
|
|
@startAnotherAtom([], ATOM_HOME: atomHome)
|
|
|
|
, 5000)
|
|
|
|
.waitForExist("atom-workspace")
|
|
|
|
.waitForPaneItemCount(1, 5000)
|
2015-08-26 00:24:11 +03:00
|
|
|
|
2015-08-23 18:07:19 +03:00
|
|
|
it "doesn't open a new window if openEmptyEditorOnStart is disabled", ->
|
2015-08-26 00:24:11 +03:00
|
|
|
configPath = path.join(atomHome, 'config.cson')
|
|
|
|
config = CSON.readFileSync(configPath)
|
|
|
|
config['*'].core = {openEmptyEditorOnStart: false}
|
|
|
|
CSON.writeFileSync(configPath, config)
|
|
|
|
|
2015-08-23 18:07:19 +03:00
|
|
|
runAtom [], {ATOM_HOME: atomHome}, (client) ->
|
|
|
|
client
|
|
|
|
.waitForExist("atom-workspace")
|
|
|
|
.waitForPaneItemCount(0, 5000)
|
2015-04-15 00:18:44 +03:00
|
|
|
|
|
|
|
it "reopens any previously opened windows", ->
|
|
|
|
runAtom [tempDirPath], {ATOM_HOME: atomHome}, (client) ->
|
|
|
|
client
|
|
|
|
.waitForExist("atom-workspace")
|
|
|
|
.waitForNewWindow(->
|
|
|
|
@startAnotherAtom([otherTempDirPath], ATOM_HOME: atomHome)
|
|
|
|
, 5000)
|
|
|
|
.waitForExist("atom-workspace")
|
|
|
|
|
|
|
|
runAtom [], {ATOM_HOME: atomHome}, (client) ->
|
|
|
|
windowProjectPaths = []
|
|
|
|
|
|
|
|
client
|
|
|
|
.waitForWindowCount(2, 10000)
|
|
|
|
.then ({value: windowHandles}) ->
|
|
|
|
@window(windowHandles[0])
|
2015-05-06 20:29:34 +03:00
|
|
|
.waitForExist("atom-workspace")
|
2015-02-24 22:40:23 +03:00
|
|
|
.treeViewRootDirectories()
|
2015-04-15 00:18:44 +03:00
|
|
|
.then ({value: directories}) -> windowProjectPaths.push(directories)
|
|
|
|
|
|
|
|
.window(windowHandles[1])
|
2015-05-06 20:29:34 +03:00
|
|
|
.waitForExist("atom-workspace")
|
2015-04-15 00:18:44 +03:00
|
|
|
.treeViewRootDirectories()
|
|
|
|
.then ({value: directories}) -> windowProjectPaths.push(directories)
|
|
|
|
|
|
|
|
.call ->
|
|
|
|
expect(windowProjectPaths.sort()).toEqual [
|
|
|
|
[tempDirPath]
|
|
|
|
[otherTempDirPath]
|
|
|
|
].sort()
|
2015-05-27 21:18:15 +03:00
|
|
|
|
|
|
|
describe "opening a remote directory", ->
|
|
|
|
it "opens the parent directory and creates an empty text editor", ->
|
|
|
|
remoteDirectory = 'remote://server:3437/some/directory/path'
|
|
|
|
runAtom [remoteDirectory], {ATOM_HOME: atomHome}, (client) ->
|
|
|
|
client
|
|
|
|
.waitForWindowCount(1, 1000)
|
|
|
|
.waitForExist("atom-workspace", 5000)
|
|
|
|
.treeViewRootDirectories()
|
|
|
|
.then ({value}) -> expect(value).toEqual([remoteDirectory])
|