That's a key concern. Many countries' rules are constantly changing. When you're departing, some countries only have you comply with the rules of the country you're going to, other departure countries have you comply with their rules too. Some countries apply their rules to all arriving passengers even if they're only connecting there, while other don't depending on how long the layover is.
So I wouldn't order test kits before understanding all applicable rules or too far ahead of the departure date in case those rules change.
As an aside, I've (unfortunately?) had to travel plenty since 2020. I've always been able to find affordable and timely in-person tests pretty easily. If anyone is abroad without a test kit and needs to figure out where to get an in-person test, I'd recommend: Googling > calling the US Embassy/Consulate > asking at a pharmacy > asking at a doctor's office > asking at a hospital. You'll likely get your answer without needing to go too far down the chain.
Edit to add: I just remembered that some airports offer quick tests that are valid for travel. So that may be a day-of-travel option depending on timing.