mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(p2p): enable pure browser p2p by default
This commit is contained in:
@@ -17,13 +17,23 @@ const browserWindow = {
|
||||
},
|
||||
} as unknown as Window;
|
||||
|
||||
const browserWindowWithDisabledPureP2P = {
|
||||
electronApi: undefined,
|
||||
isElectron: false,
|
||||
location: { hostname: '5chan.app' },
|
||||
localStorage: {
|
||||
getItem: () => 'false',
|
||||
setItem: () => undefined,
|
||||
},
|
||||
} as unknown as Window;
|
||||
|
||||
const electronWindow = {
|
||||
electronApi: { isElectron: true },
|
||||
isElectron: true,
|
||||
location: { hostname: 'localhost' },
|
||||
} as unknown as Window;
|
||||
|
||||
const p2pBrowserWindow = {
|
||||
const p2pBrowserWindowWithDisabledPureP2P = {
|
||||
electronApi: undefined,
|
||||
isElectron: false,
|
||||
location: { hostname: 'p2p.5chan.app' },
|
||||
@@ -46,17 +56,18 @@ describe('p2p-runtime', () => {
|
||||
expect(getP2PRuntimeMode(account, browserWindow)).toBeNull();
|
||||
});
|
||||
|
||||
it('shows p2p settings in browsers only when pure p2p is enabled or active', () => {
|
||||
expect(shouldShowP2PSettingsSection(undefined, browserWindow)).toBe(false);
|
||||
expect(shouldShowP2PSettingsSection({ pkcOptions: { ipfsGatewayUrls: ['https://gateway.example'] } }, browserWindow)).toBe(false);
|
||||
expect(isBrowserPureP2PEnabled({ pkcOptions: { ipfsGatewayUrls: ['https://gateway.example'] } }, browserWindow)).toBe(false);
|
||||
it('shows p2p settings in browsers when pure p2p is enabled by default', () => {
|
||||
expect(shouldShowP2PSettingsSection(undefined, browserWindow)).toBe(true);
|
||||
expect(shouldShowP2PSettingsSection({ pkcOptions: { ipfsGatewayUrls: ['https://gateway.example'] } }, browserWindow)).toBe(true);
|
||||
expect(isBrowserPureP2PEnabled({ pkcOptions: { ipfsGatewayUrls: ['https://gateway.example'] } }, browserWindow)).toBe(true);
|
||||
});
|
||||
|
||||
it('forces browser p2p on p2p subdomains even with gateway account options', () => {
|
||||
it('allows browser gateway mode when pure p2p is disabled', () => {
|
||||
const gatewayAccount = { pkcOptions: { ipfsGatewayUrls: ['https://gateway.example'] } };
|
||||
|
||||
expect(isBrowserPureP2PEnabled(gatewayAccount, p2pBrowserWindow)).toBe(true);
|
||||
expect(shouldShowP2PSettingsSection(gatewayAccount, p2pBrowserWindow)).toBe(true);
|
||||
expect(isBrowserPureP2PEnabled(gatewayAccount, browserWindowWithDisabledPureP2P)).toBe(false);
|
||||
expect(shouldShowP2PSettingsSection(gatewayAccount, browserWindowWithDisabledPureP2P)).toBe(false);
|
||||
expect(isBrowserPureP2PEnabled(gatewayAccount, p2pBrowserWindowWithDisabledPureP2P)).toBe(false);
|
||||
});
|
||||
|
||||
it('builds browser p2p and gateway account options without a direct pkc-js import', () => {
|
||||
|
||||
Reference in New Issue
Block a user