-
-
Notifications
You must be signed in to change notification settings - Fork 522
feat: use rspec retry to deflake ci #6285
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
Changes from all commits
11889b7
46a1671
c2a68f5
08c8fbf
d1d929a
0445b8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # spec/spec_helper.rb | ||
| require "rspec/retry" | ||
|
|
||
| RSpec.configure do |config| | ||
| # show retry status in spec process | ||
| config.verbose_retry = true | ||
| # show exception that triggers a retry if verbose_retry is set to true | ||
| config.display_try_failure_messages = true | ||
|
|
||
| if ENV["CI"] == "true" | ||
| # run retry only on features | ||
| config.around :each, :js do |ex| | ||
| ex.run_with_retry retry: 3 | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,17 +44,21 @@ | |
|
|
||
| find(".ts-control").click | ||
|
|
||
| ts_checkboxes = page.all(".ts-dropdown-content input") | ||
| page.all(".ts-dropdown-content input") | ||
|
|
||
| select_all_el = page.find("span[data-test=select-all-input]") | ||
| # uncheck all contact type options | ||
| select_all_el.click | ||
| ts_checkboxes.each do |el| | ||
| expect(el).not_to be_checked | ||
| within ".ts-dropdown-content" do | ||
| expect(page).not_to have_css(".form-check-input--checked") | ||
| expect(page).to have_css(".form-check-input--unchecked", count: 3) | ||
| end | ||
| # check all contact type options | ||
| select_all_el.click | ||
| expect(ts_checkboxes).to all(be_checked) | ||
| within ".ts-dropdown-content" do | ||
| expect(page).not_to have_css("input.form-check-input--unchecked") | ||
| expect(page).to have_css("input.form-check-input--checked", count: 3) | ||
| end | ||
|
Comment on lines
+58
to
+61
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an ugly fix but the issue with the initial code is that when you run Thus, if the test runs that check before the javascript on the page runs the test will fail. When we use I would like to have done something more like `have_checked("id_of_input") but tomselect does not give us something like that. instead I added a css class for checked and unchecked inputs in tomselect and assert against that. |
||
|
|
||
| # unselect contact_type from dropdown | ||
| find("span", text: contact_type.name).click | ||
|
|
@@ -238,17 +242,20 @@ | |
| expect(page).to have_text("Set Implementation Status") | ||
|
|
||
| find(".ts-control").click | ||
| ts_checkboxes = page.all(".ts-dropdown-content input") | ||
|
|
||
| select_all_el = page.find("span[data-test=select-all-input]") | ||
| # uncheck all contact type options | ||
| select_all_el.click | ||
| ts_checkboxes.each do |el| | ||
| expect(el).not_to be_checked | ||
| within ".ts-dropdown-content" do | ||
| expect(page).not_to have_css(".form-check-input--checked") | ||
| expect(page).to have_css(".form-check-input--unchecked", count: 2) | ||
| end | ||
| # check all contact type options | ||
| select_all_el.click | ||
| expect(ts_checkboxes).to all(be_checked) | ||
| within ".ts-dropdown-content" do | ||
| expect(page).not_to have_css("input.form-check-input--unchecked") | ||
| expect(page).to have_css("input.form-check-input--checked", count: 2) | ||
| end | ||
| # since all contact type options checked, don't need to select one | ||
| within ".top-page-actions" do | ||
| click_on "Update CASA Case" | ||
|
|
@@ -317,6 +324,8 @@ def sign_in_and_assign_volunteer | |
| context "when a volunteer is assigned to a case" do | ||
| it "marks the volunteer as assigned and shows the start date of the assignment", :js do | ||
| sign_in_and_assign_volunteer | ||
| expect(page).to have_content("Volunteer assigned to case") | ||
|
|
||
| expect(casa_case.case_assignments.count).to eq 1 | ||
|
|
||
| unassign_button = page.find("button.btn-outline-danger") | ||
|
|
||
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.
https://rubygems.org/gems/rspec-retry seems reasonable, last update 2019 but simple