My questions is: when someone endures a hard experience, how to know if it's a test from Allah or if it's just shaytan trying to make your life harder or make you leave Islam.
You got it confused.
Allah is responsible for testing YOU. But Shaytan uses this to his advantage to confuse and mislead you out of the fold of Islam. Hence, why you'd get thoughts like, "does God hate me? Why is my life falling apart? Why is this happening to me‽"
This is why it's called a test. Sure there's hardship, but it's not only that. It challenges your faith in Allah and in Islam.