@@ -7,6 +7,11 @@ const mocks = vi.hoisted(() => ({
77 audioInitExists : false ,
88 storageUnavailable : false ,
99 denied : false ,
10+ defaultBucket : false ,
11+ source : { type : "desktopSegments" } as {
12+ type : "desktopSegments" | "desktopMP4" ;
13+ outputKey ?: string ;
14+ } ,
1015 sign : vi . fn ( ) ,
1116 read : vi . fn ( ) ,
1217 dispose : async ( ) => { } ,
@@ -23,6 +28,7 @@ vi.mock("@cap/web-backend", async (importOriginal) => {
2328 const { Context, Effect, Option } = await import ( "effect" ) ;
2429 const { Policy, Storage : StorageDomain } = await import ( "@cap/web-domain" ) ;
2530 const bucket = {
31+ provider : "s3" ,
2632 getObject : ( ) =>
2733 Effect . sync ( ( ) => {
2834 mocks . read ( ) ;
@@ -48,7 +54,11 @@ vi.mock("@cap/web-backend", async (importOriginal) => {
4854 effect : import ( "effect" ) . Effect . Effect < A , E , R > ,
4955 ) => effect,
5056 Storage : Object . assign ( Context . GenericTag ( "PlaylistTestStorage" ) , {
51- getAccessForVideo : ( ) => Effect . succeed ( [ bucket , false ] as const ) ,
57+ getAccessForVideo : ( ) =>
58+ Effect . succeed ( [
59+ bucket ,
60+ mocks . defaultBucket ? Option . none ( ) : Option . some ( { } ) ,
61+ ] as const ) ,
5262 } ) ,
5363 Videos : Object . assign ( Context . GenericTag ( "PlaylistTestVideos" ) , {
5464 testService : {
@@ -60,7 +70,7 @@ vi.mock("@cap/web-backend", async (importOriginal) => {
6070 {
6171 id : "recording" ,
6272 ownerId : "owner" ,
63- source : { type : "desktopSegments" } ,
73+ source : mocks . source ,
6474 } ,
6575 ] ) ,
6676 ) ,
@@ -121,6 +131,8 @@ describe("Instant playlist readiness API", () => {
121131 mocks . audioInitExists = false ;
122132 mocks . storageUnavailable = false ;
123133 mocks . denied = false ;
134+ mocks . defaultBucket = false ;
135+ mocks . source = { type : "desktopSegments" } ;
124136 } ) ;
125137 afterAll ( ( ) => mocks . dispose ( ) ) ;
126138
@@ -170,4 +182,20 @@ describe("Instant playlist readiness API", () => {
170182 expect ( ( await request ( ) ) . status ) . toBe ( 401 ) ;
171183 expect ( mocks . read ) . not . toHaveBeenCalled ( ) ;
172184 } ) ;
185+
186+ it . each ( [ "custom" , "default" ] as const ) (
187+ "redirects a published MP4 in a %s bucket to its retained storage key" ,
188+ async ( bucket ) => {
189+ mocks . defaultBucket = bucket === "default" ;
190+ mocks . source = {
191+ type : "desktopMP4" ,
192+ outputKey : "owner/recording/.recording/outputs/generation/result.mp4" ,
193+ } ;
194+ const response = await request ( "mp4" , "" ) ;
195+ expect ( response . status ) . toBe ( 302 ) ;
196+ expect ( mocks . sign ) . toHaveBeenCalledExactlyOnceWith (
197+ mocks . source . outputKey ,
198+ ) ;
199+ } ,
200+ ) ;
173201} ) ;
0 commit comments