Skip to content

Commit 982b11f

Browse files
committed
fixup: fix connection-form tests for FileInput change
1 parent 9c27dd7 commit 982b11f

File tree

6 files changed

+57
-24
lines changed

6 files changed

+57
-24
lines changed

packages/compass-components/src/components/file-input.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,20 @@ export const FileInputBackendProvider: React.FunctionComponent<{
210210
);
211211
};
212212

213+
export function createJSDomFileInputDummyBackend(): () => FileInputBackend {
214+
return () => ({
215+
openFileChooser() {
216+
return;
217+
},
218+
onFilesChosen() {
219+
return () => void 0;
220+
},
221+
getPathForFile(file: File) {
222+
return (file as any).path;
223+
},
224+
});
225+
}
226+
213227
// Use as:
214228
//
215229
// import * as electronRemote from '@electron/remote';

packages/compass-components/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type {
2121
} from './components/file-input';
2222
import FileInput, {
2323
createElectronFileInputBackend,
24+
createJSDomFileInputDummyBackend,
2425
FileInputBackendProvider,
2526
} from './components/file-input';
2627
import { OptionsToggle } from './components/options-toggle';

packages/compass-e2e-tests/tests/in-use-encryption.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ describe('CSFLE / QE', function () {
11031103
}
11041104
});
11051105

1106-
it('can read QE data stored in a mongodb 6 database', async function () {
1106+
it.only('can read QE data stored in a mongodb 6 database', async function () {
11071107
// connect without QE and insert some fixture data that we generated against a 6.x database using the shell
11081108
await browser.connectWithConnectionForm({
11091109
hosts: [CONNECTION_HOSTS],

packages/connection-form/src/components/advanced-options-tabs/csfle-tab/csfle-tab.spec.tsx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import { Binary } from 'bson';
1818

1919
import ConnectionForm from '../../../';
2020
import { getNextKmsProviderName } from './kms-provider-content';
21+
import { FileInputBackendProvider } from '@mongodb-js/compass-components';
22+
import { createJSDomFileInputDummyBackend } from '@mongodb-js/compass-components/lib/components/file-input';
2123

2224
const openAdvancedTab = async (
2325
tabId: 'general' | 'authentication' | 'tls' | 'proxy' | 'advanced' | 'csfle'
@@ -85,20 +87,24 @@ describe('In-Use Encryption', function () {
8587
};
8688

8789
render(
88-
<ConnectionForm
89-
initialConnectionInfo={{
90-
id: 'conn-1',
91-
connectionOptions: {
92-
connectionString: 'mongodb://localhost:27017',
93-
},
94-
}}
95-
onSaveAndConnectClicked={(connectionInfo) => {
96-
connectSpy(connectionInfo.connectionOptions);
97-
}}
98-
onSaveClicked={() => {
99-
return Promise.resolve();
100-
}}
101-
/>
90+
<FileInputBackendProvider
91+
createFileInputBackend={createJSDomFileInputDummyBackend()}
92+
>
93+
<ConnectionForm
94+
initialConnectionInfo={{
95+
id: 'conn-1',
96+
connectionOptions: {
97+
connectionString: 'mongodb://localhost:27017',
98+
},
99+
}}
100+
onSaveAndConnectClicked={(connectionInfo) => {
101+
connectSpy(connectionInfo.connectionOptions);
102+
}}
103+
onSaveClicked={() => {
104+
return Promise.resolve();
105+
}}
106+
/>
107+
</FileInputBackendProvider>
102108
);
103109

104110
expect(connectSpy).not.to.have.been.called;

packages/connection-form/src/components/advanced-options-tabs/ssh-tunnel-tab/ssh-tunnel-identity.spec.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import type { SSHConnectionOptions } from '../../../utils/connection-ssh-handler
77
import SSHTunnelIdentity from './ssh-tunnel-identity';
88
import type { ConnectionFormError } from '../../../utils/validation';
99
import { errorMessageByFieldName } from '../../../utils/validation';
10+
import { FileInputBackendProvider } from '@mongodb-js/compass-components';
11+
import { createJSDomFileInputDummyBackend } from '@mongodb-js/compass-components/lib/components/file-input';
1012

1113
const formFields: {
1214
key: keyof SSHConnectionOptions;
@@ -49,11 +51,15 @@ describe('SSHTunnelIdentity', function () {
4951
updateConnectionFormFieldSpy = sinon.spy();
5052

5153
render(
52-
<SSHTunnelIdentity
53-
errors={[]}
54-
sshTunnelOptions={sshTunnelOptions}
55-
updateConnectionFormField={updateConnectionFormFieldSpy}
56-
/>
54+
<FileInputBackendProvider
55+
createFileInputBackend={createJSDomFileInputDummyBackend()}
56+
>
57+
<SSHTunnelIdentity
58+
errors={[]}
59+
sshTunnelOptions={sshTunnelOptions}
60+
updateConnectionFormField={updateConnectionFormFieldSpy}
61+
/>
62+
</FileInputBackendProvider>
5763
);
5864
});
5965

packages/connection-form/src/components/advanced-options-tabs/tls-ssl-tab/tls-ssl-tab.spec.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import sinon from 'sinon';
1010
import ConnectionStringUrl from 'mongodb-connection-string-url';
1111

1212
import SSLTab, { getTLSOptionForConnectionString } from './tls-ssl-tab';
13+
import { FileInputBackendProvider } from '@mongodb-js/compass-components';
14+
import { createJSDomFileInputDummyBackend } from '@mongodb-js/compass-components/lib/components/file-input';
1315

1416
describe('SchemaInput', function () {
1517
let updateConnectionFormFieldSpy: sinon.SinonSpy;
@@ -28,10 +30,14 @@ describe('SchemaInput', function () {
2830
'mongodb+srv://0ranges:p!neapp1es@localhost/?ssl=true'
2931
);
3032
const component = render(
31-
<SSLTab
32-
connectionStringUrl={testUrl}
33-
updateConnectionFormField={updateConnectionFormFieldSpy}
34-
/>
33+
<FileInputBackendProvider
34+
createFileInputBackend={createJSDomFileInputDummyBackend()}
35+
>
36+
<SSLTab
37+
connectionStringUrl={testUrl}
38+
updateConnectionFormField={updateConnectionFormFieldSpy}
39+
/>
40+
</FileInputBackendProvider>
3541
);
3642
rerender = component.rerender;
3743
});

0 commit comments

Comments
 (0)