leap_salesforce_ui 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8dac68f1cd35a89cc7051367715789f511f2bbb3bdf4cd992b62d6b4d775d8db
4
- data.tar.gz: 9b50e04ed020695d9a94ffa43f84182aa336645cc2ff4e6fb1244a5a7384b2fd
3
+ metadata.gz: 3481b31ac19a98f7d9fe40b017f0d9d2d047a50a891ed20e079aaee480c0c623
4
+ data.tar.gz: 72ec8083bcfe9155f7e631fd5354c9d8388104bf9007985440a2518e902576f8
5
5
  SHA512:
6
- metadata.gz: a31aa4579890235a69dee8192f17f7bfc74867ba23f0d0b9f10e69f41ab0c64973d1a280e7646f72f77c7be3f836746089cb28456e91342d2f4d27e7a4efc3eb
7
- data.tar.gz: 885dcb0b1df4df2b4efd76bc98bc2bf7370ef0a137d83d141d2f3bd757007b0474c027245fc88f679c6da666cde2f0323179a0be50937fd4a22708bb4eaa0396
6
+ metadata.gz: 34b181f68921877a0e0afe55fd9e4ce91f3273323065c034f8dd63e0e0b85341e1ca27187b6f8e773e25816935615c6e33baf7aab262cf65244eebfdc217de2b
7
+ data.tar.gz: 9d7d119547de5453559936160ecc520e6d0db99620050c38b6297998b3f99e3e5938bb6875621bc2cdbee698c2d6e1f817743291fa15fb6c08a1435be39d2cd6
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Version 0.1.4
2
+ * Enhancements
3
+ * Add executable to make it fast to setup testing with exe `leap_salesforce_ui init`
4
+
1
5
  Version 0.1.3
2
6
  * Enhancements
3
7
  * Explicitly specify higher version of Watir as minimum which is compatible with Ruby 3
