@@ -194,12 +194,6 @@ test("It supports multiple OpenAPI specifications on a branch", async () => {
194194 id : "main" ,
195195 name : "main" ,
196196 specifications : [ {
197- id : "foo-service.yml" ,
198- name : "foo-service.yml" ,
199- url : "/api/blob/acme/foo-openapi/foo-service.yml?ref=12345678" ,
200- editURL : "https://github.com/acme/foo-openapi/edit/main/foo-service.yml" ,
201- isDefault : false
202- } , {
203197 id : "bar-service.yml" ,
204198 name : "bar-service.yml" ,
205199 url : "/api/blob/acme/foo-openapi/bar-service.yml?ref=12345678" ,
@@ -211,6 +205,13 @@ test("It supports multiple OpenAPI specifications on a branch", async () => {
211205 url : "/api/blob/acme/foo-openapi/baz-service.yml?ref=12345678" ,
212206 editURL : "https://github.com/acme/foo-openapi/edit/main/baz-service.yml" ,
213207 isDefault : false
208+ } ,
209+ {
210+ id : "foo-service.yml" ,
211+ name : "foo-service.yml" ,
212+ url : "/api/blob/acme/foo-openapi/foo-service.yml?ref=12345678" ,
213+ editURL : "https://github.com/acme/foo-openapi/edit/main/foo-service.yml" ,
214+ isDefault : false
214215 } ] ,
215216 url : "https://github.com/acme/foo-openapi/tree/main" ,
216217 isDefault : true
@@ -663,6 +664,94 @@ test("It prioritizes main, master, develop, and development branch names when so
663664 expect ( projects [ 0 ] . versions [ 5 ] . name ) . toEqual ( "anne" )
664665} )
665666
667+ test ( "It sorts file specifications alphabetically" , async ( ) => {
668+ const sut = new GitHubProjectDataSource ( {
669+ repositoryNameSuffix : "-openapi" ,
670+ repositoryDataSource : {
671+ async getRepositories ( ) {
672+ return [ {
673+ owner : "acme" ,
674+ name : "foo-openapi" ,
675+ defaultBranchRef : {
676+ id : "12345678" ,
677+ name : "main"
678+ } ,
679+ configYaml : {
680+ text : "name: Hello World"
681+ } ,
682+ branches : [ {
683+ id : "12345678" ,
684+ name : "anne" ,
685+ files : [ {
686+ name : "z-openapi.yml" ,
687+ } , {
688+ name : "a-openapi.yml" ,
689+ } , {
690+ name : "1-openapi.yml" ,
691+ } ]
692+ } ] ,
693+ tags : [ {
694+ id : "12345678" ,
695+ name : "cathrine" ,
696+ files : [ {
697+ name : "o-openapi.yml" ,
698+ } , {
699+ name : "2-openapi.yml" ,
700+ } ]
701+ } ]
702+ } ]
703+ }
704+ } ,
705+ encryptionService : noopEncryptionService ,
706+ remoteConfigEncoder : base64RemoteConfigEncoder
707+ } )
708+ const projects = await sut . getProjects ( )
709+ expect ( projects [ 0 ] . versions [ 0 ] . specifications [ 0 ] . name ) . toEqual ( "1-openapi.yml" )
710+ expect ( projects [ 0 ] . versions [ 0 ] . specifications [ 1 ] . name ) . toEqual ( "a-openapi.yml" )
711+ expect ( projects [ 0 ] . versions [ 0 ] . specifications [ 2 ] . name ) . toEqual ( "z-openapi.yml" )
712+ expect ( projects [ 0 ] . versions [ 1 ] . specifications [ 0 ] . name ) . toEqual ( "2-openapi.yml" )
713+ expect ( projects [ 0 ] . versions [ 1 ] . specifications [ 1 ] . name ) . toEqual ( "o-openapi.yml" )
714+ } )
715+
716+ test ( "It maintains remote version specification ordering from config" , async ( ) => {
717+ const sut = new GitHubProjectDataSource ( {
718+ repositoryNameSuffix : "-openapi" ,
719+ repositoryDataSource : {
720+ async getRepositories ( ) {
721+ return [ {
722+ owner : "acme" ,
723+ name : "foo-openapi" ,
724+ defaultBranchRef : {
725+ id : "12345678" ,
726+ name : "main"
727+ } ,
728+ configYaml : {
729+ text : `
730+ name: Hello World
731+ remoteVersions:
732+ - name: Bar
733+ specifications:
734+ - id: some-spec
735+ name: Zac
736+ url: https://example.com/zac.yml
737+ - id: another-spec
738+ name: Bob
739+ url: https://example.com/bob.yml
740+ `
741+ } ,
742+ branches : [ ] ,
743+ tags : [ ]
744+ } ]
745+ }
746+ } ,
747+ encryptionService : noopEncryptionService ,
748+ remoteConfigEncoder : base64RemoteConfigEncoder
749+ } )
750+ const projects = await sut . getProjects ( )
751+ expect ( projects [ 0 ] . versions [ 0 ] . specifications [ 0 ] . name ) . toEqual ( "Zac" )
752+ expect ( projects [ 0 ] . versions [ 0 ] . specifications [ 1 ] . name ) . toEqual ( "Bob" )
753+ } )
754+
666755test ( "It identifies the default branch in returned versions" , async ( ) => {
667756 const sut = new GitHubProjectDataSource ( {
668757 repositoryNameSuffix : "-openapi" ,
0 commit comments