If you can remove the sunroof motor from the track assembly then do so and see if the motor will run ok. If it does then chances are that the cables in the track assembly are stuck, the complete track assembly may need to be replaced.
RepairPal Certified shops can diagnose and repair your 1998 Chevrolet Cavalier. They provide transparent pricing with a minimum 12-month or 12,000-mile warranty on repairs and services.