Completed Implementation of Pin Topic Backend #47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves:
#12, #13
This PR fulfils functionality left over from sprint one and successfully connects the pin button to backend logic allowing certain user groups to pin topics. This completes all the requirements for both front-end and back-end for this User Story- with acceptance criteria fulfilled. The pin functionality is extremely useful in allowing users to highlight certain posts making sure they are always 'pinned' to the top of the discussion.
The frontend for this button has been written and committed by @sschauk, while I worked on the backend after what was left off from Sprint 1.
Implementation and Changes:
After Sprint 1, the code was left unconnected to the frontend button and unable to pass the linter and test suite. At first, I attempted to connect our previous logic to the frontend button, however due to already existing pinning logic embedded into NodeBB, there were a lot of errors I faced in trying to reimplement this functionality. Therefore, I decided to use the existing pinning infrastructure and connections to help me connect my backend to the frontend button. The changes reflected in this PR are as follows:
Deletion of src/topics/pin.js that contained my previous implementation of the backend.
Edited src/topics/tools.js to shift functions from pin.js here, and refactor them.
Edited src/topics/index.js to remove sorting functions (as they were already implemented elsewhere)
Edited test/topics.js to add tests (elaborate on this below)
[Small changes to other files to correct linting errors]
In particular, the changes I made to tool.js included added functions from pin.js and correcting linting and logic errors so they pass the basic test suite. Additionally I edited this functions to add some more functionality like logging information about the post being pinned. I was then able to use the existing functions in public/src/client/topic/threadTools.js to connect my backend logic with the pin button.
Testing:
A number of different tests were added onto the test suite to make sure acceptance criteria was met. I was able to write meaningful backend tests that include testing whether the pin posts remain on top, whether posts remain pinned after logging out, whether ordering of the posts is maintained and whether only certain permissible users can pin posts among other things. These tests are elaborated on further in the UserGuide.
There is also a video attached below of my manual testing of the button:
demo.mp4