From 35b46e4fa9ad0da9e19e24bbae3c58b99d29435c Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Herrero Date: Thu, 21 Jan 2021 12:40:50 +0100 Subject: [PATCH 1/9] M #-: fix provision minor bug (#685) --- src/oneprovision/lib/provision/provision.rb | 39 +++++++++++++-------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/oneprovision/lib/provision/provision.rb b/src/oneprovision/lib/provision/provision.rb index c4d8f83107..1e9b4eefa5 100644 --- a/src/oneprovision/lib/provision/provision.rb +++ b/src/oneprovision/lib/provision/provision.rb @@ -317,7 +317,7 @@ module OneProvision end if skip == :none - configure + configure_resources else info_objects('hosts', true) {|h| h.enable } end @@ -351,19 +351,7 @@ module OneProvision return OpenNebula::Error.new('Provision already configured') end - self.state = STATE['CONFIGURING'] - - update - - rc = Ansible.configure(hosts, datastores, self) - - if rc == 0 - self.state = STATE['RUNNING'] - else - self.state = STATE['ERROR'] - end - - update + configure_resources end # Deletes provision objects @@ -371,6 +359,8 @@ module OneProvision # @param cleanup [Boolean] True to delete running VMs and images # @param timeout [Integer] Timeout for deleting running VMs def delete(cleanup, timeout) + exist = true + if running_vms? && !cleanup Utils.fail('Provision with running VMs can\'t be deleted') end @@ -416,9 +406,13 @@ module OneProvision rc = super() + exist = false + return rc if OpenNebula.is_error?(rc) 0 + ensure + unlock if exist end # Updates provision objects @@ -691,6 +685,23 @@ module OneProvision end end + # Configures provision resources + def configure_resources + self.state = STATE['CONFIGURING'] + + update + + rc = Ansible.configure(hosts, datastores, self) + + if rc == 0 + self.state = STATE['RUNNING'] + else + self.state = STATE['ERROR'] + end + + update + end + # Updates provision hosts with new name # # @param ips [Array] IPs for each host From c95884aa5163ab86eabf2a19d52d97061e30fc4a Mon Sep 17 00:00:00 2001 From: "Carlos J. Herrera" Date: Thu, 21 Jan 2021 07:49:14 -0500 Subject: [PATCH 2/9] F #4001: default VM Templates in vCenter in MarketApp (#629) --- src/cli/onemarketapp | 17 ++++++- src/oca/ruby/opennebula/marketplaceapp_ext.rb | 44 ++++++++++++++----- src/vmm_mad/remotes/vcenter/vcenterrc | 5 ++- 3 files changed, 53 insertions(+), 13 deletions(-) diff --git a/src/cli/onemarketapp b/src/cli/onemarketapp index 708fd32bfb..057b4f8f65 100755 --- a/src/cli/onemarketapp +++ b/src/cli/onemarketapp @@ -42,6 +42,9 @@ require 'one_helper/onemarketapp_helper' require 'one_helper/onemarket_helper' require 'one_helper/onedatastore_helper' +require 'vcenter_driver' +CONFIG = VCenterConf.new + CommandParser::CmdParser.new(ARGV) do usage '`onemarket` [] []' version OpenNebulaHelper::ONE_VERSION @@ -101,6 +104,13 @@ CommandParser::CmdParser.new(ARGV) do end } + TEMPLATE = { + :name => 'template', + :large => '--template template_id ', + :description => 'Associate with VM template', + :format => Integer, + } + MARKET = { :name => 'market', :large => '--market market_id', @@ -123,7 +133,8 @@ CommandParser::CmdParser.new(ARGV) do OneDatastoreHelper::FILE_DATASTORE, OneMarketPlaceAppHelper::VMNAME, TAG, - NO] + NO, + TEMPLATE] IMPORT_OPTIONS = [YES, NO, MARKET, OneMarketPlaceAppHelper::VMNAME] ######################################################################## @@ -272,7 +283,9 @@ CommandParser::CmdParser.new(ARGV) do :name => args[1], :vmtemplate_name => options[:vmname], :url_args => tag, - :notemplate => options[:no] == 'no' + :notemplate => options[:no] == 'no', + :template => options[:template], + :default_template => CONFIG[:default_template], ) if OpenNebula.is_error?(rc) diff --git a/src/oca/ruby/opennebula/marketplaceapp_ext.rb b/src/oca/ruby/opennebula/marketplaceapp_ext.rb index d1badc655c..834107a192 100644 --- a/src/oca/ruby/opennebula/marketplaceapp_ext.rb +++ b/src/oca/ruby/opennebula/marketplaceapp_ext.rb @@ -89,12 +89,14 @@ module OpenNebula::MarketPlaceAppExt private # Exports an OpenNebula Image from this marketplace app - # @param optoins to export the image + # @param options to export the image # :vmtemplate_name [String] name of new image and template # :url_args [String] optional URL arguments # :dsid [String] Datastore id to create the image # :f_dsid [String] Files Datastore id # :notemplate [Bool] if true do not create vm_template (if any) + # :template [Integer] Template id to use with image + # :default_template [String] Default template id for vCenter # @return [Hash] # :image [Array] of the new image # :image_type [String] of the new image (CONTEXT, KERNEL, CDROM) @@ -181,19 +183,41 @@ module OpenNebula::MarketPlaceAppExt return rc_info end - tmpl = Base64.decode64(self['TEMPLATE/VMTEMPLATE64']) - tmpl << <<-EOT + if !options[:template].nil? + template_id = options[:template] - NAME = "#{options[:vmtemplate_name] || options[:name]}" - DISK = [ IMAGE_ID = "#{image.id}" ] - EOT + template_id = options[:default_template] if template_id == -1 - vmtpl = Template.new(Template.build_xml, @client) + template = Template.new_with_id(template_id, @client) - rc = vmtpl.allocate(tmpl) - rc = vmtpl.id unless OpenNebula.is_error?(rc) + vmtpl_id = template.clone(options[:vmtemplate_name] || options[:name]) - rc_info[:vmtemplate] = [rc] + tmpl << <<-EOT + + NAME = "#{options[:vmtemplate_name] || options[:name]}" + DISK = [ IMAGE_ID = "#{image.id}" ] + EOT + + template = Template.new_with_id(vmtpl_id, @client) + + template.update(tmpl, true) + + rc_info[:vmtemplate] = [vmtpl_id] + else + tmpl = Base64.decode64(self['TEMPLATE/VMTEMPLATE64']) + tmpl << <<-EOT + + NAME = "#{options[:vmtemplate_name] || options[:name]}" + DISK = [ IMAGE_ID = "#{image.id}" ] + EOT + + vmtpl = Template.new(Template.build_xml, @client) + + rc = vmtpl.allocate(tmpl) + rc = vmtpl.id unless OpenNebula.is_error?(rc) + + rc_info[:vmtemplate] = [rc] + end rc_info end diff --git a/src/vmm_mad/remotes/vcenter/vcenterrc b/src/vmm_mad/remotes/vcenter/vcenterrc index 52ea919a79..c85fc301f3 100644 --- a/src/vmm_mad/remotes/vcenter/vcenterrc +++ b/src/vmm_mad/remotes/vcenter/vcenterrc @@ -35,4 +35,7 @@ :memory_dumps: true # Cache expiration for monitoring -:cache_expire: 120 \ No newline at end of file +:cache_expire: 120 + +# Default template when import from MarketPlace +:default_template: -1 From 575b8ce23aeefb81960c7b19b7b1b3290e13b430 Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Herrero Date: Thu, 21 Jan 2021 13:57:50 +0100 Subject: [PATCH 3/9] M #-: fix provision minor bug in hosts (#686) --- src/cli/one_helper/oneprovision_helper.rb | 7 +++---- src/cli/oneprovision | 3 +-- src/oneprovision/lib/provision/ansible.rb | 2 +- src/oneprovision/lib/provision/resources/physical/host.rb | 7 ++----- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/cli/one_helper/oneprovision_helper.rb b/src/cli/one_helper/oneprovision_helper.rb index 982c6eeec8..9c528c1722 100644 --- a/src/cli/one_helper/oneprovision_helper.rb +++ b/src/cli/one_helper/oneprovision_helper.rb @@ -450,9 +450,8 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper # # @param host [OpenNebula::Host] # @param operation [String] Operation to perform - # @param options [Hash] User CLI options # @param args [Array] Operation arguments - def host_operation(host, operation, options, args) + def host_operation(host, operation, args) p_id = host['TEMPLATE/PROVISION/ID'] return OpenNebula::Error.new('No provision ID found') unless p_id @@ -471,7 +470,7 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper when 'delete' provision.update_objects('hosts', :remove, host.one['ID']) when 'configure' - host.configure((options.key? :force)) + host.configure when 'ssh' host.ssh(args) end @@ -503,7 +502,7 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper case type when 'HOSTS' - host_operation(obj, operation, options, args[1]) + host_operation(obj, operation, args[1]) else msg = "Deleting #{type} #{obj['ID']}" diff --git a/src/cli/oneprovision b/src/cli/oneprovision index e7ba66612e..bb6ab3146a 100755 --- a/src/cli/oneprovision +++ b/src/cli/oneprovision @@ -261,8 +261,7 @@ CommandParser::CmdParser.new(ARGV) do command [:host, :configure], host_configure_desc, [:range, :hostid_list], - :options => [OneProvisionHelper::MODES, - OneProvisionHelper::FORCE] do + :options => [OneProvisionHelper::MODES] do operation = { :operation => 'configure', :message => 'enabled' } rc = helper.resources_operation(args, operation, options, 'HOSTS') diff --git a/src/oneprovision/lib/provision/ansible.rb b/src/oneprovision/lib/provision/ansible.rb index d25c170843..28835cbdba 100644 --- a/src/oneprovision/lib/provision/ansible.rb +++ b/src/oneprovision/lib/provision/ansible.rb @@ -83,7 +83,7 @@ module OneProvision # @param hosts [OpenNebula::Datastore array] Datastores for vars # @param provision [OpenNebula::Provision] Provision info # @param ping [Boolean] True to check ping to hosts - def configure(hosts, datastores, provision = nil, ping = true) + def configure(hosts, datastores = nil, provision = nil, ping = true) return if hosts.nil? || hosts.empty? Driver.retry_loop('Failed to configure hosts', provision) do diff --git a/src/oneprovision/lib/provision/resources/physical/host.rb b/src/oneprovision/lib/provision/resources/physical/host.rb index a1dd051f1e..b6deb68504 100644 --- a/src/oneprovision/lib/provision/resources/physical/host.rb +++ b/src/oneprovision/lib/provision/resources/physical/host.rb @@ -204,11 +204,8 @@ module OneProvision end # Configures the HOST - # - # @param force [Boolean] Force the configuration if the HOST - # is already configured - def configure(force) - Ansible.configure([{ 'id' => @one['ID'] }], force) + def configure + Ansible.configure([{ 'id' => @one['ID'] }]) end # Checks that the HOST is a baremetal HOST From abdfc782d7ff1b76d2705ea7c52455a58f837ea6 Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Herrero Date: Thu, 21 Jan 2021 14:10:57 +0100 Subject: [PATCH 4/9] M #-: fix minor bug in app export (#689) --- src/oca/ruby/opennebula/marketplaceapp_ext.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/oca/ruby/opennebula/marketplaceapp_ext.rb b/src/oca/ruby/opennebula/marketplaceapp_ext.rb index 834107a192..1e72fb0a3e 100644 --- a/src/oca/ruby/opennebula/marketplaceapp_ext.rb +++ b/src/oca/ruby/opennebula/marketplaceapp_ext.rb @@ -242,7 +242,7 @@ module OpenNebula::MarketPlaceAppExt unless OpenNebula.is_error?(vmtmpl[0]) rc[:image] += vmtmpl[1] - rc[:vmtemplate] += vmtmpl[2] + rc[:vmtemplate] += vmtmpl[2] unless options[:notemplate] end rc From c946f8a81ebbd2b42d093d5d23167f2965a39306 Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Herrero Date: Thu, 21 Jan 2021 16:06:34 +0100 Subject: [PATCH 5/9] B #5235: force update cardinality in service (#688) --- src/flow/lib/LifeCycleManager.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flow/lib/LifeCycleManager.rb b/src/flow/lib/LifeCycleManager.rb index 662d311105..97476f5135 100644 --- a/src/flow/lib/LifeCycleManager.rb +++ b/src/flow/lib/LifeCycleManager.rb @@ -772,7 +772,7 @@ class ServiceLCM next unless role.nodes.find {|n| n['deploy_id'] == node } # just update if the cardinality is positive - set_cardinality(role, cardinality, false) if cardinality >= 0 + set_cardinality(role, cardinality, true) if cardinality >= 0 role.nodes.delete_if {|n| n['deploy_id'] == node } From 0becb9035e9ff9451bf5eed22f8df7c03765f411 Mon Sep 17 00:00:00 2001 From: Jan Orel Date: Thu, 21 Jan 2021 16:07:39 +0100 Subject: [PATCH 6/9] M #: Return non-zero after fail + success cleanup (#684) --- src/cli/oneprovision | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cli/oneprovision b/src/cli/oneprovision index bb6ab3146a..83bdce9fc6 100755 --- a/src/cli/oneprovision +++ b/src/cli/oneprovision @@ -123,6 +123,9 @@ CommandParser::CmdParser.new(ARGV) do if OpenNebula.is_error?(rc) STDERR.puts rc.message exit(-1) + elsif rc < 0 + puts "ID: #{rc}" + rc else puts "ID: #{rc}" 0 From 8d498b6a4784a13658f7d30e6d5f1c99762f5e2a Mon Sep 17 00:00:00 2001 From: Jan Orel Date: Fri, 22 Jan 2021 10:39:32 +0100 Subject: [PATCH 7/9] M #-: Fix lxd,firecracker probes (#691) --- install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install.sh b/install.sh index dafb77251a..6340eb5b56 100755 --- a/install.sh +++ b/install.sh @@ -352,12 +352,14 @@ VAR_DIRS="$VAR_LOCATION/remotes \ $VAR_LOCATION/remotes/im/lxd-probes.d/host/system \ $VAR_LOCATION/remotes/im/lxd-probes.d/vm/monitor \ $VAR_LOCATION/remotes/im/lxd-probes.d/vm/status \ + $VAR_LOCATION/remotes/im/lxd-probes.d/vm/snapshot \ $VAR_LOCATION/remotes/im/firecracker.d \ $VAR_LOCATION/remotes/im/firecracker-probes.d/host/beacon \ $VAR_LOCATION/remotes/im/firecracker-probes.d/host/monitor \ $VAR_LOCATION/remotes/im/firecracker-probes.d/host/system \ $VAR_LOCATION/remotes/im/firecracker-probes.d/vm/monitor \ $VAR_LOCATION/remotes/im/firecracker-probes.d/vm/status \ + $VAR_LOCATION/remotes/im/firecracker-probes.d/vm/snapshot \ $VAR_LOCATION/remotes/im/vcenter.d \ $VAR_LOCATION/remotes/im/ec2.d \ $VAR_LOCATION/remotes/im/ec2-probes.d/host/beacon \ From c4d7383b6543c3a9f13be9c986a439b5f4db017a Mon Sep 17 00:00:00 2001 From: Jorge Miguel Lobo Escalona <47326048+jloboescalona2@users.noreply.github.com> Date: Fri, 22 Jan 2021 11:19:40 +0100 Subject: [PATCH 8/9] F #3951: Excise tests (#692) Co-authored-by: Jorge Lobo --- src/fireedge/.eslintrc | 9 +- src/fireedge/cypress.json | 9 - src/fireedge/cypress/fixtures/defaults.json | 11 - .../integration/dashboard/index.spec.js | 16 - .../integration/examples/actions.spec.js | 272 ---------- .../integration/examples/aliasing.spec.js | 42 -- .../integration/examples/assertions.spec.js | 168 ------- .../integration/examples/connectors.spec.js | 56 --- .../integration/examples/cookies.spec.js | 78 --- .../integration/examples/cypress_api.spec.js | 222 -------- .../integration/examples/files.spec.js | 114 ----- .../examples/local_storage.spec.js | 52 -- .../integration/examples/location.spec.js | 32 -- .../cypress/integration/examples/misc.spec.js | 83 --- .../integration/examples/navigation.spec.js | 56 --- .../examples/network_requests.spec.js | 194 ------- .../integration/examples/querying.spec.js | 87 ---- .../examples/spies_stubs_clocks.spec.js | 95 ---- .../integration/examples/traversal.spec.js | 121 ----- .../integration/examples/utilities.spec.js | 133 ----- .../integration/examples/viewport.spec.js | 59 --- .../integration/examples/waiting.spec.js | 34 -- .../integration/examples/window.spec.js | 22 - .../cypress/integration/header/index.spec.js | 23 - .../cypress/integration/login/index.spec.js | 35 -- src/fireedge/cypress/plugins/index.js | 17 - src/fireedge/cypress/support/commands.js | 31 -- src/fireedge/cypress/support/index.js | 20 - src/fireedge/package-lock.json | 473 ++++++++++++++++-- src/fireedge/package.json | 5 +- .../client/components/Cards/ProvisionCard.js | 4 +- .../components/Cards/ProvisionTemplateCard.js | 4 +- .../client/components/FormStepper/Stepper.js | 2 +- .../client/components/List/ListCards/index.js | 13 +- .../Form/Create/Steps/Template/index.js | 5 +- .../containers/Providers/Sections/info.js | 8 +- .../src/client/containers/Providers/index.js | 7 +- .../containers/Provisions/DialogInfo/info.js | 8 +- .../Form/Create/Steps/Provider/index.js | 1 + .../Form/Create/Steps/Template/index.js | 5 +- .../src/client/containers/Provisions/index.js | 7 +- 41 files changed, 483 insertions(+), 2150 deletions(-) delete mode 100644 src/fireedge/cypress.json delete mode 100644 src/fireedge/cypress/fixtures/defaults.json delete mode 100644 src/fireedge/cypress/integration/dashboard/index.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/actions.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/aliasing.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/assertions.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/connectors.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/cookies.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/cypress_api.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/files.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/local_storage.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/location.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/misc.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/navigation.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/network_requests.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/querying.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/spies_stubs_clocks.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/traversal.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/utilities.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/viewport.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/waiting.spec.js delete mode 100644 src/fireedge/cypress/integration/examples/window.spec.js delete mode 100644 src/fireedge/cypress/integration/header/index.spec.js delete mode 100644 src/fireedge/cypress/integration/login/index.spec.js delete mode 100644 src/fireedge/cypress/plugins/index.js delete mode 100644 src/fireedge/cypress/support/commands.js delete mode 100644 src/fireedge/cypress/support/index.js diff --git a/src/fireedge/.eslintrc b/src/fireedge/.eslintrc index 1bc7e45a53..22108bb5a8 100644 --- a/src/fireedge/.eslintrc +++ b/src/fireedge/.eslintrc @@ -2,8 +2,7 @@ "env": { "browser": true, "es2021": true, - "node": true, - "cypress/globals": true + "node": true }, "extends": [ "plugin:react/recommended", @@ -16,12 +15,8 @@ "ecmaVersion": 12, "sourceType": "module" }, - "plugins": ["react", "cypress"], + "plugins": ["react"], "rules": { - "cypress/no-assigning-return-values": "error", - "cypress/no-unnecessary-waiting": "error", - "cypress/assertion-before-screenshot": "warn", - "cypress/no-async-tests": "error", "import/no-extraneous-dependencies": [ "error", { diff --git a/src/fireedge/cypress.json b/src/fireedge/cypress.json deleted file mode 100644 index f74b72a8ce..0000000000 --- a/src/fireedge/cypress.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "port": 3001, - "numTestsKeptInMemory": 20, - "env":{}, - "video": false, - "viewportHeight": 720, - "viewportWidth": 1280, - "baseUrl": "http://localhost:3000" -} diff --git a/src/fireedge/cypress/fixtures/defaults.json b/src/fireedge/cypress/fixtures/defaults.json deleted file mode 100644 index f6f0acec7b..0000000000 --- a/src/fireedge/cypress/fixtures/defaults.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "auth": { - "jwtName": "FireedgeToken", - "username": "oneadmin", - "password": "opennebula" - }, - "endpoints": { - "login": "/api/auth/", - "userInfo": "/api/user/info" - } -} \ No newline at end of file diff --git a/src/fireedge/cypress/integration/dashboard/index.spec.js b/src/fireedge/cypress/integration/dashboard/index.spec.js deleted file mode 100644 index 3bb5060922..0000000000 --- a/src/fireedge/cypress/integration/dashboard/index.spec.js +++ /dev/null @@ -1,16 +0,0 @@ -// / - -context('Dashboard', () => { - before(() => { - cy.visit('/'); - cy.login(); - }); - - after(() => { - cy.logout(); - }); - - it('has dashboard title on header', () => { - cy.get('[data-cy=header-title]').should('have.text', 'dashboard'); - }); -}); diff --git a/src/fireedge/cypress/integration/examples/actions.spec.js b/src/fireedge/cypress/integration/examples/actions.spec.js deleted file mode 100644 index 20e12cc6df..0000000000 --- a/src/fireedge/cypress/integration/examples/actions.spec.js +++ /dev/null @@ -1,272 +0,0 @@ -/// - -context('Actions', () => { - beforeEach(() => { - cy.visit('https://example.cypress.io/commands/actions') - }) - - // https://on.cypress.io/interacting-with-elements - - it('.type() - type into a DOM element', () => { - // https://on.cypress.io/type - cy.get('.action-email') - .type('fake@email.com').should('have.value', 'fake@email.com') - - // .type() with special character sequences - .type('{leftarrow}{rightarrow}{uparrow}{downarrow}') - .type('{del}{selectall}{backspace}') - - // .type() with key modifiers - .type('{alt}{option}') //these are equivalent - .type('{ctrl}{control}') //these are equivalent - .type('{meta}{command}{cmd}') //these are equivalent - .type('{shift}') - - // Delay each keypress by 0.1 sec - .type('slow.typing@email.com', { delay: 100 }) - .should('have.value', 'slow.typing@email.com') - - cy.get('.action-disabled') - // Ignore error checking prior to type - // like whether the input is visible or disabled - .type('disabled error checking', { force: true }) - .should('have.value', 'disabled error checking') - }) - - it('.focus() - focus on a DOM element', () => { - // https://on.cypress.io/focus - cy.get('.action-focus').focus() - .should('have.class', 'focus') - .prev().should('have.attr', 'style', 'color: orange;') - }) - - it('.blur() - blur off a DOM element', () => { - // https://on.cypress.io/blur - cy.get('.action-blur').type('About to blur').blur() - .should('have.class', 'error') - .prev().should('have.attr', 'style', 'color: red;') - }) - - it('.clear() - clears an input or textarea element', () => { - // https://on.cypress.io/clear - cy.get('.action-clear').type('Clear this text') - .should('have.value', 'Clear this text') - .clear() - .should('have.value', '') - }) - - it('.submit() - submit a form', () => { - // https://on.cypress.io/submit - cy.get('.action-form') - .find('[type="text"]').type('HALFOFF') - cy.get('.action-form').submit() - .next().should('contain', 'Your form has been submitted!') - }) - - it('.click() - click on a DOM element', () => { - // https://on.cypress.io/click - cy.get('.action-btn').click() - - // You can click on 9 specific positions of an element: - // ----------------------------------- - // | topLeft top topRight | - // | | - // | | - // | | - // | left center right | - // | | - // | | - // | | - // | bottomLeft bottom bottomRight | - // ----------------------------------- - - // clicking in the center of the element is the default - cy.get('#action-canvas').click() - - cy.get('#action-canvas').click('topLeft') - cy.get('#action-canvas').click('top') - cy.get('#action-canvas').click('topRight') - cy.get('#action-canvas').click('left') - cy.get('#action-canvas').click('right') - cy.get('#action-canvas').click('bottomLeft') - cy.get('#action-canvas').click('bottom') - cy.get('#action-canvas').click('bottomRight') - - // .click() accepts an x and y coordinate - // that controls where the click occurs :) - - cy.get('#action-canvas') - .click(80, 75) // click 80px on x coord and 75px on y coord - .click(170, 75) - .click(80, 165) - .click(100, 185) - .click(125, 190) - .click(150, 185) - .click(170, 165) - - // click multiple elements by passing multiple: true - cy.get('.action-labels>.label').click({ multiple: true }) - - // Ignore error checking prior to clicking - cy.get('.action-opacity>.btn').click({ force: true }) - }) - - it('.dblclick() - double click on a DOM element', () => { - // https://on.cypress.io/dblclick - - // Our app has a listener on 'dblclick' event in our 'scripts.js' - // that hides the div and shows an input on double click - cy.get('.action-div').dblclick().should('not.be.visible') - cy.get('.action-input-hidden').should('be.visible') - }) - - it('.check() - check a checkbox or radio element', () => { - // https://on.cypress.io/check - - // By default, .check() will check all - // matching checkbox or radio elements in succession, one after another - cy.get('.action-checkboxes [type="checkbox"]').not('[disabled]') - .check().should('be.checked') - - cy.get('.action-radios [type="radio"]').not('[disabled]') - .check().should('be.checked') - - // .check() accepts a value argument - cy.get('.action-radios [type="radio"]') - .check('radio1').should('be.checked') - - // .check() accepts an array of values - cy.get('.action-multiple-checkboxes [type="checkbox"]') - .check(['checkbox1', 'checkbox2']).should('be.checked') - - // Ignore error checking prior to checking - cy.get('.action-checkboxes [disabled]') - .check({ force: true }).should('be.checked') - - cy.get('.action-radios [type="radio"]') - .check('radio3', { force: true }).should('be.checked') - }) - - it('.uncheck() - uncheck a checkbox element', () => { - // https://on.cypress.io/uncheck - - // By default, .uncheck() will uncheck all matching - // checkbox elements in succession, one after another - cy.get('.action-check [type="checkbox"]') - .not('[disabled]') - .uncheck().should('not.be.checked') - - // .uncheck() accepts a value argument - cy.get('.action-check [type="checkbox"]') - .check('checkbox1') - .uncheck('checkbox1').should('not.be.checked') - - // .uncheck() accepts an array of values - cy.get('.action-check [type="checkbox"]') - .check(['checkbox1', 'checkbox3']) - .uncheck(['checkbox1', 'checkbox3']).should('not.be.checked') - - // Ignore error checking prior to unchecking - cy.get('.action-check [disabled]') - .uncheck({ force: true }).should('not.be.checked') - }) - - it('.select() - select an option in a ({ {provisionSelected && ({ {provisionSelected &&