She wasn't told that the surgery would kill her. Marlene didn't want to scare her. Moreover, neither Joel nor Marlene wanted to actually ask Ellie outright what her decision would be, since they were both terrified that her answer would be the opposite of what they wanted. Ellie's agency is stripped from her in that moment, and it's part of the moral conundrum of the climax. We know, in some part due to her conversations with Joel afterwards, that she wouldn't want Joel to do what he did. But Joel then builds up a lie around his choices to try and keep Ellie from ever going down that path again (dozens of others like her, gave up looking for cure, killing Marlene so she wouldn't look for Ellie).