Skip to content

MMT-4004: Build a UI schema and JSON schema for building the form #1353

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

Merged
merged 11 commits into from
Apr 24, 2025

Conversation

mandyparson
Copy link
Contributor

@mandyparson mandyparson commented Apr 22, 2025

Overview

What is the feature?

Create a UI schema, JSON schema for this form.

The UI Schema/JSON schema should include all fields (pref label, reference, narrower, broader, etc.)

Render the form when element in tree is clicked.

What is the Solution?

Implemented these elements much like our other concepts

What areas of the application does this impact?

KeywordManager

Testing

Reproduction steps

  • **Environment for testing:SIT
  • **Collection to test with: 00c6f0f3-5734-4500-a69e-f6780e365985, a014021c-5636-4388-85d4-ff8dc25e3853
  1. Use either of those are your exampleUUID in KeywordManagerPage to see how the form renders.
  2. Make sure the form 'saves' without errors.

Attachments

N/a

Checklist

  • I have added automated tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@mandyparson mandyparson changed the title MMT-4004: Creating UiSchema and JSON MMT-4004: Build a UI schema and JSON schema for building the form Apr 22, 2025
render(<KeywordForm initialData={{}} />)
const preferredLabelInput = screen.getByLabelText('Preferred Label')
fireEvent.change(preferredLabelInput, { target: { value: 'New Keyword' } })
expect(preferredLabelInput).toHaveValue('New Keyword')
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be better to verify formData has the information you type, than to just check the input field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

at this point, formData won't have that information until we implement the save button, correct?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you might be able to spyOn handleChange to check if the form data is being updated?

Copy link
Contributor Author

@mandyparson mandyparson Apr 23, 2025

Choose a reason for hiding this comment

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

I've tried a few different things with this now, but spyOn is meant for objects or class prototypes, not for functions defined within the component's scope.

Copy link
Collaborator

@cgokey cgokey Apr 24, 2025

Choose a reason for hiding this comment

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

I took a few minutes and looked, there are ways but I don't really like any of them. I think maybe rename the test then, "test('updates formData when a change occurs', async () => {" -- you are not really checking formData, you are just verifying whatever you type shows up in the textfield, is there some processing going on that you are testing in terms of specific lines of code, maybe you can verify that part..., otherwise you are just testing standard html behavior, that what you type shows up in a field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay! Created a function to be called with the newly created object that's made onHandleChange. Let me know what you think.

@codecov-commenter
Copy link

codecov-commenter commented Apr 23, 2025

Codecov Report

Attention: Patch coverage is 60.49383% with 32 lines in your changes missing coverage. Please review.

Project coverage is 97.23%. Comparing base (35fd9b2) to head (049bb59).

Files with missing lines Patch % Lines
static/src/js/utils/createFormDataFromRdf.js 3.03% 25 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1353      +/-   ##
==========================================
- Coverage   97.74%   97.23%   -0.51%     
==========================================
  Files         370      374       +4     
  Lines        5901     5977      +76     
  Branches     1225     1250      +25     
==========================================
+ Hits         5768     5812      +44     
- Misses        132      157      +25     
- Partials        1        8       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mandyparson mandyparson merged commit 1eef6d6 into main Apr 24, 2025
7 checks passed
@mandyparson mandyparson deleted the MMT-4004 branch April 24, 2025 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants