I think you are missing one thing: why do you allow managers to say how to develop software when you are hired to be an expert on that matter?
I know, I know, it is convenient to not to take responsibility and just complain, but that would be so frustrating for me that I couldn't take it. And, yes, in my experience I saw many times where people who are not experts say how something should be done, for example they say "refactor is not needed" or "tests are too expensive". In that case I ask them one simple question: "how many contributions to the codebase you made last month?" The answer is usually silence. If they still oppose I just quit the job and watch the project fail from my colleagues' reports.
Simple as that.