Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tests): Reset database between each Cypress tests #302

Merged
merged 25 commits into from
Mar 22, 2020

Conversation

adrienjoly
Copy link
Member

@adrienjoly adrienjoly commented Mar 22, 2020

Extracted from PR #301.

Contributes to #199.

What does this PR do / solve?

Cypress' best practices recommend to start each test with a clean server state.

Overview of changes

Instead of seeding the database before running Cypress, we let it do that before running every test.

As a result this PR:

  • introduces a new POST /testing/reset API endpoint that clears the db and re-populates it with test data
  • removes calls to npm run test-reset
  • extracts the db initialization logic from app.js to mongodb.js
  • also takes that opportunity to extract cacheCollections() and runShellScript() out of mongodb.js's init() function

How to test this PR?

CI should pass.

Locally, you should be able to run all tests more than once in a row, using $ npm run docker:test:cypress:dev

…et test suite login after the call to dbReset
@adrienjoly adrienjoly self-assigned this Mar 22, 2020
@adrienjoly adrienjoly changed the title Fix/199 reset db from cypress fix(tests): Reset database between each Cypress tests Mar 22, 2020
@adrienjoly adrienjoly added this to 📥 Inbox / ideas in Development via automation Mar 22, 2020
@adrienjoly adrienjoly moved this from 📥 Inbox / ideas to ⚙ In progress in Development Mar 22, 2020
@adrienjoly adrienjoly marked this pull request as ready for review March 22, 2020 16:48
Copy link
Member Author

@adrienjoly adrienjoly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it!

@adrienjoly adrienjoly merged commit ced6038 into master Mar 22, 2020
Development automation moved this from ⚙ In progress to ✔️ Done / pending QA Mar 22, 2020
@adrienjoly adrienjoly deleted the fix/199-reset-db-from-cypress branch March 22, 2020 16:50
adrienjoly added a commit that referenced this pull request Mar 22, 2020
* master:
  fix(tests): Reset database between each Cypress tests (#302)

# Conflicts:
#	cypress/support/commands.js
#	cypress/support/index.d.ts
adrienjoly pushed a commit that referenced this pull request Mar 22, 2020
## [1.30.3](v1.30.2...v1.30.3) (2020-03-22)

### Bug Fixes

* **tests:** Reset database between each Cypress tests ([#302](#302)) ([ced6038](ced6038)), closes [#301](#301) [#199](#199)
adrienjoly added a commit that referenced this pull request Mar 22, 2020
…river-to-cypress

* master:
  fix(tests): create dummy posts from cypress tests instead of from initdb_testing (#304)
  chore(release): 1.30.3 [skip ci]
  fix(tests): Reset database between each Cypress tests (#302)

# Conflicts:
#	cypress/support/index.js
@adrienjoly adrienjoly moved this from ✔️ Done / pending QA to 🌲 In production in Development Mar 22, 2020
adrienjoly added a commit that referenced this pull request Mar 23, 2020
* master: (64 commits)
  chore(release): 1.30.6 [skip ci]
  fix(ui): Resizing the page should not scroll to the top (#303)
  chore(release): 1.30.5 [skip ci]
  fix(tests): Migrate acceptance tests from Webdriver to Cypress (#301)
  chore(release): 1.30.4 [skip ci]
  fix(tests): create dummy posts from cypress tests instead of from initdb_testing (#304)
  chore(release): 1.30.3 [skip ci]
  fix(tests): Reset database between each Cypress tests (#302)
  chore(release): 1.30.2 [skip ci]
  fix(ui): Display correct track error message when using electron app (#294)
  chore(release): 1.30.1 [skip ci]
  fix(error): 404 redirect when clicking load more on account stream (#296)
  test(#295): add non-regression test for pagination (#299)
  chore(release): 1.30.0 [skip ci]
  feat(ci): separate ci tasks for each type of tests (#298)
  chore(release): 1.29.0 [skip ci]
  feat(ci): enable TypeScript in Cypress tests (#297)
  remove browser cache hack preventing css from displaying correct logo (#293)
  chore(release): 1.28.2 [skip ci]
  fix(ui): never-ending loading animation on empty search (#260)
  ...

# Conflicts:
#	.github/workflows/nodejs.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development
  
🌲 In production
Development

Successfully merging this pull request may close these issues.

None yet

1 participant