Commit Graph

19889 Commits

Author SHA1 Message Date
taitus
add50d68f6 Extract proposal new from shared nested imageable specs to system specs
Make `path`, `fill_resource_method_name`, `submit_button`, and
`imageable_success_notice` dynamic based on the factory.

Also adjusted the user. The proposals no longer require the user to be an
administrator but do require them to be a level 2 user.

Note that we are adding the Style/CaseLikeIf rubocop rule.
2024-11-26 17:57:01 +01:00
taitus
fb98cb61ac Extract budgets from shared nested imageable specs to system specs
Removed `imageable_path_arguments`, `has_many_images`, and `management` parameters
because they are not used by budgets.

Hardcoded `path`, `fill_resource_method_name`, `submit_button`, and
`imageable_success_notice`parameters for budgets. These remain fixed for now until dynamic
values are required in the next commits.
2024-11-20 16:27:53 +01:00
Javi Martín
59b98db5e5 Merge pull request #5745 from consuldemocracy/image_alt
Add missing alt attributes to images
2024-11-13 15:50:51 +01:00
Javi Martín
360a181c18 Use aria-hidden when rendering SVG avatars
It looks like not all screen readers identify SVG images with empty aria
labels as a decorative image, as reported by the Axe accessibility
engine.

So we're using `aria-hidden` instead, since we don't want the text of
the SVG to be read by screen readers. We're using `aria-hidden` instead
of the `presentation` role for the reasons mentioned in commit
35659d441.
2024-11-12 18:25:20 +01:00
Javi Martín
815a4078d5 Check the alt attribute in XSS tests
Not doing so was causing a test to fail when checking that all rendered
image contain an `alt` attribute.
2024-11-12 18:25:20 +01:00
Javi Martín
a6e6a90bef Add alt test to proposal images in mail 2024-11-12 18:25:20 +01:00
Javi Martín
6d6c067296 Use an empty alt attribute for decorative images
This way people using screen readers will know that the image is a
decorative one.
2024-11-12 18:25:20 +01:00
Javi Martín
597a21eca9 Add alt attribute to map images
We were using it on the map displayed on the sidebar, but we weren't
using it in the other places were the map is rendered.
2024-11-12 18:25:20 +01:00
Javi Martín
96e4ed4c36 Merge pull request #5744 from consuldemocracy/select_name
Associate all select fields with labels
2024-11-12 16:22:37 +01:00
Javi Martín
8130e4fbc8 Add an aria-label to the "choose your booth" select
We're using the `aria-label` attribute instead of a label because this
is a page where only one field is rendered and the text of the label is
the same as the text of the <h1> tag.

We're using `aria-label` instead of `aria-labelledby` because the former
is supported by Capybara.
2024-11-12 15:58:36 +01:00
Javi Martín
39d620539c Remove unused tabindex attribute
In order for this attribute to be applied, due to the syntax of the
`select` method, it should be in a separate hash.

We're removing it instead of correctly applying it because we never use
the `tabindex` attribute with a positive value, since it might break
keyboard navigation.
2024-11-12 15:58:36 +01:00
Javi Martín
ddaf320d8a Add proper labels to shift date selectors
We were using one label for both date selectors, but it wasn't
associated with any of them.

So we're now rendering one label per control and, just like we only show
one of these date selectors at a time, we're only showing one label at a
time.
2024-11-12 15:58:26 +01:00
Javi Martín
79b7ec91dd Simplify passing polls in shifts form component 2024-11-12 15:17:20 +01:00
Javi Martín
5915194fc4 Simplify passing the booth in shift form component
Since we're using helpers instead of components, the booth is now a
method and we don't need to pass it around.
2024-11-12 15:17:20 +01:00
Javi Martín
ee34ead4ee Move poll shifts form partial to a component
Thanks to it, we can move a few helper methods to the component.
2024-11-12 15:17:16 +01:00
Javi Martín
9ab6c15975 Remove unused method in shifts helper
We don't use this method since commit 452723628.
2024-11-12 15:16:23 +01:00
Javi Martín
d254fcd7ca Fix missing "for" attribute in user segments label
Since the attribute was missing, the label wasn't correctly associated
with its field.
2024-11-12 15:15:34 +01:00
Javi Martín
b68047f265 Fix missing "for" attribute in officer assignment label
Since this attribute was missing, the label wasn't correctly associated
with its field.
2024-11-12 15:15:34 +01:00
Javi Martín
3b7948a139 Use a date field to select the date of birth
The default `date_select` used in fields presents an accessibility
issue, because in generates three select controls but only one label.
That means that there are two controls without a label.

