@@ -20,6 +20,8 @@ import {AvailableTopicsQuery} from '../../api/graphql/webhooks/generated/availab
2020import { CliTesting , CliTestingMutation } from '../../api/graphql/webhooks/generated/cli-testing.js'
2121import { SendSampleWebhookVariables } from '../../services/webhook/request-sample.js'
2222import { CreateApp } from '../../api/graphql/app-management/generated/create-app.js'
23+ import { AppVersions , AppVersionsQuery } from '../../api/graphql/app-management/generated/app-versions.js'
24+ import { AppVersionsQuerySchema } from '../../api/graphql/get_versions_list.js'
2325import { BrandingSpecIdentifier } from '../../models/extensions/specifications/app_config_branding.js'
2426import { describe , expect , test , vi } from 'vitest'
2527import { CLI_KIT_VERSION } from '@shopify/cli-kit/common/version'
@@ -753,4 +755,102 @@ describe('deploy', () => {
753755 expect ( result . appDeploy . userErrors ) . toHaveLength ( 1 )
754756 expect ( result . appDeploy . userErrors [ 0 ] ?. message ) . toBe ( 'Invalid version' )
755757 } )
758+
759+ test ( 'queries for versions list' , async ( ) => {
760+ // Given
761+ const appId = 'gid://shopify/App/123'
762+ const client = new AppManagementClient ( )
763+ client . token = ( ) => Promise . resolve ( 'token' )
764+ const mockResponse : AppVersionsQuery = {
765+ app : {
766+ id : appId ,
767+ versionsCount : 77 ,
768+ activeRelease : {
769+ id : 'gid://shopify/Release/1' ,
770+ version : {
771+ id : 'gid://shopify/Version/1' ,
772+ } ,
773+ } ,
774+ versions : {
775+ edges : [
776+ {
777+ node : {
778+ id : 'gid://shopify/Version/1' ,
779+ metadata : {
780+ versionTag : '1.0.0' ,
781+ message : 'Test deploy' ,
782+ } ,
783+ createdAt : '2021-01-01T00:00:00Z' ,
784+ 785+ } ,
786+ } ,
787+ {
788+ node : {
789+ id : 'gid://shopify/Version/2' ,
790+ metadata : {
791+ versionTag : '1.0.1' ,
792+ message : 'Test deploy 2' ,
793+ } ,
794+ createdAt : '2021-01-02T00:00:00Z' ,
795+ 796+ } ,
797+ } ,
798+ ] ,
799+ } ,
800+ } ,
801+ }
802+ vi . mocked ( appManagementRequestDoc ) . mockResolvedValueOnce ( mockResponse )
803+
804+ // When
805+ const result : AppVersionsQuerySchema = await client . appVersions ( {
806+ apiKey : 'api-key' ,
807+ organizationId : 'gid://shopify/Organization/123' ,
808+ id : appId ,
809+ title : 'Test App' ,
810+ } )
811+
812+ // Then
813+ expect ( appManagementRequestDoc ) . toHaveBeenCalledWith (
814+ 'gid://shopify/Organization/123' ,
815+ AppVersions ,
816+ 'token' ,
817+ expect . objectContaining ( { appId} ) ,
818+ )
819+ expect ( result ) . toEqual ( {
820+ app : {
821+ id : appId ,
822+ organizationId : 'gid://shopify/Organization/123' ,
823+ title : 'Test App' ,
824+ appVersions : {
825+ nodes : [
826+ {
827+ createdAt : '2021-01-01T00:00:00Z' ,
828+ createdBy : {
829+ 830+ } ,
831+ versionTag : '1.0.0' ,
832+ // Version 1 is active because it's the same as the active release
833+ status : 'active' ,
834+ versionId : 'gid://shopify/Version/1' ,
835+ message : 'Test deploy' ,
836+ } ,
837+ {
838+ createdAt : '2021-01-02T00:00:00Z' ,
839+ createdBy : {
840+ 841+ } ,
842+ versionTag : '1.0.1' ,
843+ // Version 2 is inactive because it's a different version
844+ status : 'inactive' ,
845+ versionId : 'gid://shopify/Version/2' ,
846+ message : 'Test deploy 2' ,
847+ } ,
848+ ] ,
849+ pageInfo : {
850+ totalResults : 77 ,
851+ } ,
852+ } ,
853+ } ,
854+ } )
855+ } )
756856} )
0 commit comments