Skip to content

fix(client): give useful error in solutionform#40225

Merged
raisedadead merged 1 commit intofreeCodeCamp:mainfrom
ShaunSHamilton:feat/submission-validation
Feb 1, 2021
Merged

fix(client): give useful error in solutionform#40225
raisedadead merged 1 commit intofreeCodeCamp:mainfrom
ShaunSHamilton:feat/submission-validation

Conversation

@ShaunSHamilton
Copy link
Member

@ShaunSHamilton ShaunSHamilton commented Nov 12, 2020

Checklist:

  • I have read freeCodeCamp's contribution guidelines.
  • My pull request has a descriptive title (not a vague title like Update index.md)
  • My pull request targets the master branch of freeCodeCamp.
  • All the files I changed are in the same world language, for example: only English changes, or only Chinese changes, etc.

Closes #39729

This PR includes a bit of groundwork for better error handling, but would require a bit too much refactoring. So, I would prefer this to be a PR relating more to helping with the case where Campers try to pass the incorrect URLs.

QUESTION: Should I expand this to validate whether the camper has submitted the example URLs? It would remove the need to keep updating the first user-story tests for each project.

@ShaunSHamilton ShaunSHamilton added scope: UI Threads for addressing UX changes and improvements to user interface platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. status: PR in works Work in Progress (WIP) Issues. labels Nov 12, 2020
@gitpod-io
Copy link

gitpod-io bot commented Nov 12, 2020

@ShaunSHamilton
Copy link
Member Author

@ahmadabdolsaheb I would appreciate your opinion on the wording/styling of the hint:
image

@naomi-lgbt
Copy link
Member

What about Please submit the link to the live version of your app?

@ShaunSHamilton
Copy link
Member Author

@nhcarrigan It would need to be shorter than it already is, not longer; I do not want it wrapping on smaller screens.

kbakdev
kbakdev previously approved these changes Nov 26, 2020
@ShaunSHamilton
Copy link
Member Author

ShaunSHamilton commented Nov 27, 2020

Currently, this is at a point where I could see it being merged. All it would help with is warnings about invalid URLs, and I have set up the ground work I would expect for better error handling, and URL validation.

EDIT: I need to handle the tests...

@ShaunSHamilton ShaunSHamilton removed the status: PR in works Work in Progress (WIP) Issues. label Nov 27, 2020
@ShaunSHamilton
Copy link
Member Author

I cannot seem to pass the Cypress test. Here is the failure:

 2) A certification,
       while viewing someone else's,
         "before all" hook for "should not render a LinkedIn button":
     AssertionError: Timed out retrying: Expected to find content: 'Sign me out of freeCodeCamp' but never did.

I am still busy trying to setup tests for GitPod, so cannot test this locally (laptop is struggling). Otherwise, I do not think I touched anything related in this PR, anyway.

@ojeytonwilliams
Copy link
Contributor

Hey @SKY020, there's one issue stemming from the change to formatUrlValues. That's used in handleSubmitLegacy, so that also needs to handle the { values: ...} object.

@ahmaxed
Copy link
Member

ahmaxed commented Dec 7, 2020

@ahmadabdolsaheb I would appreciate your opinion on the wording/styling of the hint:

The message is descriptive. I would add a dot to the end of the message for consistency 👍
Although we are using different elements, we should unify the padding between the form and hint/error across our UI at some point.

image

image

@gitpod-io
Copy link

gitpod-io bot commented Jan 13, 2021

@ahmaxed
Copy link
Member

ahmaxed commented Jan 13, 2021

Since only SolutionForm sets the DisplayError and only FormFields gets it and FormFields is the direct descendent of SolutionForm (SolutionForm > Form > FormFields), I think it would be better to have DisplayError as a state on SolutionForm and pass it down as props.

We could use Context to avoid passing it down one component at a time.

That way FormFields does not need to be a connected component and we can free up some space on the redux store.

Additional suggestions:
1)isOpenCompletionModal could be changed to something more descriptive such as 'isCompletionModalDisplayable'.
2) Some e2e tests are also appreciated.

@ahmaxed
Copy link
Member

ahmaxed commented Jan 14, 2021

Considerations:

Since we already have all the info we need for opening the completion modal in execute-challenge-saga, I cannot think of a good reason to have challenge-modal-epic, what do you think?

For the backend and and frontend shows, we could move the submit completely to solutionForm since it is a connected component and has the logic to handle executeChallenge. (That would simplify them a bit and make them good candidates for hookification

I am not fan of how we communicate validation information from FormFields --> Form --> SolutionForm --> Form (shows the error), but I see how it would help to keep form stateless.

@ahmaxed
Copy link
Member

ahmaxed commented Jan 15, 2021

We are setting isCompletionModalShouldOpen to the redux store with the executeChallenge. Then we would read isCompletionModalShouldOpen from store in execute-challenge-saga when executeChallenge is called.

Since isCompletionModalShouldOpen is supplied to executeChallenge as payload and it is only used in this context, It might make more sense to just use as payload directly in execute-challenge-saga and not set it in the store.

Also, what do you think of shouldCompletionModalOpen as an alternative name?

@ShaunSHamilton
Copy link
Member Author

@ahmadabdolsaheb I have compromised on the name of the variable - now isShouldCompletionModalOpen

Also, I have passed it as an argument directly (bypassing the store). However, it is currently in the payload as true, and not { isShouldCompletionModalOpen: true }. I have mixed thoughts about the clarity of this, so what do you think?

@ahmaxed
Copy link
Member

ahmaxed commented Jan 24, 2021

Quick note (we don't have to fix it on this pr IIMHO) : unvalidated (localhost) submissions to the legacy cert section of the settings page would go through, and the hints would show up for all previous submissions.

@ahmaxed
Copy link
Member

ahmaxed commented Jan 24, 2021

I have tested submitting front/backend projects with this pr and it works as expected. Other than the nit-picks mentioned above it is LGMT.

@ShaunSHamilton
Copy link
Member Author

Quick note (we don't have to fix it on this pr IIMHO) : unvalidated (localhost) submissions to the legacy cert section of the settings page would go through, and the hints would show up for all previous submissions.

For the most part, this looks like wanted behaviour. I think we do have an issue up which intends to add checks to submissions from the settings page. So, this would be resolved in that PR (perhaps, I can take a look).

@ShaunSHamilton
Copy link
Member Author

@ahmadabdolsaheb Thanks a tonne, for the suggestion about removing the displayErrors state. This is simpler.

ahmaxed
ahmaxed previously approved these changes Jan 29, 2021
@raisedadead raisedadead force-pushed the feat/submission-validation branch from 8d9a4a4 to 4427439 Compare February 1, 2021 06:11
Copy link
Member

@raisedadead raisedadead left a comment

Choose a reason for hiding this comment

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

Hi @ahmadabdolsaheb can you sanity check this again. I just rebased/squashed a lot of commits here.

If it looks good please merge.

@raisedadead raisedadead added the status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. label Feb 1, 2021
ahmaxed
ahmaxed previously approved these changes Feb 1, 2021
@raisedadead raisedadead changed the base branch from master to main February 1, 2021 13:33
@raisedadead raisedadead dismissed ahmaxed’s stale review February 1, 2021 13:33

The base branch was changed.

@raisedadead raisedadead merged commit ab83d69 into freeCodeCamp:main Feb 1, 2021
@ShaunSHamilton ShaunSHamilton deleted the feat/submission-validation branch March 30, 2021 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. scope: UI Threads for addressing UX changes and improvements to user interface status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project Submission Throws Uncaught Error

6 participants