Why does dot product return zero at non-harmonic frequency
Note that when you compute the DFT, you compute the dot product with a sine term and with a cosine term. In your third example, even though the dot product with the sine term is zero, the dot product with the cosine term isn't, so you do get spectral leakage, as you expected. The dot product with the sine term is zero because you have a whole number of periods plus one half period inside the DFT frame, so the periodized version of the signal is even and, consequently, the imaginary part of its DFT (the dot product with the sine term) vanishes.