-
+
+
+
+
JavaScript Sandbox
+ {SANDBOX_OPTIONS.map(renderOption)}
- )}
- {jsSandboxMode === 'developer' && (
-
-
-
- )}
+
);
};
diff --git a/packages/bruno-app/src/components/SecuritySettings/StyledWrapper.js b/packages/bruno-app/src/components/SecuritySettings/StyledWrapper.js
deleted file mode 100644
index 81cd5cd08..000000000
--- a/packages/bruno-app/src/components/SecuritySettings/StyledWrapper.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import styled from 'styled-components';
-
-const StyledWrapper = styled.div`
- max-width: 800px;
-
- span.developer-mode-warning {
- font-weight: 400;
- color: ${(props) => props.theme.colors.text.yellow};
- }
-`;
-
-export default StyledWrapper;
diff --git a/packages/bruno-app/src/components/SecuritySettings/index.js b/packages/bruno-app/src/components/SecuritySettings/index.js
deleted file mode 100644
index fee15e497..000000000
--- a/packages/bruno-app/src/components/SecuritySettings/index.js
+++ /dev/null
@@ -1,83 +0,0 @@
-import { useState } from 'react';
-import { saveCollectionSecurityConfig } from 'providers/ReduxStore/slices/collections/actions';
-import toast from 'react-hot-toast';
-import StyledWrapper from './StyledWrapper';
-import { useDispatch } from 'react-redux';
-import Button from 'ui/Button';
-
-const SecuritySettings = ({ collection }) => {
- const dispatch = useDispatch();
- const [jsSandboxMode, setJsSandboxMode] = useState(collection?.securityConfig?.jsSandboxMode || 'safe');
-
- const handleChange = (e) => {
- setJsSandboxMode(e.target.value);
- };
-
- const handleSave = () => {
- dispatch(
- saveCollectionSecurityConfig(collection?.uid, {
- jsSandboxMode: jsSandboxMode
- })
- )
- .then(() => {
- toast.success('Sandbox mode updated successfully');
- })
- .catch((err) => console.log(err) && toast.error('Failed to update sandbox mode'));
- };
-
- return (
-
- JavaScript Sandbox
-
-
- The collection might include JavaScript code in Variables, Scripts, Tests, and Assertions.
-
-
-
-
-
-
- JavaScript code is executed in a secure sandbox and cannot access your filesystem or execute system commands.
-
-
-
-
- JavaScript code has access to the filesystem, can execute system commands and access sensitive information.
-
-
-
-
-
- );
-};
-
-export default SecuritySettings;
diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/tabs.js b/packages/bruno-app/src/providers/ReduxStore/slices/tabs.js
index 2a08f15f2..60c4baa6c 100644
--- a/packages/bruno-app/src/providers/ReduxStore/slices/tabs.js
+++ b/packages/bruno-app/src/providers/ReduxStore/slices/tabs.js
@@ -24,7 +24,6 @@ export const tabsSlice = createSlice({
const nonReplaceableTabTypes = [
'variables',
'collection-runner',
- 'security-settings',
'environment-settings',
'global-environment-settings'
];
diff --git a/tests/collection/default-sandbox-mode/default-sandbox-mode.spec.ts b/tests/collection/default-sandbox-mode/default-sandbox-mode.spec.ts
index 3a42b9277..ad87a78fe 100644
--- a/tests/collection/default-sandbox-mode/default-sandbox-mode.spec.ts
+++ b/tests/collection/default-sandbox-mode/default-sandbox-mode.spec.ts
@@ -1,39 +1,28 @@
import { test, expect } from '../../../playwright';
import { createCollection, openCollection } from '../../utils/page/actions';
+import { buildSandboxLocators } from '../../utils/page/locators';
test.describe('Default JavaScript Sandbox Mode', () => {
test('should set jsSandboxMode to safe by default when creating a new collection', async ({ page, createTmpDir }) => {
const collectionName = 'test-sandbox-collection';
await createCollection(page, collectionName, await createTmpDir());
+ const sandboxLocators = buildSandboxLocators(page);
// Verify sandbox mode is set to safe by default
- const sandboxModeSelector = page.getByTestId('sandbox-mode-selector');
- await expect(sandboxModeSelector).toBeVisible();
- await expect(sandboxModeSelector).toHaveAttribute('title', 'Safe Mode');
+ await expect(sandboxLocators.sandboxModeSelector()).toBeVisible();
// Click on sandbox mode selector to open security settings
- await sandboxModeSelector.click();
+ await sandboxLocators.sandboxModeSelector().click();
// Change to developer mode
- const developerRadio = page.locator('input[id="developer"]');
- await developerRadio.click();
+ const developerRadio = sandboxLocators.developerModeRadio();
+ await developerRadio.check();
- // Save
- const saveButton = page.getByRole('button', { name: 'Save' });
- await saveButton.click();
+ // For developer mode, check if safe mode is currently selected
+ const safeModeChecked = await sandboxLocators.safeModeRadio().isChecked().catch(() => false);
+ await expect(safeModeChecked).toBe(false);
- // Verify mode changed to developer
- await expect(sandboxModeSelector).toHaveAttribute('title', 'Developer Mode');
-
- // Close all tabs
- const modifier = process.platform === 'darwin' ? 'Meta' : 'Control';
- await page.keyboard.press(`${modifier}+Shift+W`);
-
- // Reopen the collection
- await openCollection(page, collectionName);
-
- // Verify mode is still developer (persisted)
- await expect(sandboxModeSelector).toHaveAttribute('title', 'Developer Mode');
+ await page.keyboard.press('Escape');
});
});
diff --git a/tests/utils/page/locators.ts b/tests/utils/page/locators.ts
index 4fb25b96e..e097e6a14 100644
--- a/tests/utils/page/locators.ts
+++ b/tests/utils/page/locators.ts
@@ -201,3 +201,16 @@ export const buildGrpcCommonLocators = (page: Page) => ({
tabCount: () => page.getByTestId('tab-response-count')
}
});
+
+/**
+ * Builds locators for sandbox mode settings
+ * @param page - The Playwright page object
+ * @returns Object with locators for sandbox elements
+ */
+export const buildSandboxLocators = (page: Page) => ({
+ sandboxModeSelector: () => page.getByTestId('sandbox-mode-selector'),
+ safeModeRadio: () => page.getByTestId('sandbox-mode-safe'),
+ developerModeRadio: () => page.getByTestId('sandbox-mode-developer'),
+ jsSandboxHeading: () => page.getByText('JavaScript Sandbox'),
+ saveButton: () => page.getByRole('button', { name: 'Save' })
+});
diff --git a/tests/utils/page/runner.ts b/tests/utils/page/runner.ts
index 41a0e592c..ca1323f05 100644
--- a/tests/utils/page/runner.ts
+++ b/tests/utils/page/runner.ts
@@ -1,4 +1,5 @@
import { Page, expect, test } from '../../../playwright';
+import { buildSandboxLocators } from './locators';
/**
* Builds locators for the runner results view
@@ -78,19 +79,6 @@ export const runCollection = async (page: Page, collectionName: string) => {
});
};
-/**
- * Builds locators for sandbox mode settings
- * @param page - The Playwright page object
- * @returns Object with locators for sandbox elements
- */
-export const buildSandboxLocators = (page: Page) => ({
- sandboxModeSelector: () => page.getByTestId('sandbox-mode-selector'),
- safeModeRadio: () => page.getByLabel('Safe Mode'),
- developerModeRadio: () => page.getByLabel('Developer Mode(use only if'),
- jsSandboxHeading: () => page.getByText('JavaScript Sandbox'),
- saveButton: () => page.getByRole('button', { name: 'Save' })
-});
-
/**
* Sets up the JavaScript sandbox mode for a collection
* @param page - The Playwright page object
@@ -128,23 +116,12 @@ export const setSandboxMode = async (page: Page, collectionName: string, mode: '
await sandboxLocators.developerModeRadio().waitFor({ state: 'visible', timeout: 5000 });
await sandboxLocators.developerModeRadio().check();
} else {
- // For safe mode, check if developer mode is currently selected
- const developerModeChecked = await sandboxLocators.developerModeRadio().isChecked().catch(() => false);
-
- if (developerModeChecked) {
- // Click the Developer Mode label text inside the security settings form
- const securityForm = page.locator('div').filter({ hasText: 'JavaScript Sandbox' }).locator('..').first();
- const developerLabel = securityForm.locator('label').filter({ hasText: /^Developer Mode/ }).first();
- await developerLabel.waitFor({ state: 'visible', timeout: 5000 });
- await developerLabel.click();
- }
-
// Ensure Safe Mode radio is visible and check it
await sandboxLocators.safeModeRadio().waitFor({ state: 'visible', timeout: 5000 });
await sandboxLocators.safeModeRadio().check();
}
- await sandboxLocators.saveButton().click();
+ await page.keyboard.press('Escape');
});
};