Wales qualified for the Rugby World Cup quarter-finals as wing Josh Adams scored a hat-trick in a 29-17 victory over Fiji.