Sam Davies converted a last-minute try as Wales shocked defending champions South Africa to reach the IRB Junior World Championship final.