Skip to content

Commit 60c4e4c

Browse files
authored
Merge branch 'main' into rm-zee
2 parents 44da5eb + 3a1777b commit 60c4e4c

14 files changed

+482
-470
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"classnames": "^2.5.1",
7777
"common-tags": "^1.8.2",
7878
"copy-to-clipboard": "^3.3.3",
79-
"core-js": "^3.45.0",
79+
"core-js": "^3.45.1",
8080
"escape-string-regexp": "^4.0.0",
8181
"gecko-profiler-demangle": "^0.3.3",
8282
"idb": "^8.0.3",
@@ -115,15 +115,14 @@
115115
"@babel/preset-react": "^7.27.1",
116116
"@babel/preset-typescript": "^7.27.1",
117117
"@eslint/js": "^9.34.0",
118-
"@fetch-mock/jest": "^0.2.16",
119118
"@testing-library/dom": "^10.4.1",
120-
"@testing-library/jest-dom": "^6.6.4",
119+
"@testing-library/jest-dom": "^6.8.0",
121120
"@testing-library/react": "^16.3.0",
122121
"@types/clamp": "^1.0.3",
123122
"@types/common-tags": "^1.8.4",
124123
"@types/jest": "^30.0.0",
125124
"@types/minimist": "^1.2.5",
126-
"@types/node": "^22.17.2",
125+
"@types/node": "^22.18.0",
127126
"@types/query-string": "^6.3.0",
128127
"@types/react": "^18.3.24",
129128
"@types/react-dom": "^18.3.1",
@@ -145,7 +144,7 @@
145144
"copy-webpack-plugin": "^13.0.1",
146145
"cross-env": "^10.0.0",
147146
"css-loader": "^7.1.2",
148-
"cssnano": "^7.1.0",
147+
"cssnano": "^7.1.1",
149148
"devtools-license-check": "^0.9.0",
150149
"eslint": "^9.34.0",
151150
"eslint-config-prettier": "^10.1.8",
@@ -158,6 +157,7 @@
158157
"eslint-plugin-testing-library": "^7.6.6",
159158
"espree": "^10.4.0",
160159
"fake-indexeddb": "^6.1.0",
160+
"fetch-mock": "^12.5.3",
161161
"file-loader": "^6.2.0",
162162
"glob": "^11.0.3",
163163
"globals": "^16.3.0",
@@ -207,7 +207,7 @@
207207
"tsx"
208208
],
209209
"transformIgnorePatterns": [
210-
"/node_modules/(?!(query-string|decode-uri-component|iongraph-web|split-on-first|filter-obj|@fetch-mock/jest|fetch-mock)/)"
210+
"/node_modules/(?!(query-string|decode-uri-component|iongraph-web|split-on-first|filter-obj|fetch-mock)/)"
211211
],
212212
"moduleNameMapper": {
213213
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ftl)$": "<rootDir>/src/test/fixtures/mocks/file-mock.ts",

src/components/shared/ContextMenu.tsx

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,25 @@
44

55
import { PureComponent } from 'react';
66
import type { ComponentProps } from 'react';
7-
import ReactDOM from 'react-dom';
87
import { ContextMenu as ReactContextMenu } from '@firefox-devtools/react-contextmenu';
98

109
import './ContextMenu.css';
1110

1211
type Props = ComponentProps<typeof ReactContextMenu>;
1312

