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

always detect if there is an attachment for a decision #23138

Merged

Conversation

eviljeff
Copy link
Member

@eviljeff eviljeff commented Mar 5, 2025

follow-up fix for: mozilla/addons#15412

Description

changes how we detect if there is an attachment for a decision, to correctly include the template snippet about it.

Context

It appears while fixing #15412 I fixed the attachment being available for download in developer hub, but inadvertently stopped the existence of the attachment being exposed in the email.
The more complete fix would be to refactor how send_notifications selects the appropriate activity log but to limit the scope of this pr, which is expected to be cherry-picked, I instead changed how has_attachment was determined.

Testing

Follow the testing steps from #23121

Checklist

  • Add #ISSUENUM at the top of your PR to an existing open issue in the mozilla/addons repository.
  • Successfully verified the change locally.
  • The change is covered by automated tests, or otherwise indicated why doing so is unnecessary/impossible.
  • Add before and after screenshots (Only for changes that impact the UI).
  • Add or update relevant docs reflecting the changes made.

@eviljeff eviljeff requested review from a team and KevinMind and removed request for a team March 5, 2025 11:54
Comment on lines -2889 to -2905
def _check_notify_emails(self, decision, log_entry):
assert len(mail.outbox) == 1
assert mail.outbox[0].to == [decision.addon.authors.first().email]
assert str(log_entry.id) in mail.outbox[0].extra_headers['Message-ID']
assert 'days' not in mail.outbox[0].body
assert 'some review text' in mail.outbox[0].body
assert 'some policy text' not in mail.outbox[0].body
AttachmentLog.objects.create(
activity_log=log_entry,
file=ContentFile('Pseudo File', name='attachment.txt'),
)
decision.send_notifications()
assert 'An attachment was provided.' not in mail.outbox[0].body
assert 'To respond or view the file,' not in mail.outbox[0].body
assert 'An attachment was provided.' in mail.outbox[1].body
assert 'To respond or view the file,' in mail.outbox[1].body

Copy link
Member Author

Choose a reason for hiding this comment

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

btw, this is just refactoring because I realised _check_notify_emails was only used in one test, so it was confusing - I initially thought I could change here to test multiple tests. code has been cut&pasted into test_execute_action_with_action_date_already directly.

@KevinMind
Copy link
Contributor

KevinMind commented Mar 5, 2025

After rejecting multiple versions and proceeding with the action I can confirm the email contains the expected text

image

I can confirm the attachment is downloadable in the "review history" section for the versions

image

Copy link
Contributor

@KevinMind KevinMind left a comment

Choose a reason for hiding this comment

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

Still a bit confusing how this was passing tests before but verified.

@eviljeff eviljeff merged commit e169744 into mozilla:master Mar 5, 2025
41 checks passed
@eviljeff
Copy link
Member Author

eviljeff commented Mar 5, 2025

Still a bit confusing how this was passing tests before but verified.

There wasn't coverage for it - in the previous PR I added tests for the changes in ContentActionDisableAddon, but this fail was coming from further up the call stack, in ContentDecision. Those tests didn't test attachments with held actions.

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