-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
1,535 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,4 @@ yarn-debug.log* | |
latest.dump | ||
.env | ||
public/schema.graphql | ||
cypress/cypress-examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "hello@cypress.io", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
|
||
module.exports = (on, config) => { | ||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// *********************************************** | ||
// 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 will overwrite an existing command -- | ||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// *********************************************************** | ||
// 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' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"baseUrl": "http://localhost:5002", | ||
"defaultCommandTimeout": 10000 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# 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"].map { |f| f[(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
if defined?(DatabaseCleaner) | ||
# cleaning the database using database_cleaner | ||
DatabaseCleaner.strategy = :truncation | ||
DatabaseCleaner.clean | ||
else | ||
logger.warn "add database_cleaner or update clean_db" | ||
Post.delete_all if defined?(Post) | ||
end | ||
|
||
Rails.logger.info "APPCLEANED" # used by log_fail.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Kernel.eval(command_options) unless command_options.nil? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
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 => e | ||
logger.error "#{e.class}: #{e.message}" | ||
logger.error e.backtrace.join("\n") | ||
logger.error "#{e.record.inspect}" if e.is_a?(ActiveRecord::RecordInvalid) | ||
raise e | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# 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| | ||
begin | ||
records[record_class.to_s] = record_class.limit(100).map(&:attributes) | ||
rescue | ||
end | ||
end | ||
end | ||
|
||
filename = command_options.fetch('runnable_full_title', 'no title').gsub(/[^[:print:]]/, '') | ||
File.open("#{Rails.root}/log/#{filename}.json", "w+") do |file| | ||
file << JSON.pretty_generate(json_result) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
app = FactoryBot.create(:app, encryption_key: "unodostrescuatro", | ||
active_messenger: "true", | ||
state: 'enabled') | ||
|
||
agent = app.add_agent({email: "test@test.cl", name: "sharleena"}) | ||
#user = app.add_user({email: "test@test.cl"}) | ||
|
||
|
||
app.update( | ||
timezone: "UTC", | ||
lead_tasks_settings: { | ||
delay: false, | ||
routing: "assign", | ||
email_requirement: "email_only", | ||
assignee: agent.agent, | ||
share_typical_time: true | ||
}, | ||
email_requirement: command_options.fetch('email_requirement'), | ||
team_schedule: [ | ||
{ day: "tue", from: "01:00" , to: '01:30' }, | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
app = FactoryBot.create(:app, encryption_key: "unodostrescuatro", | ||
active_messenger: "true", | ||
state: 'enabled') | ||
|
||
agent = app.add_agent({email: "test@test.cl", name: "sharleena"}) | ||
#user = app.add_user({email: "test@test.cl"}) |
19 changes: 19 additions & 0 deletions
19
spec/cypress/app_commands/scenarios/start_conversation_from_agent.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
text="foobar" | ||
serialized_content = "{\"blocks\": [{\"key\":\"bl82q\",\"text\":\"#{text}\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}" | ||
|
||
app = FactoryBot.create(:app, encryption_key: "unodostrescuatro", | ||
active_messenger: "true", | ||
state: 'enabled') | ||
|
||
agent = app.add_agent({email: "test@test.cl", name: "sharleena"}) | ||
user = app.add_user({email: "test@test.cl"}) | ||
|
||
app.start_conversation({ | ||
message: { | ||
serialized_content: serialized_content, | ||
html_content: text | ||
}, | ||
from: agent.agent, | ||
participant: user | ||
}) |
19 changes: 19 additions & 0 deletions
19
spec/cypress/app_commands/scenarios/start_conversation_from_user.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
text="foobar" | ||
serialized_content = "{\"blocks\": [{\"key\":\"bl82q\",\"text\":\"#{text}\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}" | ||
|
||
app = FactoryBot.create(:app, encryption_key: "unodostrescuatro", | ||
active_messenger: "true", | ||
state: 'enabled') | ||
|
||
agent = app.add_agent({email: "test@test.cl", name: "sharleena"}) | ||
user = app.add_user({email: "test@test.cl"}) | ||
|
||
app.start_conversation({ | ||
message: { | ||
serialized_content: serialized_content, | ||
html_content: text | ||
}, | ||
from: agent.agent, | ||
participant: user | ||
}) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
text = command_options.fetch('text') || "aaa" | ||
serialized_content = "{\"blocks\": [{\"key\":\"bl82q\",\"text\":\"#{text}\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}" | ||
app = App.find_by(key: command_options.fetch('app_key')) | ||
|
||
app.assignment_rules.create({ | ||
title: "test", | ||
agent: app.agents.first, | ||
conditions: command_options.fetch('rules') || [], | ||
priority: 1 | ||
}) | ||
|
||
app.conversations.first.add_message({ | ||
from: app.agents.first, | ||
message: { | ||
html_content: "<p>ss</p>", | ||
serialized_content: serialized_content, | ||
text_content: serialized_content | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# host_port = "#{Capybara.current_session.server.host}:#{Capybara.current_session.server.port}" | ||
|
||
app = App.find_by(key: command_options.fetch('app_key')) | ||
|
||
tour_attributes = { | ||
"app"=> app, | ||
"key"=>nil, | ||
"from_name"=>nil, | ||
"from_email"=>nil, | ||
"reply_email"=>nil, | ||
"html_content"=>nil, | ||
"premailer"=>nil, | ||
"serialized_content"=>nil, | ||
"description"=>"oli", | ||
"sent"=>nil, | ||
"name"=>"ooioij", | ||
"scheduled_at"=>2.day.ago, | ||
"scheduled_to"=>2.day.from_now, | ||
"timezone"=>nil, | ||
"state"=> command_options.fetch('state'), | ||
"subject"=>"oijoij", | ||
"segments"=>[{"type"=>"match", "value"=>"and", "attribute"=>"match", "comparison"=>"and"}], | ||
"type"=>"Tour", | ||
"settings"=>{"url"=>"#{command_options.fetch('url')}", | ||
"steps"=>[ | ||
{"target"=>"H1", "serialized_content"=>"{\"blocks\":[{\"key\":\"f1qmb\",\"text\":\"this is the tour\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}"}, | ||
{"target"=>"H1", "serialized_content"=>"{\"blocks\":[{\"key\":\"f1qmb\",\"text\":\"final tour step\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}"} | ||
], | ||
"hidden_constraints"=>["skip", "finish"] | ||
}, | ||
} | ||
|
||
|
||
tour = app.tours.create(tour_attributes) | ||
tour.enable! if command_options.fetch('state') === "enabled" | ||
tour |
Oops, something went wrong.