-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(edit-content): drag and drop functionality (#30135)
### Parent Issue #29872 ### Proposed Changes * Create new component for Image & File component * Create new state to handle drag and drop functionality * Work in Preview component * Upload file as dotAsset ### Checklist - [x] Tests - [x] Translations - [x] Security Implications Contemplated (add notes if applicable) ### Screenshots https://github.com/user-attachments/assets/90f5deb2-a416-4e7f-bfcd-db68d9d51a76
- Loading branch information
Showing
32 changed files
with
1,997 additions
and
315 deletions.
There are no files selected for viewing
39 changes: 27 additions & 12 deletions
39
core-web/libs/data-access/src/lib/dot-upload-file/dot-upload-file.service.spec.ts
This file contains 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 |
---|---|---|
@@ -1,27 +1,42 @@ | ||
import { createServiceFactory, SpectatorService } from '@ngneat/spectator'; | ||
import { createHttpFactory, SpectatorHttp, SpyObject, mockProvider } from '@ngneat/spectator/jest'; | ||
import { of } from 'rxjs'; | ||
|
||
import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
import { DotWorkflowActionsFireService } from '@dotcms/data-access'; | ||
|
||
import { DotUploadFileService } from './dot-upload-file.service'; | ||
|
||
import { DotUploadService } from '../dot-upload/dot-upload.service'; | ||
|
||
describe('DotUploadFileService', () => { | ||
let spectator: SpectatorService<DotUploadFileService>; | ||
let service: DotUploadFileService; | ||
let spectator: SpectatorHttp<DotUploadFileService>; | ||
let dotWorkflowActionsFireService: SpyObject<DotWorkflowActionsFireService>; | ||
|
||
const createService = createServiceFactory({ | ||
const createHttp = createHttpFactory({ | ||
service: DotUploadFileService, | ||
imports: [HttpClientTestingModule], | ||
providers: [DotUploadService] | ||
providers: [DotUploadFileService, mockProvider(DotWorkflowActionsFireService)] | ||
}); | ||
|
||
beforeEach(() => { | ||
spectator = createService(); | ||
service = spectator.service; | ||
spectator = createHttp(); | ||
|
||
dotWorkflowActionsFireService = spectator.inject(DotWorkflowActionsFireService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
expect(spectator.service).toBeTruthy(); | ||
}); | ||
|
||
describe('uploadDotAsset', () => { | ||
it('should upload a file as a dotAsset', () => { | ||
dotWorkflowActionsFireService.newContentlet.mockReturnValueOnce( | ||
of({ entity: { identifier: 'test' } }) | ||
); | ||
|
||
const file = new File([''], 'test.png', { | ||
type: 'image/png' | ||
}); | ||
|
||
spectator.service.uploadDotAsset(file).subscribe(); | ||
|
||
expect(dotWorkflowActionsFireService.newContentlet).toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); |
This file contains 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 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 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 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
Oops, something went wrong.