Skip to content

Commit 657307b

Browse files
committed
fixup: update tests, improve typing
1 parent 7eb2cb9 commit 657307b

File tree

15 files changed

+137
-67
lines changed

15 files changed

+137
-67
lines changed

packages/compass-collection/src/plugin-tab-title.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ function _PluginTitle({
4343
const { getConnectionById } = useConnectionsListRef();
4444

4545
const { database, collection, ns } = toNS(workspaceProps.namespace);
46-
const namespaceId = `${workspaceProps.connectionId}.${ns}`;
4746
const connectionName =
4847
getConnectionById(workspaceProps.connectionId)?.title || '';
4948
const collectionType = isTimeSeries

packages/compass-components/src/components/workspace-tabs/workspace-tabs.tsx

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { useDarkMode } from '../../hooks/use-theme';
2727
import { FocusState, useFocusState } from '../../hooks/use-focus-hover';
2828
import { Icon, IconButton } from '../leafygreen';
2929
import { mergeProps } from '../../utils/merge-props';
30-
import { Tab } from './tab';
30+
import type { Tab } from './tab';
3131
import type { WorkspaceTabCoreProps } from './tab';
3232
import { useHotkeys } from '../../hooks/use-hotkeys';
3333

@@ -299,19 +299,13 @@ const SortableItem = ({
299299

300300
const isDragging = useMemo(() => tabId === activeId, [tabId, activeId]);
301301

302-
const tab = useMemo(
303-
() =>
304-
renderTab({
305-
isSelected,
306-
isDragging,
307-
tabContentId: tabId,
308-
onSelect: onTabSelected,
309-
onClose: onTabClosed,
310-
}),
311-
[renderTab]
312-
);
313-
314-
return tab;
302+
return renderTab({
303+
isSelected,
304+
isDragging,
305+
tabContentId: tabId,
306+
onSelect: onTabSelected,
307+
onClose: onTabClosed,
308+
});
315309
};
316310

317311
function WorkspaceTabs({
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import React from 'react';
22
import { expect } from 'chai';
33
import { render } from '@mongodb-js/testing-library-compass';
4-
import CompassPlugin from './index';
4+
import { WorkspaceTab } from './index';
55

66
describe('Compass Plugin', function () {
7-
const Plugin = CompassPlugin.withMockServices({});
7+
const Plugin = WorkspaceTab.provider.withMockServices({});
88

99
it('renders a Plugin', function () {
10-
expect(() => render(<Plugin></Plugin>)).to.not.throw();
10+
expect(() =>
11+
render(
12+
<Plugin>
13+
<WorkspaceTab.content />
14+
</Plugin>
15+
)
16+
).to.not.throw();
1117
});
1218
});

packages/compass-saved-aggregations-queries/src/index.spec.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import Sinon from 'sinon';
33
import { expect } from 'chai';
44
import { queries, pipelines } from '../test/fixtures';
5-
import { MyQueriesPlugin } from '.';
5+
import { WorkspaceTab } from '.';
66
import type {
77
PipelineStorage,
88
FavoriteQueryStorage,
@@ -81,7 +81,7 @@ describe('AggregationsAndQueriesAndUpdatemanyList', function () {
8181
let connectionsStore: RenderWithConnectionsResult['connectionsStore'];
8282

8383
const renderPlugin = () => {
84-
const PluginWithMocks = MyQueriesPlugin.withMockServices({
84+
const PluginWithMocks = WorkspaceTab.provider.withMockServices({
8585
instancesManager,
8686
favoriteQueryStorageAccess: {
8787
getStorage() {
@@ -91,9 +91,17 @@ describe('AggregationsAndQueriesAndUpdatemanyList', function () {
9191
pipelineStorage: pipelineStorage,
9292
workspaces,
9393
});
94-
const result = renderWithConnections(<PluginWithMocks></PluginWithMocks>, {
95-
connections: [connectionOne.connectionInfo, connectionTwo.connectionInfo],
96-
});
94+
const result = renderWithConnections(
95+
<PluginWithMocks>
96+
<WorkspaceTab.content />
97+
</PluginWithMocks>,
98+
{
99+
connections: [
100+
connectionOne.connectionInfo,
101+
connectionTwo.connectionInfo,
102+
],
103+
}
104+
);
97105
connectionsStore = result.connectionsStore;
98106
};
99107

packages/compass-saved-aggregations-queries/src/stores/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ export type SavedQueryAggregationThunkAction<
7979
A extends Action = AnyAction
8080
> = ThunkAction<R, RootState, SavedQueryAggregationExtraArgs, A>;
8181

82-
type SavedQueryAggregationPluginProps = {};
82+
type SavedQueryAggregationPluginProps = {
83+
children?: React.ReactNode;
84+
};
8385

8486
export function activatePlugin(
8587
_initialProps: SavedQueryAggregationPluginProps,

packages/compass-serverstats/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
ServerStatsPluginTitleComponent,
1717
} from './plugin-tab-title';
1818

19-
type PerformancePluginInitialProps = {};
19+
type PerformancePluginInitialProps = Record<string, never>;
2020

2121
const WorkspaceTab: WorkspacePlugin<typeof WorkspaceName> = {
2222
name: WorkspaceName,

packages/compass-shell/src/plugin.spec.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from 'react';
22
import { expect } from 'chai';
33
import { EventEmitter } from 'events';
4-
import { CompassShellPlugin } from './index';
4+
import { WorkspaceTab } from './index';
55
import {
66
renderWithActiveConnection,
77
screen,
88
waitFor,
99
} from '@mongodb-js/testing-library-compass';
1010
import { RuntimeMap } from './stores/store';
1111

12-
describe('CompassShellPlugin', function () {
12+
describe('CompassShellPlugin WorkspaceTab', function () {
1313
it('returns a renderable plugin', async function () {
1414
RuntimeMap.set('test', {
1515
eventEmitter: new EventEmitter(),
@@ -19,7 +19,12 @@ describe('CompassShellPlugin', function () {
1919
},
2020
} as any);
2121

22-
await renderWithActiveConnection(<CompassShellPlugin runtimeId="test" />);
22+
const ShellContentComponent = WorkspaceTab.content;
23+
await renderWithActiveConnection(
24+
<WorkspaceTab.provider runtimeId="test">
25+
<ShellContentComponent />
26+
</WorkspaceTab.provider>
27+
);
2328

2429
await waitFor(() => {
2530
expect(screen.getByTestId('shell-section')).to.exist;

packages/compass-sidebar/src/components/multiple-connections/sidebar.spec.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,18 @@ describe('Multiple Connections Sidebar Component', function () {
106106
<ConnectionImportExportProvider>
107107
<WorkspacesProvider
108108
value={[
109-
{ name: 'My Queries', component: () => null },
110-
{ name: 'Performance', component: () => null },
109+
{
110+
name: 'My Queries',
111+
content: () => null,
112+
header: () => null as any,
113+
provider: (() => null) as any,
114+
},
115+
{
116+
name: 'Performance',
117+
content: () => null,
118+
header: () => null as any,
119+
provider: (() => null) as any,
120+
},
111121
]}
112122
>
113123
<WorkspacesServiceProvider value={workspace as any}>

packages/compass-workspaces/src/components/workspace-tab-context-provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useCallback, useEffect, useRef } from 'react';
22
import { getLocalAppRegistryForTab } from '../stores/workspaces';
3-
import { WorkspaceTab } from '../types';
3+
import type { WorkspaceTab } from '../types';
44
import { NamespaceProvider } from '@mongodb-js/compass-app-stores/provider';
55
import { ConnectionInfoProvider } from '@mongodb-js/compass-connections/provider';
66
import { rafraf } from '@mongodb-js/compass-components';

packages/compass-workspaces/src/components/workspaces-provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useContext, useRef } from 'react';
22
import type { AnyWorkspace } from '../';
3-
import { WorkspacePlugin } from '../types';
3+
import type { WorkspacePlugin } from '../types';
44

55
export type AnyWorkspacePlugin =
66
| WorkspacePlugin<'Welcome'>

0 commit comments

Comments
 (0)