Skip to content

Refs #39167 - add tests for job wizard templates#1025

Open
MariaAga wants to merge 1 commit intotheforeman:masterfrom
MariaAga:wizard-rex-feature-fix-tests
Open

Refs #39167 - add tests for job wizard templates#1025
MariaAga wants to merge 1 commit intotheforeman:masterfrom
MariaAga:wizard-rex-feature-fix-tests

Conversation

@MariaAga
Copy link
Copy Markdown
Member

Follow up for #1024
Tests categories when they come from a feature from a url, or when its the default selected category in the wizard
Tests writing was AI assisted.

@MariaAga
Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

Walkthrough

A new integration test file test/integration/job_wizard_category_js_test.rb is added to test the job wizard functionality with JavaScript enabled. The test class includes setup and teardown methods that manage job template configurations and a remote execution host. Six test methods verify that the job wizard correctly selects form categories based on feature query parameters, prefills template inputs from query parameters, and properly executes the job invocation workflow through multiple wizard steps.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding tests for job wizard templates as referenced in issue #39167.
Description check ✅ Passed The description is directly related to the changeset, explaining the test scope and noting it's a follow-up to PR #1024.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/integration/job_wizard_category_js_test.rb (1)

91-94: Consider a more explicit assertion for readability.

The current assertion works correctly, but the intent (button should be enabled) could be clearer with a different approach.

Alternative for clarity
       assert_selector(:ouia_component_id, 'run-on-selected-hosts-footer', :wait => 30)
       run_on_hosts = find(:ouia_component_id, 'run-on-selected-hosts-footer')
-      assert_includes [nil, 'false'], run_on_hosts[:'aria-disabled']
+      refute_equal 'true', run_on_hosts[:'aria-disabled'], 'Run on selected hosts button should be enabled'
       assert_text 'Run on selected hosts'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/integration/job_wizard_category_js_test.rb` around lines 91 - 94, The
test's intent is to assert the "Run on selected hosts" button is enabled, but
using assert_includes [nil, 'false'] is unclear; update the assertion on
run_on_hosts[:'aria-disabled'] (the variable set by find(:ouia_component_id,
'run-on-selected-hosts-footer')) to be explicit — for example, assert_nil
run_on_hosts[:'aria-disabled'] or assert_equal 'false',
run_on_hosts[:'aria-disabled'] (or use refute run_on_hosts[:'aria-disabled'] to
assert falsiness) so the expectation that the button is enabled is immediately
clear.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/integration/job_wizard_category_js_test.rb`:
- Around line 81-85: The assertion message for the ActiveSupport::Notifications
subscriber mismatch: the subscription check uses
payload[:controller].to_s.end_with?('JobInvocationsController') (inside the
block assigned to subscriber) which matches both web and API controllers, but
the assertion text references Api::V2::JobInvocationsController#create; update
the assertion message at the assertion that checks
posted_to_job_invocations_create (around where subscriber is defined and
asserted) so the message accurately reflects the check (e.g., say
"JobInvocationsController#create was posted" or otherwise remove the Api::V2::
namespace) OR tighten the check to match Api::V2::JobInvocationsController
explicitly (change end_with? to == 'Api::V2::JobInvocationsController') so the
assertion message and check align; adjust whichever approach you choose
consistently for that assertion.

---

Nitpick comments:
In `@test/integration/job_wizard_category_js_test.rb`:
- Around line 91-94: The test's intent is to assert the "Run on selected hosts"
button is enabled, but using assert_includes [nil, 'false'] is unclear; update
the assertion on run_on_hosts[:'aria-disabled'] (the variable set by
find(:ouia_component_id, 'run-on-selected-hosts-footer')) to be explicit — for
example, assert_nil run_on_hosts[:'aria-disabled'] or assert_equal 'false',
run_on_hosts[:'aria-disabled'] (or use refute run_on_hosts[:'aria-disabled'] to
assert falsiness) so the expectation that the button is enabled is immediately
clear.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 668384fb-92f8-437c-b855-d596c86e71fc

📥 Commits

Reviewing files that changed from the base of the PR and between 0588a71 and bc8ed21.

📒 Files selected for processing (1)
  • test/integration/job_wizard_category_js_test.rb

@MariaAga MariaAga force-pushed the wizard-rex-feature-fix-tests branch 2 times, most recently from 6274fd1 to 6c22b72 Compare March 25, 2026 17:02
@Lukshio Lukshio self-assigned this Mar 26, 2026
Copy link
Copy Markdown
Contributor

@Lukshio Lukshio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good coverage improvement overall, but I’d tighten the controller matching before merge.

@Lukshio
Copy link
Copy Markdown
Contributor

Lukshio commented Mar 30, 2026

The test looks unstable, some runs ends with infinite retry

[MinitestRetry] retry 'test_0006_job wizard run on selected hosts is enabled on review and posts to job invocations API' count: 1,  msg: Timeout::Error: execution expired
    test/integration_test_helper.rb:181:in `wait_for'
    test/integration_test_helper.rb:188:in `wait_for_ajax'
    /home/vagrant/foreman_remote_execution/test/integration/job_wizard_category_js_test.rb:98:in `block in <class:JobWizardCategoryJsTest>',RuntimeError: Requests did not finish in 60 seconds: ["/foreman_tasks/api/tasks/afdd29b6-2a14-43ef-ab8a-5e626f77ba85"]
    test/integration_test_helper.rb:353:in `block in <class:IntegrationTest>'
    test/test_helper.rb:105:in `after_teardown'
[MinitestRetry] retry 'test_0006_job wizard run on selected hosts is enabled on review and posts to job invocations API' count: 2,  msg: ActiveRecord::RecordInvalid: Validation failed: Name has already been taken
    /home/vagrant/foreman_remote_execution/test/integration/job_wizard_category_js_test.rb:183:in `add_plain_template_input!'
    /home/vagrant/foreman_remote_execution/test/integration/job_wizard_category_js_test.rb:22:in `block (2 levels) in <class:JobWizardCategoryJsTest>'
    test/active_support_test_case_helper.rb:91:in `as_user'
    test/active_support_test_case_helper.rb:97:in `as_admin'
    /home/vagrant/foreman_remote_execution/test/integration/job_wizard_category_js_test.rb:11:in `block in <class:JobWizardCategoryJsTest>'
    test/test_helper.rb:88:in `before_setup'
    test/integration_test_helper.rb:403:in `before_setup',RuntimeError: Requests did not finish in 60 seconds: ["/foreman_tasks/api/tasks/afdd29b6-2a14-43ef-ab8a-5e626f77ba85"]
    test/integration_test_helper.rb:353:in `block in <class:IntegrationTest>'
    test/test_helper.rb:105:in `after_teardown'

@Lukshio
Copy link
Copy Markdown
Contributor

Lukshio commented Mar 31, 2026

CI test failures are related

@MariaAga MariaAga force-pushed the wizard-rex-feature-fix-tests branch from c45933b to 9cca4c0 Compare March 31, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants