Every Single Agency has a different protocol.
I mean every one.
It can be based on department policy, civil service rules, union contracts, politics, who you are, etc…
But it’s impossible to give even a generic blanket answer to this.
I was a Sheriffs Deputy for 25 years. I had taken the patrol Sergeants exam and did well. Ended up getting “assigned” to the rank of Detective. Never took the dick test. The last Sheriff promoted whomever he wanted, ignoring civil service rules, department policy, etc… And he got away with it.
After I retired I started a second career with another agency. Here there is no exam for any rank. When there is an opening for something a department wide announcement is put out (we do not promote from the outside or do “lateral transfers”). Those interested submit a “matter of” memo explaining their qualifications. The Chief and the Assistant Chief hand select candidates from those who apply. They are given interviews with the Chief, AC, and 3 Captains. The assistant Chief and the Captains write up their opinions, but in the end it is the Chief and only the Chief who makes the decision.
Politics? Favoritism? You bet. But that’s how it is on my department.
there could be a zillion answers to the OP.