Rabada struck an unbeaten 31 as South Africa squeaked through to a dramatic first-test victory at Centurion and ensured themselves a place in the World Test Championship final at Lord’s next June.