Skip to content

Minimal style + JS code for better manual review of screenshot differences. #8643

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

Merged
merged 1 commit into from
Mar 14, 2025
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: 15 additions & 6 deletions pkg/pub_integration/tool/compare_screenshots.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,32 @@ class _CompareTool {
File(p.join(_reportDir.path, relativeDir, '$basename-after.png'));
await afterFile.writeAsBytes(afterBytes);

_report.writeln('`$path`\n');
_report.writeln('\n<div class="image">');
_report.writeln('\n### `$path`\n\n');
_report.writeln(
'![before](${p.join(relativeDir, '$basename-before.png')})\n');
_report
.writeln('![after](${p.join(relativeDir, '$basename-after.png')})\n');
'- ![before](${p.join(relativeDir, '$basename-before.png')})\n');
_report.writeln(
'- ![after](${p.join(relativeDir, '$basename-after.png')})\n');
_report
.writeln('![diff](${p.join(relativeDir, '$basename-diff.png')})\n');
.writeln('- ![diff](${p.join(relativeDir, '$basename-diff.png')})\n');
_report.writeln('\n</div>');
_report.writeln();
}

await _writeIndexHtml();
}

Future<void> _writeIndexHtml() async {
final script = await File('tool/comparison_web.js').readAsString();
final styles = await File('tool/comparison_web.css').readAsString();
await File(p.join(_reportDir.path, 'index.html')).writeAsString([
'<html><body>',
'<html>',
'<head>',
'<style>\n$styles\n</style>',
'</head>',
'<body>',
markdownToHtml(_report.toString()),
'<script>\n$script\n</script>\n',
'</body></html>',
].join('\n'));
}
Expand Down
13 changes: 13 additions & 0 deletions pkg/pub_integration/tool/comparison_web.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.image ul {
display: flex;
flex-direction: column;
list-style-type: none;
}

.image ul li {
margin: 1px;
}

.image.row ul {
flex-direction: row;
}
7 changes: 7 additions & 0 deletions pkg/pub_integration/tool/comparison_web.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const imageDivs = document.querySelectorAll('div.image');

imageDivs.forEach(function(div) {
div.addEventListener('click', function() {
this.classList.toggle('row');
});
});