Skip to content

Commit

Permalink
increased coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ErykKul committed Jun 27, 2024
1 parent d786d9c commit be645cd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
6 changes: 4 additions & 2 deletions public/locales/en/uploadDatasetFiles.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function AddTagsModal({ show, availableTags, setTagOptions, update }: Add
{t('fileForm.tags')}
</Form.Group.Label>
<Col sm={9} className={styles.tags}>
<div className={styles.tags_select} title={t('fileForm.selectTags')}>
<div className={styles.tags_select} title={t('addTags.selectTags')}>
<SelectMultiple
options={availableTags}
onChange={(newTags) => setTagsToAdd(newTags)}></SelectMultiple>
Expand All @@ -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<HTMLInputElement>) =>
setTag(event.currentTarget.value)
}
Expand Down Expand Up @@ -91,14 +92,15 @@ export function AddTagsModal({ show, availableTags, setTagOptions, update }: Add
<Button
variant="primary"
onClick={() => handleClose(true)}
disabled={tagsToAdd.length === 0}>
disabled={tagsToAdd.length === 0}
title={t('addTags.saveChanges')}>
{t('addTags.saveChanges')}
</Button>
<Button
variant="secondary"
onClick={() => handleClose(false)}
title={t('addTags.cancelChanges')}>
{t('cancel')}
{t('addTags.cancelChanges')}
</Button>
</Modal.Footer>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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(<UploadDatasetFiles fileRepository={new FileMockRepository()} />, 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()
})
})

0 comments on commit be645cd

Please sign in to comment.