当我们填写书签搜索输入框并发送请求后,就无法删除输入框的内容。
步骤:
-
填写书签搜索输入框
-
运行搜索
-
尝试通过按退格键删除输入框的内容
-
当退格到第一个字母时,输入框的内容会重置为当前查询的值
视频:
当我们填写书签搜索输入框并发送请求后,就无法删除输入框的内容。
步骤:
填写书签搜索输入框
运行搜索
尝试通过按退格键删除输入框的内容
当退格到第一个字母时,输入框的内容会重置为当前查询的值
视频:
我也能重现这个问题。抓得好!![]()
这确实很奇怪,已为此添加了优先级标签,将在未来 4 周内有人进行处理,但在此期间,如果您愿意提交 PR,我们非常欢迎。
我查看了一下;问题出在这里:
这是发生的情况。
当您删除最后一个字符时,会调用 get。此时,_searchTerm 为空。
然而,this._searchTerm || this.q 会将空字符串视为假值,并显示 q 的值。
一个快速的修复方法是这样检查:
return this._searchTerm !== undefined ? this._searchTerm : this.q;
注意:_searchTerm 的初始值是 undefined。
注意:由于 computed("q"),当您选择/删除时(可能是因为时间太紧,无法使缓存失效?),问题不会发生。
核心测试(未经修改)不知何故失败了。
我使用的是 bin/rspec spec/system/user_activity_bookmarks_spec.rb。
日志显示搜索不存在或书签未创建。
我是否遗漏了什么?
(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:
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>'
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>'
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
您需要在后台运行 bin/ember-cli,或者在 JS 环境中的更改对系统测试进程可用之前运行 bin/ember-cli --build。
(这可能应该移到开发主题)。
Alan,我正在运行 bin/ember-cli(我也尝试过 bin/ember-cli --build)。
我做错什么了吗? ![]()
你能把你的更改推送到 GitHub 的一个分支吗?我可以帮你看看哪里可能出了问题。
我已提交 PR:
我的问题是,即使没有本地更改,这些默认测试也会失败。
具体来说,对于伪造的书签,它们似乎不可用。听起来有些东西没有正确加载/写入。
在 PR 中,我添加了一个不依赖于伪造书签的小测试,所以它可以在本地运行。
5 个帖子已拆分为新主题:在我的 WSL2 系统上运行测试时遇到问题
修复已合并,错误已修复,谢谢!![]()