import { render, screen, waitFor } from '@testing-library/react';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { App } from '../app';
import { ServerProvider } from '../context/server-context';
import { ApiClient } from '../lib/api';
import { I18nProvider } from '../lib/i18n';
describe('disabled optional features', () => {
afterEach(() => {
location.hash = '';
});
it('does not call a contract-only v2 gateway when claims are unavailable', async () => {
localStorage.setItem('xfesm.locale', 'en-US');
location.hash = '/claims';
const client = new ApiClient();
vi.spyOn(client, 'session').mockResolvedValue({
authenticated: true,
csrfToken: 'csrf',
actor: { id: 'owner', displayName: 'owner', roles: ['owner'], permissions: [], totpVerified: true },
});
const status = vi.spyOn(client, 'status').mockResolvedValue({
sampledAt: '2026-01-01T00:00:00Z',
uptimeSeconds: 1,
playersOnline: 0,
});
const features = vi.spyOn(client, 'features').mockResolvedValue({
consoleEnabled: false,
moderationEnabled: false,
claimsEnabled: false,
worldTrackingEnabled: false,
rollbackEnabled: false,
});
const claims = vi.spyOn(client, 'claims');
vi.spyOn(client, 'subscribe').mockReturnValue(() => undefined);
render(<I18nProvider><ServerProvider client={client}><App /></ServerProvider></I18nProvider>);
await waitFor(() => expect(status).toHaveBeenCalledOnce());
await waitFor(() => expect(features).toHaveBeenCalledOnce());
expect(await screen.findByText('The claims module is not enabled on the server.')).toBeInTheDocument();
expect(claims).not.toHaveBeenCalled();
});
});
import { render, screen, waitFor } from '@testing-library/react';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { App } from '../app';
import { ServerProvider } from '../context/server-context';
import { ApiClient } from '../lib/api';
import { I18nProvider } from '../lib/i18n';
describe('disabled optional features', () => {
afterEach(() => {
location.hash = '';
});
it('does not call a contract-only v2 gateway when claims are unavailable', async () => {
localStorage.setItem('xfesm.locale', 'en-US');
location.hash = '/claims';
const client = new ApiClient();
vi.spyOn(client, 'session').mockResolvedValue({
authenticated: true,
csrfToken: 'csrf',
actor: { id: 'owner', displayName: 'owner', roles: ['owner'], permissions: [], totpVerified: true },
});
const status = vi.spyOn(client, 'status').mockResolvedValue({
sampledAt: '2026-01-01T00:00:00Z',
uptimeSeconds: 1,
playersOnline: 0,
});
const features = vi.spyOn(client, 'features').mockResolvedValue({
consoleEnabled: false,
moderationEnabled: false,
claimsEnabled: false,
worldTrackingEnabled: false,
rollbackEnabled: false,
});
const claims = vi.spyOn(client, 'claims');
vi.spyOn(client, 'subscribe').mockReturnValue(() => undefined);
render(<I18nProvider><ServerProvider client={client}><App /></ServerProvider></I18nProvider>);
await waitFor(() => expect(status).toHaveBeenCalledOnce());
await waitFor(() => expect(features).toHaveBeenCalledOnce());
expect(await screen.findByText('The claims module is not enabled on the server.')).toBeInTheDocument();
expect(claims).not.toHaveBeenCalled();
});
});