Skip to content

Commit f4fe939

Browse files
committed
fix: dragging in empty pane test fails because it contained some unexpected tabs
1 parent c8ca6f7 commit f4fe939

File tree

2 files changed

+3140
-73
lines changed

2 files changed

+3140
-73
lines changed

test/spec/Extn-Tabbar-integ-test.js

Lines changed: 77 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ define(function (require, exports, module) {
928928
// Set up a horizontal split view (two columns)
929929
MainViewManager.setLayoutScheme(1, 2);
930930

931-
// Wait for layout to settle and ensure second pane is empty
931+
// Wait for layout to settle
932932
await awaitsFor(
933933
function () {
934934
return MainViewManager.getPaneCount() === 2;
@@ -937,25 +937,9 @@ define(function (require, exports, module) {
937937
1000
938938
);
939939

940-
// Force close any files that might be open in the second pane
941-
const secondPaneWorkingSet = MainViewManager.getWorkingSet("second-pane");
942-
for (const file of secondPaneWorkingSet) {
943-
await awaitsForDone(
944-
CommandManager.execute(Commands.FILE_CLOSE, { file: file, paneId: "second-pane" }),
945-
`Force close file ${file.fullPath} in second pane`
946-
);
947-
}
948-
949-
// Wait for the second pane to actually be empty after cleanup
950-
await awaitsFor(
951-
function () {
952-
return getPaneTabCount("second-pane") === 0;
953-
},
954-
"Second pane to be cleaned up",
955-
2000
956-
);
957-
958-
expect(getPaneTabCount("second-pane")).toBe(0);
940+
// Verify both panes are empty
941+
expect(MainViewManager.getWorkingSet("first-pane").length).toBe(0);
942+
expect(MainViewManager.getWorkingSet("second-pane").length).toBe(0);
959943

960944
// Create test files for the first pane
961945
const firstPaneFiles = await createTestFiles(
@@ -970,67 +954,85 @@ define(function (require, exports, module) {
970954
// Wait for all tabs to appear in the first pane
971955
await waitForTabs(firstPaneFiles, "first-pane");
972956

973-
expect(getPaneTabCount("second-pane")).toBe(0);
957+
// Verify initial state: first pane has tabs, second pane is empty
958+
expect(getPaneTabCount("first-pane")).toBe(firstPaneFiles.length);
974959

975-
// Ensure second pane is empty before proceeding
976-
await awaitsFor(
977-
function () {
978-
return getPaneTabCount("second-pane") === 0 && !isTabBarVisible("second-pane");
979-
},
980-
"Second pane to be empty",
981-
1000
982-
);
960+
// If the second pane has tabs, log what they are and close them
961+
if (getPaneTabCount("second-pane") > 0) {
962+
const secondPaneWorkingSet = MainViewManager.getWorkingSet("second-pane");
963+
for (const file of secondPaneWorkingSet) {
964+
await awaitsForDone(
965+
CommandManager.execute(Commands.FILE_CLOSE, { file: file, paneId: "second-pane" }),
966+
`Force close file ${file.fullPath} in second pane`
967+
);
968+
}
969+
970+
// Wait for the second pane to be empty
971+
await awaitsFor(
972+
function () {
973+
return getPaneTabCount("second-pane") === 0;
974+
},
975+
"Second pane to be empty after cleanup",
976+
2000
977+
);
978+
}
983979

984-
// Verify initial tab counts
985-
expect(getPaneTabCount("first-pane")).toBe(firstPaneFiles.length);
986980
expect(getPaneTabCount("second-pane")).toBe(0);
987981
expect(isTabBarVisible("second-pane")).toBe(false);
988982

989983
// Get the source tab from the first pane
990984
const sourceTab = $(`.tab[data-path="${firstPaneFiles[0]}"]`);
985+
expect(sourceTab.length).toBe(1, "Source tab should exist in the first pane");
991986

992987
// Get the empty pane content area as the drop target
993988
const emptyPaneTarget = $("#second-pane .pane-content");
994-
995-
// Simulate drag start on the source tab
996-
const dragStartEvent = $.Event("dragstart", {
997-
originalEvent: {
998-
dataTransfer: {
999-
setData: function () {},
1000-
effectAllowed: "move"
1001-
}
1002-
}
1003-
});
1004-
sourceTab.trigger(dragStartEvent);
1005-
1006-
// Simulate dragenter on the empty pane
1007-
const dragEnterEvent = $.Event("dragenter");
1008-
emptyPaneTarget.trigger(dragEnterEvent);
1009-
1010-
// Simulate drag over on the empty pane
1011-
const dragOverEvent = $.Event("dragover", {
1012-
originalEvent: {
1013-
dataTransfer: {
1014-
dropEffect: "move"
989+
expect(emptyPaneTarget.length).toBe(1, "Empty pane target should exist");
990+
991+
// Simulate drag and drop
992+
try {
993+
// Simulate drag start
994+
const dragStartEvent = $.Event("dragstart", {
995+
originalEvent: {
996+
dataTransfer: {
997+
setData: function () {},
998+
effectAllowed: "move"
999+
}
10151000
}
1016-
},
1017-
preventDefault: function () {}
1018-
});
1019-
emptyPaneTarget.trigger(dragOverEvent);
1020-
1021-
// Simulate drop on the empty pane
1022-
const dropEvent = $.Event("drop", {
1023-
originalEvent: {
1024-
dataTransfer: {}
1025-
},
1026-
preventDefault: function () {},
1027-
stopPropagation: function () {}
1028-
});
1029-
emptyPaneTarget.trigger(dropEvent);
1001+
});
1002+
sourceTab.trigger(dragStartEvent);
1003+
1004+
// Simulate dragenter
1005+
const dragEnterEvent = $.Event("dragenter");
1006+
emptyPaneTarget.trigger(dragEnterEvent);
1007+
1008+
// Simulate dragover
1009+
const dragOverEvent = $.Event("dragover", {
1010+
originalEvent: {
1011+
dataTransfer: {
1012+
dropEffect: "move"
1013+
}
1014+
},
1015+
preventDefault: function () {}
1016+
});
1017+
emptyPaneTarget.trigger(dragOverEvent);
10301018

1031-
// Simulate dragend to complete the operation
1032-
const dragEndEvent = $.Event("dragend");
1033-
sourceTab.trigger(dragEndEvent);
1019+
// Simulate drop
1020+
const dropEvent = $.Event("drop", {
1021+
originalEvent: {
1022+
dataTransfer: {}
1023+
},
1024+
preventDefault: function () {},
1025+
stopPropagation: function () {}
1026+
});
1027+
emptyPaneTarget.trigger(dropEvent);
1028+
1029+
// Simulate dragend
1030+
const dragEndEvent = $.Event("dragend");
1031+
sourceTab.trigger(dragEndEvent);
1032+
} catch (e) {
1033+
console.error("Error during drag and drop simulation:", e);
1034+
throw e;
1035+
}
10341036

10351037
// Wait for the tab to move to the second pane
10361038
await awaitsFor(
@@ -1042,7 +1044,7 @@ define(function (require, exports, module) {
10421044
);
10431045
},
10441046
"Tab to move from first pane to second pane and tab bar to appear",
1045-
1000
1047+
2000
10461048
);
10471049

10481050
// Verify the tab counts after the drag and drop
@@ -1289,9 +1291,11 @@ define(function (require, exports, module) {
12891291
// Wait for the third file to become active
12901292
await awaitsFor(
12911293
function () {
1292-
return isTabActive(testFilePath3) &&
1293-
MainViewManager.getCurrentlyViewedFile() &&
1294-
MainViewManager.getCurrentlyViewedFile().fullPath === testFilePath3;
1294+
return (
1295+
isTabActive(testFilePath3) &&
1296+
MainViewManager.getCurrentlyViewedFile() &&
1297+
MainViewManager.getCurrentlyViewedFile().fullPath === testFilePath3
1298+
);
12951299
},
12961300
"Third file to become active",
12971301
2000

0 commit comments

Comments
 (0)