How do we know if we are being tested or punished by Allah when facing calamities? This is a good question.

Why Does ALLAH Punish Disbelievers, • Signs of Hypocrite Munafiq,

However, we cannot know. So I became sick. I got an illness. There is a disease. I lost my money. I lost my job. I lost my investment. How would I know if this is a test from Allah to elevate my status in Jannah or if it is a punishment?

that Allah is punishing me for sins that I have committed, you cannot know; nevertheless, they are interlinked, so if I'm a righteous person and Allah tests me with an illness,

This means that if I am patient and do not complain, Allah will forgive my sins and elevate my status to Jannah, however, if I am a sinful person, Allah will test me with calamities, such as illness, poverty, or loss of my job.

I become humble and patient. I do not complain and I do not object to Allah's ruling, but if, on the contrary, I acknowledge my sins, this would erase my sins and elevate my posture and position in Jannah, insha'Allah.

As a result, if a calamity befalls a kafir, one can tell from the circumstances that it is not to elevate his status in Jannah; he is a disbeliever, and this is a punishment.

If it falls upon an open sinner Muslim, he's sinful; he's openly committing sin; this is a punishment we take for granted. If it falls upon a person who is righteous, and he's praying five times a day, etc., doing everything right, and yet he's being tested with calamity, he's sinful; he's openly committing sin.

This is a test; when does it become a punishment if he starts to complain, he's impatient, and he objects to Allah's rulings and decrees, though before the calamity he was a person of prayer, fasting, charity, and righteousness?

Read: The Story of Joram Van Klaveren • From Christianity to Islam

In this case, it becomes evident that this is not a test, but a punishment.