-
-
Notifications
You must be signed in to change notification settings - Fork 493
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
Pagination for organization view #3490
Conversation
I'll look into the failing tests and see what I can do. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment, in addition to the tests :)
Looks like https://github.com/rubyforgood/human-essentials/blob/main/spec/rails_helper.rb#L157 adds this DEFAULT organization during test setup, so your test should assume that it exists. |
I have an update. I'm down to two tests in the organizations_system_spec. The one that's failing on line 77 has me stumped and I'm wondering if this is actually a bug with rspec. The search works fine in the browser. Here's a screenshot provided by rspec. The one that's failing on line 114 is passing locally for me and works in localhost. Is there a way to access the screenshots that rspec takes on github? |
@Learningstuff98 I don't think the one at 77 is a bug with rspec. The name of the user in this case is "DEFAULT SUPERADMIN", and the name of the organization you are looking for is "DEFAULT. I would add a different bank with a nonsense name to be the one that I am checking isn't there. |
I just ran the tests locally and got errors with When running the test suite locally and trying to reproduce errors I recommend running the entire test file in case something is wrong in the build-up to the specific test. If you're still green locally, and there are errors on CI you should run it with the same rspec seed as on CI and see if that produces any errors -- it could be that a flakey test has been introduced or already there and CI caught it. |
@cielf I tried this and unfortunately it didn't work. |
@Learningstuff98 Yeah - it didn't work for me either - I'm still getting the tests passing on local. I stand by my recommendations re the bank name, though. |
If an individual test is passing, often it means that it's the suite that's failing - meaning that some spec is not cleaning up after itself correctly, causing a later spec to fail. If you grab the seed that ran and run the same command that ran on GitHub Actions, you're more likely to see the failure. You can use |
@cielf I should have clarified, I meant your recommendation about the bank name for line 77. Its as if the search isn't running before the expect statements execute or it isn't running at all. |
Hmmm... @Learningstuff98 Are you saying that once you use another bank with a nonsense name, instead of Organization.first to do the check, it's now failing on your local? |
@cielf Setting the foo_org variable like the following: let!(:foo_org) { create(:organization, name: 'foo') } Passes for line 77, however other assertions in the "filters by organizations by name in organizations index page" it statement to fail. Line 86 ends up failing in the same way with the search seeming to not execute. |
@Learningstuff98 Played around with it a bit -- If you look at line 69-ish It seems like what's happening is it's not showing the last alphabetically? Which would normally speak to me of a loop that's cutting out before it should somewhere. (if you change "foo" to "aoo", then it's "baz" that isn't showing...) |
Right... and it's losing the last alphabetically because for testing the # of things on the page is set to 3, right? Right, and you end up with that Default as well as what you are actauly working with. |
@cielf Yeah its messy. |
Having all the defaults have the word "DEFAULT" in them is where the problem "really" is here, IMO. If you go back to before my initial suggestion before the bank, then go to rails_helper.rb and change the DEFAULT_TEST_ORGANIZATION_NAME to, say, "FIRST TEST ORGANIZATION" (which also doesn't have the text "ba" in it), what happens? (By here, I mean with around line 77) |
Bleah. Other tests are relying on that name being DEFAULT. |
@Learningstuff98 Well, it's terribly terribly kludgey, and I don't like it one bit, but what if your nonsense bank names are all before "DEFAULT", and we'll put in a technical debt issue to clean up other tests relying on the Default Organization name being DEFAULT. |
@cielf "what if your nonsense bank names are all before "DEFAULT" " I'd have to look into this tomorrow. But I do want to ask, is it worth it to test pagination here? It seems like this is turning into a bit of a tornado as far as the tests are concerned. |
@Learningstuff98 |
@@ -1,7 +1,8 @@ | |||
RSpec.describe "Admin Organization Management", type: :system, js: true do | |||
RSpec.describe "Admin Organization Management", type: :system, js: true, seed_items: false, skip_transaction: true do | |||
let(:super_admin) { create(:super_admin) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this should be super_admin_no_org.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There really shouldn't be a difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact we should be changing super_admin
to not have an org and fix any specs that get confused by that. Super admins should not be considered to belong to orgs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. And that's probably a separate issue. g
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something else I noticed when I kicked the tires is that when you filter down the organizations, you still have the full range of pages at the bottom.
The user pagination shows that same behaviour, but we seem to handle it correctly on the distribution index.
# Conflicts: # app/views/admin/organizations/_list.html.erb
@cielf pushed a fix! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It passes my manual testing, but it looks like there are tests related to this area that are failing still.
I think this might be related to some of the seed stuff that @elasticspoon was working on. |
Could be. I dont remember working to get this spec ready to |
Looks like this is the only spec that has |
Am asking @awwaiid to take a look from a technical pov. |
Automatically unassigned after 7 days of inactivity. |
Have poked @awwaiid for a technical review. |
# Conflicts: # spec/rails_helper.rb # spec/system/admin/organizations_system_spec.rb
@@ -114,13 +114,6 @@ def self.capybara_tmp_path | |||
|
|||
# Make FactoryBot easier. | |||
config.include FactoryBot::Syntax::Methods | |||
config.around(:each, skip_transaction: true) do |example| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this removal here on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see -- there are no more specs with skip_transaction
mentioned. Got it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Small diff in the end (ignoring whitespace). I did some manual testing too.
@Learningstuff98: Your PR |
Resolves #3471
Description
This PR adds pagination to the super admin organization index page.
List any dependencies that are required for this change. (gems, js libraries, etc.)
kaminari, Rspec, FactoryBot
Type of change
How Has This Been Tested?
Visual confirmation and I wrote a system test.
Screenshots
I set the pagination to one item per page so I could take these screenshots. This PR does not change the amount of items per page.
If anything needs to change, please let me know.