@@ -4,15 +4,13 @@ import { vol } from 'memfs';
44
55import { getMockOclifConfig } from '../../../__tests__/commands/utils' ;
66import { ExpoGraphqlClient } from '../../../commandUtils/context/contextUtils/createGraphqlClient' ;
7- import { ChannelNotFoundError } from '../../../channel/errors' ;
87import { EmbeddedUpdateAssetMutation } from '../../../graphql/mutations/EmbeddedUpdateAssetMutation' ;
98import {
109 EmbeddedUpdateMutation ,
1110 isEmbeddedUpdateAssetNotReadyError ,
1211 isEmbeddedUpdateConflictError ,
1312} from '../../../graphql/mutations/EmbeddedUpdateMutation' ;
1413import { AppPlatform } from '../../../graphql/generated' ;
15- import { ChannelQuery } from '../../../graphql/queries/ChannelQuery' ;
1614import Log from '../../../log' ;
1715import * as uploads from '../../../uploads' ;
1816import * as promise from '../../../utils/promise' ;
@@ -30,9 +28,6 @@ jest.mock('../../../graphql/mutations/EmbeddedUpdateMutation', () => ({
3028 isEmbeddedUpdateAssetNotReadyError : jest . fn ( ) ,
3129 isEmbeddedUpdateConflictError : jest . fn ( ) ,
3230} ) ) ;
33- jest . mock ( '../../../graphql/queries/ChannelQuery' , ( ) => ( {
34- ChannelQuery : { viewUpdateChannelBasicInfoAsync : jest . fn ( ) } ,
35- } ) ) ;
3631jest . mock ( '../../../uploads' ) ;
3732jest . mock ( '../../../log' ) ;
3833jest . mock ( '../../../utils/promise' , ( ) => ( {
@@ -41,7 +36,6 @@ jest.mock('../../../utils/promise', () => ({
4136
4237const mockGetRuntimeVersion = jest . mocked ( Updates . getRuntimeVersionNullableAsync ) ;
4338const mockGetSignedUploadSpec = jest . mocked ( EmbeddedUpdateAssetMutation . getSignedUploadSpecAsync ) ;
44- const mockViewChannel = jest . mocked ( ChannelQuery . viewUpdateChannelBasicInfoAsync ) ;
4539const mockUpload = jest . mocked ( uploads . uploadWithPresignedPostWithRetryAsync ) ;
4640const mockLogLog = jest . mocked ( Log . log ) ;
4741const mockUploadEmbeddedUpdate = jest . mocked ( EmbeddedUpdateMutation . uploadEmbeddedUpdateAsync ) ;
@@ -78,7 +72,7 @@ const MOCK_EMBEDDED_UPDATE = {
7872 id : 'embedded-update-id-abc' ,
7973 platform : AppPlatform . Ios ,
8074 runtimeVersion : '1.0.0' ,
81- channelId : 'channel-id-123 ' ,
75+ channel : 'production ' ,
8276 createdAt : '2024-01-01T00:00:00Z' ,
8377} ;
8478
@@ -93,7 +87,6 @@ describe(UpdateUploadEmbedded, () => {
9387 [ MANIFEST_PATH ] : VALID_MANIFEST ,
9488 } ) ;
9589 mockGetRuntimeVersion . mockResolvedValue ( '1.0.0' ) ;
96- mockViewChannel . mockResolvedValue ( { id : 'channel-id-123' , name : 'production' } as any ) ;
9790 mockGetSignedUploadSpec . mockResolvedValue ( {
9891 storageKey : 'storage-key-abc' ,
9992 presignedUrl : 'https://storage.googleapis.com/upload-bucket' ,
@@ -184,31 +177,15 @@ describe(UpdateUploadEmbedded, () => {
184177 } ) ;
185178 } ) ;
186179
187- describe ( 'channel resolution' , ( ) => {
188- it ( 'resolves channel by name and app id' , async ( ) => {
189- const command = createCommand ( BASE_ARGV ) ;
190- await command . runAsync ( ) ;
191- expect ( mockViewChannel ) . toHaveBeenCalledWith (
192- MOCK_CONTEXT . loggedIn . graphqlClient ,
193- { appId : MOCK_CONTEXT . privateProjectConfig . projectId , channelName : 'production' }
194- ) ;
195- } ) ;
196-
197- it ( 'propagates ChannelNotFoundError when channel does not exist' , async ( ) => {
198- mockViewChannel . mockRejectedValue ( new ChannelNotFoundError ( 'Channel not found' ) ) ;
199- const command = createCommand ( BASE_ARGV ) ;
200- await expect ( command . runAsync ( ) ) . rejects . toThrow ( ChannelNotFoundError ) ;
201- } ) ;
202- } ) ;
203-
204180 describe ( 'bundle upload' , ( ) => {
205- it ( 'requests a presigned URL and uploads the bundle' , async ( ) => {
181+ it ( 'requests a presigned URL with embeddedUpdateId and uploads the bundle' , async ( ) => {
206182 const command = createCommand ( BASE_ARGV ) ;
207183 await command . runAsync ( ) ;
208184 expect ( mockGetSignedUploadSpec ) . toHaveBeenCalledWith (
209185 MOCK_CONTEXT . loggedIn . graphqlClient ,
210186 expect . objectContaining ( {
211187 appId : MOCK_CONTEXT . privateProjectConfig . projectId ,
188+ embeddedUpdateId : VALID_UUID ,
212189 contentType : 'application/javascript' ,
213190 } )
214191 ) ;
@@ -227,7 +204,7 @@ describe(UpdateUploadEmbedded, () => {
227204 } ) ;
228205
229206 describe ( 'mutation registration' , ( ) => {
230- it ( 'calls uploadEmbeddedUpdateAsync with all collected inputs including AppPlatform enum' , async ( ) => {
207+ it ( 'calls uploadEmbeddedUpdateAsync with channel name and AppPlatform enum' , async ( ) => {
231208 const command = createCommand ( BASE_ARGV ) ;
232209 await command . runAsync ( ) ;
233210 expect ( mockUploadEmbeddedUpdate ) . toHaveBeenCalledWith (
@@ -236,9 +213,8 @@ describe(UpdateUploadEmbedded, () => {
236213 appId : MOCK_CONTEXT . privateProjectConfig . projectId ,
237214 platform : AppPlatform . Ios ,
238215 runtimeVersion : '1.0.0' ,
239- channelId : 'channel-id-123 ' ,
216+ channel : 'production ' ,
240217 embeddedUpdateId : VALID_UUID ,
241- launchAssetStorageKey : 'storage-key-abc' ,
242218 } )
243219 ) ;
244220 } ) ;
0 commit comments