Skip to content
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

Add use cases for file tab data visualization #80

Merged
merged 27 commits into from
Aug 25, 2023
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4cee748
Stash: getDatasetFiles use case WIP
GPortas Jul 10, 2023
3d915e7
Merge branch '71-pending-integration-tests' into 77-files-display-dat…
GPortas Jul 10, 2023
c9c6fbe
Added: getFilesByDatasetId use case (pending repository impl)
GPortas Jul 11, 2023
cd2039c
Stash: FilesRepository getFilesByDatasetId impl WIP
GPortas Jul 11, 2023
a835cc3
Added: file model attributes
GPortas Jul 11, 2023
d1f2445
Stash: files response transforming WIP
GPortas Jul 12, 2023
0ef3b90
Added: files response transforming
GPortas Jul 17, 2023
7f6d55a
Added: getFilesByDatasetPersistentId use case
GPortas Jul 17, 2023
7cbf2f4
Changed: restricted field payload transform
GPortas Jul 17, 2023
9b305ea
Stash: files repository integration test WIP (now failing)
GPortas Jul 17, 2023
ee2b741
Merge branch 'develop' of github.com:IQSS/dataverse-client-javascript…
GPortas Jul 18, 2023
f4a6bdd
Fixed: file upload via API test helper
GPortas Jul 19, 2023
0111e66
Added: integration tests for FilesRepository
GPortas Jul 20, 2023
7e7730c
Added: GetFileGuestbookResponsesCount use case with repository logic …
GPortas Jul 20, 2023
448909b
Refactor: single GetDatasetFiles use case managing numeric and PID ids
GPortas Jul 20, 2023
bd59020
Refactor: single GetDataset use case managing numeric and PID ids
GPortas Jul 20, 2023
44dab6a
Added: canFileBeDownloaded use case
GPortas Jul 21, 2023
b7ff9d1
Added: getFileThumbnailClass use case
GPortas Jul 21, 2023
93e30d2
Added: getFileDataTables use case (pending repository logic)
GPortas Jul 21, 2023
b008283
Stash: file data table API access logic and model properties WIP
GPortas Jul 21, 2023
f087fc0
Added: file data table models with API access and model transform
GPortas Jul 24, 2023
28a03cd
Fixed: files module exports
GPortas Jul 24, 2023
03746b2
Added: getFileDataTables integration test
GPortas Jul 24, 2023
378cc1e
Changed: more realistic test tab file content
GPortas Jul 25, 2023
1d5fffd
Changed: GetFileDownloadCount renaming
GPortas Aug 9, 2023
76104a1
Removed: GetFileThumbnailClass use case
GPortas Aug 9, 2023
3e0c21e
Added: GetFileUserPermissions use case
GPortas Aug 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed: file upload via API test helper
GPortas committed Jul 19, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit f4a6bdd7730ef96159ea0d61d1644231c0d35bfd
25 changes: 22 additions & 3 deletions test/integration/files/FilesRepository.test.ts
Original file line number Diff line number Diff line change
@@ -8,18 +8,37 @@ import { uploadFileViaApi } from '../../testHelpers/files/filesHelper';
describe('getDataverseVersion', () => {
const sut: FilesRepository = new FilesRepository();

const testFile1Name = 'test-file-1.txt';
const testFile2Name = 'test-file-2.txt';
const testFile3Name = 'test-file-3.txt';

beforeAll(async () => {
ApiConfig.init(TestConstants.TEST_API_URL, DataverseApiAuthMechanism.API_KEY, process.env.TEST_API_KEY);
await createDatasetViaApi()
.then()
.catch(() => {
fail('Tesgooglts beforeAll(): Error while creating test Dataset');
fail('Test beforeAll(): Error while creating test Dataset');
});
// Uploading test file 1
await uploadFileViaApi(TestConstants.TEST_CREATED_DATASET_ID, testFile1Name)
.then()
.catch((e) => {
console.log(e);
fail(`Tests beforeAll(): Error while uploading file ${testFile1Name}`);
});
// Uploading test file 2
await uploadFileViaApi(TestConstants.TEST_CREATED_DATASET_ID, testFile2Name)
.then()
.catch((e) => {
console.log(e);
fail(`Tests beforeAll(): Error while uploading file ${testFile2Name}`);
});
await uploadFileViaApi(TestConstants.TEST_CREATED_DATASET_ID, 'test-file-1.txt')
// Uploading test file 3
await uploadFileViaApi(TestConstants.TEST_CREATED_DATASET_ID, testFile3Name)
.then()
.catch((e) => {
console.log(e);
fail('Tests beforeAll(): Error while creating test file');
fail(`Tests beforeAll(): Error while uploading file ${testFile3Name}`);
});
});

11 changes: 8 additions & 3 deletions test/testHelpers/files/filesHelper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { File } from '../../../src/files/domain/models/File';
import axios, { AxiosResponse } from 'axios';
import { TestConstants } from '../TestConstants';
import { readFile } from 'fs/promises';

export const createFileModel = (): File => {
return {
@@ -60,9 +61,13 @@ export const createFilePayload = (): any => {
};

export const uploadFileViaApi = async (datasetId: number, fileName: string): Promise<AxiosResponse> => {
let formData = new FormData();
formData.append('file', fileName);
const formData = new FormData();
const file = await readFile(`${__dirname}/${fileName}`);
formData.append('file', new Blob([file]), fileName);
return await axios.post(`${TestConstants.TEST_API_URL}/datasets/${datasetId}/add`, formData, {
headers: { 'Content-Type': 'multipart/form-data', 'X-Dataverse-Key': process.env.TEST_API_KEY },
headers: {
'Content-Type': 'multipart/form-data',
'X-Dataverse-Key': process.env.TEST_API_KEY,
},
});
};
1 change: 1 addition & 0 deletions test/testHelpers/files/test-file-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test file 2
1 change: 1 addition & 0 deletions test/testHelpers/files/test-file-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test file 3