Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
"package-json": "^7.0.0",
"parse-env-string": "^1.0.1",
"prettier": "^3.6.2",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-mosaic-component": "^4.1.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-mosaic-component": "^6.1.1",
"react-window": "^1.8.10",
"semver": "^7.3.4",
"shell-env": "^3.0.1",
Expand All @@ -94,16 +94,16 @@
"@reforged/maker-appimage": "^5.1.0",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^12.1.5",
"@testing-library/react": "^16.1.0",
"@testing-library/user-event": "^14.5.2",
"@tsconfig/node22": "^22.0.2",
"@types/classnames": "^2.2.11",
"@types/fs-extra": "^9.0.7",
"@types/getos": "^3.0.1",
"@types/node": "^22.19.1",
"@types/parse-env-string": "^1.0.2",
"@types/react": "^16.14.0",
"@types/react-dom": "^16.9.11",
"@types/react": "^18.3.0",
"@types/react-dom": "^18.3.0",
"@types/react-window": "^1.8.8",
"@types/semver": "^7.3.4",
"@types/tmp": "0.2.0",
Expand Down Expand Up @@ -162,7 +162,8 @@
},
"resolutions": {
"@electron-forge/maker-base": "8.0.0-alpha.3",
"@electron-forge/shared-types": "8.0.0-alpha.3"
"@electron-forge/shared-types": "8.0.0-alpha.3",
"@types/react": "^18.3.0"
},
"packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f",
"dependenciesMeta": {
Expand Down
8 changes: 5 additions & 3 deletions rtl-spec/components/commands-address-bar.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { render } from '@testing-library/react';
import { render, waitFor } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';
import { runInAction } from 'mobx';
import { beforeEach, describe, expect, it } from 'vitest';
Expand Down Expand Up @@ -76,7 +76,9 @@ describe('AddressBar component', () => {
runInAction(() => {
store.activeGistAction = action;
});
const btn = getByRole('button');
expect(btn).toBeDisabled();
await waitFor(() => {
const btn = getByRole('button');
expect(btn).toBeDisabled();
});
});
});
21 changes: 15 additions & 6 deletions rtl-spec/components/commands-publish-button.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Octokit } from '@octokit/rest';
import { act, waitFor } from '@testing-library/react';
import { beforeEach, describe, expect, it, vi } from 'vitest';

