Skip to content

Commit 3b43684

Browse files
committed
feat: test for scroll to active tab
1 parent 0196300 commit 3b43684

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

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

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,96 @@ define(function (require, exports, module) {
903903
await awaitsForDone(promise, `Close file ${filePath}`);
904904
}
905905
});
906+
907+
it("should scroll tab bar to make selected file visible when selecting from working set", async function () {
908+
// Create several test files to ensure overflow
909+
const testFiles = [];
910+
for (let i = 0; i < 15; i++) {
911+
const filePath = SpecRunnerUtils.getTempDirectory() + `/overflow-test-${i}.js`;
912+
testFiles.push(filePath);
913+
await jsPromise(SpecRunnerUtils.createTextFile(filePath, `// Overflow test file ${i}`, FileSystem));
914+
}
915+
916+
// Open all the test files
917+
for (const filePath of testFiles) {
918+
await awaitsForDone(
919+
CommandManager.execute(Commands.FILE_OPEN, { fullPath: filePath }),
920+
`Open file ${filePath}`
921+
);
922+
}
923+
924+
// Wait for all tabs to appear
925+
await awaitsFor(
926+
function () {
927+
return getTabCount() >= testFiles.length;
928+
},
929+
"All tabs to appear",
930+
1000
931+
);
932+
933+
// Wait for the overflow button to appear
934+
await awaitsFor(
935+
function () {
936+
return isOverflowButtonVisible();
937+
},
938+
"Overflow button to appear",
939+
1000
940+
);
941+
942+
// Get the list of hidden tabs
943+
const hiddenFiles = testFiles.filter((filePath) => !isTabVisible(filePath));
944+
expect(hiddenFiles.length).toBeGreaterThan(0);
945+
946+
// Select a hidden file to test
947+
const testHiddenFile = hiddenFiles[0];
948+
949+
// Verify the tab is not visible initially
950+
expect(isTabVisible(testHiddenFile)).toBe(false);
951+
952+
// Select the file directly from the working set (not using the overflow dropdown)
953+
await awaitsForDone(
954+
CommandManager.execute(Commands.FILE_OPEN, { fullPath: testHiddenFile }),
955+
"Open hidden file from working set"
956+
);
957+
958+
// Wait for the file to become active
959+
await awaitsFor(
960+
function () {
961+
return (
962+
isTabActive(testHiddenFile) &&
963+
MainViewManager.getCurrentlyViewedFile().fullPath === testHiddenFile
964+
);
965+
},
966+
"Hidden file to become active after selection from working set",
967+
1000
968+
);
969+
970+
// Verify the file is active
971+
expect(isTabActive(testHiddenFile)).toBe(true);
972+
expect(MainViewManager.getCurrentlyViewedFile().fullPath).toBe(testHiddenFile);
973+
974+
// Verify the tab is now visible (scrolled into view)
975+
await awaitsFor(
976+
function () {
977+
return isTabVisible(testHiddenFile);
978+
},
979+
"Tab to become visible after selection from working set",
980+
1000
981+
);
982+
983+
expect(isTabVisible(testHiddenFile)).toBe(true);
984+
985+
// Clean up - close all the test files
986+
for (const filePath of testFiles) {
987+
const fileToClose = FileSystem.getFileForPath(filePath);
988+
const promise = CommandManager.execute(Commands.FILE_CLOSE, { file: fileToClose });
989+
testWindow.brackets.test.Dialogs.cancelModalDialogIfOpen(
990+
testWindow.brackets.test.DefaultDialogs.DIALOG_ID_SAVE_CLOSE,
991+
testWindow.brackets.test.DefaultDialogs.DIALOG_BTN_DONTSAVE
992+
);
993+
await awaitsForDone(promise, `Close file ${filePath}`);
994+
}
995+
});
906996
});
907997

908998
describe("Tab Items", function () {

0 commit comments

Comments
 (0)