If Y has a visa for your nationality then there is no problem if you resign and Z gives you NOC. Otherwise you will have to start hunting for a new job