When the Jews were in doubt about the issue of the Qiblah, the Noble Qur’an returned to the story of Prophet Ibrahim u and how Allah U tested him. Tests can be through negative things or through good and blessed things. Allah says:
﴾وَنَبلوكُم بِالشَّرِّ وَالخَيرِ فِتنَةً﴿
“and We will test you with good and bad by way of test,” [Surah Al-Anbiya’: 35].
To be elected by Allah U happens after a test, hence, you might be tested by Allah U to purify you and choose you and raise your station.
﴾وَإِذْ ابْتَلَى ﴿ “was tried by his Lord” that is to put him through a test.
His testing is to purify and elect him. Hence, the election occurs through the test and after the trial.
﴾وَإِبراهيمَ الَّذي وَفّىٰ﴿
“and of Ibrahim, who fulfilled [the commandments]” [Surah An-Najm: 37].