import {
Expand Down Expand Up @@ -273,7 +274,7 @@ describe('Action button component', () => {
// create a button that's primed to update gistId
state.gistId = gistId;
({ instance } = createActionButton());
instance.setState({ actionType: GistActionType.update });
act(() => instance.setState({ actionType: GistActionType.update }));

mocktokit.gists.get.mockImplementation(() => {
return {
Expand Down Expand Up @@ -316,7 +317,7 @@ describe('Action button component', () => {

// create a button primed to delete gistId
({ instance } = createActionButton());
instance.setState({ actionType: GistActionType.delete });
act(() => instance.setState({ actionType: GistActionType.delete }));
});

it('attempts to delete an existing Gist', async () => {
Expand Down Expand Up @@ -349,11 +350,19 @@ describe('Action button component', () => {
} = createActionButton();
expect(container.querySelector('fieldset')).not.toBeDisabled();

state.activeGistAction = gistActionState;
expect(container.querySelector('fieldset')).toBeDisabled();
act(() => {
state.activeGistAction = gistActionState;
});
await waitFor(() => {
expect(container.querySelector('fieldset')).toBeDisabled();
});

state.activeGistAction = GistActionState.none;
expect(container.querySelector('fieldset')).not.toBeDisabled();
act(() => {
state.activeGistAction = GistActionState.none;
});
await waitFor(() => {
expect(container.querySelector('fieldset')).not.toBeDisabled();
});
}

it('while publishing', async () => {
Expand Down
1 change: 1 addition & 0 deletions rtl-spec/components/editors-toolbar-button.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('Editor toolbar button component', () => {
getRoot: vi.fn(),
},
mosaicId: 'test',
blueprintNamespace: 'bp3',
};

({ state: store } = window.app);
Expand Down
42 changes: 42 additions & 0 deletions src/blueprint-react18.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Type augmentations for Blueprint.js v3 components to work with React 18.
*
* React 18 removed implicit `children` from React.Component props.
* Blueprint v3 class components don't declare `children` in their prop types,
* so they fail type-checking with \@types/react 18.
*
* This file adds `children` to the affected Blueprint component props.
* It can be removed when Blueprint is replaced with shadcn/ui.
*/

import { ReactNode } from 'react';

declare module '@blueprintjs/core' {
interface IAlertProps {
children?: ReactNode;
}
interface IDialogProps {
children?: ReactNode;
}
interface IFormGroupProps {
children?: ReactNode;
}
interface IRadioGroupProps {
children?: ReactNode;
}
}

declare module '@blueprintjs/select' {
interface ISelectProps<T> {

Check warning on line 30 in src/blueprint-react18.d.ts

View workflow job for this annotation

GitHub Actions / test / Test (ubuntu-latest, x64)

'T' is defined but never used

Check warning on line 30 in src/blueprint-react18.d.ts

View workflow job for this annotation

GitHub Actions / test / Test (macos-15-intel, x64)

'T' is defined but never used

Check warning on line 30 in src/blueprint-react18.d.ts

View workflow job for this annotation

GitHub Actions / test / Test (windows-latest, x64)

'T' is defined but never used

Check warning on line 30 in src/blueprint-react18.d.ts

View workflow job for this annotation

GitHub Actions / test / Test (macos-latest, arm64)

'T' is defined but never used

Check warning on line 30 in src/blueprint-react18.d.ts

View workflow job for this annotation

GitHub Actions / test / Test (ubuntu-24.04-arm, armv7l)

'T' is defined but never used
children?: ReactNode;
}
}

declare module '@blueprintjs/popover2' {
interface IPopover2Props<T> {

Check warning on line 36 in src/blueprint-react18.d.ts

View workflow job for this annotation

GitHub Actions / test / Test (ubuntu-latest, x64)

'T' is defined but never used

Check warning on line 36 in src/blueprint-react18.d.ts

View workflow job for this annotation

GitHub Actions / test / Test (macos-15-intel, x64)

'T' is defined but never used

Check warning on line 36 in src/blueprint-react18.d.ts

View workflow job for this annotation

GitHub Actions / test / Test (windows-latest, x64)

'T' is defined but never used

Check warning on line 36 in src/blueprint-react18.d.ts

View workflow job for this annotation

GitHub Actions / test / Test (macos-latest, arm64)

'T' is defined but never used

Check warning on line 36 in src/blueprint-react18.d.ts

View workflow job for this annotation

GitHub Actions / test / Test (ubuntu-24.04-arm, armv7l)

'T' is defined but never used
children?: ReactNode;
}
interface ITooltip2Props<T> {

Check warning on line 39 in src/blueprint-react18.d.ts

View workflow job for this annotation

GitHub Actions / test / Test (ubuntu-latest, x64)

'T' is defined but never used

Check warning on line 39 in src/blueprint-react18.d.ts

View workflow job for this annotation

GitHub Actions / test / Test (macos-15-intel, x64)

'T' is defined but never used

Check warning on line 39 in src/blueprint-react18.d.ts

View workflow job for this annotation

GitHub Actions / test / Test (windows-latest, x64)

'T' is defined but never used

Check warning on line 39 in src/blueprint-react18.d.ts

View workflow job for this annotation

GitHub Actions / test / Test (macos-latest, arm64)

'T' is defined but never used

Check warning on line 39 in src/blueprint-react18.d.ts

View workflow job for this annotation

GitHub Actions / test / Test (ubuntu-24.04-arm, armv7l)

'T' is defined but never used
children?: ReactNode;
}
}
11 changes: 5 additions & 6 deletions src/renderer/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class App {
* Initial setup call, loading Monaco and kicking off the React
* render process.
*/
public async setup(): Promise<void | Element | React.Component> {
public async setup(): Promise<void> {
if (this.state.isUsingSystemTheme) {
await this.loadTheme(getCurrentTheme().file);
} else {
Expand All @@ -123,13 +123,13 @@ export class App {

const [
{ default: React },
{ render },
{ createRoot },
{ Dialogs },
{ OutputEditorsWrapper },
{ Header },
] = await Promise.all([
import('react'),
import('react-dom'),
import('react-dom/client'),
import('./components/dialogs.js'),
import('./components/output-editors-wrapper.js'),
import('./components/header.js'),
Expand All @@ -147,7 +147,8 @@ export class App {
</div>
);

const rendered = render(app, document.getElementById('app'));
const root = createRoot(document.getElementById('app')!);
root.render(app);

this.setupResizeListener();
this.setupOfflineListener();
Expand All @@ -161,8 +162,6 @@ export class App {
window.ElectronFiddle.addEventListener('set-show-me-template', () => {
window.ElectronFiddle.setShowMeTemplate(this.state.templateName);
});

return rendered;
}

private setupTypeListeners() {
Expand Down
9 changes: 5 additions & 4 deletions src/renderer/components/settings-electron.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,14 @@ export const ElectronSettings = observer(
* Handles a change in which channels should be displayed.
*/
public handleChannelChange(event: React.FormEvent<HTMLInputElement>) {
const { id, checked } = event.currentTarget;
const { id } = event.currentTarget;
const { appState } = this.props;
const channel = id as ElectronReleaseChannel;

if (!checked) {
appState.hideChannels([id as ElectronReleaseChannel]);
if (appState.channelsToShow.includes(channel)) {
appState.hideChannels([channel]);
} else {
appState.showChannels([id as ElectronReleaseChannel]);
appState.showChannels([channel]);
}
}

Expand Down
12 changes: 9 additions & 3 deletions tests/renderer/app-spec.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { act } from '@testing-library/react';
import * as semver from 'semver';
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';

Expand Down Expand Up @@ -59,10 +60,15 @@ describe('App component', () => {
it('renders the app', async () => {
vi.useFakeTimers();

const result = (await app.setup()) as HTMLDivElement;
vi.runAllTimers();
await act(async () => {
await app.setup();
await vi.advanceTimersByTimeAsync(100);
});

expect(result.innerHTML).toBe('Header;OutputEditorsWrapper;Dialogs;');
const appEl = document.getElementById('app')!;
expect(appEl.innerHTML).toContain('Header;');
expect(appEl.innerHTML).toContain('OutputEditorsWrapper;');
expect(appEl.innerHTML).toContain('Dialogs;');

vi.useRealTimers();
});
Expand Down
Loading
Loading