Skip to content

Commit

Permalink
Replace remote with ipcrenderer (#239)
Browse files Browse the repository at this point in the history
* WIP: replace remote.* calls with ipc events
* FIXED: removed remote.Menu calls for context menus
* UPDATED: removed more calls to remote methods
* IMPROVED: removed more remote calls

* FIXED: end to end tests

* CLEANED-UP: removed remote imports
CLEANED-UP: removed useless ContextMenu component
  • Loading branch information
warpdesign authored Jun 17, 2022
1 parent 5c42a65 commit aa12003
Show file tree
Hide file tree
Showing 19 changed files with 1,481 additions and 611 deletions.
23 changes: 13 additions & 10 deletions e2e/cypress/integration/tablist.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ describe('tablist', () => {
}
}

cy.stub(win.remote.Menu, 'buildFromTemplate')
.as('stub_buildFromTemplate')
.returns({
// remote menu stubs
popup: cy.stub().as('stub_popup'),
});
// cy.stub(win.remote.Menu, 'buildFromTemplate')
// .as('stub_buildFromTemplate')
// .returns({
// // remote menu stubs
// popup: cy.stub().as('stub_popup'),
// });
cy.stub(win.renderer, 'invoke').as('stub_invoke');
});
}

Expand Down Expand Up @@ -79,20 +80,22 @@ describe('tablist', () => {

cy.get('#view_0 .tablist').contains('/').find('[icon]').rightclick();

cy.get('@stub_buildFromTemplate').should('be.calledOnce').and('be.calledWith', []);
cy.get('@stub_invoke').should('be.calledOnce').and('be.calledWith', 'Menu:buildFromTemplate', []);

cy.get('@stub_popup').should('be.calledOnce');
// cy.get('@stub_popup').should('be.calledOnce');
});

it('right-click on the tab should show the tab menu', () => {
cy.CDAndList(0, '/');

cy.get('#view_0 .tablist').contains('/').find('.bp3-button-text').rightclick('right');

cy.get('@stub_buildFromTemplate')
cy.get('@stub_invoke')
.should('be.calledOnce')
.then((stub: any) => {
expect(stub.getCalls()[0].args[0].length).to.equal(8);
// check we have the correct number of elements in the menu template
// NOTE: I guess we can do a lot better than that!
expect(stub.getCalls()[0].args[1].length).to.equal(8);
});
});

Expand Down
51 changes: 15 additions & 36 deletions e2e/cypress/mocks/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,22 @@ module.exports = {
method(e, { data: e.data, combo: e.combo });
});
},
invoke: function () {
//
},
},
remote: {
getCurrentWindow: () => ({
id: 9,
}),
Menu: {
buildFromTemplate: function () {
return {
popup: function () {
//
},
closePopup: function () {
//
},
};
},
},
app: {
getLocale: function () {
return 'en';
},
getPath: function (str) {
return '/cy/' + str;
},
getName: function () {
return 'React-Explorer (Cypress)';
},
},
// new in 7.0
nativeTheme: {
shouldUseDarkColors: false,
on: () => {
//
invoke: function (command) {
switch (command) {
case 'window:getInitialSettings':
return {
splitView: false,
};
case 'window:getId':
return 0;
case 'nativeTheme:shouldUseDarkColors':
return false;
case 'openTerminal':
return {};
}
},
sendSync: function () {
//
},
},
};
Loading

0 comments on commit aa12003

Please sign in to comment.