Unplugged, the HV capacitor holds 4K-6k volts and has killed many people. Don't attempt to discharge the capacitor or do any repairs if your not certified.
I always replace the diode with the magnitron. Just like I would a belt and pulley on a dryer.
Sparks can be caused by several issues; a bad wave guide, grease build up and more.
The first test I do on every microwave is how many amps it is pulling.
10-14 amps -all components are good.
3-9 amps-transformer is good-problem is in HV circuit
Less than 3 amps problem is in LV circuit
Always test with a glass of water. Finish repairs with a survey test