Skip to content

Commit e825745

Browse files
committed
feat: add tests for newly added options
1 parent 867b1d0 commit e825745

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

test/spec/Terminal-integ-test.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,84 @@ define(function (require, exports, module) {
774774
.is(":visible");
775775
}, "terminal panel to close", 5000);
776776
});
777+
778+
it("should select all text in the terminal buffer",
779+
async function () {
780+
await openTerminal();
781+
await waitForShellReady();
782+
783+
// Write a unique marker string
784+
await writeToTerminal("echo SELECTALLMARKER789\r");
785+
await awaitsFor(function () {
786+
return bufferContains("SELECTALLMARKER789");
787+
}, "echo output to appear", 10000);
788+
789+
const active = getActiveTerminal();
790+
active.terminal.clearSelection();
791+
expect(active.terminal.hasSelection()).toBeFalse();
792+
793+
// Execute the select-all command
794+
await CommandManager.execute("terminal.selectAll");
795+
796+
expect(active.terminal.hasSelection()).toBeTrue();
797+
expect(active.terminal.getSelection())
798+
.toContain("SELECTALLMARKER789");
799+
800+
// Clean up
801+
clickPanelCloseButton();
802+
await awaitsFor(function () {
803+
return !testWindow.$("#terminal-panel")
804+
.is(":visible");
805+
}, "terminal panel to close", 5000);
806+
});
807+
808+
it("should kill the active terminal without dialog when idle",
809+
async function () {
810+
await openTerminal();
811+
await waitForShellReady();
812+
expect(getTerminalCount()).toBe(1);
813+
814+
// Execute the kill command
815+
await CommandManager.execute("terminal.kill");
816+
817+
await awaitsFor(function () {
818+
return getTerminalCount() === 0;
819+
}, "terminal to be killed", 5000);
820+
await awaitsFor(function () {
821+
return !testWindow.$("#terminal-panel")
822+
.is(":visible");
823+
}, "terminal panel to close", 5000);
824+
825+
// No confirmation dialog should appear for an idle shell
826+
expect(isDialogOpen()).toBeFalse();
827+
});
828+
829+
it("should create a new terminal via terminal.new command",
830+
async function () {
831+
await openTerminal();
832+
await waitForShellReady();
833+
expect(getTerminalCount()).toBe(1);
834+
835+
// Execute the new-terminal command (same path the
836+
// context menu uses)
837+
await CommandManager.execute("terminal.new");
838+
839+
await awaitsFor(function () {
840+
return getTerminalCount() === 2;
841+
}, "second terminal to be created", 10000);
842+
await waitForShellReady();
843+
844+
// Clean up: kill both terminals to avoid the
845+
// close-all confirmation dialog
846+
await CommandManager.execute("terminal.kill");
847+
await awaitsFor(function () {
848+
return getTerminalCount() === 1;
849+
}, "one terminal remaining", 5000);
850+
await CommandManager.execute("terminal.kill");
851+
await awaitsFor(function () {
852+
return getTerminalCount() === 0;
853+
}, "no terminals remaining", 5000);
854+
});
777855
});
778856

779857
describe("Programmatic hide vs user close", function () {

0 commit comments

Comments
 (0)