fix: regression in typings

This commit is contained in:
Sami Mazouz 2024-09-28 16:11:50 +01:00
parent d818e83235
commit 1f3afca482
No known key found for this signature in database
6 changed files with 13 additions and 7 deletions

View File

@ -112,6 +112,13 @@ interface FlarumObject {
declare const flarum: FlarumObject;
interface Window {
/**
* Whether we are in testing mode or not.
*/
testing?: boolean;
}
// Extend JQuery with our custom functions, defined with $.fn
interface JQuery {
/**

View File

@ -36,7 +36,7 @@ export default class Avatar<CustomAttrs extends IAvatarAttrs = IAvatarAttrs> ext
}
content = username.charAt(0).toUpperCase();
attrs.style = !process.env.testing && { '--avatar-bg': user.color() };
attrs.style = !window.testing && { '--avatar-bg': user.color() };
}
return <span {...attrs}>{content}</span>;

View File

@ -34,7 +34,7 @@ export default class Badge<CustomAttrs extends IBadgeAttrs = IBadgeAttrs> extend
const newStyle = { ...style };
if (!process.env.testing) {
if (!window.testing) {
newStyle['--badge-bg'] = color;
}

View File

@ -43,7 +43,7 @@ export default class ModalManager extends Component<IModalManagerAttrs> {
data-modal-number={i}
role="dialog"
aria-modal="true"
style={!process.env.testing && { '--modal-number': i }}
style={!window.testing && { '--modal-number': i }}
aria-hidden={this.attrs.state.modal !== modal && 'true'}
>
{!!Tag && [
@ -66,7 +66,7 @@ export default class ModalManager extends Component<IModalManagerAttrs> {
className="Modal-backdrop backdrop"
ontransitionend={this.onBackdropTransitionEnd.bind(this)}
data-showing={!!this.attrs.state.modalList.length || this.attrs.state.loadingModal}
style={!process.env.testing && { '--modal-count': this.attrs.state.modalList.length + Number(this.attrs.state.loadingModal) }}
style={!window.testing && { '--modal-count': this.attrs.state.modalList.length + Number(this.attrs.state.loadingModal) }}
>
{this.attrs.state.loadingModal && <LoadingIndicator />}
</div>

View File

@ -30,7 +30,7 @@ export default class UserCard extends Component {
const color = user.color();
return (
<div className={classList('UserCard', this.attrs.className)} style={color && !process.env.testing && { '--usercard-bg': color }}>
<div className={classList('UserCard', this.attrs.className)} style={color && !window.testing && { '--usercard-bg': color }}>
<div className="darkenBackground">
<div className="container">
<div className="UserCard-profile">{this.profileItems().toArray()}</div>

View File

@ -12,8 +12,6 @@ import jsdom from 'jsdom';
dayjs.extend(relativeTime);
dayjs.extend(localizedFormat);
process.env.testing = true;
const dom = new jsdom.JSDOM('', {
pretendToBeVisual: false,
});
@ -26,6 +24,7 @@ global.requestAnimationFrame = (callback) => callback();
// Some other needed pollyfills.
window.$ = jquery;
window.testing = true;
window.m = m;
window.$.fn.tooltip = () => {};
window.matchMedia = () => ({