A continuous function $u\colon[0,\infty)\times[0,L]\to\mathbb{R}$ that is twice continuously differentiable on $(0,\infty)\times(0,L)$ is a solution to the one-dimensional heat equation with Dirichlet boundary conditions when it has the differential property \begin{align*} \frac{\partial u}{\partial t}&=\frac{\partial^2 u}{\partial x^2} \end{align*} and satisfies the boundary and initial conditions \begin{align*} u(t,0)&=u(t,L)=0, &&\forall t\in[0,\infty),\\ u(0,x)&=f(x), &&\forall x\in[0,L]. \end{align*} Where $f\colon[0,L]\to\mathbb{R}$ is a function giving the initial conditions.
This partial differential equation has the unique solution (calculated by the method of separation of variables) \begin{align*} u(t,x)=\sum_{n=1}^\infty a_n \exp\left(-\left(\frac{n\pi}{L}\right)^2 t\right)\sin\left(\frac{n\pi x}{L}\right) \end{align*} where \begin{align*} a_n=\frac{2}{L}\int_0^Lf(x)\sin\left(\frac{n\pi x}{L}\right)dx. \end{align*}
My question is: does $f$ have to be continuous for this solution to work? In the sources that I have read it is either assumed that $f$ is continuous or nothing about the properties of $f$ is mentioned. Clearly it has to at least be integrable to calculate the coefficients $a_n$, but is this enough or does it actually have to be continuous? What are the minimum conditions that $f$ needs to fulfill?
If you examine the solution you posted and check that it satisfies the PDE, the only property in doubt is that $u(0,x)=f(x)$, which is true whenever $f$‘s Fourier series converges. There are many sufficient conditions that ensure this (but continuity is not enough).
In practice discontinuous boundary conditions are common, and pose no problems as long as you relax the boundary conditions to only require that $u$ matches $f$ almost everywhere on the boundary; in this case $f$ being in $L^2$ is enough.