From 258180dfe8a6f584c4fb6e5128c1fbf504da1f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Saracca?= Date: Wed, 5 Feb 2025 11:48:52 -0300 Subject: [PATCH 1/9] feat: update js-dv package --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 39e3377e1..066c29471 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "dependencies": { "@faker-js/faker": "7.6.0", - "@iqss/dataverse-client-javascript": "2.0.0-alpha.13", + "@iqss/dataverse-client-javascript": "2.0.0-pr250.21b1ca0", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", @@ -3674,9 +3674,9 @@ }, "node_modules/@iqss/dataverse-client-javascript": { "name": "@IQSS/dataverse-client-javascript", - "version": "2.0.0-alpha.13", - "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-alpha.13/99f81ce18bdd855a54cd79520367516c28b262b8", - "integrity": "sha512-Giv/g1+6bFUTiVcwnzrJhdhWhyMd6gcXLnArN36kxAPrhoR0adRjUa8bevE41Vb5lASw56UoVF17XS/G9Uhj7A==", + "version": "2.0.0-pr250.21b1ca0", + "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-pr250.21b1ca0/90af1733ed39440d58c94df6562cae36fa05fe06", + "integrity": "sha512-itueBRy1bdcgS5vgI5juwJGKC7nkEE/2Cfel8KOnWRxPSi8bdvq2g6Uw3ZPml6+XaRq09wnFiIFJ1C+9PuvP4g==", "license": "MIT", "dependencies": { "@types/node": "^18.15.11", diff --git a/package.json b/package.json index a373e4161..444f44f4e 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "7.6.0", - "@iqss/dataverse-client-javascript": "2.0.0-alpha.13", + "@iqss/dataverse-client-javascript": "2.0.0-pr250.21b1ca0", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", From 6d09cf28f790361b7695caae20ffc216124a7a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Saracca?= Date: Wed, 5 Feb 2025 11:49:19 -0300 Subject: [PATCH 2/9] feat: update dto sent --- .../domain/useCases/DTOs/CollectionDTO.ts | 2 + .../CollectionFormHelper.ts | 50 ------------------- .../collection-form/CollectionForm.tsx | 10 ++-- .../collection-form/useSubmitCollection.ts | 42 +++------------- 4 files changed, 12 insertions(+), 92 deletions(-) diff --git a/src/collection/domain/useCases/DTOs/CollectionDTO.ts b/src/collection/domain/useCases/DTOs/CollectionDTO.ts index 3a2d076e3..00042f10d 100644 --- a/src/collection/domain/useCases/DTOs/CollectionDTO.ts +++ b/src/collection/domain/useCases/DTOs/CollectionDTO.ts @@ -10,6 +10,8 @@ export interface CollectionDTO { metadataBlockNames?: string[] facetIds?: string[] inputLevels?: CollectionInputLevelDTO[] + inheritMetadataBlocksFromParent: boolean + inheritFacetsFromParent: boolean } export interface CollectionInputLevelDTO { diff --git a/src/sections/shared/form/EditCreateCollectionForm/CollectionFormHelper.ts b/src/sections/shared/form/EditCreateCollectionForm/CollectionFormHelper.ts index 37e5ff999..ec1210d01 100644 --- a/src/sections/shared/form/EditCreateCollectionForm/CollectionFormHelper.ts +++ b/src/sections/shared/form/EditCreateCollectionForm/CollectionFormHelper.ts @@ -246,54 +246,4 @@ export class CollectionFormHelper { return true } } - - public static defineShouldSendMetadataBlockNamesAndInputLevels( - useFieldsFromParentChecked: boolean, - isEditingRootCollection: boolean, - blockNamesHaveChanged: boolean, - inputLevelsHaveChanged: boolean, - mode: 'edit' | 'create' - ): boolean { - if (mode === 'edit') { - if (isEditingRootCollection) { - if (blockNamesHaveChanged || inputLevelsHaveChanged) return true - - return false - } else { - if (useFieldsFromParentChecked) return false - - // If useFieldsFromParentChecked is not checked we should send the default metadata block names and input levels, the only way for the user to edit them is to uncheck the useFromParent first - return true - } - } else { - if (useFieldsFromParentChecked) return false - - // If useFieldsFromParentChecked is not checked we should send the default metadata block names and input levels, the only way for the user to edit them is to uncheck the useFromParent first - return true - } - } - - public static defineShouldSendFacetIds( - useFacetsFromParentChecked: boolean, - isEditingRootCollection: boolean, - facetIdsHaveChanged: boolean, - mode: 'edit' | 'create' - ): boolean { - if (mode === 'edit') { - if (isEditingRootCollection) { - if (facetIdsHaveChanged) return true - return false - } else { - if (useFacetsFromParentChecked) return false - - // If useFacetsFromParentChecked is not checked we should send the default facetIds, changed or not - return true - } - } else { - if (useFacetsFromParentChecked) return false - - // If useFacetsFromParentChecked is not checked we should send the default facetIds, changed or not - return true - } - } } diff --git a/src/sections/shared/form/EditCreateCollectionForm/collection-form/CollectionForm.tsx b/src/sections/shared/form/EditCreateCollectionForm/collection-form/CollectionForm.tsx index 04d6a409d..1597239b1 100644 --- a/src/sections/shared/form/EditCreateCollectionForm/collection-form/CollectionForm.tsx +++ b/src/sections/shared/form/EditCreateCollectionForm/collection-form/CollectionForm.tsx @@ -10,13 +10,13 @@ import { MetadataField } from '@/metadata-block-info/domain/models/MetadataBlockInfo' import { SubmissionStatus, useSubmitCollection } from './useSubmitCollection' -import styles from './CollectionForm.module.scss' import { TopFieldsSection } from './top-fields-section/TopFieldsSection' import { SeparationLine } from '@/sections/shared/layout/SeparationLine/SeparationLine' import { MetadataFieldsSection } from './metadata-fields-section/MetadataFieldsSection' import { BrowseSearchFacetsSection } from './browse-search-facets-section/BrowseSearchFacetsSection' import { EditCreateCollectionFormMode } from '../EditCreateCollectionForm' import { RouteWithParams } from '@/sections/Route.enum' +import styles from './CollectionForm.module.scss' export interface CollectionFormProps { mode: EditCreateCollectionFormMode @@ -49,14 +49,10 @@ export const CollectionForm = ({ defaultValues }) - const { formState } = form - const { submitForm, submitError, submissionStatus } = useSubmitCollection( mode, collectionIdOrParentCollectionId, collectionRepository, - isEditingRootCollection, - formState.dirtyFields, onSubmittedCollectionError ) @@ -71,8 +67,8 @@ export const CollectionForm = ({ } const disableSubmitButton = useMemo(() => { - return submissionStatus === SubmissionStatus.IsSubmitting || !formState.isDirty - }, [submissionStatus, formState.isDirty]) + return submissionStatus === SubmissionStatus.IsSubmitting || !form.formState.isDirty + }, [submissionStatus, form.formState.isDirty]) return (
['dirtyFields'], onSubmitErrorCallback: () => void ): UseSubmitCollectionReturnType { const navigate = useNavigate() @@ -57,7 +53,7 @@ export function useSubmitCollection( const [submitError, setSubmitError] = useState(null) const submitForm = (formData: CollectionFormValuesOnSubmit): void => { - // setSubmissionStatus(SubmissionStatus.IsSubmitting) + setSubmissionStatus(SubmissionStatus.IsSubmitting) const contactsDTO = formData.contacts.map((contact) => contact.value) @@ -73,34 +69,10 @@ export function useSubmitCollection( const facetIdsDTO = formData.facetIds.map((facet) => facet.value) - const useFieldsFromParentChecked = formData[USE_FIELDS_FROM_PARENT] + const useMetadataFieldsFromParentChecked = formData[USE_FIELDS_FROM_PARENT] const useFacetsFromParentChecked = formData[USE_FACETS_FROM_PARENT] - const hasMetadataBlockNamesChangedFromDefaultValue = - formDirtyFields[METADATA_BLOCKS_NAMES_GROUPER] !== undefined - - const hasInputLevelsChangedFromDefaultValue = - formDirtyFields[INPUT_LEVELS_GROUPER] !== undefined - - const hasFacetIdsChangedFromDefaultValue = formDirtyFields[FACET_IDS_FIELD] !== undefined - - const shouldSendMetadataBlockNamesAndInputLevels = - CollectionFormHelper.defineShouldSendMetadataBlockNamesAndInputLevels( - useFieldsFromParentChecked, - isEditingRootCollection, - hasMetadataBlockNamesChangedFromDefaultValue, - hasInputLevelsChangedFromDefaultValue, - mode - ) - - const shouldSendFacetIds = CollectionFormHelper.defineShouldSendFacetIds( - useFacetsFromParentChecked, - isEditingRootCollection, - hasFacetIdsChangedFromDefaultValue, - mode - ) - const newOrUpdatedCollection: CollectionDTO = { name: formData.name, alias: formData.alias, @@ -108,11 +80,11 @@ export function useSubmitCollection( affiliation: formData.affiliation, description: formData.description, contacts: contactsDTO, - metadataBlockNames: shouldSendMetadataBlockNamesAndInputLevels - ? metadataBlockNamesDTO - : undefined, - inputLevels: shouldSendMetadataBlockNamesAndInputLevels ? inputLevelsDTO : undefined, - facetIds: shouldSendFacetIds ? facetIdsDTO : undefined + metadataBlockNames: metadataBlockNamesDTO, + inputLevels: inputLevelsDTO, + facetIds: facetIdsDTO, + inheritMetadataBlocksFromParent: useMetadataFieldsFromParentChecked, + inheritFacetsFromParent: useFacetsFromParentChecked } if (mode === 'create') { From f20cded10ba1ecc6435e3018b5045ba0869597f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Saracca?= Date: Wed, 5 Feb 2025 11:49:36 -0300 Subject: [PATCH 3/9] test: remove unneeded tests --- .../CollectionFormHelper.spec.ts | 124 ------------------ 1 file changed, 124 deletions(-) diff --git a/tests/component/sections/shared/edit-create-collection-form/CollectionFormHelper.spec.ts b/tests/component/sections/shared/edit-create-collection-form/CollectionFormHelper.spec.ts index ff83551bd..1a9a98323 100644 --- a/tests/component/sections/shared/edit-create-collection-form/CollectionFormHelper.spec.ts +++ b/tests/component/sections/shared/edit-create-collection-form/CollectionFormHelper.spec.ts @@ -612,128 +612,4 @@ describe('CollectionFormHelper', () => { expect(result).to.equal(true) }) }) - - describe('defineShouldSendMetadataBlockNamesAndInputLevels', () => { - it('for edit mode - returns true if is editing root collection and blockNamesHaveChanged is true', () => { - const result = CollectionFormHelper.defineShouldSendMetadataBlockNamesAndInputLevels( - false, - true, - true, - false, - 'edit' - ) - - expect(result).to.equal(true) - }) - - it('for edit mode - returns true if is editing root collection and inputLevelsHaveChanged is true', () => { - const result = CollectionFormHelper.defineShouldSendMetadataBlockNamesAndInputLevels( - false, - true, - false, - true, - 'edit' - ) - - expect(result).to.equal(true) - }) - - it('for edit mode - returns false if is editing root collection and blockNamesHaveChanged and inputLevelsHaveChanged are false', () => { - const result = CollectionFormHelper.defineShouldSendMetadataBlockNamesAndInputLevels( - false, - true, - false, - false, - 'edit' - ) - - expect(result).to.equal(false) - }) - - it('for edit mode - returns false if is not editing root collection and useFieldsFromParentChecked is true', () => { - const result = CollectionFormHelper.defineShouldSendMetadataBlockNamesAndInputLevels( - true, - false, - true, - true, - 'edit' - ) - - expect(result).to.equal(false) - }) - - it('for edit mode - returns true if is not editing root collection and useFieldsFromParentChecked is false', () => { - const result = CollectionFormHelper.defineShouldSendMetadataBlockNamesAndInputLevels( - false, - false, - true, - true, - 'edit' - ) - - expect(result).to.equal(true) - }) - - it('for create mode - returns false if useFieldsFromParentChecked is true', () => { - const result = CollectionFormHelper.defineShouldSendMetadataBlockNamesAndInputLevels( - true, - false, - true, - true, - 'create' - ) - - expect(result).to.equal(false) - }) - - it('for create mode - returns true if useFieldsFromParentChecked is false', () => { - const result = CollectionFormHelper.defineShouldSendMetadataBlockNamesAndInputLevels( - false, - false, - true, - true, - 'create' - ) - - expect(result).to.equal(true) - }) - }) - - describe('defineShouldSendFacetIds', () => { - it('for edit mode - returns true if is editing root collection and facetIdsHaveChanged is true', () => { - const result = CollectionFormHelper.defineShouldSendFacetIds(false, true, true, 'edit') - - expect(result).to.equal(true) - }) - - it('for edit mode - returns false if is editing root collection and facetIdsHaveChanged is false', () => { - const result = CollectionFormHelper.defineShouldSendFacetIds(false, true, false, 'edit') - - expect(result).to.equal(false) - }) - - it('for edit mode - returns false if is not editing root collection and useFacetsFromParentChecked is true', () => { - const result = CollectionFormHelper.defineShouldSendFacetIds(true, false, true, 'edit') - - expect(result).to.equal(false) - }) - - it('for edit mode - returns true if is not editing root collection and useFacetsFromParentChecked is false', () => { - const result = CollectionFormHelper.defineShouldSendFacetIds(false, false, true, 'edit') - - expect(result).to.equal(true) - }) - - it('for create mode - returns false if useFacetsFromParentChecked is true', () => { - const result = CollectionFormHelper.defineShouldSendFacetIds(true, false, true, 'create') - - expect(result).to.equal(false) - }) - - it('for create mode - returns true if useFacetsFromParentChecked is false', () => { - const result = CollectionFormHelper.defineShouldSendFacetIds(false, false, true, 'create') - - expect(result).to.equal(true) - }) - }) }) From 09dc9170e0430a6676b890e18fc8c5048a7d5624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Saracca?= Date: Wed, 5 Feb 2025 12:42:59 -0300 Subject: [PATCH 4/9] test: assert booleans instead of undefined due to changes --- .../EditCreateCollectionForm.spec.tsx | 185 ++++++------------ 1 file changed, 55 insertions(+), 130 deletions(-) diff --git a/tests/component/sections/shared/edit-create-collection-form/EditCreateCollectionForm.spec.tsx b/tests/component/sections/shared/edit-create-collection-form/EditCreateCollectionForm.spec.tsx index 12359113a..cdbd13a67 100644 --- a/tests/component/sections/shared/edit-create-collection-form/EditCreateCollectionForm.spec.tsx +++ b/tests/component/sections/shared/edit-create-collection-form/EditCreateCollectionForm.spec.tsx @@ -484,7 +484,7 @@ describe('EditCreateCollectionForm', () => { cy.findByLabelText('Subtitle').should('be.checked') }) - it('should send metadataBlockNames and inputLevels as undefined if use fields from parent is checked', () => { + it('should send inheritMetadataBlocksFromParent in true if use metadata fields from parent is checked', () => { const collectionRepository = {} as CollectionRepository collectionRepository.create = cy.stub().as('createCollection').resolves() collectionRepository.getFacets = cy.stub().resolves(CollectionFacetMother.createFacets()) @@ -510,15 +510,13 @@ describe('EditCreateCollectionForm', () => { const createCollectionSpy = spy as unknown as Cypress.Agent const collectionDTO = createCollectionSpy.getCall(0).args[0] as CollectionDTO - const inputLevels = collectionDTO.inputLevels - const metadataBlockNames = collectionDTO.metadataBlockNames + const inheritMetadataBlocksFromParent = collectionDTO.inheritMetadataBlocksFromParent - expect(inputLevels).to.be.undefined - expect(metadataBlockNames).to.be.undefined + expect(inheritMetadataBlocksFromParent).to.be.true }) }) - it('should not send metadataBlockNames and inputLevels as undefined if use fields from parent is unchecked', () => { + it('should send inheritMetadataBlocksFromParent in false if use metadata fields from parent is unchecked', () => { const collectionRepository = {} as CollectionRepository collectionRepository.create = cy.stub().as('createCollection').resolves() collectionRepository.getFacets = cy.stub().resolves(CollectionFacetMother.createFacets()) @@ -533,24 +531,22 @@ describe('EditCreateCollectionForm', () => { /> ) - cy.get('@useFieldsFromParentCheckbox').uncheck({ force: true }) - // Accept suggestion cy.findByRole('button', { name: 'Apply suggestion' }).click() // Select a Category option cy.findByLabelText(/^Category/i).select(1) + cy.get('@useFieldsFromParentCheckbox').uncheck({ force: true }) + cy.findByRole('button', { name: 'Create Collection' }).click() cy.get('@createCollection').should((spy) => { const createCollectionSpy = spy as unknown as Cypress.Agent const collectionDTO = createCollectionSpy.getCall(0).args[0] as CollectionDTO - const inputLevels = collectionDTO.inputLevels - const metadataBlockNames = collectionDTO.metadataBlockNames + const inheritMetadataBlocksFromParent = collectionDTO.inheritMetadataBlocksFromParent - expect(inputLevels).to.not.be.undefined - expect(metadataBlockNames).to.not.be.undefined + expect(inheritMetadataBlocksFromParent).to.be.false }) }) }) @@ -847,6 +843,10 @@ describe('EditCreateCollectionForm', () => { describe('BrowseSearchFacetsSection functionality', () => { beforeEach(() => { + const collectionRepository = {} as CollectionRepository + collectionRepository.create = cy.stub().as('createCollection').resolves() + collectionRepository.getFacets = cy.stub().resolves(CollectionFacetMother.createFacets()) + cy.mountAuthenticated( { cy.findByText('At least one facet must be selected.').should('not.exist') }) + + it('should send inheritFacetsFromParent in true if use facets from parent is checked', () => { + // Accept suggestion + cy.findByRole('button', { name: 'Apply suggestion' }).click() + // Select a Category option + cy.findByLabelText(/^Category/i).select(1) + + cy.findByRole('button', { name: 'Create Collection' }).click() + + cy.get('@createCollection').should((spy) => { + const createCollectionSpy = spy as unknown as Cypress.Agent + const collectionDTO = createCollectionSpy.getCall(0).args[0] as CollectionDTO + + const inheritFacetsFromParent = collectionDTO.inheritFacetsFromParent + + expect(inheritFacetsFromParent).to.be.true + }) + }) + + it('should send inheritFacetsFromParent in false if use facets from parent is unchecked', () => { + // Accept suggestion + cy.findByRole('button', { name: 'Apply suggestion' }).click() + // Select a Category option + cy.findByLabelText(/^Category/i).select(1) + + cy.get('@useFacetsFromParentCheckbox').uncheck({ force: true }) + + cy.findByRole('button', { name: 'Create Collection' }).click() + + cy.get('@createCollection').should((spy) => { + const createCollectionSpy = spy as unknown as Cypress.Agent + const collectionDTO = createCollectionSpy.getCall(0).args[0] as CollectionDTO + + const inheritFacetsFromParent = collectionDTO.inheritFacetsFromParent + + expect(inheritFacetsFromParent).to.be.false + }) + }) }) }) @@ -1161,7 +1199,7 @@ describe('EditCreateCollectionForm', () => { cy.findByLabelText(/^Email/i).should('have.value', collectionBeingEdited.contacts[0].email) }) - it('when editing the root collection, should not send metadataBlockNames and inputLevels as undefined if any of them have changed', () => { + it('when editing the root collection, should send inheritFacetsFromParent and inheritMetadataBlocksFromParent in false always', () => { const collectionRepository = {} as CollectionRepository collectionRepository.edit = cy.stub().as('editCollection').resolves() collectionRepository.getFacets = cy.stub().resolves(CollectionFacetMother.createFacets()) @@ -1186,124 +1224,11 @@ describe('EditCreateCollectionForm', () => { const editCollectionSpy = spy as unknown as Cypress.Agent const collectionDTO = editCollectionSpy.getCall(0).args[1] as CollectionDTO - const inputLevels = collectionDTO.inputLevels - const metadataBlockNames = collectionDTO.metadataBlockNames - - expect(inputLevels).not.to.be.undefined - expect(metadataBlockNames).not.to.be.undefined - }) - }) - - it('when editing the root collection, should send metadataBlockNames and inputLevels as undefined if they didnt changed', () => { - const collectionRepository = {} as CollectionRepository - collectionRepository.edit = cy.stub().as('editCollection').resolves() - collectionRepository.getFacets = cy.stub().resolves(CollectionFacetMother.createFacets()) - - cy.mountAuthenticated( - - ) - - // Change affiliation in order to be able to save - cy.findByLabelText(/^Affiliation/i) - .clear() - .type('New Affiliation') - - cy.findByRole('button', { name: 'Save Changes' }).click() - - cy.get('@editCollection').should((spy) => { - const editCollectionSpy = spy as unknown as Cypress.Agent - const collectionDTO = editCollectionSpy.getCall(0).args[1] as CollectionDTO - - const inputLevels = collectionDTO.inputLevels - const metadataBlockNames = collectionDTO.metadataBlockNames - - expect(inputLevels).to.be.undefined - expect(metadataBlockNames).to.be.undefined - }) - }) - - it('when editing root collection, should not send facetIds as undefined if they have changed', () => { - const collectionRepository = {} as CollectionRepository - collectionRepository.edit = cy.stub().as('editCollection').resolves() - collectionRepository.getFacets = cy.stub().resolves(CollectionFacetMother.createFacets()) - - cy.mountAuthenticated( - - ) - - cy.findByTestId('left-list-group').as('leftList') - cy.findByTestId('actions-column').as('actionsColumn') - cy.findByTestId('right-list-group').as('rightList') - - // Change the default selected facets - cy.get('@leftList').within(() => { - cy.findByText('Topic Classification Term').click() - }) - - cy.get('@actionsColumn').within(() => { - cy.findByLabelText('move selected to right').click() - }) - - cy.get('@rightList').within(() => { - cy.findByLabelText('Topic Classification Term').should('exist') - }) - - cy.findByRole('button', { name: 'Save Changes' }).click() - - cy.get('@editCollection').should((spy) => { - const editCollectionSpy = spy as unknown as Cypress.Agent - const collectionDTO = editCollectionSpy.getCall(0).args[1] as CollectionDTO - - const facetIds = collectionDTO.facetIds - - expect(facetIds).to.not.be.undefined - }) - }) - - it('when editing root collection, should send facetIds as undefined if they didnt changed', () => { - const collectionRepository = {} as CollectionRepository - collectionRepository.edit = cy.stub().as('editCollection').resolves() - collectionRepository.getFacets = cy.stub().resolves(CollectionFacetMother.createFacets()) - - cy.mountAuthenticated( - - ) - - // Change affiliation in order to be able to save - cy.findByLabelText(/^Affiliation/i) - .clear() - .type('New Affiliation') - - cy.findByRole('button', { name: 'Save Changes' }).click() - - cy.get('@editCollection').should((spy) => { - const editCollectionSpy = spy as unknown as Cypress.Agent - const collectionDTO = editCollectionSpy.getCall(0).args[1] as CollectionDTO - - const facetIds = collectionDTO.facetIds + const inheritFacetsFromParent = collectionDTO.inheritFacetsFromParent + const inheritMetadataBlocksFromParent = collectionDTO.inheritMetadataBlocksFromParent - expect(facetIds).to.be.undefined + expect(inheritFacetsFromParent).to.be.false + expect(inheritMetadataBlocksFromParent).to.be.false }) }) }) From b696aa8221079eca28f20075f4feb044d76ad745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Saracca?= Date: Thu, 6 Feb 2025 16:30:36 -0300 Subject: [PATCH 5/9] chore: update to latest alpha js-dv package version --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 697a2e0c2..79195dbff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@dnd-kit/sortable": "8.0.0", "@dnd-kit/utilities": "3.2.2", "@faker-js/faker": "7.6.0", - "@iqss/dataverse-client-javascript": "2.0.0-pr250.21b1ca0", + "@iqss/dataverse-client-javascript": "2.0.0-alpha.19", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", @@ -3680,9 +3680,9 @@ }, "node_modules/@iqss/dataverse-client-javascript": { "name": "@IQSS/dataverse-client-javascript", - "version": "2.0.0-pr250.21b1ca0", - "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-pr250.21b1ca0/90af1733ed39440d58c94df6562cae36fa05fe06", - "integrity": "sha512-itueBRy1bdcgS5vgI5juwJGKC7nkEE/2Cfel8KOnWRxPSi8bdvq2g6Uw3ZPml6+XaRq09wnFiIFJ1C+9PuvP4g==", + "version": "2.0.0-alpha.19", + "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-alpha.19/eaf290441d10b92b5835e5820a1b0f6ad910985a", + "integrity": "sha512-Kb65bjMFR+Gadkqi2z+9Iz4zhHMrIa6pZzia+l8yoyEIdH9lLm1T4bPYx0ETaZde4zAsio6r39A15Fs1c6CqHw==", "license": "MIT", "dependencies": { "@types/node": "^18.15.11", diff --git a/package.json b/package.json index 70337aa04..9e8567f95 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@dnd-kit/sortable": "8.0.0", "@dnd-kit/utilities": "3.2.2", "@faker-js/faker": "7.6.0", - "@iqss/dataverse-client-javascript": "2.0.0-pr250.21b1ca0", + "@iqss/dataverse-client-javascript": "2.0.0-alpha.19", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", From 9cbf55e987a693f4c9901c284319f3c29269c1ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Saracca?= Date: Thu, 6 Feb 2025 16:34:03 -0300 Subject: [PATCH 6/9] refactor: remove comments --- .../EditCreateCollectionForm.spec.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/component/sections/shared/edit-create-collection-form/EditCreateCollectionForm.spec.tsx b/tests/component/sections/shared/edit-create-collection-form/EditCreateCollectionForm.spec.tsx index cdbd13a67..5b4a08b2f 100644 --- a/tests/component/sections/shared/edit-create-collection-form/EditCreateCollectionForm.spec.tsx +++ b/tests/component/sections/shared/edit-create-collection-form/EditCreateCollectionForm.spec.tsx @@ -1043,9 +1043,8 @@ describe('EditCreateCollectionForm', () => { }) it('should send inheritFacetsFromParent in true if use facets from parent is checked', () => { - // Accept suggestion cy.findByRole('button', { name: 'Apply suggestion' }).click() - // Select a Category option + cy.findByLabelText(/^Category/i).select(1) cy.findByRole('button', { name: 'Create Collection' }).click() @@ -1061,9 +1060,8 @@ describe('EditCreateCollectionForm', () => { }) it('should send inheritFacetsFromParent in false if use facets from parent is unchecked', () => { - // Accept suggestion cy.findByRole('button', { name: 'Apply suggestion' }).click() - // Select a Category option + cy.findByLabelText(/^Category/i).select(1) cy.get('@useFacetsFromParentCheckbox').uncheck({ force: true }) From f11044dd0959157d10226ee554226db0253db9a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Saracca?= Date: Fri, 7 Feb 2025 15:40:54 -0300 Subject: [PATCH 7/9] fix: add max length validations on name and affiliation --- public/locales/en/shared.json | 10 ++++++++-- .../top-fields-section/TopFieldsSection.tsx | 14 +++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/public/locales/en/shared.json b/public/locales/en/shared.json index 6a80af135..94d48cc1a 100644 --- a/public/locales/en/shared.json +++ b/public/locales/en/shared.json @@ -74,11 +74,17 @@ "name": { "label": "Collection Name", "description": "The project, department, university, professor, or journal this collection will contain data for.", - "required": "Collection Name is required" + "required": "Collection Name is required", + "invalid": { + "maxLength": "Collection Name must be at most {{maxLength}} characters." + } }, "affiliation": { "label": "Affiliation", - "description": "The organization with which this collection is affiliated." + "description": "The organization with which this collection is affiliated.", + "invalid": { + "maxLength": "Affiliation must be at most {{maxLength}} characters." + } }, "alias": { "label": "Identifier", diff --git a/src/sections/shared/form/EditCreateCollectionForm/collection-form/top-fields-section/TopFieldsSection.tsx b/src/sections/shared/form/EditCreateCollectionForm/collection-form/top-fields-section/TopFieldsSection.tsx index 8de181dcc..76e0297ce 100644 --- a/src/sections/shared/form/EditCreateCollectionForm/collection-form/top-fields-section/TopFieldsSection.tsx +++ b/src/sections/shared/form/EditCreateCollectionForm/collection-form/top-fields-section/TopFieldsSection.tsx @@ -23,7 +23,18 @@ export const TopFieldsSection = ({ isEditingRootCollection }: TopFieldsSectionPr } const nameRules: UseControllerProps['rules'] = { - required: t('fields.name.required') + required: t('fields.name.required'), + maxLength: { + value: 120, + message: t('fields.name.invalid.maxLength', { maxLength: 60 }) + } + } + + const affiliationRules: UseControllerProps['rules'] = { + maxLength: { + value: 120, + message: t('fields.affiliation.invalid.maxLength', { maxLength: 100 }) + } } const aliasRules: UseControllerProps['rules'] = { @@ -119,6 +130,7 @@ export const TopFieldsSection = ({ isEditingRootCollection }: TopFieldsSectionPr ( Date: Fri, 7 Feb 2025 15:50:46 -0300 Subject: [PATCH 8/9] fix: match values --- .../collection-form/top-fields-section/TopFieldsSection.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sections/shared/form/EditCreateCollectionForm/collection-form/top-fields-section/TopFieldsSection.tsx b/src/sections/shared/form/EditCreateCollectionForm/collection-form/top-fields-section/TopFieldsSection.tsx index 76e0297ce..3f3ec3c93 100644 --- a/src/sections/shared/form/EditCreateCollectionForm/collection-form/top-fields-section/TopFieldsSection.tsx +++ b/src/sections/shared/form/EditCreateCollectionForm/collection-form/top-fields-section/TopFieldsSection.tsx @@ -26,14 +26,14 @@ export const TopFieldsSection = ({ isEditingRootCollection }: TopFieldsSectionPr required: t('fields.name.required'), maxLength: { value: 120, - message: t('fields.name.invalid.maxLength', { maxLength: 60 }) + message: t('fields.name.invalid.maxLength', { maxLength: 120 }) } } const affiliationRules: UseControllerProps['rules'] = { maxLength: { value: 120, - message: t('fields.affiliation.invalid.maxLength', { maxLength: 100 }) + message: t('fields.affiliation.invalid.maxLength', { maxLength: 120 }) } } From 94c8cecbb55fb0d2625648d333fb340372f31b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Saracca?= Date: Mon, 10 Feb 2025 13:26:18 -0300 Subject: [PATCH 9/9] fix: add 255 char validation --- .../top-fields-section/TopFieldsSection.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sections/shared/form/EditCreateCollectionForm/collection-form/top-fields-section/TopFieldsSection.tsx b/src/sections/shared/form/EditCreateCollectionForm/collection-form/top-fields-section/TopFieldsSection.tsx index 3f3ec3c93..278b00740 100644 --- a/src/sections/shared/form/EditCreateCollectionForm/collection-form/top-fields-section/TopFieldsSection.tsx +++ b/src/sections/shared/form/EditCreateCollectionForm/collection-form/top-fields-section/TopFieldsSection.tsx @@ -25,15 +25,15 @@ export const TopFieldsSection = ({ isEditingRootCollection }: TopFieldsSectionPr const nameRules: UseControllerProps['rules'] = { required: t('fields.name.required'), maxLength: { - value: 120, - message: t('fields.name.invalid.maxLength', { maxLength: 120 }) + value: 255, + message: t('fields.name.invalid.maxLength', { maxLength: 255 }) } } const affiliationRules: UseControllerProps['rules'] = { maxLength: { - value: 120, - message: t('fields.affiliation.invalid.maxLength', { maxLength: 120 }) + value: 255, + message: t('fields.affiliation.invalid.maxLength', { maxLength: 255 }) } }