Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests(devtools): sync e2e #15837

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
Loading