From ee898e970a156a93c2632da83a47c4f6a626b5c4 Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 17 Jan 2025 08:02:15 +0530 Subject: [PATCH 1/4] test: git history switch integ tests --- test/spec/Extn-Git-integ-test.js | 36 +++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/test/spec/Extn-Git-integ-test.js b/test/spec/Extn-Git-integ-test.js index 2d40c4b030..b841408e54 100644 --- a/test/spec/Extn-Git-integ-test.js +++ b/test/spec/Extn-Git-integ-test.js @@ -318,9 +318,12 @@ define(function (require, exports, module) { }, `History viewer to be visible: ${visible}`); } - async function testHistoryViewerToggle(commitIndex) { + it("should show the history viewer when clicking the first commit row and dismiss it on clicking again", async () => { + const $historyToggleButton = $gitPanel.find(".git-history-toggle"); + $historyToggleButton.trigger("click"); + await waitForHistoryVisible(true); // Ensure the history list is visible const $historyList = $gitPanel.find("#git-history-list"); - const $commitRow = $historyList.find(".history-commit").eq(commitIndex); + const $commitRow = $historyList.find(".history-commit").eq(1); // Ensure the commit row exists expect($commitRow.length).toBe(1); @@ -338,13 +341,30 @@ define(function (require, exports, module) { // Click the row again to dismiss the history viewer $commitRow.trigger("click"); await waitForHistoryViewerVisible(false); - } + }); - it("should show the history viewer when clicking the first commit row and dismiss it on clicking again", async () => { - const $historyToggleButton = $gitPanel.find(".git-history-toggle"); - $historyToggleButton.trigger("click"); - await waitForHistoryVisible(true); // Ensure the history list is visible - await testHistoryViewerToggle(1); // Test for the first commit row + it("should be able to switch history", async () => { + const $historyList = $gitPanel.find("#git-history-list"); + + let $commitRow = $historyList.find(".history-commit").eq(1); + $commitRow.trigger("click"); + await waitForHistoryViewerVisible(true); + + // Verify that the history viewer shows the correct commit + await awaitsFor(() => { + return $("#editor-holder .git").find(".commit-title").text().trim().includes("first commit"); + }, `History viewer to have first commit detail`); + + $commitRow = $historyList.find(".history-commit").eq(0); + $commitRow.trigger("click"); + await waitForHistoryViewerVisible(true); + await awaitsFor(() => { + return $("#editor-holder .git").find(".commit-title").text().trim().includes("second commit"); + }, `History viewer to have second commit detail`); + + // Click the row again to dismiss the history viewer + $commitRow.trigger("click"); + await waitForHistoryViewerVisible(false); }); }); From 7913e249e6067a0b4bda21d9afd08689a1e04684 Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 17 Jan 2025 08:23:42 +0530 Subject: [PATCH 2/4] test: git switch project --- test/spec/Extn-Git-integ-test.js | 73 +++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/test/spec/Extn-Git-integ-test.js b/test/spec/Extn-Git-integ-test.js index b841408e54..7d218edef2 100644 --- a/test/spec/Extn-Git-integ-test.js +++ b/test/spec/Extn-Git-integ-test.js @@ -29,7 +29,7 @@ define(function (require, exports, module) { let $, __PR, testWindow, ExtensionLoader, Menus, Commands, CommandManager, EditorManager, SpecRunnerUtils = require("spec/SpecRunnerUtils"), - anotherTestFolder = SpecRunnerUtils.getTestPath("/spec/LowLevelFileIO-test-files"); + nonGitReadOnlyTestFolder = SpecRunnerUtils.getTestPath("/spec/LowLevelFileIO-test-files"); let testPathGit; @@ -78,17 +78,31 @@ define(function (require, exports, module) { $gitIcon = $("#git-toolbar-icon"); }); - it("should only git settings, init and clone commands be enabled in non-git repos", async function () { - await forCommandEnabled(Commands.CMD_GIT_INIT); - await forCommandEnabled(Commands.CMD_GIT_CLONE); - await forCommandEnabled(Commands.CMD_GIT_SETTINGS_COMMAND_ID); - await forCommandEnabled(Commands.CMD_GIT_TOGGLE_PANEL); + async function verifyRepoInNonGitState(isNonGit = true) { + await forCommandEnabled(Commands.CMD_GIT_INIT, isNonGit); + await forCommandEnabled(Commands.CMD_GIT_CLONE, isNonGit); + await forCommandEnabled(Commands.CMD_GIT_SETTINGS_COMMAND_ID, true); + await forCommandEnabled(Commands.CMD_GIT_TOGGLE_PANEL, true); // others are disabled - await forCommandEnabled(Commands.CMD_GIT_REFRESH, false); - await forCommandEnabled(Commands.CMD_GIT_REFRESH, false); - await forCommandEnabled(Commands.CMD_GIT_FETCH, false); - await forCommandEnabled(Commands.CMD_GIT_PULL, false); - await forCommandEnabled(Commands.CMD_GIT_PUSH, false); + await forCommandEnabled(Commands.CMD_GIT_REFRESH, !isNonGit); + await forCommandEnabled(Commands.CMD_GIT_REFRESH, !isNonGit); + await forCommandEnabled(Commands.CMD_GIT_FETCH, !isNonGit); + await forCommandEnabled(Commands.CMD_GIT_PULL, !isNonGit); + await forCommandEnabled(Commands.CMD_GIT_PUSH, !isNonGit); + } + + async function verifyNonGitPanelIcons(notGitProject) { + expect($gitPanel.find(".git-init").is(":visible")).toBe(notGitProject); + expect($gitPanel.find(".git-clone").is(":visible")).toBe(notGitProject); + // in non git repos the git buttons are not visible + expect($gitPanel.find(".git-commit").is(":visible")).toBe(!notGitProject); + expect($gitPanel.find(".git-prev-gutter").is(":visible")).toBe(!notGitProject); + expect($gitPanel.find(".git-file-history").is(":visible")).toBe(!notGitProject); + expect($gitPanel.find(".git-right-icons").is(":visible")).toBe(!notGitProject); + } + + it("should only git settings, init and clone commands be enabled in non-git repos", async function () { + await verifyRepoInNonGitState(); }); it("Should Git icon be hidden in non-git repo", async function () { @@ -99,14 +113,7 @@ define(function (require, exports, module) { await __PR.execCommand(Commands.CMD_GIT_TOGGLE_PANEL); expect($gitPanel.is(":visible")).toBeTrue(); expect($gitIcon.is(":visible")).toBeTrue(); - // verify that only the init and clone button is visible - expect($gitPanel.find(".git-init").is(":visible")).toBeTrue(); - expect($gitPanel.find(".git-clone").is(":visible")).toBeTrue(); - // in non git repos the git buttons are not visible - expect($gitPanel.find(".git-commit").is(":visible")).toBeFalse(); - expect($gitPanel.find(".git-prev-gutter").is(":visible")).toBeFalse(); - expect($gitPanel.find(".git-file-history").is(":visible")).toBeFalse(); - expect($gitPanel.find(".git-right-icons").is(":visible")).toBeFalse(); + await verifyNonGitPanelIcons(true); }); it("Should be able to initialize git repo", async function () { @@ -318,6 +325,18 @@ define(function (require, exports, module) { }, `History viewer to be visible: ${visible}`); } + async function waitForBranchDropdownVisible(visible) { + await awaitsFor(() => { + return $("#git-branch-dropdown-toggle").is(":visible") === visible; + }, `Branch Dropdown to be visible: ${visible}`); + } + + async function waitForGitToolbarIconVisible(visible) { + await awaitsFor(() => { + return $gitIcon.is(":visible") === visible; + }, `Git icon to be visible: ${visible}`); + } + it("should show the history viewer when clicking the first commit row and dismiss it on clicking again", async () => { const $historyToggleButton = $gitPanel.find(".git-history-toggle"); $historyToggleButton.trigger("click"); @@ -367,6 +386,22 @@ define(function (require, exports, module) { await waitForHistoryViewerVisible(false); }); + it("should switching to a non-git project hide branch dropdown and move git panel to init state", async () => { + await SpecRunnerUtils.loadProjectInTestWindow(nonGitReadOnlyTestFolder); + await waitForBranchDropdownVisible(false); + await waitForGitToolbarIconVisible(true); + await verifyRepoInNonGitState(); + await verifyNonGitPanelIcons(true); + }); + + it("should switching back to git project show branch dropdown and show git panel controls", async () => { + await SpecRunnerUtils.loadProjectInTestWindow(testPathGit); + await waitForBranchDropdownVisible(true); + await waitForGitToolbarIconVisible(true); + await verifyRepoInNonGitState(false); + await verifyNonGitPanelIcons(false); + }); + }); }); From 04894beb107fb9e2c89df37bdb6fa503f593de3f Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 17 Jan 2025 08:29:21 +0530 Subject: [PATCH 3/4] test: git switch project impast on git toolbar icon --- test/spec/Extn-Git-integ-test.js | 34 ++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/test/spec/Extn-Git-integ-test.js b/test/spec/Extn-Git-integ-test.js index 7d218edef2..0bfd910647 100644 --- a/test/spec/Extn-Git-integ-test.js +++ b/test/spec/Extn-Git-integ-test.js @@ -91,14 +91,14 @@ define(function (require, exports, module) { await forCommandEnabled(Commands.CMD_GIT_PUSH, !isNonGit); } - async function verifyNonGitPanelIcons(notGitProject) { - expect($gitPanel.find(".git-init").is(":visible")).toBe(notGitProject); - expect($gitPanel.find(".git-clone").is(":visible")).toBe(notGitProject); + async function verifyGitPanelIcons(isGitProject) { + expect($gitPanel.find(".git-init").is(":visible")).toBe(!isGitProject); + expect($gitPanel.find(".git-clone").is(":visible")).toBe(!isGitProject); // in non git repos the git buttons are not visible - expect($gitPanel.find(".git-commit").is(":visible")).toBe(!notGitProject); - expect($gitPanel.find(".git-prev-gutter").is(":visible")).toBe(!notGitProject); - expect($gitPanel.find(".git-file-history").is(":visible")).toBe(!notGitProject); - expect($gitPanel.find(".git-right-icons").is(":visible")).toBe(!notGitProject); + expect($gitPanel.find(".git-commit").is(":visible")).toBe(isGitProject); + expect($gitPanel.find(".git-prev-gutter").is(":visible")).toBe(isGitProject); + expect($gitPanel.find(".git-file-history").is(":visible")).toBe(isGitProject); + expect($gitPanel.find(".git-right-icons").is(":visible")).toBe(isGitProject); } it("should only git settings, init and clone commands be enabled in non-git repos", async function () { @@ -113,7 +113,7 @@ define(function (require, exports, module) { await __PR.execCommand(Commands.CMD_GIT_TOGGLE_PANEL); expect($gitPanel.is(":visible")).toBeTrue(); expect($gitIcon.is(":visible")).toBeTrue(); - await verifyNonGitPanelIcons(true); + await verifyGitPanelIcons(false); }); it("Should be able to initialize git repo", async function () { @@ -391,7 +391,7 @@ define(function (require, exports, module) { await waitForBranchDropdownVisible(false); await waitForGitToolbarIconVisible(true); await verifyRepoInNonGitState(); - await verifyNonGitPanelIcons(true); + await verifyGitPanelIcons(false); }); it("should switching back to git project show branch dropdown and show git panel controls", async () => { @@ -399,7 +399,21 @@ define(function (require, exports, module) { await waitForBranchDropdownVisible(true); await waitForGitToolbarIconVisible(true); await verifyRepoInNonGitState(false); - await verifyNonGitPanelIcons(false); + await verifyGitPanelIcons(true); + }); + + it("should switching to a non-git project while git panel hidden hide git toolbar icon", async () => { + await SpecRunnerUtils.loadProjectInTestWindow(nonGitReadOnlyTestFolder); + await __PR.execCommand(Commands.CMD_GIT_TOGGLE_PANEL); + expect($gitPanel.is(":visible")).toBeFalse(); + + await SpecRunnerUtils.loadProjectInTestWindow(nonGitReadOnlyTestFolder); + await waitForGitToolbarIconVisible(false); + + await SpecRunnerUtils.loadProjectInTestWindow(testPathGit); + await waitForGitToolbarIconVisible(true); + await __PR.execCommand(Commands.CMD_GIT_TOGGLE_PANEL); + }); }); From c94b4b2d19d7a36e29daac563617ba625050dca1 Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 17 Jan 2025 08:53:56 +0530 Subject: [PATCH 4/4] chore: adjust styles so that the branch and project dropdown has enough space on ong names --- src/styles/Extn-RecentProjects.less | 1 + 1 file changed, 1 insertion(+) diff --git a/src/styles/Extn-RecentProjects.less b/src/styles/Extn-RecentProjects.less index c77967714a..3ee390a38d 100644 --- a/src/styles/Extn-RecentProjects.less +++ b/src/styles/Extn-RecentProjects.less @@ -51,6 +51,7 @@ white-space: nowrap; padding: 2px 5px; margin-left: -5px; + max-width: 60%; .dropdown-arrow { display: inline-block; width: 7px;