The function of X/Y capacitors is to filter high frequency noise on the mains and prevent it from reaching sensitive equipment. They also filter general mains noise and, since spikes are essentially wide band noise, they help with mains spikes.
The capacitors come in two basic types. An X capacitor is designed for line to line (live to neutral) and deals with differential noise. A Y capacitor is designed for line to ground (live, or neutral, to ground) and deals with common mode noise.
The capacitors are normally metalised plastic film and are designed to have specific failure characteristics. An X capacitor is designed to fail short circuit thus causing a protection device, such a fuse, to fail. A Y capacitor is designed to fail open circuit.
Depending on application the capacitors come in several grades, X1/X2/X3 and Y1/Y2/Y3/Y4.
Basic EMC testing of mains power supplies involve single and repetitive pulses, of both polarities, at peak voltages of 500V, 1kV and 2kV. In my experience a well designed power supply should have no problem in passing these tests.
Julie