data/README.md CHANGED
@@ -40,9 +40,41 @@ LeapSalesforce.ui_user = 'test.user@salesforce.com'
40
40
  See [leap salesforce test users section](https://gitlab.com/leap-dojo/leap_salesforce#test-users)
41
41
  for details on ways to set test users.
42
42
 
43
+ ### Example spec_helper
44
+
45
+ Following is example code that can be used to setup and teardown each test.
46
+
47
+ ```ruby
48
+ require 'leap_salesforce_ui'
49
+ RSpec.configure do |config|
50
+ LeapSalesforce.ui_user = LeapSalesforce::Users.list.first
51
+ config.before(:each) do |example|
52
+ # Start browser with test name as metadata
53
+ LeapSalesforce.browser example.full_description
54
+ end
55
+
56
+ config.after(:each) do |example|
57
+ # Take screenshot on failure
58
+ screenshot = "logs/#{tidy_description(example.full_description.to_s)}_failure.png"
59
+ LeapSalesforce.browser.screenshot.save screenshot if example.exception
60
+ # Use a fresh browser for each test
61
+ LeapSalesforce.close_browser
62
+ end
63
+
64
+ # Tidy RSpec example description so it's suitable for a screenshot name
65
+ # @return [String] Description of test suitable for file name
66
+ def tidy_description(rspec_description)
67
+ rspec_description.delete("#<RSpec::Core::Example").delete('>".:{}').delete("=").delete(" ")
68
+ end
69
+ end
70
+ ```
71
+
43
72
  ### Populate form using label in metadata
44
73
 
45
- Following is a walk through of one of the tests
74
+ Following is a walk through of one of the tests. If you've copied the above code into `spec/spec_helper.rb`
75
+ you should be able to copy this code into a new test file and execute it.
76
+
77
+ > It may or may not work depending on how the fields Contact has in your org
46
78
 
47
79
  ```ruby
48
80
  RSpec.describe "Creating record" do
@@ -1,4 +1,46 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require "leap_salesforce_ui"
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "lib")
5
+
6
+ require "leap_salesforce/error"
7
+ require "thor"
8
+
9
+ def init_setup?
10
+ File.exist?(".leap_salesforce.yml")
11
+ end
12
+
13
+ unless init_setup?
14
+ puts "Setting up leap_salesforce API first"
15
+ Process.fork { exec("leap_salesforce init") }
16
+ Process.wait
17
+
18
+ raise LeapSalesforce::SetupError, "Unable to setup leap_salesforce" unless init_setup?
19
+ end
20
+
21
+ require "leap_salesforce_ui/version"
22
+ require "leap_salesforce_ui/generator/appenders"
23
+ require "colorize"
24
+
25
+ module LeapSalesforce
26
+ # Executable for setting up Leap Salesforce UI
27
+ class UiExe < Thor
28
+ include LeapSalesforce::Generators::Appenders
29
+
30
+ desc "init", "Create leap salesforce ui configuration"
31
+ def init
32
+ puts "Initialising initial files to get started with leap_salesforce_ui"
33
+ append "Rakefile", "Rakefile.erb"
34
+ puts 'Running Rake task "leaps:create_poms"'
35
+ puts `rake leaps:create_poms`
36
+ append File.join("spec", "spec_helper.rb"), "spec_helper.rb.erb"
37
+ append File.join("spec", "ui_spec.rb"), "ui_spec.rb.erb"
38
+ puts "Note test 'ui_spec' is specific to 'Contact' and 'Account' object using fields that
39
+ may not exist but purely as a demonstration."
40
+ end
41
+ end
42
+ end
43
+
44
+ puts "Using #{LeapSalesforceUi::VERSION} of LeapSalesforceUi"
45
+
46
+ LeapSalesforce::UiExe.start(ARGV)
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "leap_salesforce/generator/generator"
4
+
5
+ module LeapSalesforce
6
+ module Generators
7
+ # Used for appending content onto existing files (or adding if not already present)
8
+ module Appenders
9
+ include LeapSalesforce::Generator
10
+
11
+ # Create content in a file, adding to an existing file if present
12
+ def append(filename, template_path)
13
+ FileUtils.touch filename unless File.exist? filename
14
+ content = read_template template_path, binding, folder: __dir__
15
+ if File.read(filename).include?(content)
16
+ puts "File '#{filename}' already has expected content, skipping...".colorize :red
17
+ else
18
+ puts "\u2713 Appending to #{filename}".colorize :green
19
+ open(filename, "a") { |f| f.puts content }
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1 @@
1
+ require 'leap_salesforce_ui/rake'
@@ -0,0 +1,21 @@
1
+ require 'leap_salesforce_ui'
2
+ RSpec.configure do |config|
3
+ config.before(:each) do |example|
4
+ # Default to first test user defined for each test
5
+ LeapSalesforce.ui_user = LeapSalesforce::Users.list.first
6
+ # Start browser with test name as metadata
7
+ LeapSalesforce.browser example.full_description
8
+ end
9
+
10
+ config.after(:each) do |example|
11
+ screenshot = "logs/#{tidy_description(example.full_description.to_s)}_failure.png"
12
+ LeapSalesforce.browser.screenshot.save screenshot if example.exception
13
+ LeapSalesforce.close_browser # Fresh browser for each test
14
+ end
15
+
16
+ # Tidy RSpec example description so it's suitable for a screenshot name
17
+ # @return [String] Description of test suitable for file name
18
+ def tidy_description(rspec_description)
19
+ rspec_description.delete("#<RSpec::Core::Example").delete('>".:{}').delete("=").delete(" ")
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+
2
+ RSpec.describe "Creating record" do
3
+ let(:first_name) { Faker::Name.first_name }
4
+ let(:last_name) { Faker::Name.last_name }
5
+ let(:salutation) { Contact::Salutation.sample }
6
+ let(:other_street) { Faker::Address.full_address }
7
+ it "populate form and save" do
8
+ account = FactoryBot.create(:account)
9
+ CreateContactPage.visit.submit_with({ "First Name" => first_name,
10
+ last_name: last_name,
11
+ salutation: salutation,
12
+ other_street: other_street,
13
+ account_id: account.account_name })
14
+ contact_id = ViewContactPage.id
15
+ @contact = Contact.find(id: contact_id)
16
+ expect(@contact.first_name).to eq first_name
17
+ expect(@contact.last_name).to eq last_name
18
+ expect(@contact.salutation).to eq salutation
19
+ expect(@contact.other_street).to eq other_street
20
+ expect(@contact.account_id).to eq account.id
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LeapSalesforceUi
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leap_salesforce_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - IQA
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-02-09 00:00:00.000000000 Z
12
+ date: 2021-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: leap_salesforce
@@ -88,8 +88,12 @@ files:
88
88
  - lib/leap_salesforce_ui/base_page.rb
89
89
  - lib/leap_salesforce_ui/create_page.rb
90
90
  - lib/leap_salesforce_ui/form_filler.rb
91
+ - lib/leap_salesforce_ui/generator/appenders.rb
91
92
  - lib/leap_salesforce_ui/generator/page_objects.rb
93
+ - lib/leap_salesforce_ui/generator/templates/Rakefile.erb
92
94
  - lib/leap_salesforce_ui/generator/templates/create_page.rb.erb
95
+ - lib/leap_salesforce_ui/generator/templates/spec_helper.rb.erb
96
+ - lib/leap_salesforce_ui/generator/templates/ui_spec.rb.erb
93
97
  - lib/leap_salesforce_ui/generator/templates/update_page.rb.erb
94
98
  - lib/leap_salesforce_ui/generator/templates/view_page.rb.erb
95
99
  - lib/leap_salesforce_ui/login_page.rb