From d6f309ce22cc6c63a2a14fa5f93ec2bd35baedc5 Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Tue, 21 Jul 2020 20:11:22 +0530 Subject: [PATCH] Chore: Initialize Cypress tests (#1078) Addresses: #412 Co-authored-by: Pranav Raj S --- .gitignore | 4 + Gemfile | 7 + Gemfile.lock | 5 + Procfile.test | 3 + .../components/buttons/FormSubmitButton.vue | 1 + .../dashboard/routes/login/Login.vue | 2 + config/initializers/cypress_on_rails.rb | 9 + docs/README.md | 5 +- docs/development/project-setup/quick-setup.md | 16 +- package.json | 1 + spec/cypress.json | 4 + .../app_commands/activerecord_fixtures.rb | 22 + spec/cypress/app_commands/clean.rb | 10 + spec/cypress/app_commands/eval.rb | 1 + spec/cypress/app_commands/factory_bot.rb | 12 + spec/cypress/app_commands/load_seed.rb | 1 + spec/cypress/app_commands/log_fail.rb | 23 ++ .../cypress/app_commands/scenarios/default.rb | 1 + spec/cypress/cypress_helper.rb | 33 ++ .../admin_dashboard_authentication.js | 20 + spec/cypress/plugins/index.js | 21 + spec/cypress/support/commands.js | 25 ++ spec/cypress/support/index.js | 21 + spec/cypress/support/on-rails.js | 54 +++ yarn.lock | 391 ++++++++++++++++-- 25 files changed, 654 insertions(+), 38 deletions(-) create mode 100644 Procfile.test create mode 100644 config/initializers/cypress_on_rails.rb create mode 100644 spec/cypress.json create mode 100644 spec/cypress/app_commands/activerecord_fixtures.rb create mode 100644 spec/cypress/app_commands/clean.rb create mode 100644 spec/cypress/app_commands/eval.rb create mode 100644 spec/cypress/app_commands/factory_bot.rb create mode 100644 spec/cypress/app_commands/load_seed.rb create mode 100644 spec/cypress/app_commands/log_fail.rb create mode 100644 spec/cypress/app_commands/scenarios/default.rb create mode 100644 spec/cypress/cypress_helper.rb create mode 100644 spec/cypress/integration/happy_paths/admin_dashboard_authentication.js create mode 100644 spec/cypress/plugins/index.js create mode 100644 spec/cypress/support/commands.js create mode 100644 spec/cypress/support/index.js create mode 100644 spec/cypress/support/on-rails.js diff --git a/.gitignore b/.gitignore index d058d20d1..3bf2fdbb1 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,7 @@ node_modules package-lock.json *.dump + + +# cypress +test/cypress/videos/* \ No newline at end of file diff --git a/Gemfile b/Gemfile index a769187de..ec8cd8455 100644 --- a/Gemfile +++ b/Gemfile @@ -96,6 +96,13 @@ group :development do gem 'json_refs', git: 'https://github.com/tzmfreedom/json_refs', ref: 'e32deb0' end +group :test do + # Cypress in rails. + gem 'cypress-on-rails', '~> 1.0' + # fast cleaning of database + gem 'database_cleaner' +end + group :development, :test do # locking until https://github.com/codeclimate/test-reporter/issues/418 is resolved gem 'action-cable-testing' diff --git a/Gemfile.lock b/Gemfile.lock index 40e05f084..27235335d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -146,6 +146,9 @@ GEM crack (0.4.3) safe_yaml (~> 1.0.0) crass (1.0.6) + cypress-on-rails (1.7.0) + rack + database_cleaner (1.8.5) datetime_picker_rails (0.0.7) momentjs-rails (>= 2.8.1) declarative (0.0.10) @@ -560,6 +563,8 @@ DEPENDENCIES bullet bundle-audit byebug + cypress-on-rails (~> 1.0) + database_cleaner devise devise_token_auth dotenv-rails diff --git a/Procfile.test b/Procfile.test new file mode 100644 index 000000000..760852e80 --- /dev/null +++ b/Procfile.test @@ -0,0 +1,3 @@ +backend: RAILS_ENV=test bin/rails s -p 5050 +frontend: bin/webpack-dev-server +worker: RAILS_ENV=test bundle exec sidekiq -C config/sidekiq.yml diff --git a/app/javascript/dashboard/components/buttons/FormSubmitButton.vue b/app/javascript/dashboard/components/buttons/FormSubmitButton.vue index d8934f675..9223ebcef 100644 --- a/app/javascript/dashboard/components/buttons/FormSubmitButton.vue +++ b/app/javascript/dashboard/components/buttons/FormSubmitButton.vue @@ -1,6 +1,7 @@