mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 21:45:31 +09:00
chore(repo): remove dead code and useless tests (#3375)
This commit is contained in:
1 parent
7e177a1c90
commit
1cd62eb661
1391 files changed
+783
-120415
No files matched your search
@@ -1,40 +0,0 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {afterEach, describe, expect, test, vi} from 'vitest';
|
||||
|
||||
const mocks = vi.hoisted(() => ({transitioning: false}));
|
||||
|
||||
vi.mock('@app/features/auth/state/Accounts', () => ({
|
||||
default: {
|
||||
get transitioning() {
|
||||
return mocks.transitioning;
|
||||
},
|
||||
},
|
||||
}));
|
||||
vi.mock('@app/features/devtools/state/DeveloperOptions', () => ({
|
||||
default: {bypassLoadingSkeleton: false, forceLoadingSkeleton: false},
|
||||
}));
|
||||
vi.mock('@app/features/gateway/transport/GatewayConnection', () => ({default: {isConnectionInterrupted: false}}));
|
||||
|
||||
const {default: Initialization} = await import('@app/features/app/state/Initialization');
|
||||
const {isClientReconnecting} = await import('@app/features/app/state/ClientReadiness');
|
||||
|
||||
describe('isClientReconnecting', () => {
|
||||
afterEach(() => {
|
||||
mocks.transitioning = false;
|
||||
Initialization.reset();
|
||||
});
|
||||
|
||||
test('a loaded client waiting for its gateway is reconnecting', () => {
|
||||
Initialization.setReady();
|
||||
Initialization.setConnecting();
|
||||
expect(isClientReconnecting()).toBe(true);
|
||||
});
|
||||
|
||||
test('an account transition waiting for the next gateway is not a reconnect', () => {
|
||||
Initialization.setReady();
|
||||
Initialization.setLoading();
|
||||
mocks.transitioning = true;
|
||||
expect(isClientReconnecting()).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -149,7 +149,6 @@ test('the location is resolved from GET /ip on the instance the document names',
|
||||
expect(GeoIP.regionCode).toBe('AB');
|
||||
expect(GeoIP.latitude).toBe('59.3293');
|
||||
expect(GeoIP.longitude).toBe('18.0686');
|
||||
expect(GeoIP.isBlocked()).toBe(false);
|
||||
});
|
||||
|
||||
test('no active runtime never reaches the network and stays age gated', async () => {
|
||||
@@ -176,7 +175,6 @@ test('a failed lookup leaves the gateway free to supply the country', async () =
|
||||
expect(GeoIP.countryCode).toBeNull();
|
||||
GeoIP.applyConnectionFallbackGeo({countryCode: 'SE', regionCode: 'AB', latitude: '1', longitude: '2'});
|
||||
expect(GeoIP.countryCode).toBe('SE');
|
||||
expect(GeoIP.isBlocked()).toBe(true);
|
||||
});
|
||||
|
||||
test('the gateway never overwrites a resolved location', async () => {
|
||||
@@ -235,7 +233,6 @@ test('installing the first runtime re-seeds and resolves', async () => {
|
||||
expect(GeoIP.resolution).toBe('resolved');
|
||||
expect(GeoIP.countryCode).toBe('SE');
|
||||
expect(GeoIP.ageBlockedGeos).toEqual([{countryCode: 'SE', regionCode: 'AB'}]);
|
||||
expect(GeoIP.isBlocked()).toBe(true);
|
||||
});
|
||||
|
||||
test('an instance that cannot geolocate never wipes a country the gateway already supplied', async () => {
|
||||
|
||||
@@ -139,15 +139,6 @@ class GeoIP {
|
||||
});
|
||||
}
|
||||
|
||||
isBlocked(): boolean {
|
||||
if (!this.countryCode) return false;
|
||||
return this.ageBlockedGeos.some((geo) => {
|
||||
if (geo.countryCode !== this.countryCode) return false;
|
||||
if (geo.regionCode === null) return true;
|
||||
return geo.regionCode === this.regionCode;
|
||||
});
|
||||
}
|
||||
|
||||
private adoptRuntime(runtime: ActiveRuntimeContext | null): void {
|
||||
const instanceKey = runtime?.instanceKey ?? null;
|
||||
const transportApiEndpoint = runtime?.transportApiEndpoint ?? null;
|
||||
|
||||
@@ -21,14 +21,6 @@ class Initialization {
|
||||
makeAutoObservable(this, {}, {autoBind: true});
|
||||
}
|
||||
|
||||
get isLoading(): boolean {
|
||||
return this.state === InitializationState.LOADING;
|
||||
}
|
||||
|
||||
get isConnecting(): boolean {
|
||||
return this.state === InitializationState.CONNECTING;
|
||||
}
|
||||
|
||||
get isReady(): boolean {
|
||||
return this.state === InitializationState.READY;
|
||||
}
|
||||
|
||||
@@ -38,10 +38,6 @@ class InstanceCapabilitiesStore {
|
||||
forget(instanceKey: string): void {
|
||||
this.records.delete(instanceKey);
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this.records.clear();
|
||||
}
|
||||
}
|
||||
|
||||
export default new InstanceCapabilitiesStore();
|
||||
@@ -39,11 +39,9 @@ import {InstanceDiscoveryUnreachableError} from '@fluxer/instance_bootstrap/src/
|
||||
import {InstanceEndpointKind, normalizeInstanceEndpoint} from '@fluxer/instance_bootstrap/src/EndpointNormalization';
|
||||
import {isOfficialInstanceHost, OFFICIAL_INSTANCE_DISPLAY_HOST} from '@fluxer/instance_bootstrap/src/OfficialInstance';
|
||||
import type {
|
||||
InstanceAgePolicy,
|
||||
InstanceAppPublic,
|
||||
InstanceCommunity,
|
||||
InstanceFeatures,
|
||||
InstanceRegistration,
|
||||
InstanceServices,
|
||||
InstanceSso as InstanceSsoConfig,
|
||||
} from '@fluxer/instance_bootstrap/src/Types';
|
||||
@@ -97,8 +95,6 @@ interface RuntimeConfigPublication {
|
||||
phase: RuntimeConfigPublicationPhase;
|
||||
}
|
||||
|
||||
const DEFAULT_PREMIUM_PRODUCT_NAME = 'Plutonium';
|
||||
|
||||
class RuntimeActivationSupersededError extends Error {
|
||||
constructor() {
|
||||
super('Runtime activation was superseded by another instance transition');
|
||||
@@ -270,14 +266,6 @@ class RuntimeConfig {
|
||||
return this.readableSnapshot().features;
|
||||
}
|
||||
|
||||
get sso(): InstanceSsoConfig | null {
|
||||
return this.readableSnapshot().sso;
|
||||
}
|
||||
|
||||
get registration(): InstanceRegistration {
|
||||
return this.readableSnapshot().registration;
|
||||
}
|
||||
|
||||
get community(): InstanceCommunity {
|
||||
return this.readableSnapshot().community;
|
||||
}
|
||||
@@ -286,10 +274,6 @@ class RuntimeConfig {
|
||||
return this.readableSnapshot().services;
|
||||
}
|
||||
|
||||
get publicPushVapidKey(): string | null {
|
||||
return this.readableSnapshot().publicPushVapidKey;
|
||||
}
|
||||
|
||||
get limits(): LimitConfigSnapshot {
|
||||
return this.readableSnapshot().limits;
|
||||
}
|
||||
@@ -298,10 +282,6 @@ class RuntimeConfig {
|
||||
return this.readableSnapshot().appPublic;
|
||||
}
|
||||
|
||||
get agePolicy(): InstanceAgePolicy | null {
|
||||
return this.readableSnapshot().agePolicy ?? null;
|
||||
}
|
||||
|
||||
private requireActiveSnapshot(): RuntimeConfigSnapshot {
|
||||
return this.requireActiveRuntime().snapshot;
|
||||
}
|
||||
@@ -750,10 +730,6 @@ class RuntimeConfig {
|
||||
return this.activeRuntime?.snapshot.appPublic.branding.status_page_url ?? '';
|
||||
}
|
||||
|
||||
get statusPageIncidentHistoryUrl(): string {
|
||||
return this.activeRuntime?.snapshot.appPublic.branding.status_page_incident_history_url ?? '';
|
||||
}
|
||||
|
||||
isSelfHosted(): boolean {
|
||||
return DeveloperOptions.selfHostedModeOverride || this.features.self_hosted;
|
||||
}
|
||||
@@ -770,10 +746,6 @@ class RuntimeConfig {
|
||||
return this.features.stripe_serviceable;
|
||||
}
|
||||
|
||||
get premiumProductName(): string {
|
||||
return this.appPublic.branding.premium_product_name?.trim() || DEFAULT_PREMIUM_PRODUCT_NAME;
|
||||
}
|
||||
|
||||
get premiumInfoUrl(): string | null {
|
||||
return this.appPublic.branding.premium_info_url ?? null;
|
||||
}
|
||||
@@ -802,10 +774,6 @@ class RuntimeConfig {
|
||||
return this.appPublic.branding.product_name;
|
||||
}
|
||||
|
||||
get premiumProductFullName(): string {
|
||||
return `${this.productName} ${this.premiumProductName}`;
|
||||
}
|
||||
|
||||
get iconUrl(): string | null {
|
||||
return this.appPublic.branding.icon_url;
|
||||
}
|
||||
@@ -842,14 +810,6 @@ class RuntimeConfig {
|
||||
return this.appPublic.legal.guidelines_url;
|
||||
}
|
||||
|
||||
get collectDateOfBirthOnRegistration(): boolean {
|
||||
return this.appPublic.registration.collect_date_of_birth;
|
||||
}
|
||||
|
||||
get setupAdminUrl(): string | null {
|
||||
return this.appPublic.setup.admin_url;
|
||||
}
|
||||
|
||||
requiresSelfHostedSetup(): boolean {
|
||||
if (getElectronAPI() != null) {
|
||||
return false;
|
||||
@@ -884,14 +844,6 @@ class RuntimeConfig {
|
||||
return new URL(this.marketingEndpoint).host;
|
||||
}
|
||||
|
||||
get inviteHost(): string {
|
||||
return new URL(this.inviteEndpoint).host;
|
||||
}
|
||||
|
||||
get giftHost(): string {
|
||||
return new URL(this.giftEndpoint).host;
|
||||
}
|
||||
|
||||
get inviteUrlBase(): string {
|
||||
const url = new URL(this.inviteEndpoint);
|
||||
const path = url.pathname === '/' ? '' : url.pathname;
|
||||
|
||||
@@ -31,10 +31,6 @@ class RuntimeCrash {
|
||||
logger.fatal('Triggering fatal runtime crash', normalizedError);
|
||||
return normalizedError;
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this.fatalError = null;
|
||||
}
|
||||
}
|
||||
|
||||
export default new RuntimeCrash();
|
||||
@@ -20,13 +20,11 @@ import type * as UpdaterModalCommands from '@app/features/updater/commands/Updat
|
||||
import {
|
||||
createUpdaterMachineSnapshot,
|
||||
getUpdaterDisplayVersion,
|
||||
getUpdaterMachineStateValue,
|
||||
hasManualNativeDownload,
|
||||
transitionUpdaterMachineSnapshot,
|
||||
type UpdateInfo,
|
||||
type UpdaterMachineEvent,
|
||||
type UpdaterMachineSnapshot,
|
||||
type UpdaterState,
|
||||
} from '@app/features/updater/state/UpdaterStateMachine';
|
||||
import {buildLinuxManualUpdateOptions} from '@app/features/updater/utils/LinuxManualUpdateOptions';
|
||||
import type {UpdaterEvent as NativeUpdaterEvent} from '@app/types/electron.d';
|
||||
@@ -206,10 +204,6 @@ class Updater {
|
||||
return this.updateInfo.native.available && this.hasManualNativeDownload;
|
||||
}
|
||||
|
||||
get state(): UpdaterState {
|
||||
return getUpdaterMachineStateValue(this.snapshot);
|
||||
}
|
||||
|
||||
get isChecking(): boolean {
|
||||
return this.snapshot.context.isChecking;
|
||||
}
|
||||
@@ -728,10 +722,6 @@ class Updater {
|
||||
}
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this.transition({type: 'reset'});
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
if (this.unsubscribeNativeEvents) {
|
||||
this.unsubscribeNativeEvents();
|
||||
|
||||
Reference in new issue
Block a user