Plots2: OLD CLOSED Comment Editor Overhaul Issue

Created on 9 Oct 2020  ·  14Comments  ·  Source: publiclab/plots2

MOVED PLANNING ISSUE HERE -> #9069

I've decided to move my planning issue to a fresh issue page, mostly for issues of readability. Sorry for any confusion this causes! - @noi5e

outreachy planning

Most helpful comment

@jywarren Thanks so much for that very helpful and detailed writeup!!! It really helped me figure out a lot of things about the codebase. Still a lot to learn. I made a tentative PR for a test-- with a lot of questions.

All 14 comments

For the later stages of the Comment Editor project when it might be spun out into its own repository, we may want to carefully consider this workflow documented by Sagarpreet for what would help create a standard release cycle!

https://publiclab.org/notes/sagarpreet_chadha/10-20-2020/first-timer-only-release-workflow

Noting this example of cross-wired comment boxes during image upload to a comment being edited (not newly written): https://github.com/publiclab/plots2/issues/8670

MOVED PLANNING ISSUE HERE -> #9069

I've decided to move my planning issue to a fresh issue page, mostly for issues of readability. Sorry for any confusion this causes! - @noi5e

Hi @noi5e , the planning issue looks great.
Which issue are you currently working on? Can you point me to the PR if any, also let me know if you are stuck somewhere or meed some clarity. Thanks 😄

@sagarpreet-chadha Thank you for checking in with me! Since posting this, been writing my blogpost for Outreachy (in bits and pieces, almost done), researching and working on a PR for 8618, and brushing up on Rails-- which I don't have a strong background in, but have been learning a lot this week. Worked 2 days at my other job so am feeling a little behind, but did a lot of catch-up today and will do more tomorrow & Monday. I plan on writing tests for comments tomorrow.

I need a little clarification about testing comments. I took a look at /plots2/blob/main/test/system/comment_test.rb and it looks like there are already tests for entering comments both manually and via API URL, both pointing toward /wiki/wiki-page-path/comments.

If I'm going to write new comment tests for question and note pages, will it be for a different API URL or the same as above (wiki-page-path)? I ran rails routes but it's not obvious to me which ones I'm supposed to be testing. Thanks in advance, this will save some time hunting through the code. 😅

EDIT: Also let me know if you have specific requests for types of tests for me to write!

Hi @noi5e i believe the "wiki comments" route is distinct from the "notes" one - both wikis and notes are variants of Node - but should be pretty similar.

It's been a while since I looked at this area of code, but typically Rails will have a controller action for each route, but the exception is when they are resourceful routes: https://guides.rubyonrails.org/routing.html#resource-routing-the-rails-default

Seeing this action is for viewing comments:

https://github.com/publiclab/plots2/blob/cbb807ba8e2302f09dafc0060475aa118e34c2c6/app/controllers/wiki_controller.rb#L467-L470

it seems there isn't a controller action for posting. But i do see that this route:

https://github.com/publiclab/plots2/blob/cbb807ba8e2302f09dafc0060475aa118e34c2c6/config/routes.rb#L58

points at that view action. So where are creation routes and actions? I see some here, not wiki-specific though:

https://github.com/publiclab/plots2/blob/cbb807ba8e2302f09dafc0060475aa118e34c2c6/config/routes.rb#L368-L373

So let's look at the other end of things, the templates. Here is the basic comment form:

https://github.com/publiclab/plots2/blob/main/app/views/comments/_form.html.erb

I think question comments may re-use this form, based on the logic in the <form> tag here?

https://github.com/publiclab/plots2/blob/cbb807ba8e2302f09dafc0060475aa118e34c2c6/app/views/comments/_form.html.erb#L3

So, they point at /comments/create/NID with a POST method, so the very last route from line 373 of routes.rb. Those point at the comment controller create action:

https://github.com/publiclab/plots2/blob/cbb807ba8e2302f09dafc0060475aa118e34c2c6/app/controllers/comment_controller.rb#L19-L56

So i think it's safe to say most comments are using the comment controller create action. But what about those system tests where that route is not mentioned?

The other way it's happening is here is via a JavaScript method:

https://github.com/publiclab/plots2/blob/cbb807ba8e2302f09dafc0060475aa118e34c2c6/test/system/comment_test.rb#L32

That leads us to this JS file, which submits it to the same route via AJAX:

