It is a sticky situation for sure. The situation would be like senior partner at a law firm being offered a position as a judge or some other government appointment.

The ideal plan is to work until maternity leave, give notice, return for a day, and then walk out. What is technically correct, legally correct, and ethically/morally correct can vary and contradict each other.

Luckily she is invaluable in her current role. I would personally say that letting her go in this theoretical situation would be cutting of their nose to spite their face. Not to mention the bad optics of terminating a pregnant employee with strong relations throughput the company and is constantly ranked in the top 5% of employees corporate wide.