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

WIP: fix empty discussion post in events communities #5073

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

katemoser
Copy link

Checklists not yet completed, because I am not yet done!

Backend checklist

  • Formatted my code by running ruff check --select I --fix . && ruff check . && ruff format . in app/backend
  • Added tests for any new code or added a regression test if fixing a bug
  • All tests pass
  • Run the backend locally and it works
  • Added migrations if there are any database changes, rebased onto develop if necessary for linear migration history

Web frontend checklist

  • Formatted my code with yarn format
  • There are no warnings from yarn lint --fix
  • There are no console warnings when running the app
  • Added any new components to storybook
  • Added tests where relevant
  • All tests pass
  • Clicked around my changes running locally and it works
  • Checked Desktop, Mobile and Tablet screen sizes

Copy link

vercel bot commented Oct 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
couchers ✅ Ready (Inspect) Visit Preview Nov 13, 2024 6:39pm

@katemoser
Copy link
Author

Sorry, half my comment seems to have been deleted, I think I filled out the template wrong!

This is for #4172 , added front end validation and backend check as well. Started writing tests but would like to chat with someone for 15-20 minutes about how to best write tests for this!

@nabramow
Copy link
Contributor

nabramow commented Oct 29, 2024

Sorry, half my comment seems to have been deleted, I think I filled out the template wrong!

This is for #4172 , added front end validation and backend check as well. Started writing tests but would like to chat with someone for 15-20 minutes about how to best write tests for this!

Leaving a comment here about tests in case we don't overlap soon!

Code looks great so far.

Another good frontend test would be to make a new test file CommentForm.test.tsx (since no one is testing that component yet) and test that when the comment form is empty or only filled with whitespace characters, tabs, etc. and user hits submit, it doesn't call the postReply function. You could do this by mocking the service like:

const postReplyMock = service.threads.postReply as jest.Mock;

Then check it wasn't called in the individual test:

expect(postReplyMock).not.toHaveBeenCalled();

We can assume that if the function that picks up the change wasn't called, then we successfully protected it via the frontend.

For backend, you probably wanna add a test case in test_threads.py, the def test_threads_errors(db) function looks right. Probably you'd make the content in the arguments equal to "" and then check the right error showed. Looks like there's some similar functions in there you could base it on.

Instructions for testing locally on the backend are in app/backend/readme.md. You can run tests for only one function like pytest test_threads.py::test_threads_errors (path might be different to folder).

@nabramow nabramow linked an issue Nov 13, 2024 that may be closed by this pull request
Copy link
Member

@aapeliv aapeliv left a comment

Choose a reason for hiding this comment

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

Backend looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Empty discussion posts in events and communities are allowed
3 participants