The one rule to follow in order to keep the tests working as you redesign is:
Do Black-Box testing; avoid White-Box testing.
In other words:
Test against the interface, not against the implementation.
This follows naturally from one of the principles listed in the book Design Patterns: Elements of Reusable Object-Oriented Software (Addison-Wesley, 1994) by The Gang of Four (Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides) which says Program against the interface, not against the implementation.
With black-box testing, it is possible to completely rewrite a software component from scratch to make it exhibit the same behavior but with a totally different implementation, and use the existing test to verify that the new version behaves exactly like the old version. It is also possible to have multiple independent teams of developers come up with entirely different approaches to solving the same problem, and write a single test to verify the correctness of all approaches.
Unfortunately, widespread modern testing practices prohibit this.
Specifically, Unit Testing is white-box testing by nature, because in its desire to achieve defect localization it sets out to test each component in strict isolation, which requires mocking its dependencies. The moment you start using mocks, you are engaging in white-box testing, so you are in an ocean of pain.
Other people have identified this problem; Ian Cooper in his "TDD, where did it all go wrong" talk (https://www.infoq.com/presentations/tdd-original/) speaks about it, and in an attempt to avoid sounding so blasphemous as to proclaim that Unit Testing is wrong, he suggests that in the context of Test Driven Development (TDD) the term Unit Testing does not refer to isolating the components under test from each other, but rather isolating the unit tests from each other. I do fully agree that it is the tests that should be kept isolated, but I consider this re-definition of the term to be arbitrary and unwarranted. Unit Testing has already been precisely defined, and according to the existing definition, it is problematic; I do not have a problem at all with sounding blasphemous, so here, I am about to say it. Are you ready? Here it goes:
Unit Testing is Wrong.
There, I said it.
What to use instead of Unit Testing? Use Incremental Integration Testing instead.
Incremental Integration Testing is black-box testing. It achieves defect localization not by eliminating the dependencies, but instead by requiring that the order of execution of the tests must be chosen so that when a component is tested, all of its dependencies have already been tested.
Incremental Integration Testing is described in detail here:
https://blog.michael.gr/2022/10/incremental-integration-testing.html
(Disclosure: I am the author of that post.)