Skip to content

Commit 7bed908

Browse files
Merge remote-tracking branch 'origin/main' into beta-releases
2 parents 8514d73 + b496891 commit 7bed908

File tree

63 files changed

+992
-731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+992
-731
lines changed

.evergreen/buildvariants.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ buildvariants:
9090
- name: test-packaged-app-latest
9191
depends_on: package-compass
9292

93+
- name: test-web-sandbox-chrome
94+
9395
- name: test-web-sandbox-firefox
9496

9597
- name: windows

.evergreen/config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@
140140
}
141141
],
142142
"test-web-sandbox": [
143+
{
144+
"name": "chrome",
145+
"vars": {
146+
"mongodb_version": "latest-alpha-enterprise",
147+
"browser_name": "chrome"
148+
},
149+
"skip_on": ["macos-1100", "macos-1100-arm64", "rhel76-large", "windows-vsCurrent-large"]
150+
},
143151
{
144152
"name": "firefox",
145153
"vars": {

.evergreen/tasks.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,24 @@ tasks:
419419
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'
420420

421421

422+
- name: test-web-sandbox-chrome
423+
tags: ['required-for-publish', 'run-on-pr']
424+
commands:
425+
- func: prepare
426+
- func: install
427+
- func: bootstrap
428+
vars:
429+
scope: 'compass-e2e-tests'
430+
- func: apply-compass-target-expansion
431+
vars:
432+
compass_distribution: compass
433+
- func: test-web-sandbox
434+
vars:
435+
mongodb_version: 'latest-alpha-enterprise'
436+
browser_name: 'chrome'
437+
compass_distribution: compass
438+
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'
439+
422440
- name: test-web-sandbox-firefox
423441
tags: ['required-for-publish', 'run-on-pr']
424442
commands:

THIRD-PARTY-NOTICES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The following third-party software is used by and included in **Mongodb Compass**.
2-
This document was automatically generated on Thu Feb 22 2024.
2+
This document was automatically generated on Sun Feb 25 2024.
33

44
## List of dependencies
55

package-lock.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-app-stores/src/plugin.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const CompassInstanceStorePlugin = registerHadronPlugin<
5959
return {
6060
store,
6161
deactivate: () => {
62-
helpers.cleanup();
62+
store.deactivate();
6363
},
6464
};
6565
},

packages/compass-app-stores/src/stores/instance-store.spec.ts

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { EventEmitter } from 'events';
22
import AppRegistry, { createActivateHelpers } from 'hadron-app-registry';
33
import { createInstanceStore } from './instance-store';
4-
import { once } from 'events';
54
import sinon from 'sinon';
65
import { expect } from 'chai';
76
import { createNoopLoggerAndTelemetry } from '@mongodb-js/compass-logging/provider';
@@ -47,21 +46,28 @@ describe('InstanceStore [Store]', function () {
4746
let store: ReturnType<typeof createInstanceStore>;
4847
let instance: MongoDBInstance;
4948

50-
let emitSpy: any;
5149
let initialInstanceRefreshedPromise: Promise<unknown>;
5250
let sandbox: sinon.SinonSandbox;
5351

52+
function waitForInstanceRefresh(): Promise<void> {
53+
return new Promise((resolve) => {
54+
if (instance.refreshingStatus === 'ready') {
55+
resolve();
56+
}
57+
instance.on('change:refreshingStatus', () => {
58+
if (instance.refreshingStatus === 'ready') {
59+
resolve();
60+
}
61+
});
62+
});
63+
}
64+
5465
beforeEach(function () {
5566
globalAppRegistry = new AppRegistry();
5667
sandbox = sinon.createSandbox();
5768

58-
emitSpy = sandbox.spy(globalAppRegistry, 'emit');
5969
dataService = createDataService();
6070
const logger = createNoopLoggerAndTelemetry();
61-
initialInstanceRefreshedPromise = once(
62-
globalAppRegistry,
63-
'instance-refreshed'
64-
);
6571

6672
store = createInstanceStore(
6773
{
@@ -72,22 +78,15 @@ describe('InstanceStore [Store]', function () {
7278
createActivateHelpers()
7379
);
7480
instance = store.state.instance;
81+
82+
initialInstanceRefreshedPromise = waitForInstanceRefresh();
7583
});
7684

7785
afterEach(function () {
78-
emitSpy = null;
7986
sandbox.restore();
8087
store.deactivate();
8188
});
8289

83-
context('when data service connects', function () {
84-
it('emits instance-refreshed event', async function () {
85-
await initialInstanceRefreshedPromise;
86-
const events = emitSpy.args.map(([evtName]: any) => evtName);
87-
expect(events).to.eql(['instance-created', 'instance-refreshed']);
88-
});
89-
});
90-
9190
context('on refresh data', function () {
9291
beforeEach(async function () {
9392
sandbox
@@ -99,22 +98,12 @@ describe('InstanceStore [Store]', function () {
9998
'1.2.3'
10099
);
101100
globalAppRegistry.emit('refresh-data');
102-
await once(globalAppRegistry, 'instance-refreshed');
101+
await waitForInstanceRefresh();
103102
});
104103

105104
it('calls instance model fetch', function () {
106105
expect(instance).to.have.nested.property('build.version', '3.2.1');
107106
});
108-
109-
it('emits instance-changed event', function () {
110-
const events = emitSpy.args.map(([evtName]: any) => evtName);
111-
expect(events).to.eql([
112-
'instance-created',
113-
'instance-refreshed',
114-
'refresh-data',
115-
'instance-refreshed',
116-
]);
117-
});
118107
});
119108

120109
context('when instance ready', function () {

packages/compass-app-stores/src/stores/instance-store.ts

Lines changed: 51 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ function getTopologyDescription(
3737

3838
export function createInstanceStore(
3939
{
40-
globalAppRegistry: appRegistry,
40+
globalAppRegistry,
4141
dataService,
42-
logger: { debug },
42+
logger: { log, mongoLogId },
4343
}: {
4444
dataService: DataService;
4545
logger: LoggerAndTelemetry;
@@ -57,19 +57,17 @@ export function createInstanceStore(
5757

5858
try {
5959
await instance.refresh({ dataService, ...refreshOptions });
60-
61-
appRegistry.emit('instance-refreshed', {
62-
instance,
63-
dataService,
64-
errorMessage: '',
65-
});
6660
} catch (err: any) {
67-
appRegistry.emit('instance-refreshed', {
68-
instance,
69-
dataService,
70-
errorMessage: err.message,
71-
});
72-
61+
log.warn(
62+
mongoLogId(1_001_000_295),
63+
'Instance Store',
64+
'Failed to refresh instance',
65+
{
66+
message: (err as Error).message,
67+
connectionId: dataService.id,
68+
isFirstRun,
69+
}
70+
);
7371
// The `instance.refresh` method is catching all expected errors: we treat
7472
// a lot of metadata as optional so failing to fetch it shouldn't throw.
7573
// In most cases if this failed on subsequent runs, user is probably
@@ -92,16 +90,28 @@ export function createInstanceStore(
9290
}
9391
}
9492

95-
// Event emitted when the Databases grid needs to be refreshed
96-
// We additionally refresh the list of collections as well
97-
// since there is the side navigation which could be in expanded mode
93+
// Event emitted when the Databases grid needs to be refreshed. We
94+
// additionally refresh the list of collections as well since there is the
95+
// side navigation which could be in expanded mode
9896
async function refreshDatabases() {
99-
await instance.fetchDatabases({ dataService, force: true });
100-
await Promise.allSettled(
101-
instance.databases.map((db) =>
102-
db.fetchCollections({ dataService, force: true })
103-
)
104-
);
97+
try {
98+
await instance.fetchDatabases({ dataService, force: true });
99+
await Promise.allSettled(
100+
instance.databases.map((db) =>
101+
db.fetchCollections({ dataService, force: true })
102+
)
103+
);
104+
} catch (err: any) {
105+
log.warn(
106+
mongoLogId(1_001_000_296),
107+
'Instance Store',
108+
'Failed to refresh databases',
109+
{
110+
message: (err as Error).message,
111+
connectionId: dataService.id,
112+
}
113+
);
114+
}
105115
}
106116

107117
async function fetchAllCollections() {
@@ -174,12 +184,8 @@ export function createInstanceStore(
174184

175185
addCleanup(() => {
176186
instance.removeAllListeners();
177-
appRegistry.emit('instance-destroyed', { instance: null });
178187
});
179188

180-
debug('instance-created');
181-
appRegistry.emit('instance-created', { instance });
182-
183189
void refreshInstance({
184190
fetchDatabases: true,
185191
fetchDbStats: true,
@@ -197,22 +203,22 @@ export function createInstanceStore(
197203

198204
on(dataService, 'topologyDescriptionChanged', onTopologyDescriptionChanged);
199205

200-
on(appRegistry, 'sidebar-expand-database', (dbName: string) => {
206+
on(globalAppRegistry, 'sidebar-expand-database', (dbName: string) => {
201207
void instance.databases.get(dbName)?.fetchCollections({ dataService });
202208
});
203209

204-
on(appRegistry, 'sidebar-filter-navigation-list', fetchAllCollections);
210+
on(globalAppRegistry, 'sidebar-filter-navigation-list', fetchAllCollections);
205211

206-
on(appRegistry, 'refresh-data', refreshInstance);
212+
on(globalAppRegistry, 'refresh-data', refreshInstance);
207213

208-
on(appRegistry, 'database-dropped', (dbName: string) => {
214+
on(globalAppRegistry, 'database-dropped', (dbName: string) => {
209215
const db = instance.databases.remove(dbName);
210216
if (db) {
211217
MongoDBInstance.removeAllListeners(db);
212218
}
213219
});
214220

215-
on(appRegistry, 'collection-dropped', (namespace: string) => {
221+
on(globalAppRegistry, 'collection-dropped', (namespace: string) => {
216222
const { database } = toNS(namespace);
217223
const db = instance.databases.get(database);
218224
const coll = db?.collections.get(namespace, '_id');
@@ -236,10 +242,10 @@ export function createInstanceStore(
236242
}
237243
});
238244

239-
on(appRegistry, 'refresh-databases', refreshDatabases);
245+
on(globalAppRegistry, 'refresh-databases', refreshDatabases);
240246

241247
on(
242-
appRegistry,
248+
globalAppRegistry,
243249
'collection-renamed',
244250
({ from, to }: { from: string; to: string }) => {
245251
const { database, collection } = toNS(from);
@@ -250,16 +256,20 @@ export function createInstanceStore(
250256
}
251257
);
252258

253-
on(appRegistry, 'document-deleted', refreshNamespaceStats);
254-
on(appRegistry, 'document-inserted', refreshNamespaceStats);
255-
on(appRegistry, 'import-finished', refreshNamespaceStats);
259+
on(globalAppRegistry, 'document-deleted', refreshNamespaceStats);
260+
on(globalAppRegistry, 'document-inserted', refreshNamespaceStats);
261+
on(globalAppRegistry, 'import-finished', refreshNamespaceStats);
256262

257-
on(appRegistry, 'collection-created', maybeAddAndRefreshCollectionModel);
263+
on(
264+
globalAppRegistry,
265+
'collection-created',
266+
maybeAddAndRefreshCollectionModel
267+
);
258268

259-
on(appRegistry, 'view-created', maybeAddAndRefreshCollectionModel);
269+
on(globalAppRegistry, 'view-created', maybeAddAndRefreshCollectionModel);
260270

261271
on(
262-
appRegistry,
272+
globalAppRegistry,
263273
'agg-pipeline-out-executed',
264274
// null means the out / merge stage destination wasn't a namespace in the
265275
// same cluster
@@ -271,7 +281,7 @@ export function createInstanceStore(
271281
}
272282
);
273283

274-
on(appRegistry, 'view-edited', (namespace: string) => {
284+
on(globalAppRegistry, 'view-edited', (namespace: string) => {
275285
const { database } = toNS(namespace);
276286
void instance.databases
277287
.get(database)

packages/compass-components/src/hooks/use-toast.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ import { css } from '@leafygreen-ui/emotion';
1414

1515
export type ToastProperties = Pick<
1616
ToastProps,
17-
'title' | 'description' | 'variant' | 'progress' | 'timeout' | 'dismissible'
17+
| 'title'
18+
| 'description'
19+
| 'variant'
20+
| 'progress'
21+
| 'timeout'
22+
| 'dismissible'
23+
| 'onClose'
1824
>;
1925

2026
const defaultToastProperties: Partial<ToastProperties> = {

packages/compass-e2e-tests/helpers/commands/connect-with-connection-string.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { MONGODB_TEST_SERVER_PORT } from '../compass';
1+
import { DEFAULT_CONNECTION_STRING } from '../compass';
22
import type { CompassBrowser } from '../compass-browser';
33
import * as Selectors from '../selectors';
44

55
export async function connectWithConnectionString(
66
browser: CompassBrowser,
7-
connectionString = `mongodb://localhost:${MONGODB_TEST_SERVER_PORT}/test`,
7+
connectionString = DEFAULT_CONNECTION_STRING,
88
connectionStatus: 'success' | 'failure' | 'either' = 'success',
99
timeout?: number
1010
): Promise<void> {

0 commit comments

Comments
 (0)