File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
blocks/CloudImageEditorActivity Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -351,11 +351,11 @@ export class UploaderPublicApi {
351351
352352 setCurrentActivity = < T extends ActivityType > (
353353 activityType : T ,
354- ...params : T extends keyof ActivityParamsMap
354+ ...[ params ] : T extends keyof ActivityParamsMap
355355 ? [ ActivityParamsMap [ T ] ]
356356 : T extends RegisteredActivityType
357357 ? [ undefined ?]
358- : [ any ?]
358+ : [ unknown ?]
359359 ) => {
360360 if ( this . _ctx . hasBlockInCtx ( ( b ) => b . activityType === activityType ) ) {
361361 this . _ctx . set$ ( {
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ export class CloudImageEditorActivity extends UploaderBlock {
1717
1818 override get activityParams ( ) : ActivityParams {
1919 const params = super . activityParams ;
20+
2021 if ( 'internalId' in params ) {
2122 return params ;
2223 }
Original file line number Diff line number Diff line change @@ -97,4 +97,26 @@ describe('API', () => {
9797
9898 expect ( eventPayload ) . toMatchObject ( expect . objectContaining ( { status : 'idle' , externalUrl : url } ) ) ;
9999 } ) ;
100+
101+ it ( 'should set cloud-image-edit activity with params' , async ( ) => {
102+ const uploadCtxProvider = page . getByTestId ( 'uc-upload-ctx-provider' ) . query ( ) ! as UploadCtxProvider ;
103+ const api = uploadCtxProvider . getAPI ( ) ;
104+
105+ const url =
106+ 'https://images.unsplash.com/photo-1699102241946-45c5e1937d69?ixlib=rb-4.0.3&q=85&fm=jpg&crop=entropy&cs=srgb&dl=prithiviraj-a-fa7Stge3YXs-unsplash.jpg&w=640' ;
107+ api . addFileFromUrl ( url ) ;
108+
109+ const eventHandler = ( event : CustomEvent < EventPayload [ 'file-upload-success' ] > ) => {
110+ const detail = event . detail as EventPayload [ 'file-upload-success' ] ;
111+ api . setCurrentActivity ( 'cloud-image-edit' , { internalId : detail . internalId } ) ;
112+ api . setModalState ( true ) ;
113+ } ;
114+
115+ uploadCtxProvider . addEventListener ( 'file-upload-success' , eventHandler ) ;
116+
117+ const startFrom = page . getByTestId ( 'uc-start-from' ) ;
118+ const cloudImageEdit = page . getByTestId ( 'uc-cloud-image-editor-activity' ) ;
119+ await expect . element ( startFrom ) . not . toBeVisible ( ) ;
120+ await expect . element ( cloudImageEdit ) . toBeVisible ( ) ;
121+ } ) ;
100122} ) ;
You can’t perform that action at this time.
0 commit comments