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: Handle emails more realistically in example data #1087

Merged
merged 4 commits into from
Dec 9, 2024

Conversation

gnprice
Copy link
Member

@gnprice gnprice commented Nov 26, 2024

Prompted by chat thread:
https://chat.zulip.org/#narrow/channel/516-mobile-dev-help/topic/ComposeAutocomplete.20test.20emailAddressVisbility.20help/near/1988541
(/cc @fombalang)

Commit messages

api test: Fix a test to use Account.copyWith when it means that

The "auth headers sent by default" test below assumes that the
request is made with the email and API key of eg.selfAccount.
It happens to be true that eg.account(user: eg.selfUser, …)
will get that email, but that's a bit of an accident about
how eg.account works and what data is on eg.selfUser.

Instead of eg.account, use eg.selfAccount.copyWith, to make
the intention more explicit.


test: In eg.account use deliveryEmail or generate one, not user.email

This way we avoid using a source that in real data would be guaranteed
to be a fake email address: namely user.email for a user where
user.deliveryEmail is null.


test: Cut specific emails in eg.selfUser, eg.otherUser, and friends

Most of our tests don't and shouldn't care what the specific email
address of a given user object is.

I think these were originally here because eg.user didn't generate
fresh emails, so the caller needed to invent them in order to keep
them distinct. But since d1a2538 it does, and the caller needn't.


test: Make eg.user more realistic about email and delivery email

This better reflects the fact that a User object will often have
null deliveryEmail, and that when that's the case it will have
a server-generated fake email address in email.

@gnprice gnprice added the maintainer review PR ready for review by Zulip maintainers label Nov 26, 2024
@chrisbobbe chrisbobbe self-assigned this Dec 9, 2024
@chrisbobbe chrisbobbe self-requested a review December 9, 2024 20:46
@chrisbobbe
Copy link
Collaborator

Thanks! Sorry for the delayed review. LGTM, please merge at will.

The "auth headers sent by default" test below assumes that the
request is made with the email and API key of `eg.selfAccount`.
It happens to be true that `eg.account(user: eg.selfUser, …)`
will get that email, but that's a bit of an accident about
how eg.account works and what data is on eg.selfUser.

Instead of `eg.account`, use `eg.selfAccount.copyWith`, to make
the intention more explicit.
This way we avoid using a source that in real data would be guaranteed
to be a fake email address: namely `user.email` for a user where
`user.deliveryEmail` is null.
Most of our tests don't and shouldn't care what the specific email
address of a given user object is.

I think these were originally here because `eg.user` didn't generate
fresh emails, so the caller needed to invent them in order to keep
them distinct.  But since d1a2538 it does, and the caller needn't.
This better reflects the fact that a User object will often have
null `deliveryEmail`, and that when that's the case it will have
a server-generated fake email address in `email`.
@gnprice gnprice merged commit be4196e into zulip:main Dec 9, 2024
1 check passed
@gnprice
Copy link
Member Author

gnprice commented Dec 9, 2024

Thanks for the review! Merged.

@gnprice gnprice deleted the pr-test-email branch December 9, 2024 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintainer review PR ready for review by Zulip maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants