Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[System Tests] addComment(URL), Add New Note Fixture #8809

Merged
merged 5 commits into from Dec 14, 2020

Conversation

noi5e
Copy link
Contributor

@noi5e noi5e commented Dec 9, 2020

Not to be confused with my other current PR, #8801, which adds a new test for Question pages. Please review that one first, it has more extensive write-up!

This test was fairly straightforward to write compared to questions.

I renamed some of the tests to distinguish between notes, questions, and the old tests for commenting on wiki pages.

I simulated a new note in the fixtures for testing comments:

nodes.yml

comment_note: # for testing comments on notes
  nid: 38
  uid: 2
  title: "Please don't comment here"
  path: "/notes/jeff/12-08-2020/please-don-t-comment-here"
  created: <%= DateTime.new(2020,12,8).to_i %>
  changed: <%= DateTime.new(2020,12,8).to_i %>
  status: 1
  type: "note"
  cached_likes: 0
  slug: "note-please-don-t-comment-here"

revisions.yml

comment_note: # for testing comments on notes
  nid: 38
  uid: 2
  title: "Please don't comment here"
  body: "I beg you, please"
  timestamp: <%= DateTime.new(2020,12,8).to_i %>
  status: 1

The test:

test 'note: comment via JavaScript, with comment body + URL' do
  visit nodes(:comment_note).path
  page.evaluate_script("addComment('hahaha', '/comment/create/38')")
  assert_selector('#comments-list .comment-body p', text: 'hahaha')
end

(This PR is part of the larger Comment Editor Overhaul Project with Outreachy. Refer to Planning Issue #9069 for more context)

@noi5e noi5e added the testing issues are usually for adding unit tests, integration tests or any other tests for a feature label Dec 9, 2020
@noi5e noi5e added this to the Comment Editor Winter 2020 milestone Dec 9, 2020
@gitpod-io
Copy link

gitpod-io bot commented Dec 9, 2020

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, all excellent clarifications and additions. If it runs smoothly in GitPod, let's mark it ready to merge? Hopefully we figure out the testing situation very soon and can merge this!

Copy link
Member

@pydevsg pydevsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work @noi5e 🎉

@noi5e
Copy link
Contributor Author

noi5e commented Dec 14, 2020

I caught a test that was failing because I created a new fixture:

test 'should find all research notes' do
notes = Node.research_notes
expected = [nodes(:one), nodes(:spam), nodes(:first_timer_note), nodes(:blog),
nodes(:moderated_user_note), nodes(:activity), nodes(:upgrade),
nodes(:draft), nodes(:post_test1), nodes(:post_test2),
nodes(:post_test3), nodes(:post_test4), nodes(:scraped_image), nodes(:search_trawling),
nodes(:purple_air_without_hyphen), nodes(:purple_air_with_hyphen),
nodes(:sun_note), nodes(:sunny_day_note)]
assert_equal expected, notes
end

Pushed new commits and it fixes the fail!

There might be a few more changes that need to be made. Going through the tests locally right now.

@noi5e
Copy link
Contributor Author

noi5e commented Dec 14, 2020

Caught two more tests that were failing bc of the new note fixture:

test 'first-timer moderated note (status=4) shown to author in list view with notice' do
node = nodes(:first_timer_note)
UserSession.create(node.author)
assert_equal 4, node.status
get :index
assert_response :success
selector = css_select 'div.note'
assert_equal 27, selector.size
assert_select "div p", 'Pending approval by community moderators. Please be patient!'
end

test 'first-timer moderated note (status=4) shown to moderator with notice and approval prompt in list view' do
UserSession.create(users(:moderator))
node = nodes(:first_timer_note)
assert_equal 4, node.status
get :index
assert_response :success
selector = css_select 'div.note'
assert_equal 27, selector.size
assert_select 'a[data-test="spam"]','Spam'
end

27 should be 28 in both because of the new note I created. Pushed the changes! I think this PR is good, no other new failed tests AFAIK locally.

Copy link
Contributor

@Sagarpreet Sagarpreet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 🎉 🎉
All tests are passing now, right?

@@ -368,7 +368,7 @@ def teardown

assert_response :success
selector = css_select 'div.note'
assert_equal 27, selector.size
assert_equal 28, selector.size
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct 👍

@jywarren
Copy link
Member

Awesome, now that #8801 is merged, can you resolve the conflicts noted by GitHub and then we should be good to merge this (bypassing Travis) too? Thank you @noi5e and also @Sagarpreet @pydevsg !!!

@jywarren
Copy link
Member

Also noting, this is a good example of this happening - perhaps we shouldn't do count-based assertions because it causes interdependence among fixtures. While in some ways it's nice to see the code interdependencies, because it stops us from thinking too narrowly, it also creates barriers to code changes because changes cascade and affect other tested areas. Food for thought! Thanks again!

@codeclimate
Copy link

codeclimate bot commented Dec 14, 2020

Code Climate has analyzed commit 97a6842 and detected 0 issues on this pull request.

View more on Code Climate.

@noi5e
Copy link
Contributor Author

noi5e commented Dec 14, 2020

Just resolved the conflicts!

@jywarren jywarren merged commit 1556e25 into publiclab:main Dec 14, 2020
@jywarren
Copy link
Member

Hooray!!

@noi5e noi5e deleted the test/sync-comment-on-note branch December 14, 2020 22:51
@noi5e noi5e changed the title [Comment Editor] New Test: Comment on Notes with addComment Script Testing: addComment(URL), Add New Note Fixture Dec 27, 2020
@noi5e noi5e changed the title Testing: addComment(URL), Add New Note Fixture [System Tests] addComment(URL), Add New Note Fixture Jan 23, 2021
manchere pushed a commit to manchere/plots2 that referenced this pull request Feb 13, 2021
…ubliclab#8809)

* add notes comment test & rename tests to distinguish wiki, note, question, etc.

* add new note fixture for testing comments

* update 'find all notes' to include new fixture

* alter expected result of 'all notes' lookup
lagunasmel pushed a commit to lagunasmel/plots2 that referenced this pull request Mar 2, 2021
…ubliclab#8809)

* add notes comment test & rename tests to distinguish wiki, note, question, etc.

* add new note fixture for testing comments

* update 'find all notes' to include new fixture

* alter expected result of 'all notes' lookup
reginaalyssa pushed a commit to reginaalyssa/plots2 that referenced this pull request Oct 16, 2021
…ubliclab#8809)

* add notes comment test & rename tests to distinguish wiki, note, question, etc.

* add new note fixture for testing comments

* update 'find all notes' to include new fixture

* alter expected result of 'all notes' lookup
billymoroney1 pushed a commit to billymoroney1/plots2 that referenced this pull request Dec 28, 2021
…ubliclab#8809)

* add notes comment test & rename tests to distinguish wiki, note, question, etc.

* add new note fixture for testing comments

* update 'find all notes' to include new fixture

* alter expected result of 'all notes' lookup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
readytomerge testing issues are usually for adding unit tests, integration tests or any other tests for a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants