mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-17 20:13:53 +00:00
feat(browser): add explicit runtime policy controls
This commit is contained in:
1 parent
d6c45fef04
commit
7d02f55f9f
25 files changed
+795
-50
No files matched your search
@@ -0,0 +1,47 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
import {
|
||||
resolveBrowserExposure,
|
||||
resolveBrowserLaunchFlagResolution,
|
||||
} from '../../../../src/utils/browser/browser-policy';
|
||||
|
||||
describe('browser policy', () => {
|
||||
it('strips browser launch flags and records the override', () => {
|
||||
expect(resolveBrowserLaunchFlagResolution(['glm', '--browser', 'check app'])).toEqual({
|
||||
override: 'force-enable',
|
||||
argsWithoutFlags: ['glm', 'check app'],
|
||||
});
|
||||
expect(resolveBrowserLaunchFlagResolution(['glm', '--no-browser', 'check app'])).toEqual({
|
||||
override: 'force-disable',
|
||||
argsWithoutFlags: ['glm', 'check app'],
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects conflicting browser launch flags', () => {
|
||||
expect(() => resolveBrowserLaunchFlagResolution(['--browser', '--no-browser'])).toThrow(
|
||||
'Use either `--browser` or `--no-browser`, not both.'
|
||||
);
|
||||
});
|
||||
|
||||
it('resolves browser exposure from saved policy and one-run overrides', () => {
|
||||
expect(resolveBrowserExposure({ enabled: true, policy: 'auto' })).toMatchObject({
|
||||
exposeByDefault: true,
|
||||
exposeForLaunch: true,
|
||||
});
|
||||
expect(resolveBrowserExposure({ enabled: true, policy: 'manual' })).toMatchObject({
|
||||
exposeByDefault: false,
|
||||
exposeForLaunch: false,
|
||||
});
|
||||
expect(
|
||||
resolveBrowserExposure({ enabled: true, policy: 'manual' }, 'force-enable')
|
||||
).toMatchObject({
|
||||
exposeByDefault: false,
|
||||
exposeForLaunch: true,
|
||||
});
|
||||
expect(
|
||||
resolveBrowserExposure({ enabled: true, policy: 'auto' }, 'force-disable')
|
||||
).toMatchObject({
|
||||
exposeByDefault: true,
|
||||
exposeForLaunch: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user