Skip to content

Testing improvements #1513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 89 commits into from
Jul 23, 2025
Merged

Testing improvements #1513

merged 89 commits into from
Jul 23, 2025

Conversation

Oaphi
Copy link
Member

@Oaphi Oaphi commented Jan 12, 2025

followup for #1509

Also introduces several GitHub actions that should take us off CircleCI:

  • Rubocop (see rubocop.yml);
  • Rails tests (see test.yml);
  • CodeCov coverage uploads as part of Rails tests;
  • screenshot upload as part of Rails system tests;
  • dev server deployment on success;

And fixes a vulnerability related to search:

  • categories with trust level higher than the requesting user no longer show up in search;

@Oaphi Oaphi added the area: testing Changes to testing infrastructure label Jan 12, 2025
@Oaphi Oaphi self-assigned this Jan 12, 2025
@Oaphi Oaphi force-pushed the 0valt/1509/search_tests branch from b8cc3fb to 71dc1af Compare January 12, 2025 18:57
@Oaphi Oaphi linked an issue Jan 13, 2025 that may be closed by this pull request
2 tasks
Copy link

codecov bot commented Mar 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.37%. Comparing base (cc149a5) to head (527c09b).
Report is 90 commits behind head on develop.

Additional details and impacted files
Components Coverage Δ
controllers 68.61% <100.00%> (-0.09%) ⬇️
helpers 78.33% <100.00%> (+2.36%) ⬆️
jobs 48.57% <ø> (ø)
models 85.96% <100.00%> (+0.07%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Oaphi Oaphi force-pushed the 0valt/1509/search_tests branch from 78367d0 to be1887c Compare July 11, 2025 20:38
@Oaphi Oaphi force-pushed the 0valt/1509/search_tests branch from f9d5dae to 84638af Compare July 22, 2025 21:10
# Safely gets the user's trust level even if they don't have a community user
# @return [Integer] user's trust level
def trust_level
community_user&.trust_level || 0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to restore the trust_level method on user to avoid having to explicitly check that the community user exists

@Oaphi Oaphi marked this pull request as ready for review July 22, 2025 21:39
@Oaphi Oaphi requested review from ArtOfCode-, cellio, trichoplax and a team July 22, 2025 21:39
@Oaphi Oaphi force-pushed the 0valt/1509/search_tests branch from c9b8584 to 527c09b Compare July 22, 2025 22:15
@Oaphi
Copy link
Member Author

Oaphi commented Jul 22, 2025

Just added a status badge to display in the README, no meaningful changes

Copy link
Member

@cellio cellio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'm not qualified to evaluate the workflow part but I did read through all the tests.

# @param user [User] user to check
# @return [ActiveRecord::Relation<Post>]
def self.accessible_to(user)
(user&.at_least_moderator? ? Post : Post.undeleted).qa_only.list_includes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: I assume qa_only is what we're using now. I don't know if that plays well with new post types that can be defined through the UI. Later we should come back and review that function and where it's used and make sure it still makes sense.

assert_redirected_to_sign_in
end

private
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refactoring is so much easier to read! (And presumably maintain.) Thank you.

@Oaphi
Copy link
Member Author

Oaphi commented Jul 23, 2025

LGTM. I'm not qualified to evaluate the workflow part but I did read through all the tests.

If you have time to spare, please do check whether everything works as expected in regards to the vulnerability fix (see the PR's description for details), that's the most important part (provided you haven't already, of course)

@cellio
Copy link
Member

cellio commented Jul 23, 2025

If you have time to spare, please do check whether everything works as expected in regards to the vulnerability fix (see the PR's description for details), that's the most important part (provided you haven't already, of course)

Now that you mention it...

First, I confirmed that neither anonymous users nor insufficiently-trusted users get posts from a restricted category in their search results. That's good.

But then I noticed that users who ought to be able to see the category see neither the category nor posts from it in search results. I made a category moderator-only and tested with a mod; I then made it "veteran users" and again tested with a mod and a curator. I don't know if this is because I edited a previously-open category; I'll try making a new one to see if that's different.

Update: same behavior with a brand new category with access set to "moderator only".

@Oaphi
Copy link
Member Author

Oaphi commented Jul 23, 2025

But then I noticed that users who ought to be able to see the category see neither the category nor posts from it in search results. I made a category moderator-only and tested with a mod; I then made it "veteran users" and again tested with a mod and a curator. I don't know if this is because I edited a previously-open category; I'll try making a new one to see if that's different.

Hm, that's odd, working fine for me:

2025-07-23_04-32

@cellio
Copy link
Member

cellio commented Jul 23, 2025

This turned out to be a data error (discussed in chat). It's now working for me and my moderator user gets posts from a mod-restricted category in search results, but normal users do not.

@ArtOfCode- ArtOfCode- merged commit 29b0054 into develop Jul 23, 2025
12 checks passed
@ArtOfCode- ArtOfCode- deleted the 0valt/1509/search_tests branch July 23, 2025 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: testing Changes to testing infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracking issue for improving test coverage for search
3 participants