In my experience, querying the DB to assert content is correct in the front-end is rarely done.
The main idea behind the E2E automation tests is to ensure the functionality of the web elements are working and present. Things like:
- Links are clickable and navigate to the correct page
- Forms can be filled out
- User sign up, user login, user modification (password reset), user delete, etc
- Some content is present like logo is present.
You typically want to stay away from content testing in UI automation testing since content is always changing.
Ensuring that the database is returning the correct data is usually done via API automation tests or through integration testing. If you can create test automation for the API, you are proving the data is correct and that the database is working correctly without having to involve the UI. Then, when you do UI testing, you know the data is correct and just need to verify UI usability and functionality.
My recommendation would be to review the Test Automation Pyramid. Martin Fowler has a good explanation. This concept allows you to separate out testing areas into unit tests, integration tests, and UI/E2E tests with more testing done at the bottom and fewer tests at the top.