Commit Graph

13 Commits

Author SHA1 Message Date
Javi Martín
b694ee7077 Use a button to delete an investment
Note that, since the button now generates a `form` tag, we need to
adjust the styles of this section.

As mentioned in commit 5311daadf, there are several reasons to use
buttons in these situations. And, as mentioned in the previous commits,
using buttons instead of links for actions requiring confirmation will
help us test for accessibility issues.

Note we're simplifying the `table .button` margin rules because the
`.button` class already defines `0` for all its margins except the
bottom margin. Otherwise, the margins defined by the `flex-with-gap`
mixin would be overwritten by the margins defined in the `table .button`
class.
2024-11-08 12:19:05 +01:00
Javi Martín
df716c3de6 Add missing expectations in users tests
One of these tests has failed in our CI with the following message:

```
1) Users Public activity user can hide public page

   Failure/Error: expect(page).to have_content("activity list private")
     expected to find text "activity list private" in "Language: \n
     \nEnglish\nDeutsch\nEspañol\nFrançais\nNederlands\nPortuguês
     brasileiro\n中文\n       Notifications\nYou are in\nMy content\nMy
     account\nSign out\nDebates\nProposals\nVoting\nCollaborative
     legislation\nParticipatory budgeting\nSDG\nHelp\nM\nManuela124\nUser has
     no public activity\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 how the text "User has no public activity" is present, which is a
message that appears when the user's activity is public.

A possible explanation is that we didn't check that the request done by
the "Save changes" button had finished before continuing with the tests.
Back when we wrote this test, submitting a form in a test would always
wait for the request to be finished before continuing, but a lot has
changed since then.

So we're adding an expectation to make sure the the changes have been
saved before making a new request.

We're also rearraging the blank lines in these tests and removing the
parenthesis in `have_content` expectations to be consistent with the
expectations we're adding.
2024-11-06 15:57:25 +01:00
Javi Martín
35659d4419 Replace initialjs-rails with custom avatar code
The initialjs-rails gem hasn't been maintained for years, and it
currently requires `railties < 7.0`, meaning we can't upgrade to Rails 7
while we depend on it.

Since the code in the gem is simple, and we were already rewriting its
most complex part (generating a background color), we can implement the
same code, only we're using Ruby instead of JavaScript. This way, the
avatars will be shown on browsers without JavaScript as well. Since
we're adding a component test that checks SVG images are displayed even
without JavaScript, we no longer need the test that checked images were
displayed after AJAX requests.

Now the tests show the user experience better; people don't care about
the internal name used to select the initial (which is what we were
checking); they care about the initial actually displayed.

Note initialjs generated an <img> tag using a `src="data:image/svg+xml;`
attribute. We're generating an <svg> tag instead, because it's easier.
For this reason, we need to change the code slightly, giving the <svg>
tag the `img` role and using `aria-label` so its contents won't be read
aloud by screen readers. We could give it a `presentation` role instead
and forget about `aria-label`, but then screen readers would read the
text anyway (or, at least, some of them would).
2024-04-11 18:48:33 +02:00
Javi Martín
d3b1b21d3d Extract matcher to check for avatars
We're going to change the code to render avatars, and having a matcher
will make it easier.
2024-04-11 18:48:33 +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
3cd4f3827e Hide what users are following unless they allow it
It could be argued that seeing which proposals a user follows is a good
indicator of which proposals a user has supported, since we're
automatically creating follows for supported proposals since commit
74fbde09f. So now, we're extending the `public_interests` funcionality,
so it only shows elements users are following if they've enabled it.

This is an improvement over using the `public_activity` attribute in two
ways:

* The `public_interests` attribute is disabled by default, so by default
  other users won't be able to see what a user is following
* Who has created proposals/debates/investments/comments is public
  information, while who is following which elements is not; so enabling
  `public_activity` shouldn't imply potentially private information should
  be displayed as well

We've considered removing the `public_interests` attribute completely
and just hiding the "following" page for everyone except its owner, but
keeping it provides more compatibility with existing installations.
2021-10-05 14:43:09 +02:00
Javi Martín
0875c214ba Make following tab tests easier to understand
The `click_link` part did nothing other than scrolling to the element,
since in these cases we've got a same-page link and the element it links
to is already on the page. Programmers reading the test would expect the
link to load the page or change to a different tab and would think the
element it links to wasn't there before clicking the link (at least I
did).
2021-10-05 14:40:47 +02:00
Javi Martín
9bc529dce1 Group almost identical public interests tests 2021-10-05 14:40:47 +02:00
Javi Martín
16fdffdf96 Reduce number of requests in user tests
We were adding a `visit` in a `before` block but then we started some
tests with another `visit`.

We also destroyed records in the database in between, which increased
the risk of database inconsistency since the process running the browser
had already been started.

Besides, some tests were wrong; they were visiting a page with the
browser, then destroying records in the database, and then checking the
page without reloading the browser. Since we aren't automatically
refreshing the affected areas of the page, obviously the page content
before and after destroying records is exactly the same, and the test
was passing because it's testing content that isn't there in any
situation.
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
3da4ee00b8 Simplify tests requiring admin login
We were repeating the same code over and over (with a few variants) to
setup tests which require an administrator. We can use a tag and
simplify the code.
2020-12-02 15:33:19 +01:00
Senén Rodero Rodríguez
014fa6eb1c Add mutations observer to initialize user initials added through ajax 2020-05-26 13:20:26 +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