Skip to content

Commit e6125f2

Browse files
committed
test(cli): the served shell carries the react-pages capability script by default
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X4d6XVfcfxL17bMpptytcc
1 parent e6bbf96 commit e6125f2

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

‎packages/cli/src/utils/console.branded-head.test.ts‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,25 +250,34 @@ describe('the branding read is the visitor\'s own request, re-addressed', () =>
250250
});
251251

252252
describe('with no branding to read, the document is served as before', () => {
253-
/** The shell as it was served before this change: the base tag added, nothing else. */
254-
const BEFORE = SHELL.replace('<head>', '<head>\n <base href="/_console/">');
253+
/**
254+
* The shell as it was served before this change: the base tag and the
255+
* react-pages capability script added (off by default), nothing else. The
256+
* script's per-response nonce is read off by `served`.
257+
*/
258+
const BEFORE = SHELL.replace(
259+
'<head>',
260+
'<head>\n <script>window.__OBJECTUI_CAPABILITIES_DISABLED__=(window.__OBJECTUI_CAPABILITIES_DISABLED__||[]).concat(\'react-pages\');</script>'
261+
+ '\n <base href="/_console/">',
262+
);
263+
const served = async (res: Response) => (await res.text()).replace(/ nonce="[^"]*"/g, '');
255264

256265
it('a composition with no branding door serves the shell unchanged, and says nothing', async () => {
257266
const app = await mount({});
258-
const html = await (await app.request('/_console/')).text();
267+
const html = await served(await app.request('/_console/'));
259268
expect(html).toBe(BEFORE);
260269
expect(app.warnings).toEqual([]);
261270
});
262271

263272
it('a door that answers no branding block serves the shell unchanged', async () => {
264273
const app = await mount({ stub: { kind: 'json', body: { cloudUrl: '' } } });
265-
expect(await (await app.request('/_console/')).text()).toBe(BEFORE);
274+
expect(await served(await app.request('/_console/'))).toBe(BEFORE);
266275
});
267276

268277
it('a door that fails serves the shell unchanged and warns once', async () => {
269278
const app = await mount({ stub: { kind: 'status', status: 500 } });
270-
expect(await (await app.request('/_console/')).text()).toBe(BEFORE);
271-
expect(await (await app.request('/_console/apps/x')).text()).toBe(BEFORE);
279+
expect(await served(await app.request('/_console/'))).toBe(BEFORE);
280+
expect(await served(await app.request('/_console/apps/x'))).toBe(BEFORE);
272281
expect(app.warnings).toHaveLength(1);
273282
expect(app.warnings[0]).toContain('/api/v1/runtime/config');
274283
expect(app.warnings[0]).toContain('500');
@@ -278,7 +287,7 @@ describe('with no branding to read, the document is served as before', () => {
278287
const app = await mount({ stub: { kind: 'throw' } });
279288
const res = await app.request('/_console/');
280289
expect(res.status).toBe(200);
281-
expect(await res.text()).toBe(BEFORE);
290+
expect(await served(res)).toBe(BEFORE);
282291
expect(app.warnings).toHaveLength(1);
283292
});
284293
});

0 commit comments

Comments
 (0)