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

Commit

Permalink
fix tests dependent of .tab / related selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaraugusto committed Feb 3, 2017
1 parent 4b54dfa commit 2428ae2
Show file tree
Hide file tree
Showing 18 changed files with 77 additions and 75 deletions.
2 changes: 1 addition & 1 deletion test/about/adblockTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('about:adblock', function () {
.waitForUrl(Brave.newTabUrl)
.waitForBrowserWindow()
.waitForVisible(urlInput)
.waitForExist('.tab[data-frame-key="1"]')
.waitForExist('[data-test-id="tab"][data-frame-key="1"]')
.tabByIndex(0)
.loadUrl(url)
})
Expand Down
4 changes: 2 additions & 2 deletions test/about/bookmarksManagerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('about:bookmarks', function () {
.addSite({ location: 'https://duckduckgo.com', title: 'duckduckgo', tags: bookmarkTag, parentFolderId: folderId, lastAccessedTime: lastVisit }, siteTags.BOOKMARK)
.addSite({ location: 'https://google.com', title: 'Google', tags: bookmarkTag, parentFolderId: folderId, lastAccessedTime: lastVisit }, siteTags.BOOKMARK)
.addSite({ location: 'https://bing.com', title: 'Bing', tags: bookmarkTag, parentFolderId: folderId, lastAccessedTime: lastVisit }, siteTags.BOOKMARK)
.waitForExist('.tab[data-frame-key="1"]')
.waitForExist('[data-test-id="tab"][data-frame-key="1"]')
.tabByIndex(0)
.url(aboutBookmarksUrl)
}
Expand All @@ -60,7 +60,7 @@ describe('about:bookmarks', function () {
parentFolderId: 0,
lastAccessedTime: lastVisit
}, siteTags.BOOKMARK)
.waitForExist('.tab[data-frame-key="1"]')
.waitForExist('[data-test-id="tab"][data-frame-key="1"]')
.tabByIndex(0)
.url(aboutBookmarksUrl)
}
Expand Down
2 changes: 1 addition & 1 deletion test/about/braveTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('about:brave tests', function () {
.waitForUrl(Brave.newTabUrl)
.waitForBrowserWindow()
.waitForVisible(urlInput)
.waitForExist('.tab[data-frame-key="1"]')
.waitForExist('[data-test-id="tab"][data-frame-key="1"]')
.tabByIndex(0)
.loadUrl(url)
})
Expand Down
2 changes: 1 addition & 1 deletion test/about/componentUpdaterTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('component updater', function () {
.waitForBrowserWindow()
.waitForVisible(urlInput)
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('.tab[data-frame-key="1"]')
.waitForExist('[data-test-id="tab"][data-frame-key="1"]')
}

describe('Google Widevine is disabled by default', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/about/extensionsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('about:extensions', function () {
.waitForBrowserWindow()
.waitForVisible(urlInput)
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('.tab[data-frame-key="1"]')
.waitForExist('[data-test-id="tab"][data-frame-key="1"]')
.tabByIndex(0)
.url(aboutExtensionsUrl)
}
Expand Down
4 changes: 2 additions & 2 deletions test/about/historyTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('about:history', function () {
.addSite({ location: 'https://brave.com/test', customTitle: 'customTest' })
.addSite({ location: 'https://www.youtube.com' })
.addSite({ location: 'https://www.facebook.com' })
.waitForExist('.tab[data-frame-key="1"]')
.waitForExist('[data-test-id="tab"][data-frame-key="1"]')
.tabByIndex(0)
.url(aboutHistoryUrl)
}
Expand All @@ -35,7 +35,7 @@ describe('about:history', function () {
location: site,
title: 'Page 1'
})
.waitForExist('.tab[data-frame-key="1"]')
.waitForExist('[data-test-id="tab"][data-frame-key="1"]')
.tabByIndex(0)
.url(aboutHistoryUrl)
}
Expand Down
6 changes: 3 additions & 3 deletions test/about/newTabTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ describe('about:newtab tests', function () {
.addSite({ location: 'about:preferences' })
.addSite({ location: 'about:safebrowsing' })
.addSite({ location: 'about:styles' })
.waitForExist('.tab[data-frame-key="1"]')
.waitForExist('[data-test-id="tab"][data-frame-key="1"]')
.tabByIndex(0)
.url(aboutNewTabUrl)
}

function * waitForPageLoad (client) {
yield client
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('.tab[data-frame-key="1"]')
.waitForExist('[data-test-id="tab"][data-frame-key="1"]')
.tabByIndex(0)
}

Expand Down Expand Up @@ -120,7 +120,7 @@ describe('about:newtab tests', function () {

yield this.app.client
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('.tab[data-frame-key="1"]')
.waitForExist('[data-test-id="tab"][data-frame-key="1"]')
.tabByIndex(0)
.waitForVisible('.clock .time')
.waitUntil(function () {
Expand Down
2 changes: 1 addition & 1 deletion test/about/stylesTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('about:styles', function () {
.waitForUrl(Brave.newTabUrl)
.waitForBrowserWindow()
.waitForVisible(urlInput)
.waitForExist('.tab[data-frame-key="1"]')
.waitForExist('[data-test-id="tab"][data-frame-key="1"]')
.tabByIndex(0)
.loadUrl(url)
})
Expand Down
4 changes: 2 additions & 2 deletions test/components/contentLoadingTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('content loading', function () {
.url(page1)
.windowByUrl(Brave.browserWindowUrl)
.waitUntil(function () {
return this.getText('.tabTitle').then((title) => {
return this.getText('[data-test-id="tabTitle"]').then((title) => {
return title === 'failed'
})
})
Expand All @@ -36,7 +36,7 @@ describe('content loading', function () {
.url(page1)
.windowByUrl(Brave.browserWindowUrl)
.waitUntil(function () {
return this.getText('.tabTitle').then((title) => {
return this.getText('[data-test-id="tabTitle"]').then((title) => {
return title === 'fail'
})
})
Expand Down
5 changes: 3 additions & 2 deletions test/components/findbarTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,12 @@ describe('findBar', function () {
.showFindbar(true, 2)
.waitForElementFocus(findBarInput)
.setValue(findBarInput, 'abc')
.click('.tab')
.click('[data-test-id="tab"]')
.waitUntil(function () {
return this.getValue(findBarInput).then((val) => val === 'test')
})
.click('.closeTab')
.click('[data-test-id="tab"]')
.click('[data-test-id="closeTabIcon"]')
.waitUntil(function () {
return this.getValue(findBarInput).then((val) => val === 'abc')
})
Expand Down
12 changes: 6 additions & 6 deletions test/components/frameTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('frame tests', function () {
.click('#name')
yield this.app.client
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('.tab[data-frame-key="2"]')
.waitForExist('[data-test-id="tab"][data-frame-key="2"]')
yield this.app.client
.ipcSend('shortcut-set-active-frame-by-index', 0)
.windowByUrl(Brave.browserWindowUrl)
Expand All @@ -64,9 +64,9 @@ describe('frame tests', function () {
})

it('inserts after the tab to clone', function * () {
this.tab1 = '.tabArea:nth-child(1) .tab[data-frame-key="1"]'
this.tab2 = '.tabArea:nth-child(2) .tab[data-frame-key="3"]'
this.tab3 = '.tabArea:nth-child(3) .tab[data-frame-key="2"]'
this.tab1 = '.tabArea:nth-child(1) [data-test-id="tab"][data-frame-key="1"]'
this.tab2 = '.tabArea:nth-child(2) [data-test-id="tab"][data-frame-key="3"]'
this.tab3 = '.tabArea:nth-child(3) [data-test-id="tab"][data-frame-key="2"]'
yield this.app.client
.windowByUrl(Brave.browserWindowUrl)
.waitForExist(this.tab1)
Expand Down Expand Up @@ -185,7 +185,7 @@ describe('frame tests', function () {
.tabByIndex(0)
.loadUrl(this.url)
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('.tab[data-frame-key="1"]')
.waitForExist('[data-test-id="tab"][data-frame-key="1"]')
.waitForExist(this.webview1)
})

Expand Down Expand Up @@ -214,7 +214,7 @@ describe('frame tests', function () {
yield setup(this.app.client)
yield this.app.client
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('.tab[data-frame-key="1"]')
.waitForExist('[data-test-id="tab"][data-frame-key="1"]')
})

it('loads an image', function * () {
Expand Down
10 changes: 5 additions & 5 deletions test/components/navigationBarTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ describe('navigationBar tests', function () {
const pageWithNoFavicon = Brave.server.url('page_no_favicon.html')
yield this.app.client.tabByUrl(Brave.newTabUrl).url(pageWithNoFavicon).waitForUrl(pageWithNoFavicon).windowParentByUrl(pageWithNoFavicon)
yield this.app.client.waitUntil(function () {
return this.getAttribute(activeTabFavicon, 'class').then((className) =>
className === 'tabIcon bookmarkFile fa fa-file-o')
return this.getAttribute('[data-test-id="defaultIcon"]', 'class').then((className) =>
className === 'fa fa-file-o')
})
})
})
Expand Down Expand Up @@ -759,8 +759,8 @@ describe('navigationBar tests', function () {
it('Uses the default tab color when one is not specified', function * () {
const page1Url = Brave.server.url('page1.html')
yield this.app.client.tabByUrl(Brave.newTabUrl).url(page1Url).waitForUrl(page1Url).windowParentByUrl(page1Url)
let background = yield this.app.client.getCssProperty(activeTab, 'background')
assert.equal(background.value, 'rgba(0,0,0,0)linear-gradient(white,rgb(243,243,243))repeatscroll0%0%/autopadding-boxborder-box')
let background = yield this.app.client.getCssProperty('[data-test-active-tab]', 'background')
assert.equal(background.value, 'rgba(0,0,0,0)linear-gradient(rgb(255,255,255),rgb(243,243,243))repeatscroll0%0%/autopadding-boxborder-box')
})

// We need a newer electron build first
Expand Down Expand Up @@ -1089,7 +1089,7 @@ describe('navigationBar tests', function () {

it('focuses on the urlbar', function * () {
this.app.client
.waitForExist('.tab[data-frame-key="1"].active')
.waitForExist('[data-test-active-tab][data-frame-key="1"]')
.waitForElementFocus(urlInput)
})
})
Expand Down
24 changes: 12 additions & 12 deletions test/components/pinnedTabTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ describe('pinnedTabs', function () {
.ipcSend(messages.SHORTCUT_NEW_FRAME, this.page1Url)
.waitForUrl(this.page1Url)
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('.tab[data-frame-key="2"]')
.waitForExist('[data-test-id="tab"][data-frame-key="2"]')
.setPinned(this.page1Url, true)
.waitForExist(pinnedTabsTabs)
.waitForElementCount(pinnedTabsTabs, 1)
.waitForElementCount(tabsTabs, 1)
})
it('creates when signaled', function * () {
yield this.app.client
.waitForExist('.tab.isPinned[data-frame-key="2"]')
.waitForExist('[data-test-pinned-tab][data-frame-key="2"]')
})
it('unpins and creates a non-pinned tab', function * () {
yield this.app.client
.setPinned(this.page1Url, false)
.waitForExist('.tab:not(.isPinned)[data-frame-key="2"]')
.waitForExist('[data-test-pinned-tab="false"][data-frame-key="2"]')
.waitForElementCount(pinnedTabsTabs, 0)
.waitForElementCount(tabsTabs, 2)
})
Expand All @@ -45,7 +45,7 @@ describe('pinnedTabs', function () {
.ipcSend(messages.SHORTCUT_NEW_FRAME, this.page1Url)
.waitForUrl(this.page1Url)
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('.tab[data-frame-key="3"]')
.waitForExist('[data-test-id="tab"][data-frame-key="3"]')
.setPinned(this.page1Url, true)
.waitForElementCount(pinnedTabsTabs, 1)
.waitForElementCount(tabsTabs, 2)
Expand All @@ -61,13 +61,13 @@ describe('pinnedTabs', function () {
.ipcSend(messages.SHORTCUT_NEW_FRAME, this.page1Url)
.waitForUrl(this.page1Url)
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('.tab[data-frame-key="2"]')
.waitForExist('[data-test-id="tab"][data-frame-key="2"]')
.setPinned(this.page1Url, true)
.waitForExist(pinnedTabsTabs)
.waitForElementCount(pinnedTabsTabs, 1)
.waitForElementCount(tabsTabs, 1)
.ipcSend(messages.SHORTCUT_NEW_FRAME, this.page1Url, {partitionNumber: 1})
.waitForExist('.tab[data-frame-key="3"]')
.waitForExist('[data-test-id="tab"][data-frame-key="3"]')
.setPinned(this.page1Url, true, {partitionNumber: 1})
.waitForElementCount(pinnedTabsTabs, 2)
.waitForElementCount(tabsTabs, 1)
Expand All @@ -84,11 +84,11 @@ describe('pinnedTabs', function () {
.addSite({ location: page1Url }, siteTags.PINNED)
.waitForUrl(page1Url)
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('.tab.isPinned[data-frame-key="2"]')
.waitForExist('[data-test-pinned-tab][data-frame-key="2"]')
.addSite({ location: page2Url }, siteTags.PINNED)
.waitForUrl(page2Url)
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('.tab.isPinned[data-frame-key="3"]')
.waitForExist('[data-test-pinned-tab][data-frame-key="3"]')
})
it('creates when signaled', function * () {
yield this.app.client.waitUntil(function () {
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('pinnedTabs', function () {
.ipcSend(messages.SHORTCUT_NEW_FRAME, this.page1Url)
.waitForUrl(this.page1Url)
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('.tab[data-frame-key="2"]')
.waitForExist('[data-test-id="tab"][data-frame-key="2"]')
.setPinned(this.page1Url, true)
.waitForExist(pinnedTabsTabs)
})
Expand Down Expand Up @@ -171,13 +171,13 @@ describe('pinnedTabs', function () {
.waitForElementCount(pinnedTabsTabs, 1)
.waitForElementCount(tabsTabs, 1)
.click(pinnedTabsTabs)
.waitForElementCount(pinnedTabsTabs + '.active', 1)
.waitForElementCount(pinnedTabsTabs + '[data-test-active-tab]', 1)
})
it('close attempt retains pinned tab and selects next active frame', function * () {
yield this.app.client
.waitForExist('.tab.active[data-frame-key="2"]')
.waitForExist('[data-test-active-tab][data-frame-key="2"]')
.ipcSend(messages.SHORTCUT_CLOSE_FRAME)
.waitForExist('.tab.active[data-frame-key="1"]')
.waitForExist('[data-test-active-tab][data-frame-key="1"]')
})
})
})
9 changes: 6 additions & 3 deletions test/components/tabPagesTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const Brave = require('../lib/brave')
const appConfig = require('../../js/constants/appConfig')
const settings = require('../../js/constants/settings')
const {urlInput, newFrameButton, tabsTabs, tabPage, tabPage1, tabPage2, closeTab, activeWebview} = require('../lib/selectors')
const {urlInput, newFrameButton, tabsTabs, tabPage, tabPage1, tabPage2, activeWebview} = require('../lib/selectors')

describe('tab pages', function () {
function * setup (client) {
Expand Down Expand Up @@ -35,12 +35,15 @@ describe('tab pages', function () {
})

it('shows no tab pages when you have only 1 page', function * () {
yield this.app.client.click(closeTab)
yield this.app.client
.waitForExist('[data-test-id="tab"][data-frame-key="1"]')
.click('[data-test-active-tab]')
.click('[data-test-id="closeTabIcon"]')
.waitForElementCount(tabPage, 0)
})

it('focuses active tab\'s page when closing last tab on page', function * () {
yield this.app.client.waitForVisible('.tab.active')
yield this.app.client.waitForVisible('[data-test-active-tab]')
})

describe('allows changing to tab pages', function () {
Expand Down
Loading

0 comments on commit 2428ae2

Please sign in to comment.