fix(native): Prettier on the native client files, rate-limit e2e requests in sequence

Formats the files the client formatting gate listed, and NATIVE-E2E-005 sends its twenty exchange attempts one after another: all at once they reset the test server's connections.
This commit is contained in:
Maurice
2026-10-25 17:41:32 +01:00
parent 99c1a2d6c7
commit 6f3c051c7c
30 changed files with 993 additions and 858 deletions
@@ -1,49 +1,49 @@
// FE-SETTINGS-NATIVE-SERVER-001 to FE-SETTINGS-NATIVE-SERVER-006
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { render, screen, fireEvent } from '../../../tests/helpers/render'
import NativeServerSection from './NativeServerSection'
import MSettingsServer from '../../mobile/screens/settings/MSettingsServer'
import NativeServerLink from '../../pages/login/NativeServerLink'
import { nativeServerHost } from '../../native/platform'
import { TrekShell } from '../../native/trekShell'
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { fireEvent, render, screen } from '../../../tests/helpers/render';
import MSettingsServer from '../../mobile/screens/settings/MSettingsServer';
import { nativeServerHost } from '../../native/platform';
import { TrekShell } from '../../native/trekShell';
import NativeServerLink from '../../pages/login/NativeServerLink';
import NativeServerSection from './NativeServerSection';
vi.mock('../../native/platform', () => ({ nativeServerHost: vi.fn() }))
vi.mock('../../native/trekShell', () => ({ TrekShell: { resetServer: vi.fn() } }))
vi.mock('../../native/platform', () => ({ nativeServerHost: vi.fn() }));
vi.mock('../../native/trekShell', () => ({ TrekShell: { resetServer: vi.fn() } }));
beforeEach(() => {
vi.mocked(TrekShell.resetServer).mockReset().mockResolvedValue()
})
vi.mocked(TrekShell.resetServer).mockReset().mockResolvedValue();
});
describe.each([
['desktop', NativeServerSection],
['mobile', MSettingsServer],
])('the %s server section', (_shell, Section) => {
it('renders nothing in a browser', () => {
vi.mocked(nativeServerHost).mockReturnValue(null)
const { container } = render(<Section />)
expect(container).toBeEmptyDOMElement()
})
vi.mocked(nativeServerHost).mockReturnValue(null);
const { container } = render(<Section />);
expect(container).toBeEmptyDOMElement();
});
it('names the server and leads back to the address screen', () => {
vi.mocked(nativeServerHost).mockReturnValue('trek.example.com')
render(<Section />)
expect(screen.getByText('This app is connected to trek.example.com.')).toBeInTheDocument()
fireEvent.click(screen.getByRole('button', { name: 'Change server' }))
expect(TrekShell.resetServer).toHaveBeenCalled()
})
})
vi.mocked(nativeServerHost).mockReturnValue('trek.example.com');
render(<Section />);
expect(screen.getByText('This app is connected to trek.example.com.')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: 'Change server' }));
expect(TrekShell.resetServer).toHaveBeenCalled();
});
});
describe('the sign-in screen link', () => {
it('renders nothing in a browser', () => {
vi.mocked(nativeServerHost).mockReturnValue(null)
const { container } = render(<NativeServerLink />)
expect(container).toBeEmptyDOMElement()
})
vi.mocked(nativeServerHost).mockReturnValue(null);
const { container } = render(<NativeServerLink />);
expect(container).toBeEmptyDOMElement();
});
it('leads back to the address screen in the app', () => {
vi.mocked(nativeServerHost).mockReturnValue('trek.example.com')
render(<NativeServerLink />)
fireEvent.click(screen.getByRole('button', { name: 'Change server' }))
expect(TrekShell.resetServer).toHaveBeenCalled()
})
})
vi.mocked(nativeServerHost).mockReturnValue('trek.example.com');
render(<NativeServerLink />);
fireEvent.click(screen.getByRole('button', { name: 'Change server' }));
expect(TrekShell.resetServer).toHaveBeenCalled();
});
});