Having issues running tests on my WSL2 system

Do you mean running something like this fails locally for you?

~/work/discourse [main] $ rspec spec/system/user_activity_bookmarks_spec.rb

Randomized with seed 38950
...

Finished in 7.71 seconds (files took 2.5 seconds to load)
3 examples, 0 failures

Thank you so much! I’ve approved the PR and will merge it shortly.

3 Likes

Yes,

Only my test works.
Tested on WSL2, Ubuntu 22.

(base) arkshine@HOME:~/discourse$ rspec spec/system/user_activity_bookmarks_spec.rb

Finished in 28.13 seconds (files took 4.64 seconds to load)
4 examples, 3 failures

Failed examples:

rspec ./spec/system/user_activity_bookmarks_spec.rb:36 # User activity bookmarks can filter the list of bookmarks from the URL
rspec ./spec/system/user_activity_bookmarks_spec.rb:43 # User activity bookmarks can filter the list of bookmarks
rspec ./spec/system/user_activity_bookmarks_spec.rb:50 # User activity bookmarks can clear the query

No bookmarks are registered for some reasons:

1 Like

Any failure message after your tests fail?

No error. This is the whole output:

(base) arkshine@HOME:~/discourse$ rspec spec/system/user_activity_bookmarks_spec.rb
WARN: Unresolved or ambiguous specs during Gem::Specification.reset:
      optimist (>= 3.0.0)
      Available/installed versions of this gem:
      - 3.2.1
      - 3.2.0
      rdoc (>= 4.0.0)
      Available/installed versions of this gem:
      - 6.12.0
      - 6.6.3.1
WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>'
Please report a bug if this causes problems.

Randomized with seed 5318
unknown OID 931304: failed to recognize type of 'embeddings'. It will be treated as String.
FFF.

Failures:

  1) User activity bookmarks can filter the list of bookmarks
     Failure/Error: super
     
     Capybara::ElementNotFound:
       Unable to find field "bookmark-search" that is not disabled
     
     [Screenshot Image]: /home/arkshine/discourse/tmp/capybara/failures_r_spec_example_groups_user_activity_bookmarks_can_filter_the_list_of_bookmarks_300.png

     ~~~~~~~ JS LOGS ~~~~~~~
     ~~~~~ END JS LOGS ~~~~~
     
     # ./spec/system/page_objects/pages/user_activity_bookmarks.rb:29:in `fill_in_search'
     # ./spec/system/page_objects/pages/user_activity_bookmarks.rb:14:in `search_for'
     # ./spec/system/user_activity_bookmarks_spec.rb:44:in `block (2 levels) in <main>'

  2) User activity bookmarks can filter the list of bookmarks from the URL
     Failure/Error: expect(user_activity_bookmarks).to have_topic(bookmark_1.bookmarkable.topic)
       expected `#<PageObjects::Pages::UserActivityBookmarks:0x00007f3d48e29f28>.has_topic?(#<Topic id: 917, title: "This is a test topic 0", last_posted_at: nil, created_at: "2025-03-21 02:48:...oad_id: nil, slow_mode_seconds: 0, bannered_until: nil, external_id: nil, visibility_reason_id: nil>)` to be truthy, got false
     
     [Screenshot Image]: /home/arkshine/discourse/tmp/capybara/failures_r_spec_example_groups_user_activity_bookmarks_can_filter_the_list_of_bookmarks_from_the_url_846.png

     ~~~~~~~ JS LOGS ~~~~~~~
     ~~~~~ END JS LOGS ~~~~~
     
     # ./spec/system/user_activity_bookmarks_spec.rb:40:in `block (2 levels) in <main>'

  3) User activity bookmarks can clear the query
     Failure/Error: super
     
     Capybara::ElementNotFound:
       Unable to find field "bookmark-search" that is not disabled
     
     [Screenshot Image]: /home/arkshine/discourse/tmp/capybara/failures_r_spec_example_groups_user_activity_bookmarks_can_clear_the_query_761.png

     ~~~~~~~ JS LOGS ~~~~~~~
     ~~~~~ END JS LOGS ~~~~~
     
     # ./spec/system/page_objects/pages/user_activity_bookmarks.rb:29:in `fill_in_search'
     # ./spec/system/page_objects/pages/user_activity_bookmarks.rb:14:in `search_for'
     # ./spec/system/user_activity_bookmarks_spec.rb:51:in `block (2 levels) in <main>'

Finished in 21.11 seconds (files took 5.2 seconds to load)
4 examples, 3 failures

Failed examples:

rspec ./spec/system/user_activity_bookmarks_spec.rb:43 # User activity bookmarks can filter the list of bookmarks
rspec ./spec/system/user_activity_bookmarks_spec.rb:36 # User activity bookmarks can filter the list of bookmarks from the URL
rspec ./spec/system/user_activity_bookmarks_spec.rb:50 # User activity bookmarks can clear the query

Randomized with seed 5318

did you try having a quick look at the pictures, I wonder if they offer a clue at why the test runner is not working.

(also kind of disappointed our ai bot has not nagged us to open a new topic yet ;p)

edit problem solved…

2 Likes

I put a sleep in a test and started rspec with SELENIUM_HEADLESS=0.
I found that I can see the topics created, BUT I can’t access them.
That explains why I don’t see the bookmarks!

Immediately, it reminds me of an issue I encountered every time I made tests in TC or ran existing tests: if there is a fab topic without a defined category, I can’t access it in the tests.

So, If I do the following:

I see the bookmarks:

And the tests are working:
image

It’s unclear why it happens in my environment.
There are a lot of fab topics without categories specified in the core tests, and the tests work on GitHub. What is the difference?