@@ -38,9 +38,11 @@ vi.mock("../src/commands/help.js", () => ({
3838 addNotes : vi . fn ( ) ,
3939} ) ) ;
4040
41+ import type { Command } from "commander" ;
4142import { createClient , getFormat , outputResponse } from "../src/helpers.js" ;
4243import { parseJsonInput } from "../src/input.js" ;
4344import { printSuccess } from "../src/output.js" ;
45+ import { addExamples } from "../src/commands/help.js" ;
4446import { registerUsersCommand } from "../src/commands/admin/users.js" ;
4547
4648describe ( "admin users commands" , ( ) => {
@@ -107,6 +109,40 @@ describe("admin users commands", () => {
107109 expect ( outputResponse ) . toHaveBeenCalled ( ) ;
108110 expect ( printSuccess ) . toHaveBeenCalledWith ( "User created." ) ;
109111 } ) ;
112+
113+ // #118: server schema accepts only `primaryTenantId`. Help and examples must reflect that.
114+ it ( "references primaryTenantId (not legacy tenantId) in description" , ( ) => {
115+ const program = makeProgram ( ) ;
116+ const createCmd = program . commands
117+ . find ( ( c ) => c . name ( ) === "admin" ) !
118+ . commands . find ( ( c ) => c . name ( ) === "users" ) !
119+ . commands . find ( ( c ) => c . name ( ) === "create" ) ! ;
120+ const desc = createCmd . description ( ) ;
121+ expect ( desc ) . toContain ( '"primaryTenantId":' ) ;
122+ expect ( desc ) . toContain ( "primaryTenantId is required" ) ;
123+ expect ( desc ) . not . toContain ( '"tenantId":' ) ;
124+ expect ( desc ) . not . toContain ( "tenantId is required" ) ;
125+ } ) ;
126+
127+ it ( "uses primaryTenantId in registered example payloads" , ( ) => {
128+ makeProgram ( ) ;
129+ const addExamplesMock = vi . mocked ( addExamples ) ;
130+ const createCalls = addExamplesMock . mock . calls . filter (
131+ ( [ cmd ] ) => ( cmd as Command ) . name ( ) === "create" ,
132+ ) ;
133+ expect ( createCalls . length ) . toBeGreaterThan ( 0 ) ;
134+ const examples = createCalls . flatMap (
135+ ( [ , exs ] ) => exs as ReadonlyArray < { description : string ; command : string } > ,
136+ ) ;
137+ const roleSpecificExamples = examples . filter (
138+ ( e ) => e . command . includes ( '"role":"tenant_admin"' ) || e . command . includes ( '"role":"user"' ) ,
139+ ) ;
140+ expect ( roleSpecificExamples . length ) . toBeGreaterThan ( 0 ) ;
141+ for ( const ex of roleSpecificExamples ) {
142+ expect ( ex . command ) . toContain ( '"primaryTenantId":' ) ;
143+ expect ( ex . command ) . not . toContain ( '"tenantId":' ) ;
144+ }
145+ } ) ;
110146 } ) ;
111147
112148 describe ( "users update" , ( ) => {
0 commit comments