mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-09 06:55:03 +00:00
feat(sandbox): create a dropdown selector for sandbox mode (#6519)
This commit is contained in:
@@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user