Commit Graph

1136 Commits

Author SHA1 Message Date
Javi Martín
99696cb302 Add aria-label to markers in admin map settings
We forgot to do so in commit b896fc4bb. Back then, we said:

> Note that we aren't providing a proper aria-label for markers on the
> map we use in the form to create a proposal or an investment. Adding
> one isn't trivial given the current code, and keyboard users can't add
> a marker in the first place. We'll have to revisit this issue when we
> add keyboard support for this.

However, in the admin section, the marker is already there, so it should
have a label. In this case, we're using the coordinates as label because
it's the most relevant text for the marker in the context of a form. We
could also use "Default map location" instead, but that information is
already present on the page.

Axe was reporting the same accessibility error we mentioned in commit
b896fc4bb in this situation.
2025-11-17 15:39:36 +01:00
Javi Martín
1693aa5d9c Use render_map to render the admin settings map
This way we remove duplication.

Note that to check whether to render the button to remove a marker,
we're checking whether the map location belongs to a mappable. This
means we're changing the code that renders the map in the "new proposal"
and "new investment" forms so the map location belongs to a proposal or
investment. We're association the map location to a new record because
writing something like:

```
def map_location
  proposal.map_location || MapLocation.new(proposal: proposal)
end
```

Would change the `proposal` object because of the way Rails treats
non-persisted `has_one` associations. Although probably safe in this
case, changing an object when rendering a view could have side effects.

Also note that we're changing the HTML ID of the map element from
`admin-map` to `new_map_location` (the latter is returned by the
`dom_id` method).  We were only using this ID in tests since commit
289426c1c, so changing it doesn't really affect us.
2025-11-17 15:39:36 +01:00
Javi Martín
86a12b23ad Test admin map settings from the user's point of view
People using these settings don't know about the hidden fields, but they
do know about the fields that are actually displayed on the page. So we
check that these fields are updated when the marker is updated.
2025-11-17 15:14:20 +01:00
Javi Martín
a6908f2017 Group similar map tests together
We're about to change some of these tests, and we usually group similar
system tests in order to make the test suite a bit faster.
2025-11-17 15:14:16 +01:00
Javi Martín
d0b57868af Move settings map inside the form
That's what we usually do, and it makes sense since clicking on the map
changes the content of hidden fields in the form.
2025-11-17 02:04:11 +01:00
Javi Martín
dd2fb6469f Merge pull request #6144 from consuldemocracy/serious_accessibility_issues
Fix most Axe serious accessibility issues
2025-11-14 15:49:51 +01:00
Sebastia
ebac669fd0 Merge pull request #6125 from consuldemocracy/remove-obsolete-scopes
Add missing investments filter on admin activity page
2025-11-14 15:38:25 +01:00
Sebastia
2e4a05f6b9 Merge pull request #6040 from consuldemocracy/remove-redundant-tests
Remove redundant tests
2025-11-14 15:38:08 +01:00
taitus
873968ee0a Unify related tests in wizard phases spec 2025-11-14 15:11:50 +01:00
taitus
3dc0de34bc Unify related tests in wizard headings spec 2025-11-14 15:11:50 +01:00
taitus
d43654be42 Unify related tests in wizard groups spec 2025-11-14 15:11:50 +01:00
taitus
42ef5b65bd Unify similar tests in wizard budgets spec
We are unifying the test "Create budget - Knapsack voting (default)" with
"A new budget is always created in draft mode" because they are almost the same.

On the other hand, we also merged the test "update budget" with "submit the
form with errors and then without errors". Just like in the previous case, there
were two ways to access the edit page, so we removed the one that is already
tested in other specs.
2025-11-14 15:11:22 +01:00
taitus
a9129158c1 Make moderation tests easier to read
- reuse aria-labels instead of DOM selectors when checking moderation checkboxes
- drop redundant 'first' in the within
2025-11-14 14:52:52 +01:00
taitus
a3a44f527b Give purpose to previously unused on_budget_investments scope
The "on_budget_investments" scope in Activity has never been used
anywhere in the codebase. It was introduced in commit d9d38482b3
("extends Activity to include Investment valuations") but no references
were ever added.

Instead of removing it, we make use of the scope by adding the missing
"Budget investments" filter to the admin Activity section. This aligns
it with the rest of the activity filters and gives the scope the purpose
it was originally intended for.
2025-11-14 14:31:01 +01:00
Javi Martín
b896fc4bba Add aria-label to map markers
Axe was reporting an accessibility error:

```
Found 1 accessibility violation:

1) aria-command-name: ARIA commands must have an accessible name
   (serious)
   https://dequeuniversity.com/rules/axe/4.11/aria-command-name?application=axeAPI
   The following 1 node violate this rule:

     Selector: .leaflet-marker-icon
     HTML: <div class="leaflet-marker-icon map-marker
                       leaflet-zoom-animated leaflet-interactive"
                tabindex="0" role="button">
                <div class="map-icon"></div>
           </div>
     Fix any of the following:
     - Element does not have text that is visible to screen readers
     - aria-label attribute does not exist or is empty
     - aria-labelledby attribute does not exist, references elements
       that do not exist or references elements that are empty
     - Element has no title attribute
```

