mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-10-31 16:13:15 +00:00
isHttp2Available() only inspected "resource" timing entries, which can be empty right after a fresh login or session restore, before any subresource finishes loading. On an HTTP/2 page this made getMaxAccounts() fall back to the HTTP/1.1 cap of five accounts. Include the "navigation" timing entry, whose nextHopProtocol is known immediately, so h2/h3 is recognized on first load. Environments without timing data still return false (no h2 assumed).
14 lines
788 B
TypeScript
14 lines
788 B
TypeScript
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
import { getMaxAccounts, MAX_ACCOUNT_SLOTS } from '../account-utils';
|
|
afterEach(() => vi.restoreAllMocks());
|
|
describe('account limit protocol detection', () => {
|
|
it('recognizes HTTP/2 from document navigation before resources load', () => {
|
|
vi.spyOn(performance, 'getEntriesByType').mockImplementation(type => type === 'navigation' ? [{ nextHopProtocol: 'h2' } as PerformanceResourceTiming] : []);
|
|
expect(getMaxAccounts()).toBe(MAX_ACCOUNT_SLOTS);
|
|
});
|
|
it('retains the conservative cap when no multiplexed protocol was observed', () => {
|
|
vi.spyOn(performance, 'getEntriesByType').mockReturnValue([{ nextHopProtocol: 'http/1.1' } as PerformanceResourceTiming]);
|
|
expect(getMaxAccounts()).toBe(5);
|
|
});
|
|
});
|