Commit Graph

126 Commits

Author SHA1 Message Date
Senén Rodero Rodríguez
46537cb708 Move nested_imageable helper methods to a new common actions module 2022-04-06 11:15:23 +02:00
Senén Rodero Rodríguez
071311be00 Move nested_documentable helper methods to a new common actions module 2022-04-06 11:15:23 +02:00
Senén Rodero Rodríguez
b26a7528df Move mappable helper methods to a new common actions module
So we can use the same customization technique overriding
the methods we need.
2022-04-06 11:15:23 +02:00
Javi Martín
abec716308 Show "not allowed" message on click
Defining a behavior on hover means making it different for people using
a keyboard or a touchscreen (most of the population, nowadays).

In this case, we had an accessibility issue where the message wouldn't
disappear once it appeared. That meant that, after tabbing through all
the links and buttons in, for instance, the debates index, the page
would be filled with "participation not allowed" messages, and in order
to see the information about how many people have voted, reloading the
page was required.

For touchscreen users the behavior was similar to what we get on hover,
although we've found some inconsistencies when trying to support several
elements on the same page.

We think in proposals it makes sense to hide the "support" button when
users click on it, and the same applies to the buttonsto support and
vote investment projects. However, we aren't hiding the buttons to
agree/disagree with a debate in order to keep the information about the
current number of people agreeing and disagreeing visible.

Note we're removing some support spec methods because after these
changes the duplication isn't as obvious as it was in the past.
2022-02-23 16:43:37 +01:00
Javi Martín
f638e50174 Wait for suggestions to finish loading in tests
Sometimes tests were hanging indefinitely. Debugging shows that in some
cases it's due to submitting a form before the AJAX request to get
proposals, debates or investments suggestions is finished, since having
an AJAX and a non-AJAX request at the same time when running the test
sometimes leads to unexpected results.

In our case, we were having many timeouts in Github Actions in the
branches where we use both ActiveStorage and Paperclip to store files
(based on pull request 4598). I can reproduce it in those branches
running the following test ("Should show new image after successful
creation with one uploaded file"), although only when my laptop isn't
plugged (!!):

```
rspec './spec/system/proposals_spec.rb[1:33:1:14]'
```

Since we didn't have a proper way to know the AJAX request had finished,
we're adding a `suggest-success` class to the element showing the
suggestions when that happens. Then in the tests we can look for that
class after filling in the title of a proposal, debate or investments.
Just for clarity's sake, we're also adding the `suggest-loading` class
when the suggestions are loading.

In order not to have expectations everywhere about the suggestions,
we're extracting methods to fill in those titles in the tests. Note we
aren't using these methods in the "edit" actions (suggestions are not
showing when editing) or in tests with the `no_js` tag (since
suggestions only work with JavaScript).
2021-09-22 18:29:23 +02:00
Javi Martín
7b15cc290d Use human labels to fill in proposal form in tests
This way we make sure the label is correctly associated with a field.
2021-04-16 14:33:26 +02:00
Javi Martín
287c488734 Use JavaScripts in tests using CKEditor
We were filling in textareas, so we were only testing how the
application behaves for about 1%-2% of our users.
2021-04-07 14:41:06 +02:00
Javi Martín
8ed09adcaf Extract method to generate app host in tests
On JavaScript tests, Rails URL methods don't include the port when
invoked from a test, but they do when invoked from the browser. This was
causing some tests to fail with Selenium.
2021-04-07 14:32:49 +02:00
Javi Martín
6ecb6757a6 Use real check boxes to select goals
We were using list items with the checkbox role. This is probably
confusing since list items have a listitem role, and so we were
basically using a list with no listitem.

We could add a `<span role="checkbox">` tag inside the list item, but
using real checkboxes is probably easier. We're also adding a test to
verify the checkboxes native behavior is compatible with our code.

Note we're using the "enter" key to toggle the "checked" status of the
SDG. This is probably not intuitive for screen reader users who might
try to submit the form using the "enter" key after selecting a goal.

However, the alternative would be even less intuitive for sighted
keyboard users, since for them these icons look like links or buttons
and they would accidentally submit the form when trying to select a
goal.

Since we haven't come up with a better interface yet, for now we're
following the principle of least damage; we consider submitting the form
against a user's will is less annoying than forcing users to move to a
different field before being able to submit the form.

Also note we can't write `check` in the tests because Capybara will try
to click the checkbox, which is hidden by the image in the label.
2021-02-15 15:48:25 +01:00
taitus
8a91493fe4 Extract repeating code to a method 2021-01-22 12:42:53 +01:00
Senén Rodero Rodríguez
ac6260a2ef Mock remote census responses in tests using XML
By using real XML responses developers will be able to understand better
how the integration works (the data flow), and the correspondency between
`remote_census` settings and their place at a real XML response.

As `stubbed_responses` methods were removed from the model layer now the
stubbing part should be managed from the test environment code so also
added a new helper module `RemoteCensusSetup` that can be used anywhere
where we need to call the web service.

Co-Authored-By: Javi Martín <javim@elretirao.net>
2020-11-02 11:42:39 +01:00
Javi Martín
033f3c33e3 Add SpaceAroundEqualsInParameterDefault rule
We were using it in most places, but not everywhere.
2019-10-24 17:56:03 +02:00
Senén Rodero Rodríguez
64bfab9c9c Extract spec methods to commons module to avoid code duplication
Because "translatable" and "new_translatable" shared examples needs same methods to manipulate translations.
2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
78c2f54c5d Fix proposal specs
After adding proposal translatable fields to forms, they will be generated with nested translations names and ids so we can no longer
use standard id locator.

Using input label text to fill in fields works with both types of forms.
2019-06-27 09:19:36 +02:00
decabeza
f40787561d Remove all references to question and external_url fields 2019-04-30 16:42:07 +02:00
rgarcia
74706027cb fixes specs 2019-03-28 15:47:52 +01:00
rgarcia
b4499321d3 stores officer booth on sign in 2019-03-28 15:47:52 +01:00
rgarcia
cc4eed3500 fixes specs 2019-03-28 15:47:52 +01:00
Julian Herrero
31ac8b7f55 Change single quotes to double quotes 2019-02-15 11:40:39 +01:00
Angel Perez
1e1cb660e2 Add missing CommonActions#fill_in_signup_form method
This method allows to fill in CONSUL's signup form without interacting
with other UI elements, useful when using testing locales other than English

Backported from Decide Madrid
2018-09-10 16:05:55 -04:00
Adan Amarillas
ee877888b3 Split spec common actions support helper 2018-06-04 08:55:53 -07:00
iagirre
d84895b800 Add test suite for the feature
The tests that will check the featute
is working well added. There are four test:

1. Checks that the emails are been send to
the user. The test looks for the link in there
and takes the token. Visits the page and
changes the password.

2 and 3. Both change the password by hand. One
uses a password written by the manager, whilst
the other uses the 'Generate random password'
option. Both tests check that the user can
sign in with the new passwords.

4. Checks that the password can be printed
when it is saved.
2018-04-02 09:43:17 +02:00
Angel Perez
38af45d450 Replace deprecated .trigger('click') API with .click 2018-03-27 14:47:49 -04:00
rgarcia
09c44ee583 Extend notifications to be marked as read and unread 2018-03-23 11:47:06 +01:00
iagirre
e21588ec16 The function comment_on has been modified to change the functionality. Now, a comment is generated and a email notification send manually, so that JS has been avoided, that was the original problem. 2018-03-02 13:35:50 +01:00
María Checa
017c242085 Merge pull request #2462 from consul/admin-newsletter-emails
Admin newsletter emails
2018-02-20 16:17:37 +01:00
Bertocq
4e34a1cf41 Fix common actions file rubocop issues 2018-02-15 23:17:10 +01:00
María Checa
e8c797766a Added newsletter specs 2018-02-14 16:06:33 +01:00
Bertocq
34bb9d65b1 Enable RSpec/NotToNot cop and fix all issues
Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NotToNot
2018-01-07 17:39:48 +01:00
decabeza
f95d5d4639 improves generic error message 2017-12-22 12:32:34 +01:00
Bertocq
cf8cfe363b Fix gsub+downcase usage with parameterize 2017-12-16 17:59:16 +01:00
rgarcia
2b52d26d82 refactors notifications into concerns and shared examples 2017-12-14 16:15:30 +01:00
Angel Perez
2bdc2c27d7 Add email specs for Poll 2017-11-17 13:14:03 -04:00
Angel Perez
4c110e8100 Add email specs for Topic 2017-11-17 13:14:03 -04:00
Angel Perez
3605a43947 Add email specs for Budget::Investment 2017-11-17 13:14:03 -04:00
Bertocq
cd66ba5d54 Rubocop autocorrections 2017-11-13 02:22:00 +01:00
María Checa
bb06af3877 Improved results tests 2017-10-20 16:49:25 +02:00
María Checa
8be8bb07f9 Added first poll results tests 2017-10-19 12:17:49 +02:00
Bertocq
ce0a7f6fad Rubocop autocorrections 2017-10-17 22:00:00 +02:00
rgarcia
6b7d38c27a adds spec for user voting in poll and then verifying account 2017-10-17 15:00:34 +02:00
María Checa
5b7a90221a Fixed tests 2017-10-04 11:18:09 +02:00
Bertocq
825671ad9b Fix polls answer this question show text 2017-10-03 18:53:44 +02:00
rgarcia
085991c624 allows voting only in one origin: booth or web 2017-10-02 16:22:31 +02:00
Bertocq
69f4e1c683 Fix all rubocop Metrics/LineLength issues (140+) 2017-07-10 13:22:49 +02:00
Bertocq
d7b8777395 Fix all Layout/SpaceAroundEqualsInParameterDefault rubocop issues from rubocop_todo list 2017-06-26 18:03:40 +02:00
Juanjo Bazán
c4ba6a7e94 updates specs 2017-06-12 19:48:57 +02:00
rgarcia
5c676498e2 fixes specs 2017-02-01 11:37:11 +01:00
rgarcia
6c34599e1e adds officer residence check and user voting 2017-01-29 00:36:20 +01:00
Juanjo Bazán
113f9b32d7 Merge branch 'master' into polls 2017-01-19 16:51:19 +01:00
Juanjo Bazán
5ec12e4b5b Merge branch 'master' into redux-polling 2016-12-27 18:22:06 +01:00