-
Notifications
You must be signed in to change notification settings - Fork 154
Description
Is your feature request related to a problem? Please describe.
We could improve our Cypress tests in various ways, including:
- Aliasing long component IDs
- Adding functions for interacting with API to seed database and cleanup
- Removing dependencies with regular unit tests (Cypress tests require data created by mocha tests, but should be self-contained #978)
Describe the solution you'd like
Aliasing long component IDs
Some of the latest tests added are comprehensive, but a bit hard to read and brittle in the sense that changes on the components themselves may require lots of changes to fix the tests. An initial solution to this would be aliases on the component IDs, so that we only need to change the Cypress check in one place:
cy.get('[data-testid="repo-list-view"]').as('repoList');
cy.get('@repoList').find('[data-testid="add-repo-button"]'); Database seed/cleanup functions
We could have cy.seedDb(), cy.cleanUp() functions to make sure all E2E tests have the required data before running (via API calls). A good idea is to seed with data that we know won't be present normally and then delete it after the E2E tests.
A suggestion by @andypols which comes in handy here:
[...] I just needed a user to test with, so I used the existing mechanism (#1022). Personally, I prefer having a dedicated testing service that can create and delete test users, repos, etc., so you can use something like cy.ensureUserExists(email, isAdmin, ...) for setup. That way, it's behaviorally separate from the app itself and doesn't depend on anything needing to be run first.
Removing dependencies with regular unit tests
See #978 for context.
Describe alternatives you've considered
None
Additional context
Related #978