fix(admin): Rename secureModeEnabled to strictModeDisabled (#17789)

This commit is contained in:
Shreya Keshive
2026-01-29 10:31:00 -05:00
committed by GitHub
parent 42eedc9184
commit f619cd8750
4 changed files with 70 additions and 33 deletions

View File

@@ -44,7 +44,7 @@ describe('Admin Controls', () => {
describe('sanitizeAdminSettings', () => {
it('should strip unknown fields', () => {
const input = {
secureModeEnabled: true,
strictModeDisabled: false,
extraField: 'should be removed',
mcpSetting: {
mcpEnabled: false,
@@ -55,7 +55,7 @@ describe('Admin Controls', () => {
const result = sanitizeAdminSettings(input);
expect(result).toEqual({
secureModeEnabled: true,
strictModeDisabled: false,
mcpSetting: {
mcpEnabled: false,
},
@@ -104,7 +104,7 @@ describe('Admin Controls', () => {
});
it('should use cachedSettings and start polling if provided', async () => {
const cachedSettings = { secureModeEnabled: true };
const cachedSettings = { strictModeDisabled: false };
const result = await fetchAdminControls(
mockServer,
cachedSettings,
@@ -117,7 +117,7 @@ describe('Admin Controls', () => {
// Should still start polling
(mockServer.fetchAdminControls as Mock).mockResolvedValue({
secureModeEnabled: false,
strictModeDisabled: true,
});
await vi.advanceTimersByTimeAsync(5 * 60 * 1000);
@@ -136,7 +136,7 @@ describe('Admin Controls', () => {
});
it('should fetch from server if no cachedSettings provided', async () => {
const serverResponse = { secureModeEnabled: true };
const serverResponse = { strictModeDisabled: false };
(mockServer.fetchAdminControls as Mock).mockResolvedValue(serverResponse);
const result = await fetchAdminControls(
@@ -164,7 +164,7 @@ describe('Admin Controls', () => {
// Polling should have been started and should retry
(mockServer.fetchAdminControls as Mock).mockResolvedValue({
secureModeEnabled: true,
strictModeDisabled: false,
});
await vi.advanceTimersByTimeAsync(5 * 60 * 1000);
expect(mockServer.fetchAdminControls).toHaveBeenCalledTimes(2); // Initial + poll
@@ -191,7 +191,7 @@ describe('Admin Controls', () => {
it('should sanitize server response', async () => {
(mockServer.fetchAdminControls as Mock).mockResolvedValue({
secureModeEnabled: true,
strictModeDisabled: false,
unknownField: 'bad',
});
@@ -201,7 +201,7 @@ describe('Admin Controls', () => {
true,
mockOnSettingsChanged,
);
expect(result).toEqual({ secureModeEnabled: true });
expect(result).toEqual({ strictModeDisabled: false });
expect(
(result as Record<string, unknown>)['unknownField'],
).toBeUndefined();
@@ -245,7 +245,7 @@ describe('Admin Controls', () => {
it('should poll and emit changes', async () => {
// Initial fetch
(mockServer.fetchAdminControls as Mock).mockResolvedValue({
secureModeEnabled: false,
strictModeDisabled: true,
});
await fetchAdminControls(
mockServer,
@@ -256,19 +256,19 @@ describe('Admin Controls', () => {
// Update for next poll
(mockServer.fetchAdminControls as Mock).mockResolvedValue({
secureModeEnabled: true,
strictModeDisabled: false,
});
// Fast forward
await vi.advanceTimersByTimeAsync(5 * 60 * 1000);
expect(mockOnSettingsChanged).toHaveBeenCalledWith({
secureModeEnabled: true,
strictModeDisabled: false,
});
});
it('should NOT emit if settings are deeply equal but not the same instance', async () => {
const settings = { secureModeEnabled: true };
const settings = { strictModeDisabled: false };
(mockServer.fetchAdminControls as Mock).mockResolvedValue(settings);
await fetchAdminControls(
@@ -282,7 +282,7 @@ describe('Admin Controls', () => {
// Next poll returns a different object with the same values
(mockServer.fetchAdminControls as Mock).mockResolvedValue({
secureModeEnabled: true,
strictModeDisabled: false,
});
await vi.advanceTimersByTimeAsync(5 * 60 * 1000);
@@ -293,7 +293,7 @@ describe('Admin Controls', () => {
it('should continue polling after a fetch error', async () => {
// Initial fetch is successful
(mockServer.fetchAdminControls as Mock).mockResolvedValue({
secureModeEnabled: false,
strictModeDisabled: true,
});
await fetchAdminControls(
mockServer,
@@ -313,19 +313,19 @@ describe('Admin Controls', () => {
// Subsequent poll succeeds with new data
(mockServer.fetchAdminControls as Mock).mockResolvedValue({
secureModeEnabled: true,
strictModeDisabled: false,
});
await vi.advanceTimersByTimeAsync(5 * 60 * 1000);
expect(mockServer.fetchAdminControls).toHaveBeenCalledTimes(3);
expect(mockOnSettingsChanged).toHaveBeenCalledWith({
secureModeEnabled: true,
strictModeDisabled: false,
});
});
it('should STOP polling if server returns 403', async () => {
// Initial fetch is successful
(mockServer.fetchAdminControls as Mock).mockResolvedValue({
secureModeEnabled: false,
strictModeDisabled: true,
});
await fetchAdminControls(
mockServer,