Have you also tried a new ignition coil , spark plug and plug cap too.
if the spark is there that means the cdi is sending the signal , if not , the cdi wouldn’t be sensing the engine spinning or feed from the magneto to trigger it to fire the coils.