From be645cdf8e2fd02837e54e81a1b56de849e8e694 Mon Sep 17 00:00:00 2001 From: Eryk Kullikowski Date: Thu, 27 Jun 2024 23:47:06 +0200 Subject: [PATCH] increased coverage --- public/locales/en/uploadDatasetFiles.json | 6 ++-- .../add-tags-modal/AddTagsModal.tsx | 8 +++-- .../UploadDatasetFiles.spec.tsx | 33 ++++++++++++++++++- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/public/locales/en/uploadDatasetFiles.json b/public/locales/en/uploadDatasetFiles.json index f8b424ed0..b80bfba27 100644 --- a/public/locales/en/uploadDatasetFiles.json +++ b/public/locales/en/uploadDatasetFiles.json @@ -27,7 +27,7 @@ "termsOfAccess": "Terms of Access for Restricted Files", "enableAccessRequest": "Enable access request", "saveChanges": "Save Changes", - "cancelChanges": "Cancel changes" + "cancelChanges": "Cancel Changes" }, "fileForm": { "fileName": "File name", @@ -54,7 +54,9 @@ }, "addTags": { "title": "Add tags to selected files", + "customTag": "Custom tag", + "selectTags": "Select tags to add", "saveChanges": "Save Changes", - "cancelChanges": "Cancel changes" + "cancelChanges": "Cancel Changes" } } diff --git a/src/sections/upload-dataset-files/uploaded-files-list/add-tags-modal/AddTagsModal.tsx b/src/sections/upload-dataset-files/uploaded-files-list/add-tags-modal/AddTagsModal.tsx index 14e706a36..05f3d85ec 100644 --- a/src/sections/upload-dataset-files/uploaded-files-list/add-tags-modal/AddTagsModal.tsx +++ b/src/sections/upload-dataset-files/uploaded-files-list/add-tags-modal/AddTagsModal.tsx @@ -46,7 +46,7 @@ export function AddTagsModal({ show, availableTags, setTagOptions, update }: Add {t('fileForm.tags')} -
+
setTagsToAdd(newTags)}> @@ -64,6 +64,7 @@ export function AddTagsModal({ show, availableTags, setTagOptions, update }: Add type="text" placeholder={t('tags.addNewTag')} value={tag} + title={t('addTags.customTag')} onChange={(event: FormEvent) => setTag(event.currentTarget.value) } @@ -91,14 +92,15 @@ export function AddTagsModal({ show, availableTags, setTagOptions, update }: Add diff --git a/tests/component/sections/upload-dataset-files/UploadDatasetFiles.spec.tsx b/tests/component/sections/upload-dataset-files/UploadDatasetFiles.spec.tsx index 139ae3862..91b0e7463 100644 --- a/tests/component/sections/upload-dataset-files/UploadDatasetFiles.spec.tsx +++ b/tests/component/sections/upload-dataset-files/UploadDatasetFiles.spec.tsx @@ -431,7 +431,7 @@ describe('UploadDatasetFiles', () => { cy.get('[type="checkbox"]').last().should('be.checked') cy.findByText('Edit files').first().click() cy.findByText('Restrict').first().click() - cy.findByTitle('Cancel changes').click() + cy.findByTitle('Cancel Changes').click() cy.get('[type="checkbox"]').last().should('be.checked') cy.get('[type="checkbox"]').first().click() cy.get('[type="checkbox"]').first().click() @@ -497,4 +497,35 @@ describe('UploadDatasetFiles', () => { cy.get('label:contains("Tags")').first().click() cy.get('label:contains("Tags")').first().click() }) + + it('add tags', () => { + const testDataset = DatasetMother.create() + + mountWithDataset(, testDataset) + + cy.findByTestId('drag-and-drop').as('dnd') + cy.get('@dnd').should('exist') + + cy.get('@dnd').selectFile( + { fileName: 'users1.json', contents: [{ name: 'John Doe the 1st' }] }, + { action: 'drag-drop' } + ) + // wait for upload to finish + cy.findByText('1 file uploaded').should('exist') + cy.get('[type="checkbox"]').first().click() + cy.findByText('Edit files').first().click() + cy.findByText('Add tags').first().click() + cy.findByTitle('Custom tag').type('Hello, World!') + cy.findByText('Apply').click() + cy.findByTitle('Cancel Changes').click() + cy.findByText('Edit files').first().click() + cy.findByText('Add tags').first().click() + cy.findByTitle('Custom tag').type('Hello, World!{enter}') + cy.findByLabelText('Close').click() + cy.findByText('Edit files').first().click() + cy.findByText('Add tags').first().click() + cy.findByTitle('Select tags to add').first().click() + cy.findByText('Hello, World!').click() + cy.findByTitle('Save Changes').click() + }) })