diff --git a/classes/factories/JsonDatasetFactory.inc.php b/classes/factories/JsonDatasetFactory.inc.php index 4623b19d..c5d03106 100644 --- a/classes/factories/JsonDatasetFactory.inc.php +++ b/classes/factories/JsonDatasetFactory.inc.php @@ -84,6 +84,15 @@ protected function sanitizeProps(): array $datasetFile->setId($file->dataFile->id); $datasetFile->setFileName($file->label); $datasetFile->setOriginalFileName($file->dataFile->filename); + + $encodedChar = 'Ã'; + if (str_contains($file->label, $encodedChar)) { + $datasetFile->setFileName(utf8_decode($file->label)); + } + if (str_contains($file->dataFile->filename, $encodedChar)) { + $datasetFile->setOriginalFileName(utf8_decode($file->dataFile->filename)); + } + return $datasetFile; }, $datasetVersion->files); diff --git a/cypress/tests/Test03_ResearchDataDeposit.spec.js b/cypress/tests/Test03_ResearchDataDeposit.spec.js index a113a2a2..e90fc03c 100644 --- a/cypress/tests/Test03_ResearchDataDeposit.spec.js +++ b/cypress/tests/Test03_ResearchDataDeposit.spec.js @@ -182,7 +182,7 @@ describe('Research data deposit', function () { cy.fixture('dummy.pdf', 'base64').then((fileContent) => { cy.get('#datasetFileForm-datasetFile-hiddenFileId').upload({ fileContent, - fileName: 'samples.pdf', + fileName: 'Submissão de dados.pdf', mimeType: 'application/pdf', encoding: 'base64', }); @@ -190,14 +190,14 @@ describe('Research data deposit', function () { cy.get('input[name="termsOfUse"').check(); cy.get('form:visible button:contains("Save")').click(); cy.waitJQuery(); - cy.get('#datasetFiles .listPanel__items').contains('samples.pdf'); + cy.get('#datasetFiles .listPanel__items').contains('Submissão de dados.pdf'); cy.get('#datasetTab-button .pkpBadge').contains('2'); - cy.get('.listPanel__item:contains(samples.pdf) button:contains(Delete)').click(); - cy.get('#datasetFiles .listPanel__items').contains('samples.pdf'); + cy.get('.listPanel__item:contains(Submissão de dados.pdf) button:contains(Delete)').click(); + cy.get('#datasetFiles .listPanel__items').contains('Submissão de dados.pdf'); cy.get('.modal:visible button:contains(Yes)').click(); cy.waitJQuery(); - cy.get('#datasetFiles .listPanel__items').should('not.include.text', 'samples.pdf'); + cy.get('#datasetFiles .listPanel__items').should('not.include.text', 'Submissão de dados.pdf'); cy.get('#datasetTab-button .pkpBadge').contains('1'); }); @@ -221,8 +221,8 @@ describe('Research data deposit', function () { cy.contains('Activity Log').click(); cy.get('#submissionHistoryGridContainer tr:contains(Research data deposited) td').should('contain', 'Catherine Kwantes'); cy.get('#submissionHistoryGridContainer tr:contains(Research data metadata updated) td').should('contain', 'Catherine Kwantes'); - cy.get('#submissionHistoryGridContainer tr:contains(File "samples.pdf" added as research data.) td').should('contain', 'Catherine Kwantes'); - cy.get('#submissionHistoryGridContainer tr:contains(File "samples.pdf" deleted from research data.) td').should('contain', 'Catherine Kwantes'); + cy.get('#submissionHistoryGridContainer tr:contains(File "Submissão de dados.pdf" added as research data.) td').should('contain', 'Catherine Kwantes'); + cy.get('#submissionHistoryGridContainer tr:contains(File "Submissão de dados.pdf" deleted from research data.) td').should('contain', 'Catherine Kwantes'); cy.get('#submissionHistoryGridContainer tr:contains(Research data deleted) td').should('contain', 'Catherine Kwantes'); }); @@ -500,6 +500,7 @@ describe('Research data deposit', function () { + dataverseServerName; cy.get('div[data-modal="publish"]').contains(publishMsg); cy.get('div[data-modal="publish"] button').contains('Yes').click(); + cy.wait(1000); cy.get('.value > p').contains('V1'); cy.get('button').contains('Publish research data').should('not.exist'); diff --git a/dataverseAPI/actions/DatasetFileActions.inc.php b/dataverseAPI/actions/DatasetFileActions.inc.php index c49a189e..1325915e 100644 --- a/dataverseAPI/actions/DatasetFileActions.inc.php +++ b/dataverseAPI/actions/DatasetFileActions.inc.php @@ -21,6 +21,15 @@ public function getByDatasetId(string $persistentId): array $datasetFile->setId($file['dataFile']['id']); $datasetFile->setFileName($file['label']); $datasetFile->setOriginalFileName($file['dataFile']['filename']); + + $encodedChar = 'Ã'; + if (str_contains($file['label'], $encodedChar)) { + $datasetFile->setFileName(utf8_decode($file['label'])); + } + if (str_contains($file['dataFile']['filename'], $encodedChar)) { + $datasetFile->setOriginalFileName(utf8_decode($file['dataFile']['filename'])); + } + return $datasetFile; }, $jsonContent['data']); } @@ -35,8 +44,12 @@ public function add(string $persistentId, string $filename, string $filePath): v 'name' => 'file', 'contents' => Utils::tryFopen($filePath, 'rb'), 'filename' => $filename + ], + [ + 'name' => 'jsonData', + 'contents' => json_encode(['label' => $filename]) ] - ] + ], ]; $this->nativeAPIRequest('POST', $uri, $options); diff --git a/version.xml b/version.xml index 42e3660e..1ce87d26 100644 --- a/version.xml +++ b/version.xml @@ -13,8 +13,8 @@ dataverse plugins.generic - 2.5.6.0 - 2023-10-19 + 2.5.7.0 + 2023-10-25 1 DataversePlugin