-
Notifications
You must be signed in to change notification settings - Fork 10
File: Use Case Get Available Dataset File Categories #344
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
Merged
ofahimIQSS
merged 11 commits into
develop
from
336-file-use-cases-get-available-dataset-file-categories
Aug 15, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0928200
feat: update use case get available categories
ChengShi-1 7ce1c2f
feat: update useCases.md
ChengShi-1 329831e
Revert "fix RolesRepository integration test"
ChengShi-1 273947c
Update docs/useCases.md
ChengShi-1 136e125
fix: test
ChengShi-1 7810d21
Merge branch '336-file-use-cases-get-available-dataset-file-categorie…
ChengShi-1 5fd4982
feat: add test case for persistent id
ChengShi-1 4770f56
Merge branch 'develop' into 336-file-use-cases-get-available-dataset-…
ChengShi-1 ed5feeb
fix: add a ,
ChengShi-1 5ec425a
fix: tests roleHelper
ChengShi-1 ace8b9d
fix: tests roleHelper
ChengShi-1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/datasets/domain/useCases/GetDatasetAvailableCategories.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
| import { IDatasetsRepository } from '../repositories/IDatasetsRepository' | ||
|
|
||
| export class GetDatasetAvailableCategories implements UseCase<string[]> { | ||
| private readonly datasetsRepository: IDatasetsRepository | ||
|
|
||
| constructor(datasetsRepository: IDatasetsRepository) { | ||
| this.datasetsRepository = datasetsRepository | ||
| } | ||
|
|
||
| /** | ||
| * Retrieves the available file categories for a dataset. | ||
| * | ||
| * @param {number | string} [datasetId] - Persistent dataset identifier | ||
| * @returns {Promise<string[]>} - List of available file categories | ||
| */ | ||
| async execute(datasetId: number | string): Promise<string[]> { | ||
| return this.datasetsRepository.getDatasetAvailableCategories(datasetId) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
test/functional/datasets/GetDatasetAvailableCategories.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { ApiConfig, createDataset, getDatasetAvailableCategories, ReadError } from '../../../src' | ||
| import { DataverseApiAuthMechanism } from '../../../src/core/infra/repositories/ApiConfig' | ||
| import { deleteUnpublishedDatasetViaApi } from '../../testHelpers/datasets/datasetHelper' | ||
| import { CreatedDatasetIdentifiers } from '../../../src/datasets/domain/models/CreatedDatasetIdentifiers' | ||
| import { TestConstants } from '../../testHelpers/TestConstants' | ||
|
|
||
| describe('execute', () => { | ||
| let createdDatasetIdentifiers: CreatedDatasetIdentifiers | ||
| beforeEach(async () => { | ||
| ApiConfig.init( | ||
| TestConstants.TEST_API_URL, | ||
| DataverseApiAuthMechanism.API_KEY, | ||
| process.env.TEST_API_KEY | ||
| ) | ||
| createdDatasetIdentifiers = await createDataset.execute(TestConstants.TEST_NEW_DATASET_DTO) | ||
| }) | ||
|
|
||
| afterEach(async () => { | ||
| deleteUnpublishedDatasetViaApi(createdDatasetIdentifiers.numericId) | ||
| }) | ||
|
|
||
| it('should return categories array when a dataset has files categories', async () => { | ||
| const defaultCategories = ['Code', 'Data', 'Documentation'] | ||
| const categoriesList = await getDatasetAvailableCategories.execute( | ||
| createdDatasetIdentifiers.numericId | ||
| ) | ||
| expect(categoriesList.sort()).toEqual(defaultCategories.sort()) | ||
| }) | ||
|
|
||
| it('should return error when dataset does not exist', async () => { | ||
| const nonExistentDatasetId = 99999 | ||
|
|
||
| await expect( | ||
| getDatasetAvailableCategories.execute(nonExistentDatasetId) | ||
| ).rejects.toBeInstanceOf(ReadError) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.