Skip to content
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

Merged
merged 18 commits into from
Jun 19, 2024
Merged

Conversation

Learningstuff98
Copy link
Collaborator

@Learningstuff98 Learningstuff98 commented Mar 23, 2023

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

  • New feature (non-breaking change which adds functionality)

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.
Screenshot (739)

Screenshot (740)

If anything needs to change, please let me know.

@Learningstuff98
Copy link
Collaborator Author

I'll look into the failing tests and see what I can do.

dorner
dorner previously requested changes Mar 23, 2023
Copy link
Collaborator

@dorner dorner left a 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 :)

@Learningstuff98
Copy link
Collaborator Author

Unfortunately I seem to have an extra organization instance making its way into the test file that I'm working on, called DEFAULT. I've looked through the app to see if I can find the culprit but I haven't found anything so far. If anyone has any ideas please let me know.

FAILUR~1

@awwaiid
Copy link
Collaborator

awwaiid commented Mar 26, 2023

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.

@Learningstuff98
Copy link
Collaborator Author

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.

FAILUR~1

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?

@cielf
Copy link
Collaborator

cielf commented Apr 2, 2023

@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.

@seanmarcia
Copy link
Member

I just ran the tests locally and got errors withorganizations_system_spec.

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.

@Learningstuff98
Copy link
Collaborator Author

@cielf I tried this and unfortunately it didn't work.

@cielf
Copy link
Collaborator

cielf commented Apr 3, 2023

@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.

@dorner
Copy link
Collaborator

dorner commented Apr 3, 2023

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 --fail-fast so it stops with the first failure.

@Learningstuff98
Copy link
Collaborator Author

@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.

@cielf
Copy link
Collaborator

cielf commented Apr 3, 2023

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?

@Learningstuff98
Copy link
Collaborator Author

@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.

@cielf
Copy link
Collaborator

cielf commented Apr 3, 2023

@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...)

@cielf
Copy link
Collaborator

cielf commented Apr 3, 2023

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.

@Learningstuff98
Copy link
Collaborator Author

@cielf Yeah its messy.

@cielf
Copy link
Collaborator

cielf commented Apr 3, 2023

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)

@cielf
Copy link
Collaborator

cielf commented Apr 3, 2023

Bleah. Other tests are relying on that name being DEFAULT.

@cielf
Copy link
Collaborator

cielf commented Apr 3, 2023

@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.

@Learningstuff98
Copy link
Collaborator Author

Learningstuff98 commented Apr 3, 2023

@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.

@cielf
Copy link
Collaborator

cielf commented Apr 3, 2023

@Learningstuff98
I think we should test the pagination.
The flaw in the setup of defaults is a separate newly discovered issue that has been colliding with this.

@dorner dorner requested a review from cielf April 5, 2024 21:04
@dorner dorner dismissed their stale review April 5, 2024 21:04

taking over PR

@dorner dorner self-assigned this Apr 5, 2024
@@ -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) }
Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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

cielf
cielf previously requested changes Apr 9, 2024
Copy link
Collaborator

@cielf cielf left a 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
@dorner
Copy link
Collaborator

dorner commented Apr 12, 2024

@cielf pushed a fix!

@cielf cielf dismissed their stale review April 13, 2024 13:22

Looks good from a functionality pov now

cielf
cielf previously requested changes Apr 13, 2024
Copy link
Collaborator

@cielf cielf left a 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.

@dorner
Copy link
Collaborator

dorner commented Apr 14, 2024

I think this might be related to some of the seed stuff that @elasticspoon was working on.

@elasticspoon
Copy link
Collaborator

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 skip_seed. It should work default to normal behavior if you drop the skip_seed tho

@dorner
Copy link
Collaborator

dorner commented Apr 14, 2024

Looks like this is the only spec that has skip_transaction: true. I think this was me trying to get around the seeded data and having all clean data. So this was basically the beta version of what you're doing. :) But it doesn't seem to be interacting well with your changes.

@cielf
Copy link
Collaborator

cielf commented Apr 14, 2024

Am asking @awwaiid to take a look from a technical pov.

Copy link
Contributor

Automatically unassigned after 7 days of inactivity.

@cielf
Copy link
Collaborator

cielf commented May 23, 2024

Have poked @awwaiid for a technical review.

dorner and others added 2 commits May 24, 2024 16:07
# 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|
Copy link
Collaborator

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?

Copy link
Collaborator

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.

@awwaiid awwaiid dismissed cielf’s stale review June 19, 2024 16:04

Changes addressed

Copy link
Collaborator

@awwaiid awwaiid left a 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.

@awwaiid awwaiid merged commit 4cf8899 into main Jun 19, 2024
38 checks passed
@awwaiid awwaiid deleted the pagination-for-organizaation-view branch June 19, 2024 16:12
Copy link
Contributor

@Learningstuff98: Your PR Pagination for organization view is part of today's Human Essentials production release: 2024.06.23.
Thank you very much for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add pagination to superusers organizaation view
6 participants