Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
Fix tabs so that they use the correct id when closing/focusing (#1761)
Browse files Browse the repository at this point in the history
* Fix tabs so that they use the correct id when closing/focusing

* Add integration test for opening/closing tabs with tabs.modes set to tabs
  • Loading branch information
rgehan authored and bryphe committed Mar 10, 2018
1 parent f06c25b commit adf404a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion browser/src/UI/components/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) : "",
Expand Down
1 change: 1 addition & 0 deletions test/CiTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const CiTests = [
"Editor.BufferModifiedState",
"Editor.OpenFile.PathWithSpacesTest",
"Editor.TabModifiedState",
"Editor.CloseTabWithTabModesTabsTest",
"MarkdownPreviewTest",
"PaintPerformanceTest",
"QuickOpenTest",
Expand Down
5 changes: 5 additions & 0 deletions test/ci/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
43 changes: 43 additions & 0 deletions test/ci/Editor.CloseTabWithTabModesTabsTest.ts
Original file line number Diff line number Diff line change
@@ -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("<cr>")
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",
},
}

0 comments on commit adf404a

Please sign in to comment.