Skip to content

Commit

Permalink
Modified cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elsamaryv committed Nov 4, 2024
1 parent 6842f93 commit 2dcfb86
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 349 deletions.
34 changes: 1 addition & 33 deletions app/controllers/miq_ae_class_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class MiqAeClassController < ApplicationController

MIQ_AE_COPY_ACTIONS = %w[miq_ae_class_copy miq_ae_instance_copy miq_ae_method_copy].freeze

require 'byebug'

# GET /automation_classes
# GET /automation_classes.xml
def index
Expand Down Expand Up @@ -465,7 +463,6 @@ def edit_class
end
set_form_vars
@hide_bottom_bar = true

# have to get name and set node info, to load multiple tabs correctly
# rec_name = get_rec_name(@ae_class)
# get_node_info("aec-#{@ae_class.id}")
Expand All @@ -484,9 +481,7 @@ def edit_class_record
@hide_bottom_bar = true

class_rec = MiqAeClass.find(params[:id])
# if class_rec.default
# add_flash(_("Default Class \"%{name}\" can not be edited") % {:name => class_rec.name}, :error)
# end

render :json => {
:fqname => class_rec.fqname,
:name => class_rec.name,
Expand Down Expand Up @@ -1319,7 +1314,6 @@ def new
@ae_class = MiqAeClass.new
set_form_vars
@hide_bottom_bar = true

@in_a_form = true
replace_right_cell
end
Expand Down Expand Up @@ -1883,16 +1877,7 @@ def class_update_create
case params[:button]
when "add", "save"
class_rec = params[:id].blank? ? MiqAeClass.new : MiqAeClass.find(params[:id]) # Get new or existing record

# add_flash(_("Fully Qualified Name"), :error) if params[:fqname].blank?
add_flash(_("Name is required"), :error) if params[:name].blank?
# add_flash(_("Display Name is required"), :error) if params[:display_name].blank?

# if @flash_array
# javascript_flash
# return
# end
# class_rec.relative_path = params[:fqname]
class_rec.name = params[:name]
class_rec.display_name = params[:display_name]
class_rec.description = params[:description]
Expand All @@ -1907,34 +1892,17 @@ def class_update_create
javascript_flash
else
edit_hash = {}
# edit_hash[:new] = {:relative_path => params[:fqname], :name => params[:name],
# :display_name => params[:display_name], :description => params[:description]}

edit_hash[:new] = {:name => params[:name],
:display_name => params[:display_name], :description => params[:description]}

if params[:old_data]
# edit_hash[:current] = {:relative_path => params[:old_data][:fqname], :name => params[:old_data][:name],
# :display_name => params[:old_data][:display_name],
# :description => params[:old_data][:description]}

edit_hash[:current] = {:name => params[:old_data][:name],
:display_name => params[:old_data][:display_name],
:description => params[:old_data][:description]}
else
# edit_hash[:current] = {:relative_path => nil, :name => nil, :display_name => nil, :description => nil}
edit_hash[:current] = {:name => nil, :display_name => nil, :description => nil}
end
AuditEvent.success(build_saved_audit(class_rec, edit_hash))
@edit = session[:edit] = nil # clean out the saved info
# if editing from list view then change active_node to be same as updated image_type folder node
# if x_node.split('-')[0] == "xx"
# self.x_node = "xx-MiqDialog_#{dialog.dialog_type}"
# elsif params[:button] == "add"
# d = MiqDialog.find_by(:name => dialog.name, :dialog_type => dialog.dialog_type)
# self.x_node = "odg-#{d.id}"
# end
# get_node_info
replace_right_cell(:nodetype => x_node, :replace_trees => [:ae])
end
end
Expand Down
4 changes: 0 additions & 4 deletions app/javascript/components/miq-ae-class/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const MiqAeClass = ({ classRecord, fqname }) => {
const isEdit = !!(classRecord && classRecord.id);

useEffect(() => {
debugger
if (isEdit) {
http.get(`/miq_ae_class/edit_class_record/${classRecord.id}/`).then((recordValues) => {
if (recordValues) {
Expand All @@ -38,7 +37,6 @@ const MiqAeClass = ({ classRecord, fqname }) => {

const params = {
action: isEdit ? 'edit' : 'create',
// fqname: fqname,
name: values.name,
display_name: values.display_name,
description: values.description,
Expand Down Expand Up @@ -147,7 +145,6 @@ const FormTemplate = ({
MiqAeClass.propTypes = {
classRecord: PropTypes.shape({
id: PropTypes.number,
// fqname: PropTypes.string,
name: PropTypes.string,
display_name: PropTypes.string,
description: PropTypes.string,
Expand All @@ -161,7 +158,6 @@ MiqAeClass.defaultProps = {
FormTemplate.propTypes = {
formFields: PropTypes.arrayOf(
PropTypes.shape({ id: PropTypes.number }),
// PropTypes.shape({ fqname: PropTypes.string }),
PropTypes.shape({ name: PropTypes.string }),
PropTypes.shape({ display_name: PropTypes.string }),
PropTypes.shape({ description: PropTypes.string }),
Expand Down
22 changes: 0 additions & 22 deletions app/javascript/spec/miq-ae-class-form/miq-ae-class-form.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ describe('MiqAeClass Form Component', () => {
description: 'test description',
};

// const MiqAeClassCopyData = {
// name: 'test copy',
// display_name: 'test display name',
// description: 'test copy description',
// };

const fqName = 'Sample FQ Name';

afterEach(() => {
Expand Down Expand Up @@ -65,20 +59,4 @@ describe('MiqAeClass Form Component', () => {
});
});
});

// it('should render copy class form correctly', async() => {
// const wrapper = shallow(<MiqAeClass
// classRecord={MiqAeClassCopyData}
// fqname={fqName}
// />);
// fetchMock.get(`/miq_ae_customization/old_dialogs_copy?&expand=resources`, customizationMockData);

// await new Promise((resolve) => {
// setImmediate(() => {
// wrapper.update();
// expect(toJson(wrapper)).toMatchSnapshot();
// resolve();
// });
// });
// });
});
2 changes: 1 addition & 1 deletion app/views/miq_ae_class/_class_add.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#add_class_props_div
- if @in_a_form_fields && x_node.split('-')[0] == "aec" || params[:pressed] || %w(field_select field_accept field_delete).include?(params[:action])
#form_div
= render :partial => "class_form_new"
= render :partial => "class_form"
41 changes: 6 additions & 35 deletions app/views/miq_ae_class/_class_form.html.haml
Original file line number Diff line number Diff line change
@@ -1,35 +1,6 @@
- url = url_for_only_path(:action => 'form_field_changed', :id => (@ae_class.id || 'new'))
- obs = {:interval => '.5', :url => url}.to_json
%h3
= _('Properties')
.form-horizontal
.form-group
%label.col-md-2.control-label
= _('Fully Qualified Name')
.col-md-8
= @sb[:namespace_path]
.form-group
%label.col-md-2.control-label
= _('Name')
.col-md-8
= text_field_tag("name", @edit[:new][:name],
:maxlength => ViewHelper::MAX_NAME_LEN,
:class => "form-control",
"data-miq_observe" => obs)
= javascript_tag(javascript_focus('name'))
.form-group
%label.col-md-2.control-label
= _('Display Name')
.col-md-8
= text_field_tag("display_name", @edit[:new][:display_name],
:maxlength => ViewHelper::MAX_NAME_LEN,
:class => "form-control",
"data-miq_observe" => obs)
.form-group
%label.col-md-2.control-label
= _('Description')
.col-md-8
= text_field_tag("description", @edit[:new][:description],
:maxlength => ViewHelper::MAX_NAME_LEN,
:class => "form-control",
"data-miq_observe" => obs)
- if @ae_class
- if @in_a_form
= react('MiqAeClass',
:classRecord => @ae_class,
:fqname => @sb[:namespace_path])

7 changes: 0 additions & 7 deletions app/views/miq_ae_class/_class_form_new.html.haml

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/miq_ae_class/_class_props.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
- else
#form_div
%div{:style => "padding-top: 10px;"}
= render :partial => "class_form_new"
= render :partial => "class_form"
Loading

0 comments on commit 2dcfb86

Please sign in to comment.