forked from consuldemocracy/consuldemocracy
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Upstream #1568
+544
−206
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There's a flaky test creating a group for a budget which takes place because toggling a form using jQuery sometimes results in the button not being correctly clicked by Capybara. Checking the page with `expect(page).to have_button 'Create group'` before clicking the button doesn't solve the problem; it looks like in those cases Capybara waits for AJAX requests but not for JavaScript animations. See also issue consuldemocracy#2573.
Just like jQuery animations, they can make tests fail when using Capybara.
With this name, it's easier to understand what it does.
The browser was generating one AJAX request per keystroke, ignoring the timeout. The clearTimeout() function needs to be called with the ID value returned by setTimeout().
As stated in #1196, compiling everything related to CKEditor made compilations slower. However, not compiling any plugins meant Travis had to compile them while running a test. It often resulted in a test failing because the time Travis took to compile the plugins the application uses exceeded Capybara's wait time.
The test "Budget Investments Show milestones" was failing in certain cases where `Globalize.locale` had been changed in a previous test. Since having different values in `Globalize.locale` and `I18n.locale` has proven to be an issue on the test enviroment, this commit also changes application code in order to avoid similar situations on production. See issue consuldemocracy#2718.
These tests were failing randomly because there is no guarantee the methods `Budget#email_selected` and `Budget#email_unselected` will always send the emails in the same order, because `investments.selected` and `investments.unselected` don't necessarily return the records in the order they were created. Ordering by id is certainly not very elegant; however, ordering by another field like `created_at` is dangerous because the record could be created at (almost) the exact same time. Related to issue consuldemocracy#2446 and issue consuldemocracy#2519.
There was a flaky spec supporting proposals. It's hard to reproduce and be sure about what was going on, so here is my best guess. Given the code: ``` within(".proposals-list") { click_link proposal.title } within("#proposal_#{proposal.id}_votes") { click_link('Support') } ``` The first clicked link generates an AJAX request. Usually, Capybara would wait for the AJAX request to generate a "Support" link in the element `#proposal_XX_votes`. However, there's already a `#proposal_XX_votes` element with a "Support" link on the proposals index page! So Capybara doesn't have to wait for the AJAX request to finish before clicking the "Support" link. From then on, anything can happen. Another option that works: ``` within(".proposals-list") { click_link proposal.title } within(".proposal-show #proposal_#{proposal.id}_votes") { click_link('Support') } ``` With this code, the link selector fails on the proposals index page, and Capybara waits for the AJAX request to finish. Related to issue consuldemocracy#2558.
Officing sidebar menu
Officing not to vote
As explained by @iagirre with pinpoint accuracy [1]: "If the officer_assignments are created at 23:59:59 and the rest of the test is executed after 00:00:00, the dates for the objects and the `Date.current` (used to check if there are any shifts today) won't be the same, because the shift will be for, lets say, 07/03/2018 and `Date.current` will be 08/03/2018, so, there are no shifts." Freezing time avoids this issue. Related to issues consuldemocracy#2520 and consuldemocracy#2521. [1] #1342
It could have side effects (for example, a conflict after upgrading to Rails 5). Thanks @aitbw for the suggestion!
The tests depending on the date changing were still failing because Date.current was being stubbed after loading the factories. The following lines affected these specific tests: factory :poll_officer_assignment, class: 'Poll::OfficerAssignment' do (...) date Date.current end So if the tests were executed right before midnight, the sequence was: 1. The factories file was loaded, assigning Date.current to the date of every Poll::OfficerAssignment to be created. 2. Time passed, so now it was after midnight. 3. The `travel_to` method freezed time, after midnight. 4. A Poll::OfficerAssignment factory was created, using the date it was before midnight. Using dynamic fixtures solves the problem: factory :poll_officer_assignment, class: 'Poll::OfficerAssignment' do (...) date { Date.current } end Now the sequence is: 1. The factories file is loaded, and since it finds a block, doesn't assign a static value to every Poll::OfficerAssignment to be created. 2. Time passes, so now it's after midnight. 3. The `travel_to` method freezes time, after midnight. 4. A Poll::OfficerAssignment factory was created, and in executes the block, using the current date, that is, after midnight.
Sorry, at work we have a co-worker (@rochgs) that thanks this "spaced" style because of his visual handicap. Here you are!! ;)
…ages_on_dev_seeds add proposal image on dev_seeds task
…r-recommendations Debates and proposals recommendations for users
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
References 🚀
This PR updates this repo with CONSUL one, including the following PR's:
Fix flaky spec: Admin budgets Manage groups and headings Create group Fix flaky spec: Admin budgets Manage groups and headings Create group consuldemocracy/consuldemocracy#2696
Fix suggestions being requested with every keystroke Fix suggestions being requested with every keystroke consuldemocracy/consuldemocracy#2708
Fix flaky specs using CKEditor Fix flaky specs using CKEditor consuldemocracy/consuldemocracy#2711
Fix flaky spec: Budget Investments Show milestones Fix flaky spec: Budget Investments Show milestones consuldemocracy/consuldemocracy#2719
Fix flaky specs: Emails Budgets Selected/Unselected investment Fix flaky specs: Emails Budgets Selected/Unselected investment consuldemocracy/consuldemocracy#2695
Fix flaky spec: Proposals Voting Voting proposals on behalf of someone in show view Fix flaky spec: Proposals Voting Voting proposals on behalf of someone in show view consuldemocracy/consuldemocracy#2697
Add issue template Add issue template consuldemocracy/consuldemocracy#2722
Legislation help gif Legislation help gif consuldemocracy/consuldemocracy#2732
Fix flaky specs: Officing Results Add/Edit results Fix flaky specs: Officing Results Add/Edit results consuldemocracy/consuldemocracy#2712
Improves admin banners section Improves admin banners section consuldemocracy/consuldemocracy#2319
Fix flaky specs: Votes Debates and Voting comments Update Fix flaky specs: Votes Debates and Voting comments Update consuldemocracy/consuldemocracy#2734
Add proposal image on dev_seeds task add proposal image on dev_seeds task consuldemocracy/consuldemocracy#2768
Also in the commits list but are backports (already on AyuntamientoMadrid#master)
A11y A11y consuldemocracy/consuldemocracy#2724
Officing sidebar menu Officing sidebar menu consuldemocracy/consuldemocracy#2725
Officing not to vote Officing not to vote consuldemocracy/consuldemocracy#2726
UI design UI design consuldemocracy/consuldemocracy#2733
Deal gracefully with recommendations of hidden proposals Deal gracefully with recommendations of hidden proposals consuldemocracy/consuldemocracy#2751
Deal gracefully with hidden followable in my activity Deal gracefully with hidden followable in my activity consuldemocracy/consuldemocracy#2752
Polls UI Polls UI consuldemocracy/consuldemocracy#2765
Budgets investment show messages Budgets investment show messages consuldemocracy/consuldemocracy#2766
Debates and proposals recommendations for users Debates and proposals recommendations for users consuldemocracy/consuldemocracy#2760