WordPress / theme-review-action

Other
31 stars 10 forks source link

Requirement: Display the correct content according to the front page setting #36

Closed carolinan closed 3 years ago

carolinan commented 3 years ago

In the WordPress admin under reading settings, "Your homepage displays:" can be set to "Your latest posts" or "A static page".

The theme directory has a requirement that if the setting is set to the latest posts, then the latest posts must show. If it is set to a static page, then the page and its page content must show.

In both cases, it is also allowed to show both so the requirement passes if the correct content is displayed anywhere on the page -it doesn't have to be the only content.

This is currently tested manually.

Can this be checked with an "UI check"? (or with theme review action at all).

StevenDufresne commented 3 years ago

This should be possible using the UI check.

carolinan commented 3 years ago

I started on this, but I want to check that I understand the logic correctly.

When the front page setting is set to display the latest posts -which is it is for these tests, then the / page (home) will have the classes "home blog" on the body tag. The page will also include the post ID "post-1" somewhere on the page.

Is that enough to check for? I am not sure if this is the right idea? Because it relies on the theme using the body class and post class correctly, there can be so many ways around this.

When themes update the front page settings (page_on_front) programmatically, this blog class is removed, but it is not the only way that themes change what the page shows, sometimes, it's just a bad query, or a missing post loop.

And we only want to run the check on the home page, not loop through all the pages. And on this part, I got stuck :)

Oh, and, I'd need to double check what classes are output for block themes, it is not guaranteed to be the same.

StevenDufresne commented 3 years ago

That seems to make sense and would be a fair way to test.

Since we also import our own data, we could also check for the presence of our posts using the copy. Scan the DOM for the correct post title maybe. If we wanted to go further, we could also navigate to wp-admin and update the reading setting and test that we see the correct page as well.