Yennefer was trying to capture the djinn and believed Dandilion to currently be its "master" and so made him express his wish upon going through the portal.
“The last wish!” repeated the priest. “She made the bard express the last, the third wish. And Yennefer set a magical trap and, no doubt, captured the genie before he managed to escape into his own dimension! Mr. Neville, we must—”
The Last Wish, "The Last Wish" VII
“Get out of here!” she yelled, grimacing ominously. “It's getting dangerous! The whole thing's getting out of control; do you understand? I can't master him. I don't get it, but the scoundrel isn't weakening at all! I caught him once he'd fulfilled the troubadour's third wish and I should have him in the sphere by now. But he's not getting any weaker! Dammit, it looks as if he's getting stronger! But I’m still going to get the better of him. I’ll break—”
The Last Wish, "The Last Wish" VIII
Both of these quotes imply, to me, that Yennefer set the trap to activate when the djinn appeared after fulfilling Dandilion's last wish. However, we know that the djinn wasn't currently fulfilling Dandilion's wishes but Gertalt's.
“He's the one who held the seal which imprisoned the djinn. The djinn's fulfilling his wishes. That's why the witch can't master it. But the witcher mustn't tell her, even if he's caught on to it by now. He shouldn't tell her.”
The Last Wish, "The Last Wish" XI
So why did the djinn appear if the wishes weren't actually fulfilled/completed?