@@ -54,6 +54,28 @@ describe("getMetaData", () => {
5454 expect ( result . feedbackMechanism ) . toContain ( "/issues" ) ;
5555 } ) ;
5656
57+ it ( "preserves existing languages over GitHub-detected languages" , async ( ) => {
58+ const deps = createMockDeps ( ) ;
59+ const helpers = createHelpers ( deps ) ;
60+
61+ const existing = {
62+ ...validCodeJSON ,
63+ languages : [ "TypeScript" , "Markdown" ] ,
64+ } as any ;
65+ const result = await getMetaData ( helpers , deps , existing ) ;
66+
67+ expect ( result . languages ) . toEqual ( [ "TypeScript" , "Markdown" ] ) ;
68+ } ) ;
69+
70+ it ( "falls back to GitHub-detected languages when none exist" , async ( ) => {
71+ const deps = createMockDeps ( ) ;
72+ const helpers = createHelpers ( deps ) ;
73+
74+ const result = await getMetaData ( helpers , deps , null ) ;
75+
76+ expect ( result . languages ) . toEqual ( [ "TypeScript" , "JavaScript" ] ) ;
77+ } ) ;
78+
5779 it ( "sets Archival status when isArchived" , async ( ) => {
5880 const deps = createMockDeps ( { isArchived : true } ) ;
5981 const helpers = createHelpers ( deps ) ;
@@ -109,6 +131,43 @@ describe("getMetaData", () => {
109131 URL : "https://github.com/upstream-owner/upstream-repo" ,
110132 } ) ;
111133 } ) ;
134+
135+ it ( "preserves existing tags that are not repository topics" , async ( ) => {
136+ const deps = createMockDeps ( ) ;
137+ const helpers = createHelpers ( deps ) ;
138+
139+ const existing = {
140+ ...validCodeJSON ,
141+ tags : [ "featured" ] ,
142+ } as any ;
143+
144+ const result = await getMetaData ( helpers , deps , existing ) ;
145+
146+ expect ( result . tags ) . toEqual ( [ "test" , "automation" , "featured" ] ) ;
147+ } ) ;
148+
149+ it ( "does not duplicate tags that already exist as repository topics" , async ( ) => {
150+ const deps = createMockDeps ( ) ;
151+ const helpers = createHelpers ( deps ) ;
152+
153+ const existing = {
154+ ...validCodeJSON ,
155+ tags : [ "test" , "featured" ] ,
156+ } as any ;
157+
158+ const result = await getMetaData ( helpers , deps , existing ) ;
159+
160+ expect ( result . tags ) . toEqual ( [ "test" , "automation" , "featured" ] ) ;
161+ } ) ;
162+
163+ it ( "uses repository topics when no existing code.json is present" , async ( ) => {
164+ const deps = createMockDeps ( ) ;
165+ const helpers = createHelpers ( deps ) ;
166+
167+ const result = await getMetaData ( helpers , deps , null ) ;
168+
169+ expect ( result . tags ) . toEqual ( [ "test" , "automation" ] ) ;
170+ } ) ;
112171} ) ;
113172
114173describe ( "runWithDeps" , ( ) => {
@@ -152,6 +211,30 @@ describe("runWithDeps", () => {
152211 expect ( deps . setOutput ) . toHaveBeenCalledWith ( "method_used" , "pull_request" ) ;
153212 } ) ;
154213
214+ it ( "includes enum keys in the generated blank code.json" , async ( ) => {
215+ process . env . GITHUB_EVENT_NAME = "schedule" ;
216+
217+ const deps = createMockDeps ( {
218+ readFile : jest . fn < any > ( ) . mockRejectedValue ( new Error ( "no file" ) ) ,
219+ skipPR : false ,
220+ } ) ;
221+
222+ await runWithDeps ( deps ) ;
223+
224+ const createPullRequestMock = deps . octokit . createPullRequest as jest . Mock ;
225+ const pullRequestArgs = createPullRequestMock . mock . calls [ 0 ] [ 0 ] as any ;
226+ const codeJSONContent = pullRequestArgs . changes [ 0 ] . files [ "code.json" ] ;
227+ const generatedCodeJSON = JSON . parse ( codeJSONContent ) ;
228+
229+ expect ( generatedCodeJSON ) . toHaveProperty ( "status" ) ;
230+ expect ( generatedCodeJSON ) . toHaveProperty ( "repositoryHost" ) ;
231+ expect ( generatedCodeJSON ) . toHaveProperty ( "repositoryVisibility" ) ;
232+ expect ( generatedCodeJSON ) . toHaveProperty ( "softwareType" ) ;
233+ expect ( generatedCodeJSON ) . toHaveProperty ( "maintenance" ) ;
234+ expect ( generatedCodeJSON ) . toHaveProperty ( "repositoryType" ) ;
235+ expect ( generatedCodeJSON ) . toHaveProperty ( "fismaLevel" ) ;
236+ } ) ;
237+
155238 it ( "attempts direct push when skipPR is true with admin token" , async ( ) => {
156239 process . env . GITHUB_EVENT_NAME = "workflow_dispatch" ;
157240
0 commit comments