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(full-page-screenshot): add node verification and debug tool #15324

Merged
merged 7 commits into from
Mar 8, 2024

Conversation

connorjclark
Copy link
Collaborator

  • Adds tests for verification that nodes saved in the FPS artifact line up with the saved screenshot, by using solid color elements and asserting on the color of the pixels.
  • Also adds a debug tool core/scripts/full-page-screenshot-debug.js to markup a FPS screenshot with its nodes. Some examples:

image

image

@connorjclark connorjclark requested a review from a team as a code owner August 1, 2023 23:38
@connorjclark connorjclark requested review from adamraine and removed request for a team August 1, 2023 23:38
@connorjclark connorjclark changed the title test(full-page-screenshot): add node verification tests and debug tool tests(full-page-screenshot): add node verification tests and debug tool Aug 1, 2023
@connorjclark connorjclark changed the title tests(full-page-screenshot): add node verification tests and debug tool tests(full-page-screenshot): add node verification and debug tool Aug 1, 2023
core/gather/gatherers/full-page-screenshot.js Outdated Show resolved Hide resolved
import * as puppeteer from 'puppeteer-core';
import {getChromePath} from 'chrome-launcher';

import * as LH from '../../../../types/lh.js';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary for a test file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was.
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah this test is excluded in the tsconfig.json, so the normal LH global isn't available. I guess this is fine for now.

@@ -202,4 +208,338 @@ describe('FullPageScreenshot gatherer', () => {
}
);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are good, but IMO should completely replace the old test cases. I understand not doing that to make the diff cleaner in this PR tho.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But they test different things, why would we remove the existing ones?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing ones are only as good as our ability to simulate how the browser handles DPR, page scale, and CDP emulation together. IMO we are never going to get that right so we should just rely on these new e2e tests (and smoke tests) to get this right.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump, could be a follow-up but I still think the old test cases should be converted to smoke tests or this kind of test

const row = [];
debugData.push(row);

for (let x = node.left; x <= right; x++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a lot like a re-implementation of existing pixel matchers. Could we leverage something like expect-mocha-image-snapshot to do the image diffs for us? We use something similar in LHCI and I found it very helpful to review image diffs in Github that way.

Copy link
Collaborator Author

@connorjclark connorjclark Mar 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm doing outline detection here, not just a image snapshot. I think this must be a bespoke implementation.

core/test/gather/gatherers/full-page-screenshot-test.js Outdated Show resolved Hide resolved
@@ -202,4 +208,338 @@ describe('FullPageScreenshot gatherer', () => {
}
);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump, could be a follow-up but I still think the old test cases should be converted to smoke tests or this kind of test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants