report: fix wording when screenEmulation disabled (#14587)
This commit is contained in:
Родитель
5fc4f035ff
Коммит
a8236d4c3e
|
@ -516,10 +516,12 @@ class Util {
|
|||
summary = cpuThrottling = networkThrottling = Util.i18n.strings.runtimeUnknown;
|
||||
}
|
||||
|
||||
const deviceEmulation = {
|
||||
mobile: Util.i18n.strings.runtimeMobileEmulation,
|
||||
desktop: Util.i18n.strings.runtimeDesktopEmulation,
|
||||
}[settings.formFactor] || Util.i18n.strings.runtimeNoEmulation;
|
||||
let deviceEmulation = Util.i18n.strings.runtimeMobileEmulation;
|
||||
if (settings.screenEmulation.disabled) {
|
||||
deviceEmulation = Util.i18n.strings.runtimeNoEmulation;
|
||||
} else if (!settings.screenEmulation.mobile) {
|
||||
deviceEmulation = Util.i18n.strings.runtimeDesktopEmulation;
|
||||
}
|
||||
|
||||
const screenEmulation = settings.screenEmulation.disabled ?
|
||||
undefined :
|
||||
|
|
|
@ -58,11 +58,17 @@ describe('SidebarRuntimeSettings', () => {
|
|||
throughputKbps: 1.6 * 1024,
|
||||
rttMs: 150,
|
||||
},
|
||||
screenEmulation: {disabled: true},
|
||||
screenEmulation: {
|
||||
disabled: false,
|
||||
width: 200,
|
||||
height: 200,
|
||||
deviceScaleFactor: 3,
|
||||
mobile: true,
|
||||
},
|
||||
} as any;
|
||||
const root = render(<SidebarRuntimeSettings settings={settings}/>, {wrapper});
|
||||
|
||||
expect(root.getByText('Emulated Moto G4')).toBeTruthy();
|
||||
expect(root.getByText('Emulated Moto G4 - 200x200, DPR 3')).toBeTruthy();
|
||||
expect(root.queryByText('Emulated Moto G4 -')).toBeFalsy();
|
||||
expect(root.getByText('Slow 4G throttling')).toBeTruthy();
|
||||
expect(root.getByText('4x slowdown'));
|
||||
|
@ -83,6 +89,7 @@ describe('SidebarRuntimeSettings', () => {
|
|||
screenEmulation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
mobile: false,
|
||||
deviceScaleFactor: 2,
|
||||
},
|
||||
} as any;
|
||||
|
@ -92,4 +99,18 @@ describe('SidebarRuntimeSettings', () => {
|
|||
expect(root.getByText('Custom throttling')).toBeTruthy();
|
||||
expect(root.getByText('1x slowdown'));
|
||||
});
|
||||
|
||||
it('displays runtime settings when screenEmulation disabled', async () => {
|
||||
const settings = {
|
||||
formFactor: 'mobile',
|
||||
throttlingMethod: 'provided',
|
||||
throttling: {},
|
||||
screenEmulation: {disabled: true},
|
||||
} as any;
|
||||
const root = render(<SidebarRuntimeSettings settings={settings}/>, {wrapper});
|
||||
|
||||
expect(root.getByText('No emulation')).toBeTruthy();
|
||||
expect(root.queryByText('Emulated Moto G4 -')).toBeFalsy();
|
||||
expect(root.getByText('Provided by environment')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -512,10 +512,12 @@ class Util {
|
|||
summary = cpuThrottling = networkThrottling = Util.i18n.strings.runtimeUnknown;
|
||||
}
|
||||
|
||||
const deviceEmulation = {
|
||||
mobile: Util.i18n.strings.runtimeMobileEmulation,
|
||||
desktop: Util.i18n.strings.runtimeDesktopEmulation,
|
||||
}[settings.formFactor] || Util.i18n.strings.runtimeNoEmulation;
|
||||
let deviceEmulation = Util.i18n.strings.runtimeMobileEmulation;
|
||||
if (settings.screenEmulation.disabled) {
|
||||
deviceEmulation = Util.i18n.strings.runtimeNoEmulation;
|
||||
} else if (!settings.screenEmulation.mobile) {
|
||||
deviceEmulation = Util.i18n.strings.runtimeDesktopEmulation;
|
||||
}
|
||||
|
||||
const screenEmulation = settings.screenEmulation.disabled ?
|
||||
undefined :
|
||||
|
|
|
@ -33,12 +33,13 @@ describe('util helpers', () => {
|
|||
});
|
||||
|
||||
it('builds device emulation string', () => {
|
||||
const get = opts => Util.getEmulationDescriptions({
|
||||
...opts,
|
||||
screenEmulation: {disabled: true},
|
||||
}).deviceEmulation;
|
||||
assert.equal(get({formFactor: 'mobile'}), 'Emulated Moto G4');
|
||||
assert.equal(get({formFactor: 'desktop'}), 'Emulated Desktop');
|
||||
const get = settings => Util.getEmulationDescriptions(settings).deviceEmulation;
|
||||
/* eslint-disable max-len */
|
||||
assert.equal(get({formFactor: 'mobile', screenEmulation: {disabled: false, mobile: true}}), 'Emulated Moto G4');
|
||||
assert.equal(get({formFactor: 'mobile', screenEmulation: {disabled: true, mobile: true}}), 'No emulation');
|
||||
assert.equal(get({formFactor: 'desktop', screenEmulation: {disabled: false, mobile: false}}), 'Emulated Desktop');
|
||||
assert.equal(get({formFactor: 'desktop', screenEmulation: {disabled: true, mobile: false}}), 'No emulation');
|
||||
/* eslint-enable max-len */
|
||||
});
|
||||
|
||||
it('builds throttling strings when provided', () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче