foreman_remote_execution 4.8.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/api/v2/job_invocations_controller.rb +9 -0
- data/app/controllers/ui_job_wizard_controller.rb +16 -4
- data/app/graphql/mutations/job_invocations/create.rb +43 -0
- data/app/graphql/types/job_invocation_input.rb +13 -0
- data/app/graphql/types/recurrence_input.rb +8 -0
- data/app/graphql/types/scheduling_input.rb +6 -0
- data/app/graphql/types/targeting_enum.rb +7 -0
- data/app/lib/actions/remote_execution/run_host_job.rb +4 -0
- data/app/models/concerns/foreman_remote_execution/host_extensions.rb +8 -0
- data/app/models/job_invocation_composer.rb +1 -1
- data/app/models/targeting.rb +2 -2
- data/app/views/job_invocations/refresh.js.erb +1 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20210816100932_rex_setting_category_to_dsl.rb +5 -0
- data/lib/foreman_remote_execution/engine.rb +110 -6
- data/lib/foreman_remote_execution/version.rb +1 -1
- data/package.json +6 -6
- data/test/functional/api/v2/job_invocations_controller_test.rb +10 -0
- data/test/functional/cockpit_controller_test.rb +0 -1
- data/test/graphql/mutations/job_invocations/create.rb +58 -0
- data/test/helpers/remote_execution_helper_test.rb +0 -1
- data/test/unit/actions/run_host_job_test.rb +21 -0
- data/test/unit/concerns/host_extensions_test.rb +36 -3
- data/test/unit/job_invocation_composer_test.rb +3 -5
- data/test/unit/job_invocation_report_template_test.rb +1 -1
- data/test/unit/job_template_effective_user_test.rb +0 -4
- data/test/unit/remote_execution_provider_test.rb +0 -4
- data/test/unit/targeting_test.rb +68 -1
- data/webpack/JobWizard/JobWizard.js +94 -13
- data/webpack/JobWizard/JobWizard.scss +59 -35
- data/webpack/JobWizard/JobWizardConstants.js +28 -1
- data/webpack/JobWizard/JobWizardSelectors.js +32 -0
- data/webpack/JobWizard/__tests__/fixtures.js +81 -6
- data/webpack/JobWizard/__tests__/integration.test.js +26 -15
- data/webpack/JobWizard/__tests__/validation.test.js +141 -0
- data/webpack/JobWizard/autofill.js +38 -0
- data/webpack/JobWizard/index.js +7 -0
- data/webpack/JobWizard/steps/AdvancedFields/AdvancedFields.js +7 -4
- data/webpack/JobWizard/steps/AdvancedFields/DescriptionField.js +32 -9
- data/webpack/JobWizard/steps/AdvancedFields/__tests__/AdvancedFields.test.js +216 -12
- data/webpack/JobWizard/steps/AdvancedFields/__tests__/__snapshots__/AdvancedFields.test.js.snap +82 -0
- data/webpack/JobWizard/steps/CategoryAndTemplate/CategoryAndTemplate.js +1 -0
- data/webpack/JobWizard/steps/CategoryAndTemplate/index.js +3 -2
- data/webpack/JobWizard/steps/HostsAndInputs/HostPreviewModal.js +62 -0
- data/webpack/JobWizard/steps/HostsAndInputs/HostSearch.js +54 -0
- data/webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js +33 -0
- data/webpack/JobWizard/steps/HostsAndInputs/SelectGQL.js +52 -0
- data/webpack/JobWizard/steps/HostsAndInputs/SelectedChips.js +82 -7
- data/webpack/JobWizard/steps/HostsAndInputs/__tests__/HostsAndInputs.test.js +151 -0
- data/webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js +7 -4
- data/webpack/JobWizard/steps/HostsAndInputs/buildHostQuery.js +18 -0
- data/webpack/JobWizard/steps/HostsAndInputs/hostgroups.gql +8 -0
- data/webpack/JobWizard/steps/HostsAndInputs/hosts.gql +8 -0
- data/webpack/JobWizard/steps/HostsAndInputs/index.js +182 -34
- data/webpack/JobWizard/steps/ReviewDetails/index.js +193 -0
- data/webpack/JobWizard/steps/Schedule/PurposeField.js +31 -0
- data/webpack/JobWizard/steps/Schedule/QueryType.js +46 -43
- data/webpack/JobWizard/steps/Schedule/RepeatCron.js +53 -0
- data/webpack/JobWizard/steps/Schedule/RepeatDaily.js +37 -0
- data/webpack/JobWizard/steps/Schedule/RepeatHour.js +54 -0
- data/webpack/JobWizard/steps/Schedule/RepeatMonth.js +46 -0
- data/webpack/JobWizard/steps/Schedule/RepeatOn.js +95 -31
- data/webpack/JobWizard/steps/Schedule/RepeatWeek.js +70 -0
- data/webpack/JobWizard/steps/Schedule/StartEndDates.js +59 -19
- data/webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js +258 -11
- data/webpack/JobWizard/steps/Schedule/__tests__/StartEndDates.test.js +11 -2
- data/webpack/JobWizard/steps/Schedule/index.js +97 -21
- data/webpack/JobWizard/steps/form/DateTimePicker.js +41 -8
- data/webpack/JobWizard/steps/form/FormHelpers.js +4 -0
- data/webpack/JobWizard/steps/form/Formatter.js +39 -8
- data/webpack/JobWizard/steps/form/NumberInput.js +3 -2
- data/webpack/JobWizard/steps/form/ResourceSelect.js +29 -0
- data/webpack/JobWizard/steps/form/SearchSelect.js +121 -0
- data/webpack/JobWizard/steps/form/SelectField.js +14 -3
- data/webpack/JobWizard/steps/form/__tests__/SelectSearch.test.js +33 -0
- data/webpack/JobWizard/submit.js +120 -0
- data/webpack/JobWizard/validation.js +53 -0
- data/webpack/__mocks__/foremanReact/Root/Context/ForemanContext/index.js +2 -0
- data/webpack/__mocks__/foremanReact/common/I18n.js +2 -0
- data/webpack/__mocks__/foremanReact/components/AutoComplete/AutoCompleteActions.js +1 -0
- data/webpack/__mocks__/foremanReact/components/AutoComplete/AutoCompleteConstants.js +1 -0
- data/webpack/__mocks__/foremanReact/routes/RouterSelector.js +1 -0
- data/webpack/helpers.js +1 -0
- data/webpack/react_app/components/RecentJobsCard/RecentJobsCard.js +1 -1
- metadata +38 -6
- data/app/models/setting/remote_execution.rb +0 -94
- data/webpack/JobWizard/steps/AdvancedFields/__tests__/DescriptionField.test.js +0 -23
- data/webpack/JobWizard/steps/HostsAndInputs/__tests__/SelectedChips.test.js +0 -37
- data/webpack/JobWizard/steps/form/__tests__/Formatter.test.js.example +0 -76
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_remote_execution
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Foreman Remote Execution team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -136,7 +136,12 @@ files:
|
|
136
136
|
- app/controllers/remote_execution_features_controller.rb
|
137
137
|
- app/controllers/template_invocations_controller.rb
|
138
138
|
- app/controllers/ui_job_wizard_controller.rb
|
139
|
+
- app/graphql/mutations/job_invocations/create.rb
|
139
140
|
- app/graphql/types/job_invocation.rb
|
141
|
+
- app/graphql/types/job_invocation_input.rb
|
142
|
+
- app/graphql/types/recurrence_input.rb
|
143
|
+
- app/graphql/types/scheduling_input.rb
|
144
|
+
- app/graphql/types/targeting_enum.rb
|
140
145
|
- app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb
|
141
146
|
- app/helpers/concerns/foreman_remote_execution/job_templates_extensions.rb
|
142
147
|
- app/helpers/job_invocation_output_helper.rb
|
@@ -179,7 +184,6 @@ files:
|
|
179
184
|
- app/models/remote_execution_feature.rb
|
180
185
|
- app/models/remote_execution_provider.rb
|
181
186
|
- app/models/rex_mail_notification.rb
|
182
|
-
- app/models/setting/remote_execution.rb
|
183
187
|
- app/models/ssh_execution_provider.rb
|
184
188
|
- app/models/target_remote_execution_proxy.rb
|
185
189
|
- app/models/targeting.rb
|
@@ -317,6 +321,7 @@ files:
|
|
317
321
|
- db/migrate/20200820122057_add_proxy_selector_override_to_remote_execution_feature.rb
|
318
322
|
- db/migrate/20210312074713_add_provider_inputs.rb
|
319
323
|
- db/migrate/2021051713291621250977_add_host_proxy_invocations.rb
|
324
|
+
- db/migrate/20210816100932_rex_setting_category_to_dsl.rb
|
320
325
|
- db/seeds.d/100-assign_features_with_templates.rb
|
321
326
|
- db/seeds.d/20-permissions.rb
|
322
327
|
- db/seeds.d/50-notification_blueprints.rb
|
@@ -373,6 +378,7 @@ files:
|
|
373
378
|
- test/functional/job_invocations_controller_test.rb
|
374
379
|
- test/functional/job_templates_controller_test.rb
|
375
380
|
- test/functional/ui_job_wizard_controller_test.rb
|
381
|
+
- test/graphql/mutations/job_invocations/create.rb
|
376
382
|
- test/graphql/queries/job_invocation_query_test.rb
|
377
383
|
- test/graphql/queries/job_invocations_query_test.rb
|
378
384
|
- test/helpers/remote_execution_helper_test.rb
|
@@ -402,22 +408,38 @@ files:
|
|
402
408
|
- webpack/JobWizard/__tests__/__snapshots__/integration.test.js.snap
|
403
409
|
- webpack/JobWizard/__tests__/fixtures.js
|
404
410
|
- webpack/JobWizard/__tests__/integration.test.js
|
411
|
+
- webpack/JobWizard/__tests__/validation.test.js
|
412
|
+
- webpack/JobWizard/autofill.js
|
405
413
|
- webpack/JobWizard/index.js
|
406
414
|
- webpack/JobWizard/steps/AdvancedFields/AdvancedFields.js
|
407
415
|
- webpack/JobWizard/steps/AdvancedFields/DescriptionField.js
|
408
416
|
- webpack/JobWizard/steps/AdvancedFields/Fields.js
|
409
417
|
- webpack/JobWizard/steps/AdvancedFields/__tests__/AdvancedFields.test.js
|
410
|
-
- webpack/JobWizard/steps/AdvancedFields/__tests__/
|
418
|
+
- webpack/JobWizard/steps/AdvancedFields/__tests__/__snapshots__/AdvancedFields.test.js.snap
|
411
419
|
- webpack/JobWizard/steps/CategoryAndTemplate/CategoryAndTemplate.js
|
412
420
|
- webpack/JobWizard/steps/CategoryAndTemplate/CategoryAndTemplate.test.js
|
413
421
|
- webpack/JobWizard/steps/CategoryAndTemplate/index.js
|
422
|
+
- webpack/JobWizard/steps/HostsAndInputs/HostPreviewModal.js
|
423
|
+
- webpack/JobWizard/steps/HostsAndInputs/HostSearch.js
|
424
|
+
- webpack/JobWizard/steps/HostsAndInputs/SelectAPI.js
|
425
|
+
- webpack/JobWizard/steps/HostsAndInputs/SelectGQL.js
|
414
426
|
- webpack/JobWizard/steps/HostsAndInputs/SelectedChips.js
|
415
427
|
- webpack/JobWizard/steps/HostsAndInputs/TemplateInputs.js
|
416
|
-
- webpack/JobWizard/steps/HostsAndInputs/__tests__/
|
428
|
+
- webpack/JobWizard/steps/HostsAndInputs/__tests__/HostsAndInputs.test.js
|
417
429
|
- webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
|
430
|
+
- webpack/JobWizard/steps/HostsAndInputs/buildHostQuery.js
|
431
|
+
- webpack/JobWizard/steps/HostsAndInputs/hostgroups.gql
|
432
|
+
- webpack/JobWizard/steps/HostsAndInputs/hosts.gql
|
418
433
|
- webpack/JobWizard/steps/HostsAndInputs/index.js
|
434
|
+
- webpack/JobWizard/steps/ReviewDetails/index.js
|
435
|
+
- webpack/JobWizard/steps/Schedule/PurposeField.js
|
419
436
|
- webpack/JobWizard/steps/Schedule/QueryType.js
|
437
|
+
- webpack/JobWizard/steps/Schedule/RepeatCron.js
|
438
|
+
- webpack/JobWizard/steps/Schedule/RepeatDaily.js
|
439
|
+
- webpack/JobWizard/steps/Schedule/RepeatHour.js
|
440
|
+
- webpack/JobWizard/steps/Schedule/RepeatMonth.js
|
420
441
|
- webpack/JobWizard/steps/Schedule/RepeatOn.js
|
442
|
+
- webpack/JobWizard/steps/Schedule/RepeatWeek.js
|
421
443
|
- webpack/JobWizard/steps/Schedule/ScheduleType.js
|
422
444
|
- webpack/JobWizard/steps/Schedule/StartEndDates.js
|
423
445
|
- webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js
|
@@ -428,12 +450,19 @@ files:
|
|
428
450
|
- webpack/JobWizard/steps/form/Formatter.js
|
429
451
|
- webpack/JobWizard/steps/form/GroupedSelectField.js
|
430
452
|
- webpack/JobWizard/steps/form/NumberInput.js
|
453
|
+
- webpack/JobWizard/steps/form/ResourceSelect.js
|
454
|
+
- webpack/JobWizard/steps/form/SearchSelect.js
|
431
455
|
- webpack/JobWizard/steps/form/SelectField.js
|
432
456
|
- webpack/JobWizard/steps/form/WizardTitle.js
|
433
|
-
- webpack/JobWizard/steps/form/__tests__/
|
457
|
+
- webpack/JobWizard/steps/form/__tests__/SelectSearch.test.js
|
458
|
+
- webpack/JobWizard/submit.js
|
459
|
+
- webpack/JobWizard/validation.js
|
434
460
|
- webpack/Routes/routes.js
|
461
|
+
- webpack/__mocks__/foremanReact/Root/Context/ForemanContext/index.js
|
435
462
|
- webpack/__mocks__/foremanReact/common/I18n.js
|
436
463
|
- webpack/__mocks__/foremanReact/common/helpers.js
|
464
|
+
- webpack/__mocks__/foremanReact/components/AutoComplete/AutoCompleteActions.js
|
465
|
+
- webpack/__mocks__/foremanReact/components/AutoComplete/AutoCompleteConstants.js
|
437
466
|
- webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js
|
438
467
|
- webpack/__mocks__/foremanReact/components/SearchBar.js
|
439
468
|
- webpack/__mocks__/foremanReact/components/common/ActionButtons/ActionButtons.js
|
@@ -442,8 +471,10 @@ files:
|
|
442
471
|
- webpack/__mocks__/foremanReact/redux/API/APISelectors.js
|
443
472
|
- webpack/__mocks__/foremanReact/redux/API/index.js
|
444
473
|
- webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware/IntervalSelectors.js
|
474
|
+
- webpack/__mocks__/foremanReact/routes/RouterSelector.js
|
445
475
|
- webpack/__mocks__/foremanReact/routes/common/PageLayout/PageLayout.js
|
446
476
|
- webpack/global_index.js
|
477
|
+
- webpack/helpers.js
|
447
478
|
- webpack/index.js
|
448
479
|
- webpack/react_app/components/RecentJobsCard/JobStatusIcon.js
|
449
480
|
- webpack/react_app/components/RecentJobsCard/RecentJobsCard.js
|
@@ -525,6 +556,7 @@ test_files:
|
|
525
556
|
- test/functional/job_invocations_controller_test.rb
|
526
557
|
- test/functional/job_templates_controller_test.rb
|
527
558
|
- test/functional/ui_job_wizard_controller_test.rb
|
559
|
+
- test/graphql/mutations/job_invocations/create.rb
|
528
560
|
- test/graphql/queries/job_invocation_query_test.rb
|
529
561
|
- test/graphql/queries/job_invocations_query_test.rb
|
530
562
|
- test/helpers/remote_execution_helper_test.rb
|
@@ -1,94 +0,0 @@
|
|
1
|
-
class Setting::RemoteExecution < Setting
|
2
|
-
|
3
|
-
::Setting::BLANK_ATTRS.concat %w{remote_execution_ssh_password remote_execution_ssh_key_passphrase remote_execution_sudo_password remote_execution_effective_user_password remote_execution_cockpit_url remote_execution_form_job_template}
|
4
|
-
|
5
|
-
def self.default_settings
|
6
|
-
[
|
7
|
-
self.set('remote_execution_fallback_proxy',
|
8
|
-
N_('Search the host for any proxy with Remote Execution, useful when the host has no subnet or the subnet does not have an execution proxy'),
|
9
|
-
false,
|
10
|
-
N_('Fallback to Any Proxy')),
|
11
|
-
self.set('remote_execution_global_proxy',
|
12
|
-
N_('Search for remote execution proxy outside of the proxies assigned to the host. ' +
|
13
|
-
"The search will be limited to the host's organization and location."),
|
14
|
-
true,
|
15
|
-
N_('Enable Global Proxy')),
|
16
|
-
self.set('remote_execution_ssh_user',
|
17
|
-
N_('Default user to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_user.'),
|
18
|
-
'root',
|
19
|
-
N_('SSH User')),
|
20
|
-
self.set('remote_execution_effective_user',
|
21
|
-
N_('Default user to use for executing the script. If the user differs from the SSH user, su or sudo is used to switch the user.'),
|
22
|
-
'root',
|
23
|
-
N_('Effective User')),
|
24
|
-
self.set('remote_execution_effective_user_method',
|
25
|
-
N_('What command should be used to switch to the effective user. One of %s') % SSHExecutionProvider::EFFECTIVE_USER_METHODS.inspect,
|
26
|
-
'sudo',
|
27
|
-
N_('Effective User Method'),
|
28
|
-
nil,
|
29
|
-
{ :collection => proc { Hash[SSHExecutionProvider::EFFECTIVE_USER_METHODS.map { |method| [method, method] }] } }),
|
30
|
-
self.set('remote_execution_effective_user_password', N_("Effective user password"), '', N_("Effective user password"), nil, {:encrypted => true}),
|
31
|
-
self.set('remote_execution_sync_templates',
|
32
|
-
N_('Whether we should sync templates from disk when running db:seed.'),
|
33
|
-
true,
|
34
|
-
N_('Sync Job Templates')),
|
35
|
-
self.set('remote_execution_ssh_port',
|
36
|
-
N_('Port to use for SSH communication. Default port 22. You may override per host by setting a parameter called remote_execution_ssh_port.'),
|
37
|
-
'22',
|
38
|
-
N_('SSH Port')),
|
39
|
-
self.set('remote_execution_connect_by_ip',
|
40
|
-
N_('Should the ip addresses on host interfaces be preferred over the fqdn? '\
|
41
|
-
'It is useful when DNS not resolving the fqdns properly. You may override this per host by setting a parameter called remote_execution_connect_by_ip. '\
|
42
|
-
'For dual-stacked hosts you should consider the remote_execution_connect_by_ip_prefer_ipv6 setting'),
|
43
|
-
false,
|
44
|
-
N_('Connect by IP')),
|
45
|
-
self.set('remote_execution_connect_by_ip_prefer_ipv6',
|
46
|
-
N_('When connecting using ip address, should the IPv6 addresses be preferred? '\
|
47
|
-
'If no IPv6 address is set, it falls back to IPv4 automatically. You may override this per host by setting a parameter called remote_execution_connect_by_ip_prefer_ipv6. '\
|
48
|
-
'By default and for compatibility, IPv4 will be preferred over IPv6 by default'),
|
49
|
-
false,
|
50
|
-
N_('Prefer IPv6 over IPv4')),
|
51
|
-
self.set('remote_execution_ssh_password',
|
52
|
-
N_('Default password to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_password'),
|
53
|
-
nil,
|
54
|
-
N_('Default SSH password'),
|
55
|
-
nil,
|
56
|
-
{ :encrypted => true }),
|
57
|
-
self.set('remote_execution_ssh_key_passphrase',
|
58
|
-
N_('Default key passphrase to use for SSH. You may override per host by setting a parameter called remote_execution_ssh_key_passphrase'),
|
59
|
-
nil,
|
60
|
-
N_('Default SSH key passphrase'),
|
61
|
-
nil,
|
62
|
-
{ :encrypted => true }),
|
63
|
-
self.set('remote_execution_workers_pool_size',
|
64
|
-
N_('Amount of workers in the pool to handle the execution of the remote execution jobs. Restart of the dynflowd/foreman-tasks service is required.'),
|
65
|
-
5,
|
66
|
-
N_('Workers pool size')),
|
67
|
-
self.set('remote_execution_cleanup_working_dirs',
|
68
|
-
N_('When enabled, working directories will be removed after task completion. You may override this per host by setting a parameter called remote_execution_cleanup_working_dirs.'),
|
69
|
-
true,
|
70
|
-
N_('Cleanup working directories')),
|
71
|
-
self.set('remote_execution_cockpit_url',
|
72
|
-
N_('Where to find the Cockpit instance for the Web Console button. By default, no button is shown.'),
|
73
|
-
nil,
|
74
|
-
N_('Cockpit URL'),
|
75
|
-
nil),
|
76
|
-
self.set('remote_execution_form_job_template',
|
77
|
-
N_('Choose a job template that is pre-selected in job invocation form'),
|
78
|
-
'Run Command - SSH Default',
|
79
|
-
N_('Form Job Template'),
|
80
|
-
nil,
|
81
|
-
{ :collection => proc { Hash[JobTemplate.unscoped.map { |template| [template.name, template.name] }] } }),
|
82
|
-
self.set('remote_execution_job_invocation_report_template',
|
83
|
-
N_('Select a report template used for generating a report for a particular remote execution job'),
|
84
|
-
'Jobs - Invocation report template',
|
85
|
-
N_('Job Invocation Report Template'),
|
86
|
-
nil,
|
87
|
-
{ :collection => proc { self.job_invocation_report_templates_select } }),
|
88
|
-
]
|
89
|
-
end
|
90
|
-
|
91
|
-
def self.job_invocation_report_templates_select
|
92
|
-
Hash[ReportTemplate.unscoped.joins(:template_inputs).where(template_inputs: TemplateInput.where(name: 'job_id')).map { |template| [template.name, template.name] }]
|
93
|
-
end
|
94
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { mount } from '@theforeman/test';
|
3
|
-
import { DescriptionField } from '../DescriptionField';
|
4
|
-
|
5
|
-
describe('DescriptionField', () => {
|
6
|
-
it('rendring', () => {
|
7
|
-
const component = mount(
|
8
|
-
<DescriptionField
|
9
|
-
inputs={[{ name: 'command' }]}
|
10
|
-
value="Run %{command}"
|
11
|
-
setValue={jest.fn()}
|
12
|
-
/>
|
13
|
-
);
|
14
|
-
const preview = component.find('#description-preview').hostNodes();
|
15
|
-
const findLink = () => component.find('.pf-m-link.pf-m-inline');
|
16
|
-
expect(findLink().text()).toEqual('Edit job description template');
|
17
|
-
expect(preview.props().value).toEqual('Run command');
|
18
|
-
findLink().simulate('click');
|
19
|
-
const description = component.find('#description').hostNodes();
|
20
|
-
expect(description.props().value).toEqual('Run %{command}');
|
21
|
-
expect(findLink().text()).toEqual('Preview job description');
|
22
|
-
});
|
23
|
-
});
|
@@ -1,37 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { Provider } from 'react-redux';
|
3
|
-
import { fireEvent, screen, render, act } from '@testing-library/react';
|
4
|
-
import * as api from 'foremanReact/redux/API';
|
5
|
-
import { JobWizard } from '../../../JobWizard';
|
6
|
-
import * as selectors from '../../../JobWizardSelectors';
|
7
|
-
import { testSetup, mockApi } from '../../../__tests__/fixtures';
|
8
|
-
|
9
|
-
const store = testSetup(selectors, api);
|
10
|
-
mockApi(api);
|
11
|
-
|
12
|
-
describe('TemplateInputs', () => {
|
13
|
-
it('should save data between steps for template input fields', async () => {
|
14
|
-
render(
|
15
|
-
<Provider store={store}>
|
16
|
-
<JobWizard advancedValues={{}} setAdvancedValues={jest.fn()} />
|
17
|
-
</Provider>
|
18
|
-
);
|
19
|
-
await act(async () => {
|
20
|
-
await fireEvent.click(
|
21
|
-
screen.getByText('Target hosts and inputs', { selector: 'button' })
|
22
|
-
);
|
23
|
-
});
|
24
|
-
|
25
|
-
expect(
|
26
|
-
screen.getAllByLabelText('host2', { selector: 'button' })
|
27
|
-
).toHaveLength(1);
|
28
|
-
const chip1 = screen.getByLabelText('host1', { selector: 'button' });
|
29
|
-
fireEvent.click(chip1);
|
30
|
-
expect(
|
31
|
-
screen.queryAllByLabelText('host1', { selector: 'button' })
|
32
|
-
).toHaveLength(0);
|
33
|
-
expect(
|
34
|
-
screen.queryAllByLabelText('host2', { selector: 'button' })
|
35
|
-
).toHaveLength(1);
|
36
|
-
});
|
37
|
-
});
|
@@ -1,76 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { Provider } from 'react-redux';
|
3
|
-
import configureMockStore from 'redux-mock-store';
|
4
|
-
import * as patternfly from '@patternfly/react-core';
|
5
|
-
import { mount, shallow } from '@theforeman/test';
|
6
|
-
import { formatter } from '../Formatter';
|
7
|
-
|
8
|
-
jest.spyOn(patternfly, 'Select');
|
9
|
-
jest.spyOn(patternfly, 'SelectOption');
|
10
|
-
jest.spyOn(patternfly, 'FormGroup');
|
11
|
-
patternfly.Select.mockImplementation(props => <div props={props} />);
|
12
|
-
patternfly.SelectOption.mockImplementation(props => <div props={props} />);
|
13
|
-
patternfly.FormGroup.mockImplementation(props => <div props={props} />);
|
14
|
-
const mockStore = configureMockStore([]);
|
15
|
-
const store = mockStore({});
|
16
|
-
|
17
|
-
describe('formatter', () => {
|
18
|
-
it('render date input', () => {
|
19
|
-
const props = {
|
20
|
-
name: 'date adv',
|
21
|
-
required: false,
|
22
|
-
options: '',
|
23
|
-
advanced: true,
|
24
|
-
value_type: 'date',
|
25
|
-
resource_type: 'ansible_roles',
|
26
|
-
default: '',
|
27
|
-
hidden_value: false,
|
28
|
-
};
|
29
|
-
expect(shallow(formatter(props, {}, jest.fn()))).toMatchSnapshot();
|
30
|
-
});
|
31
|
-
it('render text input', () => {
|
32
|
-
const props = {
|
33
|
-
name: 'plain adv hidden',
|
34
|
-
required: true,
|
35
|
-
description: 'some Description',
|
36
|
-
options: '',
|
37
|
-
advanced: true,
|
38
|
-
value_type: 'plain',
|
39
|
-
resource_type: 'ansible_roles',
|
40
|
-
default: 'Default val',
|
41
|
-
hidden_value: true,
|
42
|
-
};
|
43
|
-
expect(shallow(formatter(props, {}, jest.fn()))).toMatchSnapshot();
|
44
|
-
});
|
45
|
-
it('render select input', () => {
|
46
|
-
const props = {
|
47
|
-
name: 'adv plain search',
|
48
|
-
required: false,
|
49
|
-
input_type: 'user',
|
50
|
-
options: 'option 1\r\noption 2\r\noption 3\r\noption 4',
|
51
|
-
advanced: true,
|
52
|
-
value_type: 'plain',
|
53
|
-
resource_type: 'ansible_roles',
|
54
|
-
default: '',
|
55
|
-
hidden_value: false,
|
56
|
-
};
|
57
|
-
expect(shallow(formatter(props, {}, jest.fn()))).toMatchSnapshot();
|
58
|
-
});
|
59
|
-
it('render search input', () => {
|
60
|
-
const props = {
|
61
|
-
name: 'search adv',
|
62
|
-
required: false,
|
63
|
-
options: '',
|
64
|
-
advanced: true,
|
65
|
-
value_type: 'search',
|
66
|
-
resource_type: 'foreman_tasks/tasks',
|
67
|
-
default: '',
|
68
|
-
hidden_value: false,
|
69
|
-
};
|
70
|
-
expect(
|
71
|
-
mount(
|
72
|
-
<Provider store={store}>{formatter(props, {}, jest.fn())}</Provider>
|
73
|
-
)
|
74
|
-
).toMatchSnapshot();
|
75
|
-
});
|
76
|
-
});
|