A book (or play or film) should simply have the right ending. That could been tragic or happy. It would be absurd (and morally obtuse) for The Godfather Part II to end happily, for instance.
Whether one enjoys tragedy or not I think speaks volumes about personality, temperament, and so forth. Personally, I love a good tragic story, well-told (as Carey Mulligan’s Sally Sparrow said in classic Doctor Who episode “Blink”: “Sad is happy for deep people”), but to my original point, a story should have the right ending. It would be just as ridiculous to end Mary Poppins on an unhappy note.
Here are a couple of articles of mine that might interest you. Firstly, on the subject of writing tragedy in an effective way. Secondly, a list of my favourite romantic dramas in film, most of which are tragic. :)
Why the Best Tragedies Are Funny | ILLUMINATION (medium.com)
My Ten Favourite Romantic Dramas | Fanfare
As for my own novels (mostly horror-thriller mysteries), some are tragic, some are not, and some are a bit of both. It all depends on the story being told. :)