refactor progress
This commit is contained in:
70
fluxer_app/src/test/LibfluxcoreMock.tsx
Normal file
70
fluxer_app/src/test/LibfluxcoreMock.tsx
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export default async function initLibfluxcore(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
export function is_animated_image(_data: Uint8Array): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function crop_and_rotate_gif(
|
||||
gif: Uint8Array,
|
||||
_x: number,
|
||||
_y: number,
|
||||
_width: number,
|
||||
_height: number,
|
||||
_rotation: number,
|
||||
_resizeWidth: number | null,
|
||||
_resizeHeight: number | null,
|
||||
): Uint8Array {
|
||||
return gif;
|
||||
}
|
||||
|
||||
export function crop_and_rotate_image(
|
||||
image: Uint8Array,
|
||||
_format: string,
|
||||
_x: number,
|
||||
_y: number,
|
||||
_width: number,
|
||||
_height: number,
|
||||
_rotation: number,
|
||||
_resizeWidth: number | null,
|
||||
_resizeHeight: number | null,
|
||||
): Uint8Array {
|
||||
return image;
|
||||
}
|
||||
|
||||
export function crop_and_rotate_apng(
|
||||
apng: Uint8Array,
|
||||
_x: number,
|
||||
_y: number,
|
||||
_width: number,
|
||||
_height: number,
|
||||
_rotation: number,
|
||||
_resizeWidth: number | null,
|
||||
_resizeHeight: number | null,
|
||||
): Uint8Array {
|
||||
return apng;
|
||||
}
|
||||
|
||||
export function decompress_zstd_frame(input: Uint8Array): Uint8Array {
|
||||
return input;
|
||||
}
|
||||
BIN
fluxer_app/src/test/LibfluxcoreMock.wasm
Normal file
BIN
fluxer_app/src/test/LibfluxcoreMock.wasm
Normal file
Binary file not shown.
@@ -20,12 +20,9 @@
|
||||
import {observer} from 'mobx-react-lite';
|
||||
import type {ReactNode} from 'react';
|
||||
import {vi} from 'vitest';
|
||||
import 'urlpattern-polyfill';
|
||||
|
||||
if (typeof globalThis.URLPattern === 'undefined') {
|
||||
await import('urlpattern-polyfill');
|
||||
}
|
||||
|
||||
vi.mock('~/lib/Platform', () => ({
|
||||
vi.mock('@app/lib/Platform', () => ({
|
||||
Platform: {
|
||||
OS: 'web',
|
||||
isWeb: true,
|
||||
@@ -51,7 +48,7 @@ vi.mock('mobx-persist-store', () => ({
|
||||
isPersisting: vi.fn(() => false),
|
||||
}));
|
||||
|
||||
vi.mock('~/lib/Logger', () => {
|
||||
vi.mock('@app/lib/Logger', () => {
|
||||
const noop = () => {};
|
||||
class MockLogger {
|
||||
child() {
|
||||
@@ -70,7 +67,7 @@ vi.mock('~/lib/Logger', () => {
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock('~/stores/UpdaterStore', () => ({
|
||||
vi.mock('@app/stores/UpdaterStore', () => ({
|
||||
default: {
|
||||
hasUpdate: false,
|
||||
state: 'idle',
|
||||
@@ -96,7 +93,7 @@ vi.mock('katex', () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock('~/lib/HttpClient', () => {
|
||||
vi.mock('@app/lib/HttpClient', () => {
|
||||
const defaultInstance = {
|
||||
api_code_version: 1,
|
||||
endpoints: {
|
||||
@@ -114,6 +111,14 @@ vi.mock('~/lib/HttpClient', () => {
|
||||
},
|
||||
captcha: {provider: 'none', hcaptcha_site_key: null, turnstile_site_key: null},
|
||||
features: {sms_mfa_enabled: false, voice_enabled: false, stripe_enabled: false, self_hosted: false},
|
||||
limits: {version: 1, traitDefinitions: [], rules: []},
|
||||
app_public: {
|
||||
sentry_dsn: '',
|
||||
sentry_proxy_path: '',
|
||||
sentry_report_host: '',
|
||||
sentry_project_id: '',
|
||||
sentry_public_key: '',
|
||||
},
|
||||
};
|
||||
|
||||
const mockResponse = Promise.resolve({ok: true, status: 200, headers: {}, body: defaultInstance});
|
||||
@@ -130,12 +135,14 @@ vi.mock('~/lib/HttpClient', () => {
|
||||
setSudoTokenProvider: vi.fn(),
|
||||
setSudoTokenListener: vi.fn(),
|
||||
setSudoTokenInvalidator: vi.fn(),
|
||||
setRelayDirectoryUrl: vi.fn(),
|
||||
setTargetInstanceDomain: vi.fn(),
|
||||
};
|
||||
|
||||
return {__esModule: true, default: client};
|
||||
});
|
||||
|
||||
vi.mock('~/components/channel/emoji-picker/EmojiPickerConstants', () => ({
|
||||
vi.mock('@app/components/channel/emoji_picker/EmojiPickerConstants', () => ({
|
||||
EMOJI_CLAP: '👏',
|
||||
EMOJI_SPRITE_SIZE: 32,
|
||||
EMOJI_ROW_HEIGHT: 48,
|
||||
@@ -146,21 +153,25 @@ vi.mock('~/components/channel/emoji-picker/EmojiPickerConstants', () => ({
|
||||
getSpriteSheetBackground: () => 'url(sprite.png)',
|
||||
}));
|
||||
|
||||
vi.mock('~/components/modals/ImageCropModal', () => ({
|
||||
vi.mock('@app/components/modals/ImageCropModal', () => ({
|
||||
default: () => null,
|
||||
}));
|
||||
|
||||
vi.mock('@lingui/core/macro', () => {
|
||||
const formatMessage = (
|
||||
str: TemplateStringsArray | string | {message?: string; defaultMessage?: string} | undefined,
|
||||
...expr: Array<unknown>
|
||||
) => {
|
||||
interface LinguiMessage {
|
||||
message?: string;
|
||||
defaultMessage?: string;
|
||||
}
|
||||
|
||||
const formatMessage = (str: TemplateStringsArray | string | LinguiMessage | undefined, ...expr: Array<unknown>) => {
|
||||
if (typeof str === 'string') return str;
|
||||
if (Array.isArray(str)) {
|
||||
return String(str.reduce((acc, chunk, i) => acc + chunk + (expr[i] ?? ''), ''));
|
||||
}
|
||||
if (str && typeof str === 'object') {
|
||||
return (str as any).message ?? (str as any).defaultMessage ?? '';
|
||||
if (str && typeof str === 'object' && !Array.isArray(str)) {
|
||||
const message = (str as LinguiMessage).message;
|
||||
const defaultMessage = (str as LinguiMessage).defaultMessage;
|
||||
return message ?? defaultMessage ?? '';
|
||||
}
|
||||
return '';
|
||||
};
|
||||
@@ -171,8 +182,8 @@ vi.mock('@lingui/core/macro', () => {
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock('@lingui/react/macro', async () => {
|
||||
const React = await import('react');
|
||||
vi.mock('@lingui/react/macro', () => {
|
||||
const React = require('react');
|
||||
|
||||
interface TransProps {
|
||||
children?: ReactNode;
|
||||
@@ -222,7 +233,7 @@ vi.mock('@lingui/react/macro', async () => {
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock('~/utils/NotificationUtils', () => ({
|
||||
vi.mock('@app/utils/NotificationUtils', () => ({
|
||||
ensureDesktopNotificationClickHandler: vi.fn(),
|
||||
hasNotification: () => false,
|
||||
isGranted: async () => false,
|
||||
25
fluxer_app/src/test/StyleMock.ts
Normal file
25
fluxer_app/src/test/StyleMock.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export default new Proxy(
|
||||
{},
|
||||
{
|
||||
get: (_target, prop) => prop,
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user