The Gaggia three way valve is attached to the side of the group head on many coffee machines, and operates to route the hot water through to the coffee puck when pulling a shot. At all other times, the solenoid valve is de-energised, and routes any remaining pressure above the puck to the drain so that you can safety remove the portafilter after the shot without being sprayed with coffee resulting from the residual pressure.
To check its operation, you should also be able to hear the metal slug inside the solenoid moving as the supply is applied and removed at the start and end of the shot (you may want to disconnect the pump so you can hear the solenoid operating).
If you cannot hear this, then make sure volts are delivered to the solenoid whilst the shot is being drawn. The voltage will be either 24Vac, 110Vac or 230Vac (230Vac for the Gaggia Classic), so you need to be competent in the use of a multimeter in the presence of mains voltages. The voltage should disappear as soon as the shot is complete.
If this is correct, remove the solenoid, and blow into the drain port. Your breath should exhaust through one of the ports (see diagram below).
If it is still not working, then there is most likely some debris in the small internal galleries of the valve, either small pieces of scale, coffee grounds or rubber resulting from the replacement of the portafilter gasket.
The diagram below shows the internal arrangement of the 3-way valve as used on the Gaggia Classic and other models.
If you have a professional machine, the mounting flange may be different, but the operation will be similar.
Here the ports are marked 1 and 2, with port 2 normally closed when the coil is de-energised and the flow being from port 1 to the drain.
The slug inside the valve has a washer on either end, and due to the spring, is normally resting on port 2 completely sealing it. When the supply is connected to the coil this causes the metal slug to move against the spring force, and opens port 2 allowing flow between port 2 and port 1. At the same time, it comes to rest against the third port at the top of the valve (which runs to the drain), sealing that off.
Here is a summary of the test procedures:
1. Are there volts to the solenoid whilst pulling a shot?
2. Can you hear the solenoid slug moving when starting and stopping the shot?
3. If you push an unfolded paper clip into the drain opening, does it get pushed out when the valve is energised?
4. With the solenoid removed, can you blow freely through from the drain to one of the ports?
If the answer to these four questions is yes, then if there is still a fault there must be debris blocking the remaining port (the port from the boiler). This is the smallest port (only about 1.2mm diameter, so is likely to be the first to be obstructed, generally by scale). The remaining two ports are about 3mm in diameter, and so are less prone to blockage; any debris on this route are filtered by the shower screen.