Skip to content

[SuperEditor] Migrate golden tests (Resolves #2654) #2702

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

angelosilvestre
Copy link
Collaborator

No description provided.

Copy link
Contributor

@matthew-carroll matthew-carroll left a comment

Choose a reason for hiding this comment

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

I read through the new golden file and left some questions/thoughts about the current flutter_test_goldens API.

Also, any thoughts on your end based on your direct usage?

testGoldenSceneOnMac('shows caret at right side of an image', (tester) async {
await Gallery(
tester,
sceneName: 'goldens/super-editor-image-caret-downstream-mac',
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we wanna do something different here. The term sceneName doesn't imply a file path, but it is. There are three things related to this: the directory path, the file name, and a human readable description of the scene. This is a note for us to figure out those properties.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe we should default to place the file in a goldens directory. Since this the default in the golden_toolkit people are already used to it.

)
.itemFromPumper(
id: "1",
description: 'SuperEditor',
Copy link
Contributor

Choose a reason for hiding this comment

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

These descriptions are meant to be a short statement about what's captured in the golden. I'm guessing that "SuperEditor" isn't what this one should be.

await tester.pump();
},
)
.renderOrCompareGolden();
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we should have a single shot API, too. I don't know if that's worth it or not, but obviously in this test we're not utilizing the gallery part of a Gallery.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I think it makes sense for single image tests.

await tester.pump();

await screenMatchesGolden(tester, 'super-editor-image-caret-downstream-ios');
testGoldenSceneOnIOS('shows caret at right side of an image', (tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we should try to rework the platform structure so that the platform is configured per golden image?

As I look at this I'm wondering, wouldn't it feel more appropriate to see the various platform versions of the caret all in one scene? It looks like most/all of the tests in this file could be a single scene image...

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 would be nice. We'll need to see how practical would that be. I guess this would only work when using itemFromPumper, right?

});

group('phone rotation updates caret position', () {
const screenSizePortrait = Size(400.0, 800.0);
const screenSizeLandscape = Size(800.0, 400);

testGoldensOniOS('from portrait to landscape', (tester) async {
testGoldenSceneOnIOS('from portrait to landscape', (tester) async {
tester.view
..devicePixelRatio = 1.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you remember why we're making these changes to the test view here? The golden test runners set the pixel ratio to 1 for all goldens to reduce anti-aliasing.

})
.takePhoto(find.byType(SuperEditor), "landscape")
.renderOrCompareGolden(
goldenName: "super-editor-caret-rotation-portrait-landscape-ios",
Copy link
Contributor

Choose a reason for hiding this comment

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

I changed Gallery to include these configurations in the constructor. Should we do the same for FilmStrip?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I think it makes more sense to have this in the constructor.

tester.view.physicalSize = screenSizeLandscape;
await tester.pumpAndSettle();
})
.takePhoto(find.byType(SuperEditor), "landscape")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make the Finder optional and default to looking for a GoldenImageBounds to reduce the verbosity?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it would be helpful.

@angelosilvestre
Copy link
Collaborator Author

Also, any thoughts on your end based on your direct usage?

The only downside for now that we have to add this to the tests:

return scaffold(
  _widgetTester,
  GoldenImageBounds(
    child: decorator != null //
        ? decorator.call(_widgetTester, superEditor)
        : superEditor,
  ),
);

But I don't have a better alternative at the moment.

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

Successfully merging this pull request may close these issues.

2 participants