Skip to content

Commit 8a26bdc

Browse files
authored
chore(settings, shell, preferences-model): add typecheck for test files (#7571)
1 parent edc8751 commit 8a26bdc

File tree

10 files changed

+27
-19
lines changed

10 files changed

+27
-19
lines changed

packages/compass-preferences-model/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"test": "mocha",
4848
"test-ci": "npm run test",
4949
"reformat": "npm run eslint . -- --fix && npm run prettier -- --write .",
50-
"typecheck": "echo \"TODO(COMPASS-9897): typecheck is failing in test files\" && tsc -p tsconfig-build.json --noEmit"
50+
"typecheck": "tsc -p tsconfig.json --noEmit"
5151
},
5252
"dependencies": {
5353
"@mongodb-js/compass-app-registry": "^9.4.28",

packages/compass-preferences-model/src/renderer-ipc.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { makePreferencesIpc } from './renderer-ipc';
22
import { EventEmitter } from 'events';
33
import { expect } from 'chai';
4+
import type { UserPreferences } from './preferences-schema';
45

56
describe('Renderer IPC', function () {
67
const ipcImpl = {
7-
'compass:save-preferences'(attributes) {
8+
'compass:save-preferences'(attributes: Partial<UserPreferences>) {
89
return { savePreferences: 1, attributes };
910
},
1011
'compass:get-preferences'() {
@@ -19,7 +20,7 @@ describe('Renderer IPC', function () {
1920
};
2021
const ipcMock = Object.assign(new EventEmitter(), {
2122
invoke(method: string, ...args: any[]) {
22-
return Promise.resolve(ipcImpl[method](...args));
23+
return Promise.resolve((ipcImpl as any)[method](...args));
2324
},
2425
});
2526
const preferencesIpc = makePreferencesIpc(ipcMock as any);

packages/compass-settings/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"bootstrap": "npm run compile",
3434
"compile": "tsc -p tsconfig-build.json",
3535
"start": "npm run webpack serve -- --mode development",
36-
"typecheck": "echo \"TODO(COMPASS-9897): typecheck is failing in test files\" && tsc -p tsconfig-build.json --noEmit",
36+
"typecheck": "tsc -p tsconfig.json --noEmit",
3737
"eslint": "eslint-compass",
3838
"prettier": "prettier-compass",
3939
"lint": "npm run eslint . && npm run prettier -- --check .",

packages/compass-settings/src/components/modal.spec.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
cleanup,
99
userEvent,
1010
} from '@mongodb-js/testing-library-compass';
11-
import { spy, stub } from 'sinon';
11+
import { spy } from 'sinon';
1212
import type { SinonSpy } from 'sinon';
1313
import { expect } from 'chai';
1414
import { Provider } from 'react-redux';
@@ -18,7 +18,6 @@ import { SettingsModal } from './modal';
1818

1919
describe('SettingsModal', function () {
2020
let onCloseSpy: SinonSpy;
21-
let fetchSettingsSpy: SinonSpy;
2221
let onSaveSpy: SinonSpy;
2322
let onSelectTabSpy: SinonSpy;
2423
let renderSettingsModal: (
@@ -27,7 +26,6 @@ describe('SettingsModal', function () {
2726

2827
beforeEach(function () {
2928
onCloseSpy = spy();
30-
fetchSettingsSpy = stub().resolves();
3129
onSaveSpy = spy();
3230
onSelectTabSpy = spy();
3331

@@ -40,11 +38,11 @@ describe('SettingsModal', function () {
4038
<SettingsModal
4139
isOpen={false}
4240
onClose={onCloseSpy}
43-
fetchSettings={fetchSettingsSpy}
4441
onSave={onSaveSpy}
4542
onSelectTab={onSelectTabSpy}
46-
loadingState="ready"
43+
selectedTab={undefined}
4744
hasChangedSettings={false}
45+
isOIDCEnabled={false}
4846
{...props}
4947
/>
5048
</Provider>
@@ -59,7 +57,6 @@ describe('SettingsModal', function () {
5957
it('renders nothing until it is open and loaded', function () {
6058
renderSettingsModal({ isOpen: false });
6159

62-
expect(fetchSettingsSpy.called).to.be.false;
6360
const container = screen.queryByTestId('settings-modal');
6461
expect(container).to.not.exist;
6562
});

packages/compass-settings/src/components/settings/general.spec.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ describe('GeneralSettings', function () {
3636
cleanup();
3737
});
3838

39-
[
39+
const settings: (keyof ReturnType<typeof getSettings>)[] = [
4040
'readOnly',
4141
'enableShell',
4242
'protectConnectionStrings',
4343
'showKerberosPasswordField',
44-
].forEach((option) => {
44+
];
45+
settings.forEach((option) => {
4546
it(`renders ${option}`, function () {
4647
expect(within(container).getByTestId(option)).to.exist;
4748
});

packages/compass-settings/src/components/settings/oidc-settings.spec.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ describe('OIDCSettings', function () {
3636
cleanup();
3737
});
3838

39-
['showOIDCDeviceAuthFlow', 'persistOIDCTokens'].forEach((option) => {
39+
const settings: (keyof ReturnType<typeof getSettings>)[] = [
40+
'showOIDCDeviceAuthFlow',
41+
'persistOIDCTokens',
42+
];
43+
settings.forEach((option) => {
4044
it(`renders ${option}`, function () {
4145
expect(within(container).getByTestId(option)).to.exist;
4246
});

packages/compass-settings/src/components/settings/privacy.spec.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import configureStore from '../../../test/configure-store';
1313
import { fetchSettings } from '../../stores/settings';
1414

1515
function renderPrivacySettings(
16-
store,
16+
store: ReturnType<typeof configureStore>,
1717
props: Partial<React.ComponentProps<typeof PrivacySettings>> = {}
1818
) {
1919
const component = () => (
@@ -47,12 +47,13 @@ describe('PrivacySettings', function () {
4747
container = renderPrivacySettings(store);
4848
});
4949

50-
[
50+
const settings: (keyof ReturnType<typeof getSettings>)[] = [
5151
'autoUpdates',
5252
'enableMaps',
5353
'trackUsageStatistics',
5454
'enableFeedbackPanel',
55-
].forEach((option) => {
55+
];
56+
settings.forEach((option) => {
5657
it(`renders ${option}`, function () {
5758
expect(within(container).getByTestId(option)).to.exist;
5859
});

packages/compass-shell/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"bootstrap": "npm run compile",
3434
"compile": "tsc -p tsconfig-build.json",
3535
"start": "npm run webpack serve -- --mode development",
36-
"typecheck": "echo \"TODO(COMPASS-9897): typecheck is failing in test files\" && tsc -p tsconfig-build.json --noEmit",
36+
"typecheck": "tsc -p tsconfig.json --noEmit",
3737
"eslint": "eslint-compass",
3838
"prettier": "prettier-compass",
3939
"lint": "npm run eslint . && npm run prettier -- --check .",

packages/compass-shell/src/components/shell-header/shell-header.spec.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import { expect } from 'chai';
44

55
import { ShellHeader } from './shell-header';
66

7-
function renderShellHeader(props) {
7+
function renderShellHeader(
8+
props: Partial<React.ComponentProps<typeof ShellHeader>> = {}
9+
) {
810
return render(
911
<ShellHeader
1012
isExpanded={false}
13+
darkMode
1114
isOperationInProgress={false}
1215
onShellToggleClicked={() => {}}
1316
showInfoModal={() => {}}

packages/compass-shell/src/modules/history-storage.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ describe('HistoryStorage', function () {
6262
try {
6363
await fs.access(historyFilePath);
6464
expect.fail('Expected file to not exist');
65-
} catch (e) {
65+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
66+
} catch (e: any) {
6667
expect(e.code).to.equal('ENOENT');
6768
}
6869
expect(await historyStorage.load()).to.deep.equal([]);

0 commit comments

Comments
 (0)