1010 *
1111 * - with an agent in the catalog the chip is unchanged: "Build an app", to
1212 * `/studio`, dimmed with its reason for a session that may not author;
13- * - with none it says what it opens, "New in Studio ", and opens Studio's
13+ * - with none it says what it opens, "New blank app ", and opens Studio's
1414 * new-package flow (`SETUP_NEW_PACKAGE_PATH`, Setup → Packages with New
1515 * Package open since objectstack#36908);
1616 * - with none, a session that may not author gets no build chip at all,
2020 *
2121 * objectstack#36969 — the AI form is drawn where the catalog serves the build
2222 * agent itself (alias-aware), not any agent: where in-app building is closed
23- * the catalog keeps `ask` and drops `build`, and the chip takes the "New in
24- * Studio " form there, as for an empty catalog. So the unchanged-chip cases
23+ * the catalog keeps `ask` and drops `build`, and the chip takes the "New
24+ * blank app " form there, as for an empty catalog. So the unchanged-chip cases
2525 * serve `build`; a catalog of `ask` or of another agent alone is pinned below.
2626 *
2727 * The catalog stand-in moves the way the real `useAgents` does: an empty first
@@ -44,8 +44,12 @@ const state = vi.hoisted(() => ({
4444 agents : [ ] as Array < { name : string } > ,
4545 /** Holds the catalog in flight. */
4646 catalogPending : false ,
47- /** Whether the session holds the Setup → Packages pair (`setup.access` + `manage_platform_settings`). */
48- setupPair : true ,
47+ /**
48+ * Whether the session holds the Setup → Packages pair (`setup.access` +
49+ * `manage_platform_settings`). `'unreported'` stubs nothing: the real
50+ * provider around the page answers, with no `systemPermissions` at all.
51+ */
52+ setupPair : true as boolean | 'unreported' ,
4953} ) ) ;
5054
5155vi . mock ( 'react-router-dom' , async ( ) => {
@@ -117,6 +121,7 @@ vi.mock('@object-ui/permissions', async (importOriginal) => {
117121 ...actual ,
118122 usePermissions : ( ) => {
119123 const real = actual . usePermissions ( ) ;
124+ if ( state . setupPair === 'unreported' ) return real ;
120125 return {
121126 ...real ,
122127 hasCapabilities : ( required : string [ ] ) =>
@@ -174,6 +179,7 @@ vi.mock('../../deployment-notice/DeploymentNotice', () => ({ DeploymentNotice: (
174179import '@objectstack/lint' ;
175180import { HomePage } from '../HomePage' ;
176181import { SETUP_NEW_PACKAGE_PATH } from '../../../views/metadata-admin/packageSource' ;
182+ import { MePermissionsProvider , type MePermissionsAuthenticatedResponse } from '@object-ui/permissions' ;
177183
178184beforeEach ( ( ) => {
179185 navigateMock . mockReset ( ) ;
@@ -213,7 +219,7 @@ describe('with the build agent in the catalog, the build chip is unchanged (obje
213219} ) ;
214220
215221describe ( 'with no agent in the catalog (objectstack#26614)' , ( ) => {
216- it ( 'the chip reads "New in Studio " and opens Studio\'s new-package flow' , async ( ) => {
222+ it ( 'the chip reads "New blank app " and opens Studio\'s new-package flow' , async ( ) => {
217223 const user = userEvent . setup ( ) ;
218224 render ( < HomePage /> ) ;
219225 const chip = await screen . findByTestId ( 'home-build-in-studio' ) ;
@@ -234,6 +240,41 @@ describe('with no agent in the catalog (objectstack#26614)', () => {
234240 expect ( navigateMock ) . not . toHaveBeenCalledWith ( SETUP_NEW_PACKAGE_PATH ) ;
235241 } ) ;
236242
243+ /**
244+ * objectstack#36908 — the doors fail OPEN where the server never reported
245+ * the capability set, as their own authoring gate (`useCanAuthorMetadata`)
246+ * does: the door is only a link, and Setup → Packages and the create route
247+ * keep their own server-side gates. Nothing is stubbed here: the real
248+ * provider answers, once with no `systemPermissions` and once (the control)
249+ * with a reported set that holds neither capability of the pair.
250+ */
251+ it . each ( [
252+ [ 'an unreported set (no `systemPermissions`) fails open, to Setup\'s New Package' , undefined , SETUP_NEW_PACKAGE_PATH ] ,
253+ [ 'control: a reported set without the pair goes to the "All metadata" area' , [ 'manage_metadata' ] , '/studio/~all/metadata' ] ,
254+ ] ) ( '%s' , async ( _case , systemPermissions , to ) => {
255+ state . setupPair = 'unreported' ;
256+ const answer : MePermissionsAuthenticatedResponse = {
257+ authenticated : true ,
258+ userId : 'u1' ,
259+ tenantId : 'org_1' ,
260+ positions : [ ] ,
261+ hasAnyQueue : false ,
262+ objectsUsingQueues : [ ] ,
263+ permissionSets : [ 'member' ] ,
264+ ...( systemPermissions ? { systemPermissions } : { } ) ,
265+ objects : { } ,
266+ fields : { } ,
267+ } ;
268+ const user = userEvent . setup ( ) ;
269+ render (
270+ < MePermissionsProvider initialPermissions = { answer } >
271+ < HomePage />
272+ </ MePermissionsProvider > ,
273+ ) ;
274+ await user . click ( await screen . findByTestId ( 'home-build-in-studio' ) ) ;
275+ expect ( navigateMock ) . toHaveBeenCalledWith ( to ) ;
276+ } ) ;
277+
237278 it ( 'a session that may not author gets no build chip; the template chip keeps the reason' , async ( ) => {
238279 state . canAuthorMetadata = false ;
239280 render ( < HomePage /> ) ;
@@ -249,7 +290,7 @@ describe('without the build agent in the catalog, the chip takes its Studio form
249290 it . each ( [
250291 [ 'in-app building closed: `ask` served, `build` not' , [ { name : 'ask' } ] ] ,
251292 [ 'another agent only' , [ { name : 'custom_helper' } ] ] ,
252- ] ) ( '%s: "New in Studio ", to Studio\'s new-package flow, and no "Build an app"' , async ( _case , agents ) => {
293+ ] ) ( '%s: "New blank app ", to Studio\'s new-package flow, and no "Build an app"' , async ( _case , agents ) => {
253294 state . agents = agents ;
254295 const user = userEvent . setup ( ) ;
255296 render ( < HomePage /> ) ;
0 commit comments