Assume $\int_{\mathbb{R}^N}|\nabla |u||^2 = \int_{\mathbb{R}^N}|\nabla u |^2 $.
Is is true that $u=e^{iC} |u|$, where $C$ is a constant.
Assume $\int_{\mathbb{R}^N}|\nabla |u||^2 = \int_{\mathbb{R}^N}|\nabla u |^2 $.
Is is true that $u=e^{iC} |u|$, where $C$ is a constant.
If
$$u = |u|e^{i\theta}$$
then
$$\nabla u = e^{i\theta}\nabla |u| + ie^{i\theta}|u|\nabla\theta$$
and
$$|\nabla u|^2 = |\nabla|u||^2 + |u|^2|\nabla\theta|^2$$
so the condition, $\int_{\mathbb{R}^n}|\nabla u|^2 = \int_{\mathbb{R}^n}|\nabla |u||^2$, given in the question implies $\int_{\mathbb{R}^n}|u|^2|\nabla\theta|^2 =0$. Since the integrand is positive it follows that $|u||\nabla\theta| = 0$ a.e. If $|u| > 0$ it follows that $\theta = $ constant a.e.
Note that we cannot rule out the constant being different in different regions of $\mathbb{R}^n$ (ref the other answer) without more conditions on $u$.