Skip to content

Commit 01048e2

Browse files
committed
feat: add test to make sure that tab clicks are working fine
1 parent f52daad commit 01048e2

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,49 @@ define(function (require, exports, module) {
536536
// Verify the tab for the previous active file is no longer active
537537
expect(isTabActive(activeFile.fullPath)).toBe(false);
538538
});
539+
540+
it("should switch files properly when different tabs are clicked", async function () {
541+
// Helper function to click a tab and verify it becomes active
542+
async function clickTabAndVerify(filePath, description) {
543+
const $tab = getTab(filePath);
544+
expect($tab.length).toBe(1);
545+
$tab.trigger("mousedown");
546+
547+
// Wait for the file to become active
548+
await awaitsFor(
549+
function () {
550+
return (
551+
isTabActive(filePath) && MainViewManager.getCurrentlyViewedFile().fullPath === filePath
552+
);
553+
},
554+
`${description} to become active after tab click`,
555+
1000
556+
);
557+
558+
// Verify this tab is active and others are not
559+
const allPaths = [testFilePath, testFilePath2, testFilePath3];
560+
allPaths.forEach((path) => {
561+
expect(isTabActive(path)).toBe(path === filePath);
562+
});
563+
564+
// Verify the correct file is loaded in the editor
565+
expect(MainViewManager.getCurrentlyViewedFile().fullPath).toBe(filePath);
566+
}
567+
// add a small timer to make sure that the tab bar is properly loaded
568+
await awaits(100);
569+
570+
// Initially, verify the third file is active (last opened)
571+
expect(isTabActive(testFilePath3)).toBe(true);
572+
expect(MainViewManager.getCurrentlyViewedFile().fullPath).toBe(testFilePath3);
573+
574+
// Test clicking on each tab
575+
await clickTabAndVerify(testFilePath, "First file");
576+
await clickTabAndVerify(testFilePath2, "Second file");
577+
await clickTabAndVerify(testFilePath3, "Third file");
578+
579+
// Click back on the first tab to ensure it still works
580+
await clickTabAndVerify(testFilePath, "First file");
581+
});
539582
});
540583

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

0 commit comments

Comments
 (0)