Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #9539 from brave/test/9306
Browse files Browse the repository at this point in the history
Always switch back to active tab after sequentially closing tabs
  • Loading branch information
bbondy authored Jun 20, 2017
2 parents f44726d + f69209b commit 81f05a4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
7 changes: 4 additions & 3 deletions app/browser/reducers/tabsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ const updateActiveTab = (state, closeTabId) => {
return
}

if (!tabState.isActive(state, closeTabId)) {
const windowId = tabState.getWindowId(state, closeTabId)
if (windowId === windowState.WINDOW_ID_NONE) {
return
}

const windowId = tabState.getWindowId(state, closeTabId)
if (windowId === windowState.WINDOW_ID_NONE) {
const lastActiveTabId = tabState.getTabsByLastActivated(state, windowId).last()
if (lastActiveTabId !== closeTabId && !tabState.isActive(state, closeTabId)) {
return
}

Expand Down
35 changes: 34 additions & 1 deletion test/tab-components/tabTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,40 @@ describe('tab tests', function () {
})
})

describe('sequentially closing tabs', function () {
Brave.beforeAll(this)
before(function * () {
const page1 = Brave.server.url('adblock2.html')
const page2 = Brave.server.url('red_bg.html')
const page3 = Brave.server.url('yellow_header.html')

yield setup(this.app.client)
yield this.app.client
.newTab({ url: page1 })
.waitForUrl(page1)
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('[data-test-id="tab"][data-frame-key="2"]')
.newTab({ url: page2 })
.waitForUrl(page2)
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('[data-test-id="tab"][data-frame-key="3"]')
.newTab({ url: page3 })
.waitForUrl(page3)
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('[data-test-id="tab"][data-frame-key="4"]')
})

it('fallsback to last active tab if next tab does not exist', function * () {
yield this.app.client.changeSetting(settings.SHOW_TAB_PREVIEWS, false)
yield this.app.client
.moveToObject('[data-test-id="tab"][data-frame-key="3"]')
.middleClick('[data-test-id="tab"][data-frame-key="3"]')
.moveToObject('[data-test-id="tab"][data-frame-key="4"]')
.middleClick('[data-test-id="tab"][data-frame-key="4"]')
.waitForVisible('[data-test-active-tab="true"][data-frame-key="2"]')
})
})

describe('webview previews when tab is hovered', function () {
Brave.beforeAll(this)
before(function * () {
Expand Down Expand Up @@ -432,7 +466,6 @@ describe('tab tests', function () {
.click('[data-test-id="tab"][data-frame-key="2"]')
.moveToObject('[data-test-id="tab"][data-frame-key="5"]')
.middleClick('[data-test-id="tab"][data-frame-key="5"]')
.waitForExist('.frameWrapper.isPreview webview')
// no preview should be shown
.waitForVisible('.frameWrapper.isPreview webview', 500, true)
})
Expand Down

0 comments on commit 81f05a4

Please sign in to comment.