Computing the Newton polytope of the discriminant from the fiber polytope. Continuity of plurisubharmonic envelopes in non-Archimedean geometry and test ideals. With an appendix by José Ignacio Burgos Gil and Martín Sombra. 