Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

feat(appointments) reason field no longer labelled as a required field when making appointments. #2003

Merged
merged 15 commits into from
Apr 23, 2020

Conversation

JDarke
Copy link
Contributor

@JDarke JDarke commented Apr 21, 2020

Fixes #1997 .

Changes proposed in this pull request:

changed line 21 of src/components/input/textfieldwithlabelformgroup.tsx , so that Label attr 'isRequired' now takes value from Props.isRequired? (line 11).

JDarke added 2 commits April 21, 2020 10:38
Reason field on new appointment screen no longer a required field.  Line 21, Label element now takes
isRequired attr from interface Props.

fix HospitalRun#1997
@jsf-clabot
Copy link

jsf-clabot commented Apr 21, 2020

CLA assistant check
All committers have signed the CLA.

@vercel
Copy link

vercel bot commented Apr 21, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/hospitalrun/hospitalrun-frontend/2pxqe7pqh
✅ Preview: https://hospitalrun-frontend-git-fork-jdarke-master.hospitalrun.now.sh

package.json Outdated
@@ -31,7 +31,8 @@
"redux-thunk": "~2.3.0",
"shortid": "^2.2.15",
"typescript": "~3.8.2",
"uuid": "^7.0.1"
"uuid": "^7.0.1",
"yarn": "~1.22.4"
Copy link
Member

Choose a reason for hiding this comment

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

You are right, this can be removed. Yarn is expected to be globally installed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll take that out in the next commit.

const id = `${name}TextField`
return (
<div className="form-group">
<Label text={label} htmlFor={id} isRequired />
<Label text={label} htmlFor={id} isRequired={isRequired} />
Copy link
Member

Choose a reason for hiding this comment

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

can we add a test that, if isRequired is provided`, that it is passed to the label and marks the label as required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I can see, that's tested when FormLabel is imported into Label.tsx...see the attached screenshot (it seemed more useful to use a pic in this instance than to just post the code - apologies if that's incorrect practice!)

The /src/components path contains a lot more subfolders than my local clone, so I can't access a local copy of Label.tsx. Is that being compiled on the server side?

Screen Shot 2020-04-21 at 18 15 49

Copy link
Member

Choose a reason for hiding this comment

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

The components that you are seeing are coming from this library:
https://github.com/HospitalRun/components

For this test, all we want to verify is that if the isRequired prop is given to the TextFieldWithLabelFormGroup component, that is passes it to the Label component.

It doesn't actually verify that the functionality is working, per se. We trust that the implementation of the Label component works as intended. What we are testing is that we are using the Label component correctly. See this test for how we tested the that the correct text is used:

describe('text field with label form group', () => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see...yup, I'll give it a go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is the test to be added into TextFieldWithLabelFormGroup.test.tsx (with the text field test suite you referenced) or should it be a separate local test in TextFieldWithLabelFormGroup.tsx?

Copy link
Member

Choose a reason for hiding this comment

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

Either! I don't have a preference

Copy link
Contributor Author

@JDarke JDarke Apr 22, 2020

Choose a reason for hiding this comment

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

I've got a new commit to push, but it's telling me that my local and remote have diverged. Tried a pull to merge them, and my terminal locked up. Restarted and retried, and now I have this message in terminal:

error: You have not concluded your merge (MERGE_HEAD exists).
hint: Please, commit your changes before merging.
fatal: Exiting because of unfinished merge.

Is this fixable, or do I need to save my local changes, re-clone the repo to local, and then send a whole new PR, or does it need to be connected to this thread's PR?

Copy link
Contributor Author

@JDarke JDarke Apr 22, 2020

Choose a reason for hiding this comment

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

Here's the test, btw:

describe('text field with label form group', () => {
  describe('layout', () => {
    it('should render a label', () => {
      const expectedName = 'test'
      const wrapper = shallow(
        <TextFieldWithLabelFormGroup
          name={expectedName}
          label="test"
          value=""
          isEditable
          onChange={jest.fn()}
        />,
      )

      const label = wrapper.find(Label)
      expect(label).toHaveLength(1)
      expect(label.prop('htmlFor')).toEqual(`${expectedName}TextField`)
      expect(label.prop('text')).toEqual(expectedName)
    })

   it('should render label as required if isRequired is true', () => {
      const expectedName = 'test'
      const expectedRequired = true
      const wrapper = shallow(
        <TextFieldWithLabelFormGroup
          name={expectedName}
          label="test"
          value=""
          isEditable
          isRequired={expectedRequired}
          onChange={jest.fn()}
        />,
      )

      const label = wrapper.find(Label)
      expect(label).toHaveLength(1)
      expect(label.prop('isRequired')).toBeTruthy()
    })


Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I seem to have got it pushed now, and it looks like the earlier ones did, too. Apologies if I'm cluttering up this PR with multiple commits.

Previously added a listing for yarn in the dependencies in package.json.  This commit undoes that.

re |
@vercel vercel bot temporarily deployed to Preview April 22, 2020 12:49 Inactive
Added a test case to test if the Label receives the isRequired prop on required fields

re HospitalRun#2003
Changed const expectedValue to const expectedRequired, named for prop isRequired

re HospitalRun#2003
@jackcmeyer jackcmeyer added scheduling issue/pull request that interacts with scheduling module 🐛bug issue/pull request that documents/fixes a bug labels Apr 23, 2020
@jackcmeyer jackcmeyer added this to the v2.0 milestone Apr 23, 2020
@jackcmeyer jackcmeyer changed the title Reason field no longer labelled as a required field when making appointments. feat(scheduling) reason field no longer labelled as a required field when making appointments. Apr 23, 2020
@jackcmeyer jackcmeyer changed the title feat(scheduling) reason field no longer labelled as a required field when making appointments. feat(appointments) reason field no longer labelled as a required field when making appointments. Apr 23, 2020
@jackcmeyer jackcmeyer merged commit d5a16b1 into HospitalRun:master Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐛bug issue/pull request that documents/fixes a bug scheduling issue/pull request that interacts with scheduling module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reason is incorrectly being marked as required field on edit/new appointment screen
3 participants