So we're using a date field instead. This type is field is supported by
about 99% of the browsers, and we've already got JavaScript code
converting this field to a jQuery UI datepicker in case the browser
doesn't support date fields.

Note that, since we no longer need to parse the three date fields into
one, we can simplify the code in both the models and the tests.

Another slight improvement is that, previously, we couldn't restrict the
month and day controls in order to set the minimum date, so the maximum
selectable date was always the 31st of December of the year set by the
minimum age setting. As seen in the component test, now that we use only
one field, we can set a specific date as the maximum one.
2024-11-12 15:15:34 +01:00
Javi Martín
6af8ddd324 Extract component to render the date of birth
We reduce code duplication thanks to that, and make it easier
to change this field.

Note that there was one place where the "16.years" value was
hardcoded. We're moving the test for this case to the
component and changing it so the test doesn't use the default
age.

We're also removing the redundant helper method that had the
same code as a method in the User class which is called
everywhere else.
2024-11-12 15:15:34 +01:00
Javi Martín
ab673557c4 Merge pull request #5788 from consuldemocracy/hide_money_expectation
Add missing expectation in hide money test
2024-11-11 16:08:49 +01:00
Javi Martín
64bb42b288 Add missing expectation in hide money test
All the expectations checked after the `click_link "Check my votes"`
action were already true before clicking the link, meaning the test
could finish before the request did.

It's possible that this request caused a test run 8274, job 2 [1], since
a multitenancy test failed and a possible cause could have been
simultaneous requests to both a tenant subdomain and the application's
main domain. The failure was:

```
1) Multitenancy PostgreSQL extensions work for tenants
     Failure/Error: expect(page).to have_content "Proposal created
successfully."
       expected to find text "Proposal created successfully." in
       "Language: \n
       \nEnglish\nDeutsch\nEspañol\nFrançais\nNederlands\nPortuguês
       brasileiro\n中文\n       Notifications\nMy content\nMy account\nSign
       out\nDebates\nYou are in\nProposals\nVoting\nCollaborative
       legislation\nParticipatory budgeting\nSDG\nHelp\nProposals\nCreate new
       proposal\nHow do citizen proposals work?\nRecommendations for creating a
       proposal\nDo not use capital letters for the proposal title or for whole
       sentences. On the internet, this is considered shouting. And nobody
       likes being shouted at.\nAny proposal or comment suggesting illegal
       action will be deleted, as well as those intending to sabotage the
       debate spaces. Anything else is allowed.\nEnjoy this space and the
       voices that fill it. It belongs to you too.\n×\n1 error prevented this
       Proposal from being saved.\nPlease check the marked fields to know how
       to correct them:\nREQUIRED FIELDS\nProposal title\nProposal
       summary\n(maximum 200 characters)\ntsvector for María the
       Martian\nProposal text\n    Format\n    ◢\n  If you are human, ignore
       this field\nOPTIONAL FIELDS\nExternal video URL\nYou may add a link to
       YouTube or Vimeo\nDescriptive image\nYou can upload one image of
       following content types: jpg, up to 1 MB.\nAdd image\nDocuments\nYou can
       upload up to a maximum of 3 documents of following content types: pdf,
       up to 3 MB per file.\nAdd new document\nTags\nTag this proposal. You can
       choose from proposed categories or add your own\nCategories\n\nFull name
       of the person submitting the proposal\n(individually or as
       representative of a collective; will not be displayed publically)\ncan't
       be blank, is too short (minimum is 6 characters)\nSustainable
       Development Goals and Targets\nYou can choose one or several SDGs
       aligned with your citizen proposal\nGoals and Targets\nYou can introduce
       the code of a specific goal/target or a text to find one. For more
       information visit the SDG help page.\nI agree to the Privacy Policy and
       the Terms and conditions of use\nOpen government\nThis portal uses the
       CONSUL DEMOCRACY application which is open-source
       software.\nParticipation\nDecide how to shape the city you want to live
       in.\nCONSUL DEMOCRACY, 2024 Privacy Policy Terms and conditions of use
       Accessibility"
```

Note the `can't be blank, is too short` reference to the responsible
name, which is only checked when user verification is not skipped. In
this test, the `mars` tenant skips the verification while the default
tenant does not. The mentioned possibility of simultaneous requests
might have caused the issue.

[1] https://github.com/consuldemocracy/consuldemocracy/actions/runs/11747689680/job/32730131655
2024-11-11 15:53:43 +01:00
Javi Martín
6f81215425 Merge pull request #5786 from consuldemocracy/stats_turbolinks_reload
Include stat graphs JavaScript in all admin stats actions
2024-11-11 15:46:15 +01:00
Javi Martín
c34cab282a Merge pull request #5509 from consuldemocracy/labels_everywhere
Associate all form inputs with labels
2024-11-11 15:21:25 +01:00
Javi Martín
4102330abc Add labels to investments filters
Note that adding the labels broke the layout because the button was no
longer aligned with the fields, so we're now using a flex layout.

Since we're using labels, we no longer need a placeholder (which wasn't
very informative, by the way) in the text field.
2024-11-11 15:04:40 +01:00
Javi Martín
670f4515ab Remove obsolete HTML class in advanced filters button
The `clear` class isn't needed since commit c9f31b8e1, when we moved
this button above the regular search fields.

We're also moving the `float` property to the CSS file.
2024-11-11 15:04:40 +01:00
Javi Martín
29968d1d9f Use a button to toggle advanced filters
As mentioned in commit 5311daadf, there are several reasons to use
buttons in these situations.
2024-11-11 15:04:40 +01:00
Javi Martín
bc4fd63950 Simplify advanced filter params initialization 2024-11-11 15:04:40 +01:00
Javi Martín
c28ff49f10 Move investments search form partial to a component
As a bonus, we now have a few less helper methods :).
2024-11-11 15:04:40 +01:00
Javi Martín
1cefc040a7 Add labels to the search form in the management area
The text for the unfeasible checkbox wasn't correctly defined as a
label, while the fields to search investments and select the heading
weren't intuitive since their purpose wasn't obvious.
2024-11-11 15:04:35 +01:00
Javi Martín
b45f928703 Fix label width in the management area search form
With a 50% width on medium and large screens, depending on the size of
the text and the size of the screen, the label could unnecessarily use
two rows, looking broken.
2024-11-11 13:58:48 +01:00
Javi Martín
39d68fd928 Use form_tag in management area investments search form
Since this form isn't associated to an object, using `form_tag` instead
of `form_for` simplifies the code.
2024-11-11 13:58:48 +01:00
Javi Martín
02825c22fe Include stat graphs JavaScript in all admin stats actions
Since the main stats index loads this JavaScript using
`"data-turbolinks-track" => "reload"`, going from the stats index to a
section that doesn't include this JavaScript did the strange effect
Turbolinks does in these situations: it first loaded the page using an
AJAX request and, after getting the contents of the page, it reloaded it
in order to apply the changes in the included JavaScript.

This behavior was a bit confusing, particularly when browsing to a
section of the admin stats, clicking the browser's back button to go
back to the stats index, the going to another section, ...

One of the admin stats tests was failing sometimes with this message:

```
  1) Stats Budget investments Supporting phase Number of users and
     supports in investment projects
     Failure/Error: raise ex, cause: cause

     Selenium::WebDriver::Error::UnknownError:
       unknown error: unhandled inspector error:
         {"code":-32000,"message":"Node with given id does not belong to the document"}
         (Session info: chrome=129.0.6668.89)
```

This was probably caused by the mentioned Turbolinks behavior that loads
the page twice. It's possible that Selenium was somehow checking the
node related to the first request when the second request had finished.

Avoiding that double request solves the issue.
2024-11-08 19:54:29 +01:00
Javi Martín
9a4aea9381 Extract method to include stat graphs JavaScript
We're going to use this method everywhere in the admin stats section.
2024-11-08 19:37:09 +01:00
Javi Martín
f8d06bcaf2 Move management investments search partial to a component
We're also moving it to the `management` subfolder, since it's only used
in the budget investments management.
2024-11-08 15:03:55 +01:00
Javi Martín
b7e9d1118e Add ARIA labels to moderation checkboxes
This way it'll be easier for people using screen readers to know which
element the checkbox is related to.

Note that we're using the `aria-label` attribute because it makes
testing with Capybara easier than using the `aria-labelledby` attribute.
The only exception are the comments, since comments don't have a title
and there isn't a proper label for them. In this case, we're using the
title of the associated commentable as the label; we might change it in
the future since there might be many comments for the same commentable.
2024-11-08 15:03:55 +01:00
Javi Martín
8213f23629 Use I18n texts for image dimensions
This way it'll be possible to customize the text in languages not using
parenthesis or not using an "x" to define dimensions.
2024-11-08 15:03:55 +01:00
Javi Martín
b82d7032ba Add a hint to the site customization image fields
This way people using screen readers will hear the required dimensions
of the images while filling in the form.
2024-11-08 15:03:55 +01:00
Javi Martín
5ca65a787f Add an ARIA label to site customization images fields
This way it'll be easier for people using screen readers to know which
field they're on.
2024-11-08 15:03:55 +01:00
Javi Martín
331228cb2a Add proper labels for site customization texts
We were rendering one label and many textarea fields for that label.
This meant that, when switching to a different language, the label
wasn't correctly associated with the textarea.

So we're now rendering one label for each textarea. We could use
`aria-label` or `aria-labelledby` instead, but using a label offers some
advantages like the fact that clicking on the label makes the textarea
take the focus.
2024-11-08 15:03:55 +01:00
Javi Martín
0f712635a4 Extract method in information text field component
This will make it easier to reuse this method.
2024-11-08 15:03:55 +01:00
Javi Martín
e1353fd865 Fix duplicate fields in information texts form
We were rendering the same hidden field, with the same HTML ID, one time
per enabled locale.
2024-11-08 15:03:55 +01:00
Javi Martín
55d81fcac7 Fix missing "for" attribute in user invitations label
Since the attribute was missing, the label wasn't correctly associated
with its field.
2024-11-08 15:03:55 +01:00
Javi Martín
431ebeda87 Fix missing "for" attribute in document number label
Since this attribute was missing, the label wasn't correctly associated
with its field.
2024-11-08 15:03:55 +01:00
Javi Martín
9f738b8d5f Fix labels in progress bar percentage selection
We were using the same label for two elements, but the label was only
assigned to one of them.
2024-11-08 15:03:55 +01:00
Javi Martín
233ba3c72f Move progress bars form partial to a component
This way we can move some of the view logic to the Ruby class. It'll
also make it easier to write tests for it.
2024-11-08 15:03:55 +01:00
Javi Martín
9c057d5695 Fix labels in color selection
We were using the same label for two elements, but the label was only
assigned to one of them.
2024-11-08 15:03:55 +01:00
Javi Martín
8aff1414c5 Move legislation process form partial to a component
This will make it easier to write tests for it.
2024-11-08 15:03:55 +01:00
Javi Martín
c1fbcb4e0f Remove obsolete resource method in controllers
This method was used by controllers using the `Translatable` concern. We
forgot to remove it in commit 71601bd3f.
2024-11-08 15:03:51 +01:00
Javi Martín
e850ae2ff9 Move banner form partial to a component
Other than simplifying the controller, this'll make it easier to write
tests for this code.
2024-11-08 14:24:57 +01:00