Webpack and React unit test failures for Discovery

Hello,

I was able to deal with many (not all) discovery unit tests except few which are related to Javascript. Can someone help me out with these please? I really need to get discovery to green state before making a release for 3.0 and I am already late.

Here is the first one:

Error:
DiscoveredHostsTest::Delete hosts#test_0001_it removes all hosts:
ActionView::Template::Error: Can't find entry point 'foreman_ansible:global' in webpack manifest
    app/helpers/reactjs_helper.rb:64:in `block (2 levels) in global_css_tags'
    app/helpers/reactjs_helper.rb:63:in `map'
    app/helpers/reactjs_helper.rb:63:in `block in global_css_tags'
    app/helpers/reactjs_helper.rb:62:in `map'
    app/helpers/reactjs_helper.rb:62:in `global_css_tags'
    app/helpers/reactjs_helper.rb:22:in `webpacked_plugins_with_global_css'
    app/views/layouts/base.html.erb:16
    app/views/layouts/login.html.erb:7
    app/controllers/users_controller.rb:149:in `login'
    app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
    app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
    app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
    lib/foreman/middleware/telemetry.rb:10:in `call'
    lib/foreman/middleware/catch_json_parse_errors.rb:9:in `call'
    lib/foreman/middleware/logging_context_session.rb:22:in `call'
    lib/foreman/middleware/logging_context_request.rb:11:in `call'

The second one:

Error:
DiscoveredHostsControllerTest#test_index:
ActionView::Template::Error: DEPRECATION WARNING: You are using a deprecated behavior, it will be removed in version 3.1, notifications method is deprecated, and instead, toasts alerts are handled in the root of the React app. (called from block in __home_lzap_work_foreman_discovery_app_views_discovered_hosts_welcome_html_erb___1810809074715367311_542400 at /home/lzap/work/foreman_discovery/app/views/discovered_hosts/welcome.html.erb:11)
    /home/lzap/work/foreman_discovery/app/views/discovered_hosts/welcome.html.erb:11
    /home/lzap/work/foreman_discovery/app/views/discovered_hosts/welcome.html.erb:10
    app/controllers/application_controller.rb:36:in `welcome'
    app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
    app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
    /home/lzap/work/foreman_discovery/test/functional/discovered_hosts_controller_test.rb:26:in `test_index'

Thanks!

The second one can be fixed by removing https://github.com/theforeman/foreman_discovery/blob/012851e7cf1423db1f65c0e350afac989141d9ab/app/views/discovered_hosts/welcome.html.erb#L11
And all other <%= notifications %>.
I’ll open a PR :slight_smile:

1 Like

Is the first from your local env? If so try rake webpack:precompile as tests are using precompiled assets.

1 Like

Thanks all, solved!