-
Notifications
You must be signed in to change notification settings - Fork 114
Refactor Conditional Questions Tests #3522
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
base: conditional-question-fix-for-removing-questions-bug-rails7
Are you sure you want to change the base?
Refactor Conditional Questions Tests #3522
Conversation
-I'm not sure why, but the `:radio_button` type was missing from several remove_list: values. This change adds it to all of the remove_list arrays.
Please add. That was a slip up on my part. |
- The `expect(page).to have_text('Answered just now')` was could not be relied upon to perform the desired check for the saved answer. This is because 'Answered just now' is rendered for many answers on the page, rather than just the newly answered one. - This change also removes all `click_button 'Save'` executions. This code already appears to be absent from some saved answers. In addition, all of the saves seem to be auto-executed so this change makes the tests more consistent and removes redundancy. - Some refactoring has also been performed.
Generated by 🚫 Danger |
Removed the overall number of questions and answers in the two changed files. This change should improve test completion speed without affecting test quality.
The tests are getting noticeably faster, but I will try to improve things a bit more. BEFOREhttps://github.com/DMPRoadmap/roadmap/actions/runs/14705500339/job/41264851295
AFTERhttps://github.com/DMPRoadmap/roadmap/actions/runs/15404832747/job/43345375835?pr=3522 (up to commit 8893f32)
|
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 like the re-factoring. A good example for writing future tests.
Just need to fix the Rubocop offences.
Previously, `spec/features/questions/conditions_questions_spec.rb` tested `remove_data` and `add_webhook` functionality separately for each question type: checkbox, radiobutton, and dropdown. While thorough, this approach added a lot of overhead to test execution time. This change reduces that overhead by randomly choosing only one of checkbox, radiobutton, or dropdown for each of the tests. Over time, repeated executions via the GitHub Actions should ensure that all types continue to be exercised, maintaining coverage while also improving overall test time.
379194a
to
e951b4d
Compare
Commit e951b4d greatly reduces the test time overhead.
However, the testing approach is a bit different with this change. Here is a copy of the commit description which describes the change:
|
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.
Good change for improving performance. Just fix Rubocop offense.
Changes proposed in this PR:
spec/features/questions/conditions_questions_spec.rb
andspec/controllers/answers_controller_with_conditional_questions_spec.rb
. This PR attempts to refactor those files by applying DRY principles.spec/support/helpers/conditional_questions_helper.rb
has been created to facilitate the shared logic between the two aforementioned files.@non_conditional_questions[:radiobutton][index].id
to someremove_data:
values. (I am not sure why these:radiobutton
options were absent in the first place and could add them back if needed.)