diff --git a/flow-report/src/icons.tsx b/flow-report/src/icons.tsx index 8f56bd3da6d5..1c92bf8ae86d 100644 --- a/flow-report/src/icons.tsx +++ b/flow-report/src/icons.tsx @@ -104,6 +104,14 @@ const EnvIcon: FunctionComponent = () => { ); }; +const NetworkIcon: FunctionComponent = () => { + return ( + + + + ); +}; + const CpuIcon: FunctionComponent = () => { return ( @@ -137,6 +145,7 @@ export { SnapshotIcon, CloseIcon, EnvIcon, + NetworkIcon, CpuIcon, HamburgerIcon, InfoIcon, diff --git a/flow-report/src/sidebar/sidebar.tsx b/flow-report/src/sidebar/sidebar.tsx index d697cf95cc1b..3c39aa77a8ef 100644 --- a/flow-report/src/sidebar/sidebar.tsx +++ b/flow-report/src/sidebar/sidebar.tsx @@ -6,9 +6,10 @@ import {FunctionComponent} from 'preact'; +import {Util} from '../../../report/renderer/util'; import {Separator} from '../common'; import {useI18n, useLocalizedStrings} from '../i18n/i18n'; -import {CpuIcon, EnvIcon, SummaryIcon} from '../icons'; +import {CpuIcon, EnvIcon, NetworkIcon, SummaryIcon} from '../icons'; import {classNames, useHashState, useFlowResult} from '../util'; import {SidebarFlow} from './flow'; @@ -32,8 +33,10 @@ const SidebarSummary: FunctionComponent = () => { ); }; -const SidebarRuntimeSettings: FunctionComponent<{settings: LH.ConfigSettings}> = ({settings}) => { +const SidebarRuntimeSettings: FunctionComponent<{settings: LH.ConfigSettings}> = +({settings}) => { const strings = useLocalizedStrings(); + const env = Util.getEmulationDescriptions(settings); return (
@@ -42,9 +45,18 @@ const SidebarRuntimeSettings: FunctionComponent<{settings: LH.ConfigSettings}> =
{ - settings.formFactor === 'desktop' ? - strings.runtimeDesktopEmulation : - strings.runtimeMobileEmulation + env.deviceEmulation + } + +
+
+ +
+ { + env.summary }
@@ -87,6 +99,7 @@ const Sidebar: FunctionComponent = () => { export { SidebarSummary, + SidebarRuntimeSettings, SidebarHeader, Sidebar, }; diff --git a/flow-report/test/sidebar/sidebar-test.tsx b/flow-report/test/sidebar/sidebar-test.tsx index a7a7f1d804ba..6967050f45c0 100644 --- a/flow-report/test/sidebar/sidebar-test.tsx +++ b/flow-report/test/sidebar/sidebar-test.tsx @@ -8,7 +8,7 @@ import {render} from '@testing-library/preact'; import {FunctionComponent} from 'preact'; import {I18nProvider} from '../../src/i18n/i18n'; -import {SidebarHeader, SidebarSummary} from '../../src/sidebar/sidebar'; +import {SidebarHeader, SidebarRuntimeSettings, SidebarSummary} from '../../src/sidebar/sidebar'; import {FlowResultContext} from '../../src/util'; import {flowResult} from '../sample-flow'; @@ -45,3 +45,45 @@ describe('SidebarSummary', () => { expect(link.classList).toContain('Sidebar--current'); }); }); + +describe('SidebarRuntimeSettings', () => { + it('displays default runtime settings', async () => { + const settings = { + formFactor: 'mobile', + throttlingMethod: 'simulate', + throttling: { + cpuSlowdownMultiplier: 4, + requestLatencyMs: 150 * 3.75, + downloadThroughputKbps: 1.6 * 1024 * 0.9, + uploadThroughputKbps: 750 * 0.9, + throughputKbps: 1.6 * 1024, + rttMs: 150, + }, + } as any; + const root = render(, {wrapper}); + + expect(root.getByText('Emulated Moto G4')).toBeTruthy(); + expect(root.getByText('Slow 4G throttling')).toBeTruthy(); + expect(root.getByText('4x slowdown')); + }); + + it('displays custom runtime settings', async () => { + const settings = { + formFactor: 'desktop', + throttlingMethod: 'devtools', + throttling: { + cpuSlowdownMultiplier: 1, + requestLatencyMs: 1, + downloadThroughputKbps: 1, + uploadThroughputKbps: 1, + throughputKbps: 1, + rttMs: 1, + }, + } as any; + const root = render(, {wrapper}); + + expect(root.getByText('Emulated Desktop')).toBeTruthy(); + expect(root.getByText('Custom throttling')).toBeTruthy(); + expect(root.getByText('1x slowdown')); + }); +});