Using the title of the proposal/investment as the text of the marker is
definitely a good solution when there are several markers on the map.
Not sure whether there's a better option when there's only one marker,
though.

Note that we aren't providing a proper aria-label for markers on the map
we use in the form to create a proposal or an investment. Adding one
isn't trivial given the current code, and keyboard users can't add a
marker in the first place. We'll have to revisit this issue when we add
keyboard support for this.

We're also changing a test to make sure that titles with quotes in their
names don't break the markup due to an invalid aria-label attribute.
2025-11-14 12:53:37 +01:00
Javi Martín
2d72144048 Extract component to render question options table
This way it's easier to know that the styles for the `break` HTML class
and the JavaScript for sortable elements (which we shouldn't use, by the
way, because of its accessibility issues) are only used here.
2025-11-05 19:57:33 +01:00
Javi Martín
4ec2e87c2c Add and apply RSpec/IncludeExamples rubocop rule
This rule was added in rubocop-rspec 3.6. We were already following it
most of the time.
2025-11-05 11:23:49 +01:00
taitus
b1cb6f8372 Exclude open-ended questions from managing physical votes
Also make the :yes_no factory trait create a votation_type_unique
by default, since yes/no questions should always be unique.
2025-10-16 14:31:16 +02:00
taitus
2a2edd17d1 Move results specs to Polls::ResultsComponent
Running tests at the component level is faster than at the system level,
so we move tests from system/polls/results_spec.rb to the component.

Note that moving these tests removes vote_for_poll_via_web and the visit
to results_poll_path, but both are already covered in other tests. We
also take the opportunity to reuse the method in another test where
it makes sense.

Additionally, the spec title has been reverted from "Results for polls
with questions but without options" to "renders results for polls with
questions but without answers", as it was before commit 8997ed316c.
2025-10-16 11:09:36 +02:00
taitus
83b206f0b7 Enable voting for open-ended questions in public section 2025-10-16 11:09:36 +02:00
taitus
b3f8ba819b Adapt 'show' view for open questions without options
- Prevent creating options for open questions
- Skip rendering the options table when none exist
2025-10-15 15:52:14 +02:00
taitus
d3f32978c8 Hide "Maximum number of votes" message for unique and open-ended questions
The "Maximum number of votes" text in poll question show was unnecessary.
It appeared for both unique and open-ended questions, but it only makes
sense for questions that allow multiple answers.
2025-10-15 15:52:14 +02:00
taitus
4e57e311dc Add support for open-ended questions in admin section
Introduce a new "open" votation type for poll questions in the admin
interface. This type allows open answers provided by the user.
2025-10-15 15:52:12 +02:00
taitus
2a5985f6ef Update tests for votation type form behavior
Ensure the form toggles descriptions and fields correctly depending on the selected
votation type.
2025-09-26 15:41:09 +02:00
taitus
7f376c3005 Extract admin poll results to component
Note that we have the same code in the officing section.
Then we can use the same component.

Note also that we are removing the parts of the system specs that are now
covered by the component itself, and taking the chance to unify tests.
In these removals and unifications we take into account that there are
other specs which already cover user interaction in this section.
2025-09-26 09:58:17 +02:00
Javi Martín
3cf6e9b1ca Merge pull request #6046 from Anamika1608/oidc_auth
Add support for OIDC authentication
2025-09-01 19:55:10 +02:00
Anamika Aggarwal
5e263baed2 Add OIDC section for sign in and sign up page
- name: :oidc → Identifier for this login provider in the app.
- scope: [:openid, :email, :profile] → Tells the provider we want the user’s ID (openid), their email, and basic profile info (name, picture, etc.).
- response_type: :code → Uses Authorization Code Flow, which is more secure because tokens are not exposed in the URL.
- issuer: Rails.application.secrets.oidc_issuer → The base URL of the OIDC provider (e.g., Auth0). Used to find its config.
- discovery: true → Automatically fetches the provider’s endpoints from its discovery document instead of manually setting them.
- client_auth_method: :basic → Sends client ID and secret using HTTP Basic Auth when exchanging the code for tokens.

Add system tests for OIDC Auth

Edit the oauth docs to support OIDC auth
2025-08-29 12:20:16 +02:00
taitus
fc0d79b47b Move dashboard poll partial to component 2025-08-27 17:40:45 +02:00
taitus
1e06e676a4 Move dashboard system tests to resources component specs
We're making the `new_actions_since_last_login` parameter optional in
order to simplify the tests.
2025-08-27 17:40:45 +02:00
taitus
048c8ce917 Move dashboard resources partial to a component
We're renaming the HTML class (and removing the id attribute, which was
only used in tests) in order to follow our naming conventions.
2025-08-27 17:40:45 +02:00
taitus
1d89fe0738 Unify similar tests in proposal notifications spec
The test "Link to send the message" was already included inside
"Send a notification". We removed the first one to keep only one
test that covers everything.
2025-08-25 14:13:11 +02:00
Javi Martín
8deb1964bd Show errors when submitting too many answers
This could be the case when JavaScript is disabled.

