/*global describe it before after bar*/ "use client"; require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"], function (architect, chai, baseProc) { var expect = chai.expect; expect.setupArchitectTest([ { packagePath: "plugins/c9.core/c9", workspaceId: "johndoe/dev", startdate: new Date(), debug: true, hosted: true, local: false, }, "plugins/c9.core/ext", "plugins/c9.core/http-xhr", "plugins/c9.core/util", "plugins/c9.ide.ui/lib_apf", { packagePath: "plugins/c9.core/settings", testing: true }, { packagePath: "plugins/c9.ide.ui/ui", staticPrefix: "plugins/c9.ide.ui" }, "plugins/c9.ide.editors/document", "plugins/c9.ide.editors/undomanager", "plugins/c9.ide.editors/editors", "plugins/c9.ide.editors/editor", "plugins/c9.ide.editors/tabmanager", "plugins/c9.ide.ui/focus", "plugins/c9.ide.editors/pane", "plugins/c9.ide.editors/tab", "plugins/c9.ide.terminal/terminal", "plugins/c9.ide.preferences/preferences", "plugins/c9.ide.ui/forms", { packagePath: "plugins/c9.fs/proc", tmuxName: "cloud9test" }, "plugins/c9.vfs.client/vfs_client", "plugins/c9.vfs.client/endpoint", "plugins/c9.ide.auth/auth", "plugins/c9.core/api", { packagePath: "plugins/c9.fs/fs", baseProc: baseProc }, { consumes: ["tabManager", "proc", "terminal"], provides: [], setup: main } ], architect); function main(options, imports, register) { var tabs = imports.tabManager; var proc = imports.proc; expect.html.setConstructor(function(tab) { if (typeof tab == "object") return tab.pane.aml.getPage("editor::" + tab.editorType).$ext; }); describe('terminal', function() { before(function(done) { bar.$ext.style.background = "rgba(220, 220, 220, 0.93)"; bar.$ext.style.position = "fixed"; bar.$ext.style.left = "20px"; bar.$ext.style.right = "20px"; bar.$ext.style.bottom = "20px"; bar.$ext.style.height = "33%"; document.body.style.marginBottom = "33%"; proc.execFile("~/.c9/bin/tmux", { args: ["-L", "cloud9test", "kill-server"]}, function(err) { tabs.once("ready", function() { tabs.getPanes()[0].focus(); done(); }); }); }); describe("open", function() { this.timeout(15000); var sessId; it('should open a pane with just an editor', function(done) { tabs.openEditor("terminal", function(err, tab) { expect(err).to.not.ok; expect(tabs.getTabs()).length(1); var doc = tab.document; doc.on("setTitle", function c1() { // expect(doc.title).match(new RegExp("^bash - ")); sessId = doc.getSession().id; doc.off("setTitle", c1); done(); }); }); }); // @todo Test mouse // @todo Test menu it.skip('should reconnect when the connection has been lost', function(done) { var doc = tabs.focussedTab.document; var session = doc.getSession(); session.once("connected", function() { doc.once("setTitle", function() { // expect(doc.title).to.match(/^bash - /); expect(session.id).to.equal(sessId); done(); }); }); // Kill connection session.pty.kill(); session.doc.editor.focus(); }); it.skip('should reconnect when the session has been lost', function(done) { var doc = tabs.focussedTab.document; var session = doc.getSession(); proc.execFile("tmux", { args: ["kill-session", "-t", session.id] }, function(err) { // Ignore errors for now if (err) throw err.message; }); session.on("connected", function c0() { doc.on("setTitle", function c1() { expect(session.id).to.not.equal(sessId); doc.off("setTitle", c1); done(); }); session.off("connected", c0); }); }); it('should handle multiple terminals in the same pane', function(done) { tabs.openEditor("terminal", function(err, tab) { expect(err).to.not.ok; expect(tabs.getTabs()).length(2); tab.activate(); var doc = tab.document; doc.once("setTitle", function() { var terminal = tab.editor.ace.session.term; terminal.once("afterWrite", function() { expect(window.xss).to.not.ok; terminal.write("echo \"\""); tab.editor.ace.resize(true); expect(tab.editor.ace.container.textContent.indexOf(" -1).is.not.ok; // done(); // }); // }, 3000); }); }); // @todo test split api and menu if (!onload.remain) { after(function(done) { tabs.unload(); bar.destroy(true, true); document.body.style.marginBottom = ""; done(); }); } }); register(); } });