Skip to content
Closed
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
50 changes: 24 additions & 26 deletions test/functional/data-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,41 @@ describe('#data-service', function() {
this.timeout(60000);
let app = null;
let client = null;
const dataService = new DataService(CONNECTION);

before(function() {
return launchCompass()
.then(function(application) {
app = application;
client = application.client;
return client.connectToCompass({ hostname: 'localhost', port: 27018 });
before(function(done) {
dataService.connect(function() {
const docs = [
{'name': 'Aphex Twin', 'genre': 'Electronic', 'location': 'London'},
{ name: 'Bauhaus' }
];
dataService.insertMany('music.artists', docs, {}, function() {
done();
});
});
});

after(function() {
return quitCompass(app);
after(function(done) {
dataService.dropDatabase('music', function() {
dataService.disconnect();
done();
});
});

context('when using data-service directly', function() {
const dataService = new DataService(CONNECTION);

before(function(done) {
dataService.connect(function() {
const docs = [
{'name': 'Aphex Twin', 'genre': 'Electronic', 'location': 'London'},
{ name: 'Bauhaus' }
];
dataService.insertMany('music.artists', docs, {}, function() {
before(function() {
return launchCompass()
.then(function(application) {
app = application;
client = application.client;
return client
.goToCollection('music', 'artists').then(function() {
done();
});
.connectToCompass({ hostname: 'localhost', port: 27018 })
.goToCollection('music', 'artists');
});
});
});

after(function(done) {
dataService.dropDatabase('music', function() {
dataService.disconnect();
done();
});
after(function() {
return quitCompass(app);
});

context('when refreshing the documents list', function() {
Expand Down
44 changes: 21 additions & 23 deletions test/functional/explain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,38 @@ describe('#explain', function() {
this.timeout(60000);
let app = null;
let client = null;
const dataService = new DataService(CONNECTION);

before(function() {
return launchCompass()
.then(function(application) {
app = application;
client = application.client;
return client.connectToCompass({ hostname: 'localhost', port: 27018 });
before(function(done) {
const doc = {'name': 'Aphex Twin', 'genre': 'Electronic', 'location': 'London'};
dataService.connect(function() {
dataService.insertOne('music.artists', doc, function() {
done();
});
});
});

after(function() {
return quitCompass(app);
after(function(done) {
dataService.dropDatabase('music', function() {
dataService.disconnect();
done();
});
});

context('when running queries on the explain plan', function() {
const dataService = new DataService(CONNECTION);

before(function(done) {
const doc = {'name': 'Aphex Twin', 'genre': 'Electronic', 'location': 'London'};
dataService.connect(function() {
dataService.insertOne('music.artists', doc, function() {
before(function() {
return launchCompass()
.then(function(application) {
app = application;
client = application.client;
return client
.goToCollection('music', 'artists').then(function() {
done();
});
.connectToCompass({ hostname: 'localhost', port: 27018 })
.goToCollection('music', 'artists');
});
});
});

after(function(done) {
dataService.dropDatabase('music', function() {
dataService.disconnect();
done();
});
after(function() {
return quitCompass(app);
});

context('when applying a filter', function() {
Expand Down
42 changes: 20 additions & 22 deletions test/functional/indexes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,40 @@ describe('#indexes', function() {
let app = null;
let client = null;
let serverVersion;
const dataService = new DataService(CONNECTION);

before(function() {
return launchCompass()
.then(function(application) {
app = application;
client = application.client;
return client.connectToCompass({ hostname: 'localhost', port: 27018 });
before(function(done) {
const doc = {'name': 'Aphex Twin', 'genre': 'Electronic', 'location': 'London'};
dataService.connect(function() {
dataService.insertOne('music.artists', doc, function() {
done();
});
});
});

after(function() {
return quitCompass(app);
after(function(done) {
dataService.dropDatabase('music', function() {
dataService.disconnect();
done();
});
});

context('when navigating to the indexes tab', function() {
const dataService = new DataService(CONNECTION);

before(function(done) {
const doc = {'name': 'Aphex Twin', 'genre': 'Electronic', 'location': 'London'};
dataService.connect(function() {
dataService.insertOne('music.artists', doc, function() {
return client
before(function() {
return launchCompass()
.then(function(application) {
app = application;
client = application.client;
return client.connectToCompass({ hostname: 'localhost', port: 27018 })
.goToCollection('music', 'artists')
.getServerVersion().then(function(value) {
serverVersion = value.replace(/MongoDB ([0-9.]+) Community/, '$1');
done();
});
});
});
});

after(function(done) {
dataService.dropDatabase('music', function() {
dataService.disconnect();
done();
});
after(function() {
return quitCompass(app);
});

it('renders the indexes table', function() {
Expand Down
44 changes: 21 additions & 23 deletions test/functional/query-bar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,38 @@ describe('#query-bar', function() {
this.timeout(60000);
let app = null;
let client = null;
const dataService = new DataService(CONNECTION);

before(function() {
return launchCompass()
.then(function(application) {
app = application;
client = application.client;
return client.connectToCompass({ hostname: 'localhost', port: 27018 });
before(function(done) {
dataService.connect(function() {
const docs = _.map(_.range(100), mgenerate.bind(null, fanclubTemplate));
dataService.insertMany('mongodb.fanclub', docs, {}, function() {
done();
});
});
});

after(function() {
return quitCompass(app);
after(function(done) {
dataService.dropDatabase('mongodb', function() {
dataService.disconnect();
done();
});
});

context('when using advanced query options', function() {
const dataService = new DataService(CONNECTION);

before(function(done) {
dataService.connect(function() {
const docs = _.map(_.range(100), mgenerate.bind(null, fanclubTemplate));
dataService.insertMany('mongodb.fanclub', docs, {}, function() {
before(function() {
return launchCompass()
.then(function(application) {
app = application;
client = application.client;
return client
.goToCollection('mongodb', 'fanclub').then(function() {
done();
});
.connectToCompass({ hostname: 'localhost', port: 27018 })
.goToCollection('mongodb', 'fanclub');
});
});
});

after(function(done) {
dataService.dropDatabase('mongodb', function() {
dataService.disconnect();
done();
});
after(function() {
return quitCompass(app);
});

context('when using the fanclub collection with 100 docs', function() {
Expand Down
44 changes: 22 additions & 22 deletions test/functional/schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,42 @@ describe('#schema', function() {
let app = null;
let client = null;

before(function() {
return launchCompass()
.then(function(application) {
app = application;
client = application.client;
return client.connectToCompass({ hostname: 'localhost', port: 27018 });
const dataService = new DataService(CONNECTION);

before(function(done) {
const doc = {'name': 'Aphex Twin', 'genre': 'Electronic', 'location': 'London'};
dataService.connect(function() {
dataService.insertOne('music.artists', doc, function() {
done();
});
});
});

after(function() {
return quitCompass(app);
after(function(done) {
dataService.dropDatabase('music', function() {
dataService.disconnect();
done();
});
});

context('when applying a filter in the schema tab', function() {
const filter = '{"name":"Bonobo"}';
const expectedOneDoc = 'Query returned 1 document. This report is based on a sample of 1 document (100.00%).';
const expectedZeroDoc = 'Query returned 0 documents. This report is based on a sample of 0 documents (0.00%).';
const dataService = new DataService(CONNECTION);

before(function(done) {
const doc = {'name': 'Aphex Twin', 'genre': 'Electronic', 'location': 'London'};
dataService.connect(function() {
dataService.insertOne('music.artists', doc, function() {
before(function() {
return launchCompass()
.then(function(application) {
app = application;
client = application.client;
return client
.goToCollection('music', 'artists').then(function() {
done();
});
.connectToCompass({ hostname: 'localhost', port: 27018 })
.goToCollection('music', 'artists');
});
});
});

after(function(done) {
dataService.dropDatabase('music', function() {
dataService.disconnect();
done();
});
after(function() {
return quitCompass(app);
});

it('shows schema view', function() {
Expand Down
43 changes: 21 additions & 22 deletions test/functional/sidebar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,42 @@ describe('#sidebar', function() {
this.timeout(60000);
let app = null;
let client = null;
const dataService = new DataService(CONNECTION);

before(function() {
return launchCompass()
.then(function(application) {
app = application;
client = application.client;
return client.connectToCompass({ hostname: 'localhost', port: 27018 });
before(function(done) {
dataService.connect(function() {
dataService.createCollection('music.artists', {}, function() {
done();
});
});
});

after(function() {
return quitCompass(app);
after(function(done) {
dataService.dropDatabase('music', function() {
dataService.disconnect();
done();
});
});

context('when entering filters in the sidebar', function() {
const dataService = new DataService(CONNECTION);
let dbCount;

before(function(done) {
dataService.connect(function() {
dataService.createCollection('music.artists', {}, function() {
before(function() {
return launchCompass()
.then(function(application) {
app = application;
client = application.client;
return client
.clickInstanceRefreshIcon()
.waitForInstanceRefresh()
.getSidebarDatabaseNames().then(function(names) {
.connectToCompass({ hostname: 'localhost', port: 27018 })
.getSidebarDatabaseNames()
.then(function(names) {
dbCount = names.length;
done();
});
});
});
});

after(function(done) {
dataService.dropDatabase('music', function() {
dataService.disconnect();
done();
});
after(function() {
return quitCompass(app);
});

context('when entering a plain string', function() {
Expand Down
Loading