Most statistical tests for treatment effects used in randomized clinical trials with survival outcomes are based on the proportional hazards assumption, which often fails in practice. Data from early exploratory studies may provide evidence of non-proportional hazards which can guide the choice of alternative tests in the design of practice-changing confirmatory trials. We study a test to detect treatment effects in a late-stage trial which accounts for the deviations from proportional hazards suggested by early-stage data. Conditional on early-stage data, among all tests which control the frequentist Type I error rate at a fixed $\alpha$ level, our testing procedure maximizes the Bayesian prediction of the finite-sample power. Hence, the proposed test provides a useful benchmark for other tests commonly used in presence of non-proportional hazards, for example weighted log-rank tests. We illustrate the approach in a simulations based on data from a published cancer immunotherapy phase III trial.