Commit Graph

4 Commits

Author SHA1 Message Date
Javi Martín
f93c85bd2e Don't check the database during system tests
As mentioned in commits like a586ba806, a7664ad81, 006128da5, b41fbfa52
and c480cdd91, accessing the database after starting the browser with
the `visit` method sometimes results in database corruption and failing
tests on our CI due to the process running the test accessing the
database after the process running the browser has started.

IMHO this is also a bad practice for system tests, since these tests
should be checking what users experience.

So, just like we did a few commits ago with tests that reloaded records,
we're modifying the tests to check the results of user interactions from
the point of view of the users.

Also note we aren't changing tests with the `:no_js` tag, since these
tests don't run a real browser in a separate process. In the future, we
should also change most of these tests so they don't access the database
and they use a real browser.

Finally, note that one of the tests we're changing in the shared
`notifiable_in_app` file did not check the database content, but we're
also changing it for consistency.
2025-04-01 14:53:27 +02:00
Javi Martín
98fec3bb2f Add missing expectation before checking metadata
We weren't checking whether the request creating the proposal had
finished before checking the document. That's probably why this test has
recently failed on our CI:

```
1) Documents Metadata download document without metadata
     Failure/Error: io = URI.parse(
                          "#{app_host}#{polymorphic_path(
                                        Document.last.attachment)}"
                        ).open

     NoMethodError:
       undefined method `attachment' for nil:NilClass
```
2025-03-26 16:27:08 +01:00
Javi Martín
9da582cb91 Wait for suggestions in multitenancy and document tests
In commit f638e5017 we introduced some methods to avoid race conditions
in tests that created debates, proposals or investments.

However, since we don't have a way to effectively make sure we use these
methods in new code, we forgot to do so when adding tests in commits
c483c6036 and 84b88c0ec.

So we're using them now.

There's a chance that this is what was causing multitenancy tests to
fail sometimes; if we don't wait for the request to get the suggestions
to finish, the application might still be dealing with this request when
we make another request to a different subdomain, or when the test has
finished and the tenant has already been deleted.

On my machine, the test "Creating content in one tenant doesn't affect
other tenants" failed about 5% of the time without these changes, and I
haven't been able to reproduce this failure after applying them. Having
said that, it's possible that this is a coincidence and that this test
will fail for a different reason in the future (like `login_as` not
working properly with subdomains).
2024-10-23 21:04:06 +02:00
taitus
84b88c0ec3 Allow testing remove metadata from PDF
In order to test that we remove metadata from PDF we need add
"pdf-reader" gem.

With this gem we can check the info from the PDF and ensure that
this info is removed.
2023-11-22 14:46:11 +01:00