Skip to content

Cypress tests require data created by mocha tests, but should be self-contained #978

@kriswest

Description

@kriswest

Describe the bug
The cypress tests for the repo page depend on data that is created and abandoned by the mocha tests. I.e. the test-repo used here:

const cloneURL = 'http://localhost:8000/finos/test-repo.git';
const tooltipQuery = 'div[role="tooltip"]';
cy
// tooltip isn't open to start with
.get(tooltipQuery)
.should('not.exist');
cy
// find the entry for finos/test-repo
.get('a[href="https://github.com/admin/repo/test-repo"]')

The data is created in a mocha test here:

const res = await chai.request(app).post('/api/v1/repo').set('Cookie', `${cookie}`).send({
project: 'finos',
name: 'test-repo',
url: 'https://github.com/finos/test-repo.git',
});
res.should.have.status(200);

Which also has to handle it (perhaps) already existing on run:

// Prepare the data.
await db.deleteRepo('test-repo');
await db.deleteUser('u1');
await db.deleteUser('u2');

Ideally tests should handle their own set-up and tear-down (clean-up). As the cypress tests use client-side JS they can't directly import the DB clients and create the data they need, but they could make API calls or a node script be used for setup and tear down before/after the cypress command.

Expected behaviour
Each set of tests handles its own data creation and subsequent clean-up.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions