Can't erase the bookmark search input

When we fill in the bookmark search input and send the request, then we can’t delete the input’s content.

Steps:

  1. Fill in the bookmark search input

  2. Run the search

  3. Try deleting the input’s content by pressing backspace

  4. When reaching the first letter, the input’s content resets to the current query’s value

Video:

3 Likes

I can repro this too. Nice catch! :fishing_pole:

2 Likes

Wow that sure is odd, added a priority tag on this, someone will have a look over the next 4 weeks, but if anyone feels like a submitting a PR in the meantime you are welcome to.

2 Likes

I took a look; the issue is here:

Here is what happens.

When you remove the last character, get is called. At this point, _searchTerm is empty.
However, this._searchTerm || this.q will treat the empty string as falsy, and the value of q is displayed instead.

A quick fix could be to check this way:

return this._searchTerm !== undefined ? this._searchTerm : this.q;

Note: the initial value of _searchTerm is undefined.
Note: because of computed("q"), the issue doesn’t happen when you select/delete (probably because the timing is too tight to invalidate the cache?)


I wanted to PR, but..

the core tests (without modification) fail for some reason.
I’m using bin/rspec spec/system/user_activity_bookmarks_spec.rb.
The log says that either the search is not present or bookmarks are not created.
Do I miss something?

Logs

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

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

Failures:

  1. User activity bookmarks can clear the query
    Failure/Error: super

    Capybara::ElementNotFound:
    Unable to find field “bookmark-search” that is not disabled

    ~~~~~ END JS LOGS ~~~~~
    
    # ./spec/system/page_objects/pages/user_activity_bookmarks.rb:24: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>'
    
    
  2. User activity bookmarks can filter the list of bookmarks
    Failure/Error: super

    Capybara::ElementNotFound:
    Unable to find field “bookmark-search” that is not disabled

    ~~~~~ END JS LOGS ~~~~~
    
    # ./spec/system/page_objects/pages/user_activity_bookmarks.rb:24: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>'
    
    
  3. 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:0x00007f51dcb37b00>.has_topic?(#<Topic id: 699, title: "This is a test topic 0", last_posted_at: nil, created_at: "2025-03-19 04:35:...oad_id: nil, slow_mode_seconds: 0, bannered_until: nil, external_id: nil, visibility_reason_id: nil>) to be truthy, got false

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

Finished in 21.7 seconds (files took 3.8 seconds to load)
3 examples, 3 failures

Failed examples:

rspec ./spec/system/user_activity_bookmarks_spec.rb:50 # User activity bookmarks can clear the query
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

4 Likes

You will need to run bin/ember-cli in the background or run bin/ember-cli --build before your changes in JS land is available to the system test process.

2 Likes

(this should probably be moved to a dev topic).

Alan, I have bin/ember-cli running (I also tried bin/ember-cli --build).

Am I doing something wrong? :thinking:

1 Like

Can you please push your changes to a branch on github? I can help you have a look to see what might be wrong.

2 Likes

I made the PR:

My issue is that these default tests fail, even without local changes.
Specifically, for fabricated bookmarks, they seem not to be available. It sounds like something is not loaded/written correctly.

In the PR, I added a small test that doesn’t rely on a fabricated bookmark, so it works on my local.

3 Likes

5 posts were split to a new topic: Having issues running tests on my WSL2 system

The fix has been merged and the bug is fixed, thank you! :rocket:

1 Like