Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf8a6bc0b4 |
@@ -4,7 +4,6 @@ module.exports = {
|
|||||||
'prettier',
|
'prettier',
|
||||||
'plugin:vue/recommended',
|
'plugin:vue/recommended',
|
||||||
'plugin:storybook/recommended',
|
'plugin:storybook/recommended',
|
||||||
'plugin:cypress/recommended',
|
|
||||||
],
|
],
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
parser: '@babel/eslint-parser',
|
parser: '@babel/eslint-parser',
|
||||||
|
|||||||
@@ -207,10 +207,6 @@ group :development do
|
|||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
# Cypress in rails.
|
|
||||||
gem 'cypress-on-rails'
|
|
||||||
# fast cleaning of database
|
|
||||||
gem 'database_cleaner'
|
|
||||||
# mock http calls
|
# mock http calls
|
||||||
gem 'webmock'
|
gem 'webmock'
|
||||||
# test profiling
|
# test profiling
|
||||||
|
|||||||
@@ -175,14 +175,6 @@ GEM
|
|||||||
rexml
|
rexml
|
||||||
crass (1.0.6)
|
crass (1.0.6)
|
||||||
csv-safe (3.2.1)
|
csv-safe (3.2.1)
|
||||||
cypress-on-rails (1.16.0)
|
|
||||||
rack
|
|
||||||
database_cleaner (2.0.2)
|
|
||||||
database_cleaner-active_record (>= 2, < 3)
|
|
||||||
database_cleaner-active_record (2.1.0)
|
|
||||||
activerecord (>= 5.a)
|
|
||||||
database_cleaner-core (~> 2.0.0)
|
|
||||||
database_cleaner-core (2.0.1)
|
|
||||||
date (3.3.4)
|
date (3.3.4)
|
||||||
ddtrace (1.11.1)
|
ddtrace (1.11.1)
|
||||||
debase-ruby_core_source (>= 0.10.16, <= 3.2.0)
|
debase-ruby_core_source (>= 0.10.16, <= 3.2.0)
|
||||||
@@ -863,8 +855,6 @@ DEPENDENCIES
|
|||||||
climate_control
|
climate_control
|
||||||
commonmarker
|
commonmarker
|
||||||
csv-safe
|
csv-safe
|
||||||
cypress-on-rails
|
|
||||||
database_cleaner
|
|
||||||
ddtrace
|
ddtrace
|
||||||
debug (~> 1.8)
|
debug (~> 1.8)
|
||||||
devise (>= 4.9.4)
|
devise (>= 4.9.4)
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
if defined?(CypressOnRails)
|
|
||||||
CypressOnRails.configure do |c|
|
|
||||||
c.cypress_folder = File.expand_path("#{__dir__}/../../spec/cypress")
|
|
||||||
# WARNING!! CypressOnRails can execute arbitrary ruby code
|
|
||||||
# please use with extra caution if enabling on hosted servers or starting your local server on 0.0.0.0
|
|
||||||
c.use_middleware = Rails.env.test?
|
|
||||||
c.logger = Rails.logger
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -122,13 +122,11 @@
|
|||||||
"babel-jest": "29",
|
"babel-jest": "29",
|
||||||
"babel-loader": "8.2.2",
|
"babel-loader": "8.2.2",
|
||||||
"babel-preset-vue": "^2.0.2",
|
"babel-preset-vue": "^2.0.2",
|
||||||
"cypress": "^13.4.0",
|
|
||||||
"eslint": "^8.49.0",
|
"eslint": "^8.49.0",
|
||||||
"eslint-config-airbnb-base": "15.0.0",
|
"eslint-config-airbnb-base": "15.0.0",
|
||||||
"eslint-config-prettier": "^9.0.0",
|
"eslint-config-prettier": "^9.0.0",
|
||||||
"eslint-import-resolver-webpack": "^0.13.7",
|
"eslint-import-resolver-webpack": "^0.13.7",
|
||||||
"eslint-plugin-babel": "5.3.1",
|
"eslint-plugin-babel": "5.3.1",
|
||||||
"eslint-plugin-cypress": "^2.15.1",
|
|
||||||
"eslint-plugin-html": "7.1.0",
|
"eslint-plugin-html": "7.1.0",
|
||||||
"eslint-plugin-import": "2.28.1",
|
"eslint-plugin-import": "2.28.1",
|
||||||
"eslint-plugin-jsx-a11y": "6.7.1",
|
"eslint-plugin-jsx-a11y": "6.7.1",
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
const { defineConfig } = require('cypress');
|
|
||||||
|
|
||||||
module.exports = defineConfig({
|
|
||||||
defaultCommandTimeout: 10000,
|
|
||||||
viewportWidth: 1250,
|
|
||||||
viewportHeight: 800,
|
|
||||||
e2e: {
|
|
||||||
baseUrl: 'http://localhost:5050',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
# you can delete this file if you don't use Rails Test Fixtures
|
|
||||||
|
|
||||||
fixtures_dir = command_options.try(:[], 'fixtures_dir')
|
|
||||||
fixture_files = command_options.try(:[], 'fixtures')
|
|
||||||
|
|
||||||
if defined?(ActiveRecord)
|
|
||||||
require 'active_record/fixtures'
|
|
||||||
|
|
||||||
fixtures_dir ||= ActiveRecord::Tasks::DatabaseTasks.fixtures_path
|
|
||||||
fixture_files ||= Dir["#{fixtures_dir}/**/*.yml"].pluck((fixtures_dir.size + 1)..-5)
|
|
||||||
|
|
||||||
logger.debug "loading fixtures: { dir: #{fixtures_dir}, files: #{fixture_files} }"
|
|
||||||
ActiveRecord::FixtureSet.reset_cache
|
|
||||||
ActiveRecord::FixtureSet.create_fixtures(fixtures_dir, fixture_files)
|
|
||||||
'Fixtures Done' # this gets returned
|
|
||||||
else # this else part can be removed
|
|
||||||
logger.error 'Looks like activerecord_fixtures has to be modified to suite your need'
|
|
||||||
Post.create(title: 'MyCypressFixtures')
|
|
||||||
Post.create(title: 'MyCypressFixtures2')
|
|
||||||
Post.create(title: 'MyRailsFixtures')
|
|
||||||
Post.create(title: 'MyRailsFixtures2')
|
|
||||||
end
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
if defined?(DatabaseCleaner)
|
|
||||||
# cleaning the database using database_cleaner
|
|
||||||
DatabaseCleaner.strategy = :truncation
|
|
||||||
DatabaseCleaner.clean
|
|
||||||
else
|
|
||||||
logger.warn 'add database_cleaner or update cypress/app_commands/clean.rb'
|
|
||||||
Post.delete_all if defined?(Post)
|
|
||||||
end
|
|
||||||
|
|
||||||
Rails.logger.info 'APPCLEANED' # used by log_fail.rb
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Kernel.eval(command_options) unless command_options.nil?
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
Array.wrap(command_options).map do |factory_options|
|
|
||||||
factory_method = factory_options.shift
|
|
||||||
begin
|
|
||||||
logger.debug "running #{factory_method}, #{factory_options}"
|
|
||||||
CypressOnRails::SmartFactoryWrapper.public_send(factory_method, *factory_options)
|
|
||||||
rescue StandardError => e
|
|
||||||
logger.error "#{e.class}: #{e.message}"
|
|
||||||
logger.error e.backtrace.join("\n")
|
|
||||||
logger.error e.record.inspect.to_s if e.is_a?(ActiveRecord::RecordInvalid)
|
|
||||||
raise e
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Rails.application.load_seed
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
# This file is called when a cypress spec fails and allows for extra logging to be captured
|
|
||||||
filename = command_options.fetch('runnable_full_title', 'no title').gsub(/[^[:print:]]/, '')
|
|
||||||
|
|
||||||
# grab last lines until "APPCLEANED" (Make sure in clean.rb to log the text "APPCLEANED")
|
|
||||||
system "tail -n 10000 -r log/#{Rails.env}.log | sed \"/APPCLEANED/ q\" | sed 'x;1!H;$!d;x' > 'log/#{filename}.log'"
|
|
||||||
|
|
||||||
# create a json debug file for server debugging
|
|
||||||
json_result = {}
|
|
||||||
json_result['error'] = command_options.fetch('error_message', 'no error message')
|
|
||||||
|
|
||||||
if defined?(ActiveRecord::Base)
|
|
||||||
json_result['records'] =
|
|
||||||
ActiveRecord::Base.descendants.each_with_object({}) do |record_class, records|
|
|
||||||
records[record_class.to_s] = record_class.limit(100).map(&:attributes)
|
|
||||||
rescue StandardError => e
|
|
||||||
Rails.logger.error e.message
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
filename = command_options.fetch('runnable_full_title', 'no title').gsub(/[^[:print:]]/, '')
|
|
||||||
Rails.root.join("log/#{filename}.json").open('w+') do |file|
|
|
||||||
file << JSON.pretty_generate(json_result)
|
|
||||||
end
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Rails.application.load_seed
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
# This is loaded once before the first command is executed
|
|
||||||
|
|
||||||
begin
|
|
||||||
require 'database_cleaner'
|
|
||||||
rescue LoadError => e
|
|
||||||
puts e.message
|
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
|
||||||
require 'factory_bot_rails'
|
|
||||||
rescue LoadError => e
|
|
||||||
puts e.message
|
|
||||||
begin
|
|
||||||
require 'factory_girl_rails'
|
|
||||||
rescue LoadError => e
|
|
||||||
puts e.message
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
require 'cypress_on_rails/smart_factory_wrapper'
|
|
||||||
|
|
||||||
factory = CypressOnRails::SimpleRailsFactory
|
|
||||||
factory = FactoryBot if defined?(FactoryBot)
|
|
||||||
factory = FactoryGirl if defined?(FactoryGirl)
|
|
||||||
|
|
||||||
CypressOnRails::SmartFactoryWrapper.configure(
|
|
||||||
always_reload: !Rails.configuration.cache_classes,
|
|
||||||
factory: factory,
|
|
||||||
files: [
|
|
||||||
Rails.root.join('spec/factories.rb'),
|
|
||||||
Rails.root.join('spec/factories/**/*.rb')
|
|
||||||
]
|
|
||||||
)
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
describe('AdminDashboardAuthentication', () => {
|
|
||||||
before(() => {
|
|
||||||
cy.app('clean');
|
|
||||||
cy.appScenario('default');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('authenticates an admin ', () => {
|
|
||||||
cy.visit('/');
|
|
||||||
|
|
||||||
cy.get("[data-testid='email_input']").clear();
|
|
||||||
cy.get("[data-testid='email_input']").type('john@acme.inc');
|
|
||||||
cy.get("[data-testid='password_input']").clear();
|
|
||||||
cy.get("[data-testid='password_input']").type('Password1!');
|
|
||||||
|
|
||||||
cy.get("[data-testid='submit_button']").click();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
describe('AdminCreateLabel', () => {
|
|
||||||
before(() => {
|
|
||||||
cy.visit('/');
|
|
||||||
|
|
||||||
cy.get("[data-testid='email_input']").clear();
|
|
||||||
cy.get("[data-testid='email_input']").type('john@acme.inc');
|
|
||||||
cy.get("[data-testid='password_input']").clear();
|
|
||||||
cy.get("[data-testid='password_input']").type('Password1!');
|
|
||||||
|
|
||||||
cy.get("[data-testid='submit_button']").click();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('open add label modal and create a label', () => {
|
|
||||||
cy.get("[data-testid='sidebar-new-label-button']").click();
|
|
||||||
|
|
||||||
cy.get("[data-testid='label-title'] > input").clear();
|
|
||||||
cy.get("[data-testid='label-title'] > input").type(
|
|
||||||
`show_stopper_${new Date().getTime()}`
|
|
||||||
);
|
|
||||||
|
|
||||||
cy.get("[data-testid='label-description'] > input").clear();
|
|
||||||
cy.get("[data-testid='label-description'] > input").type(
|
|
||||||
'denote it with show show stopper cases'
|
|
||||||
);
|
|
||||||
|
|
||||||
cy.get("[data-testid='label-submit']").click();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
// ***********************************************
|
|
||||||
// This example commands.js shows you how to
|
|
||||||
// create various custom commands and overwrite
|
|
||||||
// existing commands.
|
|
||||||
//
|
|
||||||
// For more comprehensive examples of custom
|
|
||||||
// commands please read more here:
|
|
||||||
// https://on.cypress.io/custom-commands
|
|
||||||
// ***********************************************
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// -- This is a parent command --
|
|
||||||
// Cypress.Commands.add("login", (email, password) => { ... })
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// -- This is a child command --
|
|
||||||
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// -- This is a dual command --
|
|
||||||
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// -- This is will overwrite an existing command --
|
|
||||||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
// ***********************************************************
|
|
||||||
// This example support/index.js is processed and
|
|
||||||
// loaded automatically before your test files.
|
|
||||||
//
|
|
||||||
// This is a great place to put global configuration and
|
|
||||||
// behavior that modifies Cypress.
|
|
||||||
//
|
|
||||||
// You can change the location of this file or turn off
|
|
||||||
// automatically serving support files with the
|
|
||||||
// 'supportFile' configuration option.
|
|
||||||
//
|
|
||||||
// You can read more here:
|
|
||||||
// https://on.cypress.io/configuration
|
|
||||||
// ***********************************************************
|
|
||||||
|
|
||||||
// Import commands.js using ES2015 syntax:
|
|
||||||
import './commands'
|
|
||||||
import './on-rails'
|
|
||||||
|
|
||||||
// Alternatively you can use CommonJS syntax:
|
|
||||||
// require('./commands')
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
// CypressOnRails: dont remove these command
|
|
||||||
Cypress.Commands.add('appCommands', function (body) {
|
|
||||||
cy.log("APP: " + JSON.stringify(body))
|
|
||||||
return cy.request({
|
|
||||||
method: 'POST',
|
|
||||||
url: "/__cypress__/command",
|
|
||||||
body: JSON.stringify(body),
|
|
||||||
log: true,
|
|
||||||
failOnStatusCode: true
|
|
||||||
}).then((response) => {
|
|
||||||
return response.body
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
Cypress.Commands.add('app', function (name, command_options) {
|
|
||||||
return cy.appCommands({name: name, options: command_options}).then((body) => {
|
|
||||||
return body[0]
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
Cypress.Commands.add('appScenario', function (name, options = {}) {
|
|
||||||
return cy.app('scenarios/' + name, options)
|
|
||||||
});
|
|
||||||
|
|
||||||
Cypress.Commands.add('appEval', function (code) {
|
|
||||||
return cy.app('eval', code)
|
|
||||||
});
|
|
||||||
|
|
||||||
Cypress.Commands.add('appFactories', function (options) {
|
|
||||||
return cy.app('factory_bot', options)
|
|
||||||
});
|
|
||||||
|
|
||||||
Cypress.Commands.add('appFixtures', function (options) {
|
|
||||||
cy.app('activerecord_fixtures', options)
|
|
||||||
});
|
|
||||||
// CypressOnRails: end
|
|
||||||
|
|
||||||
// The next is optional
|
|
||||||
// beforeEach(() => {
|
|
||||||
// cy.app('clean') // have a look at cypress/app_commands/clean.rb
|
|
||||||
// });
|
|
||||||
|
|
||||||
// comment this out if you do not want to attempt to log additional info on test fail
|
|
||||||
Cypress.on('fail', (err, runnable) => {
|
|
||||||
// allow app to generate additional logging data
|
|
||||||
Cypress.$.ajax({
|
|
||||||
url: '/__cypress__/command',
|
|
||||||
data: JSON.stringify({name: 'log_fail', options: {error_message: err.message, runnable_full_title: runnable.fullTitle() }}),
|
|
||||||
async: false,
|
|
||||||
method: 'POST'
|
|
||||||
});
|
|
||||||
|
|
||||||
throw err;
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user