Skip to content

Commit c155232

Browse files
authored
COMPASS-805: Backport COMPASS-648: Reorganise test structure (#755) (#794)
* COMPASS-648 reorganize test structure * bump [email protected] for new test structure. * try sorting test files for travis. * test new hadron-build before bumping version. * bump [email protected] (--sort flag) #retry https://travis-ci.com/10gen/compass/jobs/66208746
1 parent d9e0860 commit c155232

28 files changed

+66
-65
lines changed

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,20 @@
7171
"scripts": {
7272
"start": "hadron-build develop",
7373
"pretest": "mongodb-runner install && mongodb-runner start --port 27018",
74-
"test": "npm run test-main && npm run test-renderer && hadron-build test",
74+
"test": "hadron-build test",
7575
"posttest": "mongodb-runner stop --port 27018",
7676
"check": "mongodb-js-precommit ./src/app/*.js ./src/app/**/**/*.js ./src/{app/**/*.js,main/**/*.js} ./test/*.js ./src/internal-packages/**/*.js ./src/internal-packages/**/**/*{.js,.jsx} ./src/internal-packages/**/**/**/*{.js,.jsx} ./src/internal-packages/**/**/**/**/*{.js,.jsx}",
7777
"ci": "npm run check && npm run test",
7878
"clean": "hadron-build clean",
7979
"compile-ui": "hadron-build ui",
8080
"fmt": "mongodb-js-fmt ./*.js src/{**/*.js,*.js} test/{**/*.js,*.js}",
8181
"release": "hadron-build release",
82-
"test-functional": "npm test -- --functional",
83-
"test-main": "electron-mocha ./tests/main-process/*.test.js",
84-
"test-packages": "npm test -- --packages",
85-
"test-renderer": "electron-mocha --renderer ./tests/renderer-process/*.test.js",
8682
"test-unit": "npm test -- --unit",
83+
"test-enzyme": "npm test -- --enzyme",
84+
"test-packages": "npm test -- --packages",
85+
"test-main": "npm test -- --main",
86+
"test-renderer": "npm test -- --renderer",
87+
"test-functional": "npm test -- --functional",
8788
"test-release": "npm test -- --release",
8889
"upload": "hadron-build upload",
8990
"evergreen-expansions": "hadron-build info --format=yaml --flatten > expansions.yml"
@@ -109,7 +110,7 @@
109110
"ampersand-view": "^9.0.0",
110111
"ampersand-view-switcher": "^2.0.0",
111112
"app-migrations": "mongodb-js/app-migrations#v0.1.2",
112-
"async": "^1.5.0",
113+
"async": "^1.5.2",
113114
"babel-register": "^6.7.2",
114115
"backoff": "^2.4.1",
115116
"bootstrap": "https://github.com/twbs/bootstrap/archive/v3.3.5.tar.gz",
@@ -191,7 +192,7 @@
191192
"electron-prebuilt": "1.2.8",
192193
"enzyme": "^2.5.1",
193194
"eslint-config-mongodb-js": "^2.2.0",
194-
"hadron-build": "^5.1.9",
195+
"hadron-build": "^6.0.1",
195196
"jsdom": "^9.8.3",
196197
"mocha": "^3.1.2",
197198
"mock-require": "^2.0.1",
File renamed without changes.

test/collection-component.test.js renamed to test/enzyme/collection-component.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const React = require('react');
77
const sinon = require('sinon');
88
const shallow = require('enzyme').shallow;
99
const AppRegistry = require('hadron-app-registry');
10-
const Collection = require('../src/internal-packages/collection/lib/components/index');
11-
const TabNavBar = require('../src/internal-packages/app/lib/components/tab-nav-bar');
10+
const Collection = require('../../src/internal-packages/collection/lib/components/index');
11+
const TabNavBar = require('../../src/internal-packages/app/lib/components/tab-nav-bar');
1212

1313
// const debug = require('debug')('compass:collection:test');
1414

test/collections-table-component.test.js renamed to test/enzyme/collections-table-component.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const React = require('react');
77
const sinon = require('sinon');
88
const {mount} = require('enzyme');
99
const AppRegistry = require('hadron-app-registry');
10-
const SortableTable = require('../src/internal-packages/app/lib/components/sortable-table');
11-
const TabNavBar = require('../src/internal-packages/app/lib/components/tab-nav-bar');
10+
const SortableTable = require('../../src/internal-packages/app/lib/components/sortable-table');
11+
const TabNavBar = require('../../src/internal-packages/app/lib/components/tab-nav-bar');
1212

1313
chai.use(chaiEnzyme());
1414

@@ -35,7 +35,7 @@ describe('<CollectionsTable />', () => {
3535
// but got: undefined. Check the render method of `DatabasesTable`.
3636
app.appRegistry.registerComponent('App.SortableTable', SortableTable);
3737

38-
this.CollectionsTable = require('../src/internal-packages/database/lib/components/collections-table');
38+
this.CollectionsTable = require('../../src/internal-packages/database/lib/components/collections-table');
3939
});
4040
afterEach(() => {
4141
// Restore properties on the global app object,

test/crud.test.js renamed to test/enzyme/crud.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ const crudActions = {
2222
closeAllMenus: closeAllMenusSpy
2323
};
2424

25-
mock('../src/internal-packages/crud/lib/actions', crudActions);
25+
mock('../../src/internal-packages/crud/lib/actions', crudActions);
2626

2727
const React = require('react');
2828
const Element = require('hadron-document').Element;
29-
const LineNumber = require('../src/internal-packages/crud/lib/component/line-number');
29+
const LineNumber = require('../../src/internal-packages/crud/lib/component/line-number');
3030

3131
// use chai-enzyme assertions, see https://github.com/producthunt/chai-enzyme
3232
chai.use(chaiEnzyme());

test/databases-table-component.test.js renamed to test/enzyme/databases-table-component.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ const React = require('react');
77
const sinon = require('sinon');
88
const {mount, shallow} = require('enzyme');
99
const AppRegistry = require('hadron-app-registry');
10-
const CreateCollectionCheckbox = require('../src/internal-packages/database/lib/components/create-collection-checkbox');
11-
const CreateCollectionInput = require('../src/internal-packages/database/lib/components/create-collection-input');
12-
const CreateCollectionSizeInput = require('../src/internal-packages/database/lib/components/create-collection-size-input');
13-
const SortableTable = require('../src/internal-packages/app/lib/components/sortable-table');
14-
const TabNavBar = require('../src/internal-packages/app/lib/components/tab-nav-bar');
10+
const CreateCollectionCheckbox = require('../../src/internal-packages/database/lib/components/create-collection-checkbox');
11+
const CreateCollectionInput = require('../../src/internal-packages/database/lib/components/create-collection-input');
12+
const CreateCollectionSizeInput = require('../../src/internal-packages/database/lib/components/create-collection-size-input');
13+
const SortableTable = require('../../src/internal-packages/app/lib/components/sortable-table');
14+
const TabNavBar = require('../../src/internal-packages/app/lib/components/tab-nav-bar');
1515

1616
// use chai-enzyme assertions, see https://github.com/producthunt/chai-enzyme
1717
chai.use(chaiEnzyme());
@@ -57,7 +57,7 @@ describe('<DatabasesTable />', () => {
5757
app.appRegistry.registerComponent('Database.CreateCollectionInput', CreateCollectionInput);
5858
app.appRegistry.registerComponent('Database.CreateCollectionSizeInput', CreateCollectionSizeInput);
5959

60-
this.DatabasesTable = require('../src/internal-packages/server-stats/lib/component/databases-table');
60+
this.DatabasesTable = require('../../src/internal-packages/server-stats/lib/component/databases-table');
6161
});
6262
afterEach(() => {
6363
// Restore properties on the global app object,

test/indexes.column.test.js renamed to test/enzyme/indexes.column.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ const expect = chai.expect;
88
const React = require('react');
99
const {mount, shallow} = require('enzyme');
1010

11-
const SizeColumn = require('../src/internal-packages/indexes/lib/component/size-column');
12-
const UsageColumn = require('../src/internal-packages/indexes/lib/component/usage-column');
11+
const SizeColumn = require('../../src/internal-packages/indexes/lib/component/size-column');
12+
const UsageColumn = require('../../src/internal-packages/indexes/lib/component/usage-column');
1313

1414
chai.use(chaiEnzyme());
1515

16-
require('../src/app/reflux-listen-to-external-store.js');
16+
require('../../src/app/reflux-listen-to-external-store.js');
1717

1818
describe('<Indexes />', () => {
1919
let component;
@@ -36,7 +36,7 @@ describe('<Indexes />', () => {
3636
app.appRegistry = new AppRegistry();
3737
app.instance = {build: {version: '3.2.0'}};
3838

39-
this.CreateIndexButton = require('../src/internal-packages/indexes/lib/component/create-index-button');
39+
this.CreateIndexButton = require('../../src/internal-packages/indexes/lib/component/create-index-button');
4040
});
4141
afterEach(function() {
4242
// Restore properties on the global app object,

test/rtss.test.js renamed to test/enzyme/rtss.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const expect = chai.expect;
66
const React = require('react');
77
const {shallow} = require('enzyme');
88
const AppRegistry = require('hadron-app-registry');
9-
const StatusRow = require('../src/internal-packages/app/lib/components/status-row');
9+
const StatusRow = require('../../src/internal-packages/app/lib/components/status-row');
1010

1111
chai.use(chaiEnzyme());
1212

@@ -20,7 +20,7 @@ describe('rtss', () => {
2020
// appRegistry.getComponent (i.e. appRegistry being undefined)
2121
app.appRegistry = new AppRegistry();
2222
app.appRegistry.registerComponent('App.StatusRow', StatusRow);
23-
this.performance = require('../src/internal-packages/server-stats/lib/component/performance-component');
23+
this.performance = require('../../src/internal-packages/server-stats/lib/component/performance-component');
2424
});
2525
afterEach(() => {
2626
// Restore properties on the global app object,

test/sampling-message-component.test.js renamed to test/enzyme/sampling-message-component.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('<SamplingMessage />', () => {
2121
app.appRegistry.registerAction('CRUD.Actions', sinon.spy());
2222
app.appRegistry.registerStore('CRUD.ResetDocumentListStore', sinon.spy());
2323

24-
this.SamplingMessage = require('../src/internal-packages/query/lib/component/sampling-message');
24+
this.SamplingMessage = require('../../src/internal-packages/query/lib/component/sampling-message');
2525
});
2626
afterEach(() => {
2727
// Restore properties on the global app object,

test/schema.field.test.js renamed to test/enzyme/schema.field.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,29 +82,29 @@ describe('<Schema />', () => {
8282
// appRegistry.getComponent (i.e. appRegistry being undefined)
8383
app.appRegistry = new AppRegistry();
8484
// register QueryStore
85-
require('../src/internal-packages/query').activate();
85+
require('../../src/internal-packages/query').activate();
8686
});
8787
after(function() {
8888
// unregister QueryStore
89-
require('../src/internal-packages/query').deactivate();
89+
require('../../src/internal-packages/query').deactivate();
9090
// Restore properties on the global app object,
9191
// so they don't affect other tests
9292
app.appRegistry = appRegistry;
9393
});
9494

9595
context('when adding fields to the schema view', () => {
9696
it('renders field types', () => {
97-
const Field = require('../src/internal-packages/schema/lib/component/field');
98-
const Type = require('../src/internal-packages/schema/lib/component/type');
97+
const Field = require('../../src/internal-packages/schema/lib/component/field');
98+
const Type = require('../../src/internal-packages/schema/lib/component/type');
9999

100100
fieldProp.types = typesWithUndefined;
101101
component = mount(<Field {...fieldProp} />);
102102
expect(component.find(Type)).to.have.length(2);
103103
});
104104

105105
it('renders the first type as string', () => {
106-
const Field = require('../src/internal-packages/schema/lib/component/field');
107-
const Type = require('../src/internal-packages/schema/lib/component/type');
106+
const Field = require('../../src/internal-packages/schema/lib/component/field');
107+
const Type = require('../../src/internal-packages/schema/lib/component/type');
108108

109109
fieldProp.types = typesWithUndefined;
110110
component = mount(<Field {...fieldProp} />);
@@ -113,8 +113,8 @@ describe('<Schema />', () => {
113113
});
114114

115115
it('renders the second type as undefined', () => {
116-
const Field = require('../src/internal-packages/schema/lib/component/field');
117-
const Type = require('../src/internal-packages/schema/lib/component/type');
116+
const Field = require('../../src/internal-packages/schema/lib/component/field');
117+
const Type = require('../../src/internal-packages/schema/lib/component/type');
118118

119119
fieldProp.types = typesWithUndefined;
120120
component = mount(<Field {...fieldProp} />);
@@ -124,8 +124,8 @@ describe('<Schema />', () => {
124124

125125
context('when rendering multiple fields', () => {
126126
it('renders type with highest probability first', () => {
127-
const Field = require('../src/internal-packages/schema/lib/component/field');
128-
const Type = require('../src/internal-packages/schema/lib/component/type');
127+
const Field = require('../../src/internal-packages/schema/lib/component/field');
128+
const Type = require('../../src/internal-packages/schema/lib/component/type');
129129

130130
fieldProp.types = typesWithMultiple;
131131
component = mount(<Field {...fieldProp} />);

0 commit comments

Comments
 (0)