Skip to content

Commit

Permalink
Show found redux tab instead of last tab for Electron test
Browse files Browse the repository at this point in the history
also add 5 attempts for find Redux tab
  • Loading branch information
jhen0409 committed Jul 7, 2016
1 parent 7c0a6a2 commit 08f8d39
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions test/electron/devpanel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('DevTools panel for Electron', function() {
})
.forBrowser('electron')
.build();
await this.driver.manage().timeouts().setScriptTimeout(10000);
});

after(async () => {
Expand All @@ -34,11 +35,23 @@ describe('DevTools panel for Electron', function() {

await this.driver.manage().timeouts().pageLoadTimeout(5000);

const id = await this.driver.executeScript(function() {
const tabs = WebInspector.inspectorView._tabbedPane._tabs;
const lastPanelId = tabs[tabs.length - 1].id;
WebInspector.inspectorView.showPanel(lastPanelId);
return lastPanelId;
const id = await this.driver.executeAsyncScript(function(callback) {
let attempts = 5;
function showReduxPanel() {
if (attempts === 0) {
return callback('Redux panel not found');
}
const tabs = WebInspector.inspectorView._tabbedPane._tabs;
const idList = tabs.map(tab => tab.id);
const reduxPanelId = 'chrome-extension://redux-devtoolsRedux';
if (idList.indexOf(reduxPanelId) !== -1) {
WebInspector.inspectorView.showPanel(reduxPanelId);
return callback(reduxPanelId);
}
attempts--;
setTimeout(showReduxPanel, 500);
}
showReduxPanel();
});
expect(id).toBe('chrome-extension://redux-devtoolsRedux');

Expand Down

0 comments on commit 08f8d39

Please sign in to comment.