Skip to content

Commit f42f617

Browse files
committed
test: git history switch integ tests
1 parent e0d2a49 commit f42f617

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

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

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,12 @@ define(function (require, exports, module) {
318318
}, `History viewer to be visible: ${visible}`);
319319
}
320320

321-
async function testHistoryViewerToggle(commitIndex) {
321+
it("should show the history viewer when clicking the first commit row and dismiss it on clicking again", async () => {
322+
const $historyToggleButton = $gitPanel.find(".git-history-toggle");
323+
$historyToggleButton.trigger("click");
324+
await waitForHistoryVisible(true); // Ensure the history list is visible
322325
const $historyList = $gitPanel.find("#git-history-list");
323-
const $commitRow = $historyList.find(".history-commit").eq(commitIndex);
326+
const $commitRow = $historyList.find(".history-commit").eq(1);
324327

325328
// Ensure the commit row exists
326329
expect($commitRow.length).toBe(1);
@@ -338,13 +341,30 @@ define(function (require, exports, module) {
338341
// Click the row again to dismiss the history viewer
339342
$commitRow.trigger("click");
340343
await waitForHistoryViewerVisible(false);
341-
}
344+
});
342345

343-
it("should show the history viewer when clicking the first commit row and dismiss it on clicking again", async () => {
344-
const $historyToggleButton = $gitPanel.find(".git-history-toggle");
345-
$historyToggleButton.trigger("click");
346-
await waitForHistoryVisible(true); // Ensure the history list is visible
347-
await testHistoryViewerToggle(1); // Test for the first commit row
346+
it("should be able to switch history", async () => {
347+
const $historyList = $gitPanel.find("#git-history-list");
348+
349+
let $commitRow = $historyList.find(".history-commit").eq(1);
350+
$commitRow.trigger("click");
351+
await waitForHistoryViewerVisible(true);
352+
353+
// Verify that the history viewer shows the correct commit
354+
await awaitsFor(() => {
355+
return $("#editor-holder .git").find(".commit-title").text().trim().includes("first commit");
356+
}, `History viewer to have first commit detail`);
357+
358+
$commitRow = $historyList.find(".history-commit").eq(0);
359+
$commitRow.trigger("click");
360+
await waitForHistoryViewerVisible(true);
361+
await awaitsFor(() => {
362+
return $("#editor-holder .git").find(".commit-title").text().trim().includes("second commit");
363+
}, `History viewer to have second commit detail`);
364+
365+
// Click the row again to dismiss the history viewer
366+
$commitRow.trigger("click");
367+
await waitForHistoryViewerVisible(false);
348368
});
349369

350370
});

0 commit comments

Comments
 (0)