Commit Graph

21 Commits

Author SHA1 Message Date
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
cyrillefr
31ceb31256 Replace link with button in Dashboard show 2025-07-03 11:14:53 +02:00
Javi Martín
6c3e7391d4 Use buttons to execute/unexecute dashboard actions
As mentioned in commit 5311daadf, using buttons for non-GET requests has
several advantages over using links.
2025-04-02 16:03:07 +02:00
Javi Martín
4e08f3f147 Add a text to the links to execute dashboard actions
People using screen readers had no idea what these links were about (not
that the icons are very usable for people seeing them either... but
that's a different topic). Axe was reporting this error:

```
link-name: Links must have discernible text (serious)
https://dequeuniversity.com/rules/axe/4.10/link-name?application=axeAPI
The following 1 node violate this rule:

  Selector: #dashboard_action_2_execute
  HTML: <a id="dashboard_action_2_execute" class="unchecked-link"
           rel="nofollow" data-method="post"
           href="/proposals/16-proposal-6-title/dashboard/actions/2/execute">
          <span class="unchecked"></span>
        </a>
  Fix all of the following:
  - Element is in tab order and does not have accessible text
  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
```
2025-04-02 16:02:55 +02:00
Javi Martín
942ccf6674 Group similar dashboard progress tests together
All these tests were basically checking the same things. Since system
tests are slow, we're grouping them together so executing them is
slightly faster.
2025-04-02 15:58:23 +02:00
Javi Martín
e2d9d0f2b4 Fix default dashboard actions factories
We had a trait called `:admin_request` for actions that are requests to
administrators, but the default factories were also requests to
administrators.

The tests checking that the "Request" button is not present, which
shouldn't pass with the wrong default factories, were passing by
coincidence. The issue was that we weren't checking whether that the
request had finished before checking that the "Request" button wasn't
present. That meant that we were checking that the "Request" button
wasn't there right at the moment we pressed the link, before the request
was finished.

So we're now checking that the request is finished before checking that
the button isn't there.

On the other hand, the tests checking for the "Request resource" link
being present were checking a behavior that's no longer there since
commit 9d85b3935, when we changed the conditions affecting that link.
2024-10-11 15:05:24 +02:00
Javi Martín
0cec581ec0 Add and apply Capybara/RSpec/HaveSelector rule
This rule was added in rubocop-capybara 2.19.0. We were following it
about 85% of the time.

Now we won't have to check both have_css and have_selector when
searching the code.
2023-11-08 14:18:16 +01:00
Javi Martín
243d55ec82 Add method to get the archived proposals date limit 2023-08-30 14:46:35 +02:00
Javi Martín
96a0aa2a88 Add and apply LineContinuationSpacing rubocop rule
So now we're consistent when separating multiline strings.
2023-08-18 14:56:17 +02:00
Javi Martín
629e208e9d Add and apply ArgumentAlignment rubocop rule
We're choosing the default `with_first_argument` style because it's the
one we use the most.
2023-08-18 14:56:16 +02:00
Javi Martín
8b13daad95 Add and apply rules for multi-line hashes
For the HashAlignment rule, we're using the default `key` style (keys
are aligned and values aren't) instead of the `table` style (both keys
and values are aligned) because, even if we used both in the
application, we used the `key` style a lot more. Furthermore, the
`table` style looks strange in places where there are both very long and
very short keys and sometimes we weren't even consistent with the
`table` style, aligning some keys without aligning other keys.

Ideally we could align hashes to "either key or table", so developers
can decide whether keeping the symmetry of the code is worth it in a
case-per-case basis, but Rubocop doesn't allow this option.
2023-08-18 14:56:16 +02:00
Javi Martín
d776923ffe Use "withdraw" instead of "retire"
We used "retire" because we translated it literally from the Spanish
verb "retirar" which can mean both "retire" and "withdraw".

Note we're still using "retire" in database fields and method names;
changing that might make it harder to upgrade from a previous version of
CONSUL.
2022-06-01 14:27:33 +02:00
Javi Martín
d5d9eb5093 Fix tests after replacing message with notification
Looks like our test suite wasn't executed in commit 4dbc027e5, and so we
weren't notified of these failures.
2021-08-17 14:23:24 +02:00
Andrew Davis
8991bb0302 replace the word message with notification on proposal notification screens 2021-06-04 20:05:57 +08:00
Javi Martín
b52d381da5 Simplify emulating last_sign_in_at
We were updating the database after starting the browser to emulate the
behavior where a user logs in a day before the current request. We can
use `current_sign_in_at` instead and devise will automatically copy that
value to `last_sign_in_at` after users visit a page.

This way we avoid setting up the database after the process runnin the
browser has been started.
2021-04-13 21:54:26 +02:00
Javi Martín
92ddcb7aef Use JavaScript in system tests by default
JavaScript is used by about 98% of web users, so by testing without it
enabled, we're only testing that the application works for a very
reduced number of users.

We proceeded this way in the past because CONSUL started using Rails 4.2
and truncating the database between JavaScript tests with database
cleaner, which made these tests terribly slow.

When we upgraded to Rails 5.1 and introduced system tests, we started
using database transactions in JavaScript tests, making these tests much
faster. So now we can use JavaScript tests everywhere without critically
slowing down our test suite.
2021-04-07 14:41:06 +02:00
Javi Martín
9cfcbf2f3b Use visible texts in tests
Content like lowercase letters with `text-transform: uppercase` or
spaces after elements with `display: block` or "You're on page:" are not
seen that way by users with a browser supporting CSS.

So we're testing what most users actually experience.
2021-04-07 14:41:06 +02:00
Javi Martín
0ec8878db9 Reduce number of requests in dashboard tests
Using separate tests to check every link on the page made the tests
slower. We were also adding a useless initial request on tests which
started by visiting a different URL.

This useless initial request meant in some tests the browser was started
before using factories to create data. Accessing the database in the
test after the browser starts might cause concurrency issues in
JavaScript tests.
2021-04-07 14:35:30 +02:00
Javi Martín
6ea9383743 Allow toggling elements with the keyboard
Using `<a>` tags with no `href` means these elements cannot be activated
by keyboard users, so we're replacing them with buttons.

In the future we probably want to add more consistency so all toggle
buttons use the same code. We might also add styles depending on the
`aria-expanded` property.
2021-03-31 13:38:38 +02:00
Javi Martín
9427f01442 Use system specs instead of feature specs
We get rid of database cleaner, and JavaScript tests are faster because
between tests we now rollback transactions instead of truncating the
database.
2020-04-24 15:43:54 +02:00