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

Fix #22: Add Gravatar utility functions #29

Merged
merged 10 commits into from
Jan 23, 2024

Conversation

maxme
Copy link
Contributor

@maxme maxme commented Jan 19, 2024

Fix #22 and fix #11 (by adding some tests)

@maxme maxme force-pushed the maxime/22-gravatar-utility-functions branch from b372467 to b95b76e Compare January 19, 2024 13:03
ktlint_function_naming_ignore_when_annotated_with = Composable
max_line_length=120
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

Comment on lines +9 to +21
# IntelliJ/Android Studio exceptions
!/.idea/codeStyles/
!/.idea/fileTemplates/
!/.idea/inspectionProfiles/
!/.idea/scopes/
!/.idea/codeStyleSettings.xml
!/.idea/encodings.xml
!/.idea/copyright/
# Enforce plugins
!/.idea/externalDependencies.xml
# Checkstyle configuration
!/.idea/checkstyle-idea.xml

Copy link
Contributor

Choose a reason for hiding this comment

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

❓Why do we not want to track those files? Some of them allow us to share some code styles for the Android Studio autoformatting. The code will be validated by Ktlint, but I think some of them could be useful. I usually use gitignore.io to see what they suggest. In our case this

Copy link
Contributor Author

@maxme maxme Jan 19, 2024

Choose a reason for hiding this comment

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

Note that we want to track those above ^, but I don't I want to track everything for .idea/ (eg. .idea/deploymentTargetDropDown.xml isn't useful IMO because it changes depending on the tests you run in AS)

I took it wpandroid, I haven't checked everything, but I'm fine using another list.

Copy link
Contributor

Choose a reason for hiding this comment

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

🤦🏼‍♂️ My bad, I didn't notice the !... Sorry.

import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class GravatarUtilsInstrumentedTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ We need to add these tests as InstrumentedTest because we internally use android.net.Uri but all of them look like a unit test to me. Should we try to add Robolectric and/or mock the Uri.Builder? We don't have DI yet, which complicates things; maybe we should dedicate some time to it?

We don't need to take care of this right now. We can merge and keep working on improving our testing possibilities.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I was thinking of add Robolectric, but it seemed like an overkill for this. We'll likely have connected tests anyway so why not having them here to test the full path.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we'll need several connected tests, at least for the non-UI part.
My main concern is about the execution time. Now, it is insignificant, but if we implement the majority of the tests as instrumented tests, the execution time will increase rapidly.

But as I mentioned, we can iterate. 🙂

Copy link
Contributor Author

@maxme maxme Jan 19, 2024

Choose a reason for hiding this comment

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

Good point about speed, I removed connected tests and I setup up Robolectric tests in 3d20326

return emailAddressToGravatarUri(email, defaultAvatarImage, size).toString()
}

fun emailAddressToGravatarUri(
Copy link
Contributor

Choose a reason for hiding this comment

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

❓Could it make sense to trim the email here, too, and verify it's not empty? Verify that it's a well-formatted e-mail could be going too far?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I doubt we want to go too far here, we can check for empty string, but we shouldn't check if the e-mail address is valid.

@maxme
Copy link
Contributor Author

maxme commented Jan 19, 2024

Note this is still a draft PR (but we can't use them in free private repo), I opened it to test github actions.

@maxme maxme force-pushed the maxime/22-gravatar-utility-functions branch 2 times, most recently from 432fed4 to 76c8f83 Compare January 19, 2024 14:24
Copy link
Contributor

@hamorillo hamorillo left a comment

Choose a reason for hiding this comment

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

Note this is still a draft PR (but we can't use them in free private repo)

TIL - Maybe we can add the title DRAFT - PR Title or create a draft label. Wdyt?

Sorry if I was too fast with my comment, I thought the PR was ready and you were waiting the review. Let me know when is ready.

Comment on lines +9 to +21
# IntelliJ/Android Studio exceptions
!/.idea/codeStyles/
!/.idea/fileTemplates/
!/.idea/inspectionProfiles/
!/.idea/scopes/
!/.idea/codeStyleSettings.xml
!/.idea/encodings.xml
!/.idea/copyright/
# Enforce plugins
!/.idea/externalDependencies.xml
# Checkstyle configuration
!/.idea/checkstyle-idea.xml

Copy link
Contributor

Choose a reason for hiding this comment

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

🤦🏼‍♂️ My bad, I didn't notice the !... Sorry.

import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class GravatarUtilsInstrumentedTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we'll need several connected tests, at least for the non-UI part.
My main concern is about the execution time. Now, it is insignificant, but if we implement the majority of the tests as instrumented tests, the execution time will increase rapidly.

But as I mentioned, we can iterate. 🙂

@maxme maxme force-pushed the maxime/22-gravatar-utility-functions branch from 76c8f83 to 653364b Compare January 19, 2024 14:43
@maxme maxme force-pushed the maxime/22-gravatar-utility-functions branch from 653364b to 9953113 Compare January 19, 2024 14:56
@maxme
Copy link
Contributor Author

maxme commented Jan 19, 2024

Sorry if I was too fast with my comment, I thought the PR was ready and you were waiting the review. Let me know when is ready.

No worries, that's a good pre-review :).

Adding Draft: .... to the title is a good idea. I'll ping you when this one is ready for another pass.

@maxme maxme changed the title Fix #22: Add Gravatar utility functions Draft: Fix #22: Add Gravatar utility functions Jan 19, 2024
@maxme maxme changed the title Draft: Fix #22: Add Gravatar utility functions Fix #22: Add Gravatar utility functions Jan 23, 2024
@maxme
Copy link
Contributor Author

maxme commented Jan 23, 2024

I wanted to remove the GravatarUtils.java file from WordPress-Utils before opening this PR, but dependency management is getting more complicated that I thought.

Note: if we want to add connected tests back to CI, we can revert this commit b2de8a5

@hamorillo can you do another pass on this one?

Copy link
Contributor

@hamorillo hamorillo left a comment

Choose a reason for hiding this comment

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

🚀 LGTM!

@maxme maxme merged commit b7c3177 into trunk Jan 23, 2024
1 check failed
@maxme maxme deleted the maxime/22-gravatar-utility-functions branch January 23, 2024 12:24
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.

Add utility functions or extensions to generate gravatar URLs or hash from an email address Setup unit tests
2 participants