What a heartbreaking situation for everyone.
All things considered, I wonder if she will follow though on her own, get tested and do whatever else the court needs her to do to regain custody of her child, assuming she is able to get and stay clean.
Try and take it one day at a time. You may be worrying about something that may never happen.