Commit Graph

17 Commits

Author SHA1 Message Date
Javi Martín
609d6ab9a3 Fix rubocop offense in budgets system spec
This offense was introduced in commit 28caabecdf.
2021-04-07 14:41:06 +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
02981324ab Move exception tests to controller specs
System tests are used to test the application from the user's point of
view. To test for specific exceptions, particularly regarding
authorization permissions, controller tests fit better.

Another option would be to test the page displayed shows a certain text,
like "Internal server error". I'm choosing controller tests because
they're faster and we're basically testing the same scenario many times
and we've already got a test checking what happens when users access a
page raising an exception.
2021-03-31 14:42:20 +02:00
Javi Martín
4c02317909 Fix enabled/disabled phase text for screen readers
Since we were using an icon font with no text, screen readers were
announcing things like "Enabled, L", trying to read the icon generated
with CSS.

Using text and replacing it with CSS with an icon solves the problem.

We could also use aria-label, but I prefer using "Yes/No" so the text
can be shown/hidden with CSS. Also useful when using
`save_and_open_page` during tests, since the displayed page will not
have any CSS rules applied.

Out of several existing techniques to hide text [1], we're setting the
font size to 1px in combination with moving the content off-screen
because that way we can override it in the `::before` element.

Just moving the content off-screen has the inconvenient of the content
still being taken into account when calculating the text indentation.

And just using a 1px font would make a 1px-sized square appear when
selecting text, which could confuse users.

[1] https://webaim.org/techniques/css/invisiblecontent/
2021-03-11 19:37:58 +01:00
Julian Herrero
d20e521ee9 Display the time a phase ends at in admin section 2021-03-11 19:37:58 +01:00
Javi Martín
a2a6ae7bdd Use a caption to identify budget phases table
This makes the table easier to identify when writing tests and using
screen readers.

Since we do not render any other table captions anywhere else, we're
making the caption invisible so only screen reader users will be
affected by this change.
2021-03-11 19:37:58 +01:00
Javi Martín
150fb91686 Simplify test for budget phases table
Even if the test checked all possibilities, it was hard to understand.
Using `have_table with_cols:` to test the order of the rows and testing
one phase is enabled and has a link to edit it es enough IMHO.
2021-03-11 19:37:58 +01:00
Javi Martín
70cf956210 Extract method to check the current phase 2021-03-09 16:37:47 +01:00
decabeza
2f636eaf77 Add completed info on finished budgets 2021-02-23 18:39:45 +01:00
decabeza
4ff8162a2e Add filter to show all budgets in admin 2021-02-23 18:39:45 +01:00
Julian Herrero
28caabecdf Refactor participatory budgets in draft mode
Previously the draft mode was a phase of the PB, but that had some
limitations.

Now the phase drafting disappears and therefore the PB can have the
status published or not published (in draft mode).

That will give more flexibility in order to navigate through the
different phases and see how it looks for administrators before
publishing the PB and everybody can see.

By default, the PB is always created in draft mode, so it gives you
the flexibility to adjust and modify anything before publishing it.
2021-02-23 17:05:24 +01:00
Julian Herrero
0b2b8b557d Fix staff not being loaded after creating budget 2021-02-23 16:28:00 +01:00
decabeza
f685020fd0 Show results and stats settings only in budget edit view 2021-02-23 16:11:14 +01: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
Ziyan Junaideen
1e3e8c1304 Add approval voting to budgets
Co-Authored-By: Javi Martín <javim@elretirao.net>
2020-08-06 12:38:18 +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