Skip to content

Commit

Permalink
tests(devtools): sync e2e (#15837)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine committed Feb 28, 2024
1 parent fbf438a commit baedd46
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
21 changes: 16 additions & 5 deletions third-party/devtools-tests/e2e/lighthouse/navigation_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
// This test will fail (by default) in headful mode, as the target page never gets painted.
// To resolve this when debugging, just make sure the target page is visible during the lighthouse run.

describe('Navigation', async function() {
describe('Navigation', function() {
// The tests in this suite are particularly slow
if (this.timeout() !== 0) {
this.timeout(60_000);
Expand Down Expand Up @@ -108,6 +108,12 @@ describe('Navigation', async function() {
assert.include(lhr.configSettings.emulatedUserAgent, 'Mobile');
assert.include(lhr.environment.networkUserAgent, 'Mobile');

const trace = artifacts.Trace;
assert.notOk(
trace.traceEvents.some((e: Record<string, unknown>) => e.cat === 'disabled-by-default-v8.cpu_profiler'),
'Trace contained v8 profiler events',
);

assert.deepStrictEqual(artifacts.ViewportDimensions, {
innerHeight: 823,
innerWidth: 412,
Expand Down Expand Up @@ -160,17 +166,15 @@ describe('Navigation', async function() {
const waitForJson = await interceptNextFileSave();

// For some reason the CDP click command doesn't work here even if the tools menu is open.
await reportEl.$eval(
'a[data-action="save-json"]:not(.hidden)', saveJsonEl => (saveJsonEl as HTMLElement).click());
await reportEl.$eval('a[data-action="save-json"]:not(.hidden)', saveJsonEl => (saveJsonEl as HTMLElement).click());

const jsonContent = await waitForJson();
assert.strictEqual(jsonContent, JSON.stringify(lhr, null, 2));

const waitForHtml = await interceptNextFileSave();

// For some reason the CDP click command doesn't work here even if the tools menu is open.
await reportEl.$eval(
'a[data-action="save-html"]:not(.hidden)', saveHtmlEl => (saveHtmlEl as HTMLElement).click());
await reportEl.$eval('a[data-action="save-html"]:not(.hidden)', saveHtmlEl => (saveHtmlEl as HTMLElement).click());

const htmlContent = await waitForHtml();
const iframeHandle = await renderHtmlInIframe(htmlContent);
Expand Down Expand Up @@ -222,6 +226,7 @@ describe('Navigation', async function() {
await navigateToLighthouseTab('lighthouse/hello.html');
await registerServiceWorker();

await setToolbarCheckboxWithText(true, 'Enable JS sampling'); // TODO: Use translated string once it's added
await setToolbarCheckboxWithText(false, 'Borrar almacenamiento');
await selectCategories(['performance', 'best-practices']);
await selectDevice('desktop');
Expand All @@ -230,6 +235,12 @@ describe('Navigation', async function() {

const {reportEl, lhr, artifacts} = await waitForResult();

const trace = artifacts.Trace;
assert.ok(
trace.traceEvents.some((e: Record<string, unknown>) => e.cat === 'disabled-by-default-v8.cpu_profiler'),
'Trace did not contain any v8 profiler events',
);

const {innerWidth, innerHeight, devicePixelRatio} = artifacts.ViewportDimensions;
// TODO: Figure out why outerHeight can be different depending on OS
assert.strictEqual(innerHeight, 720);
Expand Down
2 changes: 1 addition & 1 deletion third-party/devtools-tests/e2e/lighthouse/snapshot_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
// This test will fail (by default) in headful mode, as the target page never gets painted.
// To resolve this when debugging, just make sure the target page is visible during the lighthouse run.

describe('Snapshot', async function() {
describe('Snapshot', function() {
// The tests in this suite are particularly slow
if (this.timeout() !== 0) {
this.timeout(60_000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
waitForStorageUsage,
} from '../helpers/lighthouse-helpers.js';

describe('The Lighthouse start view', async () => {
describe('The Lighthouse start view', () => {
it('shows a button to generate a new report', async () => {
await navigateToLighthouseTab('empty.html');

Expand Down
2 changes: 1 addition & 1 deletion third-party/devtools-tests/e2e/lighthouse/timespan_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
// This test will fail (by default) in headful mode, as the target page never gets painted.
// To resolve this when debugging, just make sure the target page is visible during the lighthouse run.

describe('Timespan', async function() {
describe('Timespan', function() {
// The tests in this suite are particularly slow
if (this.timeout() !== 0) {
this.timeout(60_000);
Expand Down

0 comments on commit baedd46

Please sign in to comment.