Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/compass-connect/src/stores/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,15 @@ const Store = Reflux.createStore({
return;
}

// Set the connection's app name to the electron app name of Compass.
connectionModel.appname = electron.remote.app.getName();
/**
* Set the connection's app name to the electron app name only if it's not
* set by the user already
*
* See https://jira.mongodb.org/browse/COMPASS-4901
*/
if (typeof connectionModel.appname === 'undefined') {
connectionModel.appname = electron.remote.app.getName();
}

try {
const dataService = new DataService(connectionModel);
Expand Down
28 changes: 23 additions & 5 deletions packages/compass-connect/test/renderer/stores/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import AppRegistry from 'hadron-app-registry';
import Connection, { ConnectionCollection } from 'mongodb-connection-model';
import Reflux from 'reflux';
import { remote } from 'electron';

import Actions from '../../../src/actions';
import {
Expand Down Expand Up @@ -1794,14 +1795,15 @@ describe('Store', () => {
});

describe('#_connect', () => {
const connection = new Connection({
hostname: 'localhost',
port: 27018,
authStrategy: 'NONE'
});
let connection;
let appRegistryEmitStub;

beforeEach(() => {
connection = new Connection({
hostname: 'localhost',
port: 27018,
authStrategy: 'NONE'
});
const connections = {
[connection._id]: connection.getAttributes({ props: true, derived: true })
};
Expand Down Expand Up @@ -1850,6 +1852,22 @@ describe('Store', () => {
sinon.restore();
});

describe('connection.appname', () => {
it('should set connection appname to Electron app name when undefined', async() => {
expect(connection.appname).to.be.undefined;
Store.state.currentConnectionAttempt = createConnectionAttempt();
await Store._connect(connection);
expect(connection.appname).to.eq(remote.app.getName());
});

it('should preserve appname if set on connection', async() => {
connection.appname = 'My App';
Store.state.currentConnectionAttempt = createConnectionAttempt();
await Store._connect(connection);
expect(connection.appname).to.eq('My App');
});
});

it('connects to the database and sets the dataService on the store', async() => {
Store.state.currentConnectionAttempt = createConnectionAttempt();
await Store._connect(connection);
Expand Down