Problem/Motivation

In #3338666: Add functional test that proves there is reasonable UX whenever a stage event subscriber has an exception, we added a new test method to UpdateErrorTest, called testExceptionFromEventSubscriber(). This is a very thorough test method that walks through the entire attended update process, asserting that exceptions thrown by subscribers to all of the stage events are caught, logged, and redirected properly.

The existing methods of UpdateErrorTest have some amount of overlap with this new test, and that means the test is longer and possibly more confusing than it needs to be, as @tedbow detailed in #3338666-47: Add functional test that proves there is reasonable UX whenever a stage event subscriber has an exception.

Proposed resolution

Let's tighten up UpdateErrorTest as a whole, and ensure that there's no duplicate coverage. That will means refactoring or removing some methods entirely, and adding more assertions to testExceptionFromEventSubscriber() -- for example, to assert that the expected buttons are present (or not present), and that we're on the pages we expect to be at certain points.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

phenaproxima created an issue. See original summary.

phenaproxima’s picture

phenaproxima’s picture

Title: [PLACEHOLDER] Consolidate UpdateErrorTest » Consolidate UpdateErrorTest
kunal.sachdev’s picture

Assigned: Unassigned » kunal.sachdev
Issue tags: +sprint

phenaproxima’s picture

After discussion with @kunal.sachdev, I'm gonna take this on to try and clarify it. It's very complicated, touchy stuff.

phenaproxima’s picture

Assigned: phenaproxima » wim leers
Status: Active » Needs review

I think this makes sense. Assigning to Wim for review.

I also think Kunal's instincts are right on the money; the PostRequireEvent check is indeed redundant, and was never reachable because of the early return. That's okay; because it's redundant, I removed it.

wim leers’s picture

Assigned: wim leers » phenaproxima
Status: Needs review » Needs work

🏓

phenaproxima’s picture

Assigned: phenaproxima » wim leers
Status: Needs work » Needs review
wim leers’s picture

Assigned: wim leers » phenaproxima

This was tricky to review, and in doing so, I think I found a now misnamed test method, one piece of now superfluous test logic and one missing assertion.

Assigning to @phenaproxima to confirm.

phenaproxima’s picture

Assigned: phenaproxima » wim leers

Back to you, Wim.

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs review » Reviewed & tested by the community
Issue tags: +maintainability

This looks far better now, and with excellent clarifications from @phenaproxima that really get to the heart of the problem: what UX the user is forced to go through depending on:

  1. what happens (validation error vs exception/failure)
  2. and when that happens (during which part of the stage life cycle)

👍

🚢

wim leers’s picture

Oh, and per https://git.drupalcode.org/project/automatic_updates/-/merge_requests/84..., @phenaproxima, you are saying that the current test coverage proves that #3346644: If an error occurs during an attended process, delete the stage on behalf of the user is unnecessary because it already works that way, right?

phenaproxima’s picture

That issue is still necessary, because currently the update process does not delete the stage if any event has a failure. It does it for some, but not others. The test coverage here proves that.

PostCreateEvent errors will not destroy the stage; the other first-phase events will. I don't think a failure in any of the second-phase events will destroy it. That issue exists to decide if and how to make the behavior consistent.

phenaproxima’s picture

Status: Reviewed & tested by the community » Fixed
wim leers’s picture

Then I'm confused why we removed the @todo 😇 But no big deal — we still have the issue. 👍

phenaproxima’s picture

We didn't.

The todo is still there, just a bit higher. (It was already there in two places.) We removed the irrelevant reference to it, but kept the relevant one.

tedbow’s picture

Issue tags: +core-post-mvp
wim leers’s picture

#18 Oh, I must've missed that then!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.