Note that, in `Poll/WebVote` we're calling `given_answers` inside a
transaction. Putting this code before the transaction resulted in a test
failing sometimes, probably because of a bug that might be possible to
reproduce by doing simultaneous requests.
2025-08-14 13:06:43 +02:00
werdenktwas-gmbh
abf02808bf Disable other answers when reaching maximum votes
This is similar to the way we were disabling buttons in the old design.

Co-authored-by: Javi Martín <javim@elretirao.net>
2025-08-14 13:06:43 +02:00
Javi Martín
7ea4f63b07 Allow blank votes in polls via web
With the old interface, there wasn't a clear way to send a blank ballot.
But now that we've got a form, there's an easy way: clicking on "Vote"
while leaving the form blank.
2025-08-14 13:06:43 +02:00
Javi Martín
5402cb6042 Move poll callout partial to a component
This way it'll be easier to refactor it.

Note there was a system test which tested both the callout and the form
when unverified users visit a poll. We've split this system test in two
component tests.
2025-08-14 13:06:43 +02:00
Javi Martín
a7e1b42b6c Use checkboxes and radio buttons on poll forms
Our original interface to vote in a poll had a few issues:

* Since there was no button to send the form, it wasn't clear that
  selecting an option would automatically store it in the database.
* The interface was almost identical for single-choice questions and
  multiple-choice questions, which made it hard to know which type of
  question we were answering.
* Adding other type of questions, like open answers, was hard since we
  would have to add a different submit button for each answer.

So we're now using radio buttons for single-choice questions and
checkboxes for multiple-choice questions, which are the native controls
designed for these purposes, and a button to send the whole form.

Since we don't have a database table for poll ballots like we have for
budget ballots, we're adding a new `Poll::WebVote` model to manage poll
ballots. We're using WebVote instead of Ballot or Vote because they
could be mistaken with other vote classes.

Note that browsers don't allow removing answers with radio buttons, so
once somebody has voted in a single-choice question, they can't remove
the vote unless they manually edit their HTML. This is the same behavior
we had before commit 7df0e9a96.

As mentioned in c2010f975, we're now adding the `ChangeByZero` rubocop
rule, since we've removed the test that used `and change`.
2025-08-14 13:06:37 +02:00
Javi Martín
a5054089b8 Fix typo in poll voter test 2025-08-12 12:45:12 +02:00
Anamika Aggarwal
c9bf7797a0 Add multi-tenancy support for SAML 2025-07-23 14:43:45 +02:00
taitus
a4709f9da0 Add omniauth saml section for sign in and sign up page
Co-authored-by: Anamika Aggarwal <anamikaagg18@gmail.com>
2025-07-23 14:43:44 +02:00
Sebastia
f4189365ea Merge pull request #5955 from cyrillefr/ReplaceLinkWithButtonInVariousComponentsPartI
Replace link with button in various components part i
2025-07-09 15:26:38 +02:00
cyrillefr
f0e696b972 Replace link with button in letter verification 2025-07-09 13:48:58 +02:00
cyrillefr
c989210e74 Replace link with button in finish signup in registrations 2025-07-09 13:48:58 +02:00
cyrillefr
3eba2d27a4 Replace link with button in Topics show 2025-07-09 13:48:58 +02:00
cyrillefr
d4b7939d2c Replace link with button in Proposal created 2025-07-09 13:48:58 +02:00
cyrillefr
ddd34d5cd0 Replace link with button in index notifications 2025-07-09 13:48:58 +02:00
cyrillefr
75ed7ae3ef Replace link with button in nofications 2025-07-09 13:48:58 +02:00
cyrillefr
267dd931d8 Replace link with button in change user link 2025-07-09 13:48:58 +02:00
cyrillefr
31ceb31256 Replace link with button in Dashboard show 2025-07-03 11:14:53 +02:00
dependabot[bot]
123c97771a Bump rubocop from 1.71.2 to 1.75.8
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.71.2 to 1.75.8.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.71.2...v1.75.8)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-version: 1.75.8
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Notes:

This commit also includes several style and lint fixes required after
updating RuboCop:

- Removed redundant parentheses now detected by improved
  'Style/RedundantParentheses' (1.72 and 1.75.3).
- Replaced ternary expressions with logical OR when the ternary was
  returning 'true', as flagged by 'Style/RedundantCondition' (1.73).
- Adjusted block variables to resolve new 'Lint/ShadowingOuterLocalVariable'
  offenses (1.75), helping avoid future conflicts during upgrades with
  'rails app:updates'

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-16 16:07:32 +02:00
taitus
b8583f2eae Move shared imageable specs to nested imageable specs file
In order to unify all related tests with imageable, we move shared imageable
specs and remove that file.
2025-06-12 09:14:38 +02:00