diff --git a/browser/src/UI/components/Tabs.tsx b/browser/src/UI/components/Tabs.tsx index 7c87c47761..1529dd7384 100644 --- a/browser/src/UI/components/Tabs.tsx +++ b/browser/src/UI/components/Tabs.tsx @@ -303,7 +303,7 @@ const getTabsFromVimTabs = createSelector( allBuffers: State.IBuffer[], ) => { return tabState.tabs.map((t: State.ITab, idx: number) => ({ - id: t.id, + id: idx + 1, name: getIdPrefix((idx + 1).toString(), shouldShowId) + getTabName(t.name), highlightColor: t.id === tabState.selectedTabId ? color : "transparent", iconFileName: showFileIcon ? getTabName(t.name) : "", diff --git a/test/CiTests.ts b/test/CiTests.ts index 702c06472d..5a1ca0a7e0 100644 --- a/test/CiTests.ts +++ b/test/CiTests.ts @@ -26,6 +26,7 @@ const CiTests = [ "Editor.BufferModifiedState", "Editor.OpenFile.PathWithSpacesTest", "Editor.TabModifiedState", + "Editor.CloseTabWithTabModesTabsTest", "MarkdownPreviewTest", "PaintPerformanceTest", "QuickOpenTest", diff --git a/test/ci/Common.ts b/test/ci/Common.ts index ef78bddebc..a3c43b715a 100644 --- a/test/ci/Common.ts +++ b/test/ci/Common.ts @@ -22,6 +22,11 @@ export const getElementByClassName = (className: string) => { } } +export const getElementsBySelector = (selector: string) => { + const elements = document.body.querySelectorAll(selector) + return elements || [] +} + export const createNewFile = async ( fileExtension: string, oni: Oni.Plugin.Api, diff --git a/test/ci/Editor.CloseTabWithTabModesTabsTest.ts b/test/ci/Editor.CloseTabWithTabModesTabsTest.ts new file mode 100644 index 0000000000..ec8801d2fa --- /dev/null +++ b/test/ci/Editor.CloseTabWithTabModesTabsTest.ts @@ -0,0 +1,43 @@ +import * as assert from "assert" +import * as Oni from "oni-api" + +import { getElementsBySelector } from "./Common" + +export const test = async (oni: Oni.Plugin.Api) => { + const getTabsCount = () => getElementsBySelector(".tabs .tab").length + const waitForTabCount = count => oni.automation.waitFor(() => getTabsCount() === count) + + const openTab = () => { + const initialTabCount = getTabsCount() + oni.automation.sendKeys(":tabnew") + oni.automation.sendKeys("") + return waitForTabCount(initialTabCount + 1) + } + + const closeLastTabWithMouse = () => { + const tabs = getElementsBySelector(".tabs .tab") + const closeButton = tabs[tabs.length - 1].querySelector(".corner.enable-hover") + closeButton.click() + return waitForTabCount(tabs.length - 1) + } + + await oni.automation.waitForEditors() + + // 1. Create two tabs, then close the last on + await openTab() + await openTab() + await closeLastTabWithMouse() + + // 3. Open another tab + await openTab() + + // 4.1 Attempt to close it + await closeLastTabWithMouse() +} + +// Bring in custom config. +export const settings = { + config: { + "tabs.mode": "tabs", + }, +}