试图“解冻”一个已有多年历史的项目,并看到一些奇怪的JavaScript错误。寻找解决方案的运气不怎么好。
我猜测这与我的开发箱上的某些东西太新(或太旧)无法使用此代码库有关,但不确定解决此问题的最佳方法。
有人想如何解决这个问题?
感谢您的帮助!
这是规格:
# ./spec/support/helpers/comments_page_helpers
...
def open_image_comments_modal(section_position:, photo_position:)
selector = "editable-section:nth-child(#{section_position}) " \
"li.photo:nth-child(#{photo_position})"
within selector do
find('a.image-wrapper img').click ### <== line #23
end
expect(page).to have_css('.modal-comments-container')
end
...
和失败:
5) Comment creation for image behaves like added comment adds single comment
Failure/Error: find('a.image-wrapper img').click
Capybara::Poltergeist::JavascriptError:
One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).
Possibly unhandled rejection: {"data":{"message":"unauthorized"},"status":401,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"/api/v1/comments","params":{"commentable_id":4179,"commentable_type":"Attachment"},"headers":{"Accept":"application/json"}},"statusText":"Unauthorized "}
Possibly unhandled rejection: {"data":{"message":"unauthorized"},"status":401,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"/api/v1/comments","params":{"commentable_id":4179,"commentable_type":"Attachment"},"headers":{"Accept":"application/json"}},"statusText":"Unauthorized "}
at http://127.0.0.1:50066/assets/application-f59647de5de8bec0c768ec8da4dfa097f8e2db01844d3e5d71b6a6dd8b15abfb.js:26422
Shared Example Group: "added comment" called from ./spec/features/comments/creation_spec.rb:76
# ./spec/support/helpers/comments_page_helpers.rb:23:in `block in open_image_comments_modal'
# ./spec/support/helpers/comments_page_helpers.rb:22:in `open_image_comments_modal'
# ./spec/features/comments/creation_spec.rb:69:in `block (3 levels) in <top (required)>'