1413
export class ContextMenu extends PureComponent<Props> {
15-
_contextMenu: any = null;
16-
_takeContextMenuRef = (contextMenu: any) => {
17-
this._contextMenu = contextMenu;
18-
};
19-
20-
_mouseDownHandler(event: Event): void {
14+
_mouseDownHandler = (event: React.MouseEvent<HTMLDivElement>): void => {
2115
// This prevents from stealing the focus from where it was.
2216
event.preventDefault();
23-
}
24-
25-
override componentDidMount() {
26-
if (this._contextMenu) {
27-
// The context menu component does not expose a reference to its internal
28-
// DOM node so using findDOMNode is currently unavoidable.
29-
// eslint-disable-next-line react/no-find-dom-node
30-
const contextMenuNode = ReactDOM.findDOMNode(this._contextMenu);
31-
if (contextMenuNode) {
32-
// There's no need to remove this event listener since the component is
33-
// never unmounted. Duplicate event listeners will also be discarded
34-
// automatically so we don't need to handle that.
35-
contextMenuNode.addEventListener('mousedown', this._mouseDownHandler);
36-
}
37-
}
38-
}
39-
40-
override componentWillUnmount() {
41-
// eslint-disable-next-line react/no-find-dom-node
42-
const contextMenuNode = ReactDOM.findDOMNode(this._contextMenu);
43-
if (contextMenuNode) {
44-
contextMenuNode.removeEventListener('mousedown', this._mouseDownHandler);
45-
}
46-
}
17+
};
4718

4819
override render() {
4920
return (
50-
<ReactContextMenu ref={this._takeContextMenuRef} {...this.props}>
51-
{this.props.children ? this.props.children : <div />}
52-
</ReactContextMenu>
21+
<div onMouseDown={this._mouseDownHandler}>
22+
<ReactContextMenu {...this.props}>
23+
{this.props.children ? this.props.children : <div />}
24+
</ReactContextMenu>
25+
</div>
5326
);
5427
}
5528
}

src/test/components/AppLocalizationProvider.test.tsx

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,23 @@ describe('AppLocalizationProvider', () => {
161161

162162
expect(await screen.findByText(translatedText('de'))).toBeInTheDocument();
163163
expect(document.documentElement).toHaveAttribute('lang', 'de');
164-
expect(window.fetch).toHaveFetched('/locales/de/app.ftl', {
165-
// @ts-expect-error fetch-mock's TypeScript types for toHaveFetched don't know about `credentials`, not sure why
166-
credentials: 'include',
167-
mode: 'no-cors',
168-
});
169-
expect(window.fetch).toHaveFetched('/locales/en-US/app.ftl', {
170-
// @ts-expect-error fetch-mock's TypeScript types for toHaveFetched don't know about `credentials`, not sure why
171-
credentials: 'include',
172-
mode: 'no-cors',
173-
});
174-
expect(window.fetch).toHaveFetchedTimes(2);
164+
expect(
165+
window.fetchMock.callHistory.lastCall('/locales/de/app.ftl')?.options
166+
).toEqual(
167+
expect.objectContaining({
168+
credentials: 'include',
169+
mode: 'no-cors',
170+
})
171+
);
172+
expect(
173+
window.fetchMock.callHistory.lastCall('/locales/en-US/app.ftl')?.options
174+
).toEqual(
175+
expect.objectContaining({
176+
credentials: 'include',
177+
mode: 'no-cors',
178+
})
179+
);
180+
expect(window.fetchMock.callHistory.callLogs.length).toBe(2);
175181
});
176182

177183
it('falls back properly on en-US if the primary locale lacks a string', async () => {
@@ -193,16 +199,22 @@ describe('AppLocalizationProvider', () => {
193199
await screen.findByText(translatedText('en-US'))
194200
).toBeInTheDocument();
195201
expect(document.documentElement).toHaveAttribute('lang', 'de');
196-
expect(window.fetch).toHaveFetched('/locales/de/app.ftl', {
197-
// @ts-expect-error fetch-mock's TypeScript types for toHaveFetched don't know about `credentials`, not sure why
198-
credentials: 'include',
199-
mode: 'no-cors',
200-
});
201-
expect(window.fetch).toHaveFetched('/locales/en-US/app.ftl', {
202-
// @ts-expect-error fetch-mock's TypeScript types for toHaveFetched don't know about `credentials`, not sure why
203-
credentials: 'include',
204-
mode: 'no-cors',
205-
});
206-
expect(window.fetch).toHaveFetchedTimes(2);
202+
expect(
203+
window.fetchMock.callHistory.lastCall('/locales/de/app.ftl')?.options
204+
).toEqual(
205+
expect.objectContaining({
206+
credentials: 'include',
207+
mode: 'no-cors',
208+
})
209+
);
210+
expect(
211+
window.fetchMock.callHistory.lastCall('/locales/en-US/app.ftl')?.options
212+
).toEqual(
213+
expect.objectContaining({
214+
credentials: 'include',
215+
mode: 'no-cors',
216+
})
217+
);
218+
expect(window.fetchMock.callHistory.callLogs.length).toBe(2);
207219
});
208220
});

0 commit comments

Comments
 (0)