https://github.com/publiclab/plots2/blob/484bf69ead7a1f69c9047a25b3f63b9d6f875728/app/assets/javascripts/comment.js#L62-L70

The way our codebase looks now, the sendFormSubmissionAjax() function may look like it didn't have to be in its own file, but i think @nstjean (a fantastic Outreachy alum, hi!!!!!! 🎉 ) planned for it to streamline JS form submission across our codebase, which i fully support. Here it is!

https://github.com/publiclab/plots2/blob/876d0fc084064aaecc23f8003630d7d1ab858fa1/app/assets/javascripts/submit_form_ajax.js#L1-L4

Hope this is helpful! It's not the worst i've seen in terms of code organization, but it's definitely convoluted. This is partly just because this is a big and old codebase which has seen many different phases of revision. Actually, prior to system tests, which only got installed in the past 2 years or so, we had no way to do full-stack testing of JavaScript comment submission! So it was constantly breaking :-(

Thanks folks!!!

@jywarren Thanks so much for that very helpful and detailed writeup!!! It really helped me figure out a lot of things about the codebase. Still a lot to learn. I made a tentative PR for a test-- with a lot of questions.

Also looking to clarify these:

"Save and recover icons Key feature causing Mimi to workaround" (don't get this)

I couldn't actually find this in https://pad.publiclab.org/p/outreachy - where did it come from? It sounds vaguely familiar... sorry!

Preview doesn't work sometimes (I can't reproduce)

Maybe this is a good candidate for the kind of "standard suite of tests" we could automatically run on multiple variants of the comment editor, when we re-organize the test code? I wonder if that would catch it, or perhaps it's just already resolved.

Bold and italic buttons are "cross-wired" (can't reproduce)

This seems to be in https://github.com/publiclab/plots2/issues/8478 and i wonder if the same strategy could help, of including this in a standard suite of comment editor tests and running across all variants.

Ensure grey "drag-and-drop to insert images" is everywhere (can't reproduce, would like some examples)

Same as above maybe... and i also couldn't find it in https://pad.publiclab.org/p/outreachy so maybe i can add more, knowing where it came from?

Issues with liking comments (See "Comment Likes Does Not Work #5113"). I understand the issue, basically I need to clarify what the expected behavior here is.

This might just be really old?? We don't have comment likes anymore, as it was replaced by the "reactions" system. But, maybe we clarify by asking Sasha, who made #5113

Thanks, @noi5e ! Hope these help!!!!

Thanks @jywarren definitely helpful... I think the points you were looking for are in this Google doc

Hi @noi5e i'm not sure if you saw this or fixed this already but i noticed this on our comments - there seems to be an unnecessary grey bar under the form:

image

Also, i think some of the spacing around the emojis is a little off. See how it seems like it has white padding on top and bottom, esp when compared to GitHub's style?

image

Just a couple tiny things maybe we could address in an upcoming PR, but nothing urgent. Thanks!

@jywarren Definitely, I have noticed those too! Adding to my to-dos.

I also was wondering after the speed optimizations of https://github.com/publiclab/plots2/pull/9045, i remember that Skylight shows that actually posting a comment on PublicLab.org can take quite a while... and I thought we had optimized somewhat but not as much as we'd hoped. Do you still find it to be a slow load time to post a comment? I wonder if that's also a way to improve system test runtime, while improving user experience as well.

Here's a snapshot; it apparently still takes up to 10 seconds occasionally, but unfortunately our monitoring isn't good enough to show more than that this time is spent in the controller, it seems:

image

This is also not a requirement of your project, but i thought it might be interesting. The code driving this is here and here.

No worries really about this to be honest... but i am curious if you felt that comment post time was quite slow or not?

@jywarren Yes! I definitely think that time to post comments is very slow! (also, time to react to a comment)

Interesting to learn about Skylight and what it does. I wonder what exactly is causing the slowdown, do you think it might be the ActiveRecord query?

EDIT: adding it to the stretch goals wishlist in this Planning Issue!

MOVED PLANNING ISSUE HERE -> #9069

I've decided to move my planning issue to a fresh issue page, mostly for issues of readability. Sorry for any confusion this causes! - @noi5e

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grvsachdeva picture grvsachdeva  ·  3Comments

noi5e picture noi5e  ·  3Comments

jywarren picture jywarren  ·  3Comments

divyabaid16 picture divyabaid16  ·  3Comments

grvsachdeva picture grvsachdeva  ·  3Comments