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

test(authenticator): add golden tests for new configs #1831

Merged

Conversation

Jordan-Nelson
Copy link
Member

Issue #, if available: #1827

Description of changes:

  • Add stubs for auth_cognito and amplify
  • Update authenticator tests, add new ones
  • Regenerate golden files

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Jordan-Nelson Jordan-Nelson requested a review from a team as a code owner June 28, 2022 18:20
dnys1
dnys1 previously approved these changes Jun 28, 2022
Copy link
Contributor

@dnys1 dnys1 left a comment

Choose a reason for hiding this comment

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

Missing license header on one file. Looks good, though - thanks!

@@ -44,10 +44,44 @@ class AuthenticatorGoldenComparator extends LocalFileComparator {
}
if (!result.passed) {
safePrint(
'A tolerable difference of ${result.diffPercent * 100}% was found when '
'D1 tolerable difference of ${result.diffPercent * 100}% was found when '
Copy link
Contributor

Choose a reason for hiding this comment

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

What does D1 mean here?

Copy link
Member Author

Choose a reason for hiding this comment

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

That was a cmd + f and replace mistake. Updated.

AuthenticatorStep.resetPassword,
];

testMatrix3(TestConfig.values, steps, Brightness.values, (
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: This runs 120 tests (5 configs, 3 initial steps, 2 brightnesses, 4 themes). Some are a bit repetitive. I think it is fine for now though since this runs in about 90 seconds. At some point I would like to add golden tests for each step (confirm sign up, confirm reset password, etc.). At that point I may only run the theme tests for a couple configs.

export 'package:amplify_auth_cognito/src/types.dart';

/// A stub of [AmplifyAuthCognito] that creates users in memory.
class AmplifyAuthCognitoStub extends AuthPluginInterface
Copy link
Member Author

@Jordan-Nelson Jordan-Nelson Jun 28, 2022

Choose a reason for hiding this comment

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

Note: This stub is from the Authenticator demo on the docs site. Everything other than addPlugin() and fetchAuthSession() could be a no-op for the current test suite since those should be the only methods called to load the authenticator.

This could be used to run integration tests with a stubbed backend, which would allow us to create golden tests for all the steps. I am open to trimming this down to just what is needed for now, but I think it could be useful in the future.

@@ -44,10 +44,44 @@ class AuthenticatorGoldenComparator extends LocalFileComparator {
}
if (!result.passed) {
safePrint(
'A tolerable difference of ${result.diffPercent * 100}% was found when '
'D1 tolerable difference of ${result.diffPercent * 100}% was found when '
Copy link
Member Author

Choose a reason for hiding this comment

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

That was a cmd + f and replace mistake. Updated.

@@ -0,0 +1,202 @@
// Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: I renamed this file because the name didn't make sense anymore. New name + all the changes are making this look like a new file.

@Jordan-Nelson Jordan-Nelson merged commit 765fc93 into aws-amplify:main Jul 7, 2022
@Jordan-Nelson Jordan-Nelson deleted the test/authenticator-golden-tests branch July 7, 2022 23:39
haverchuck pushed a commit that referenced this pull request Jul 13, 2022
* chore: add stubs for auth cognito and amplify

* test: refactor tests, add tests for new configs

* chore: regenerate golden files

* chore: update comment, fix accidential cmd f change

* chore: add license headers

* chore: make internal mocks private
haverchuck pushed a commit that referenced this pull request Jul 14, 2022
* chore: add stubs for auth cognito and amplify

* test: refactor tests, add tests for new configs

* chore: regenerate golden files

* chore: update comment, fix accidential cmd f change

* chore: add license headers

* chore: make internal mocks private
Jordan-Nelson added a commit to Jordan-Nelson/amplify-flutter that referenced this pull request Dec 2, 2022
* chore: add stubs for auth cognito and amplify

* test: refactor tests, add tests for new configs

* chore: regenerate golden files

* chore: update comment, fix accidential cmd f change

* chore: add license headers

* chore: make internal mocks private
Jordan-Nelson added a commit that referenced this pull request Dec 2, 2022
…y tests (#2455)

* test(authenticator): add golden tests for new configs (#1831)

* chore: add stubs for auth cognito and amplify

* test: refactor tests, add tests for new configs

* chore: regenerate golden files

* chore: update comment, fix accidential cmd f change

* chore: add license headers

* chore: make internal mocks private

* chore: update auth, amplify stub

* chore: update golden snapshots

* chore: add tests for different device size, pixelRatio

* chore: re-generate golden snapshots

* chore: remove print statement

* chore: address PR comments
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.

4 participants