fix: update unit tests

This commit is contained in:
Bijin A B
2025-12-09 12:00:20 +05:30
parent 2c34844172
commit 6dc76e023a
4 changed files with 8 additions and 13 deletions

View File

@@ -24,6 +24,7 @@ const JsSandboxMode = ({ collection }) => {
{jsSandboxMode === 'safe' && (
<div
className="sandbox-icon safe-mode"
data-testid="sandbox-mode-selector"
onClick={viewSecuritySettings}
title="Safe Mode"
>
@@ -33,6 +34,7 @@ const JsSandboxMode = ({ collection }) => {
{jsSandboxMode === 'developer' && (
<div
className="sandbox-icon developer-mode"
data-testid="sandbox-mode-selector"
onClick={viewSecuritySettings}
title="Developer Mode"
>

View File

@@ -18,7 +18,7 @@ test.describe('Response Pane Actions', () => {
await test.step('Create collection and request', async () => {
await createCollection(page, collectionName, await createTmpDir(collectionName), { openWithSandboxMode: 'safe' });
await createRequest(page, 'copy-test', collectionName, { url: 'https://httpbin.org/json' });
await createRequest(page, 'copy-test', collectionName, { url: 'https://testbench-sanity.usebruno.com/ping' });
});
await test.step('Send request and wait for response', async () => {

View File

@@ -1,5 +1,5 @@
{
"maximized": true,
"maximized": false,
"lastOpenedCollections": [
"{{projectRoot}}/tests/scripting/inbuilt-libraries/fs/fixtures/collections/should_allow_fs",
"{{projectRoot}}/tests/scripting/inbuilt-libraries/fs/fixtures/collections/should_disallow_fs"

View File

@@ -84,8 +84,7 @@ export const runCollection = async (page: Page, collectionName: string) => {
* @returns Object with locators for sandbox elements
*/
export const buildSandboxLocators = (page: Page) => ({
developerModeBadge: () => page.locator('.developer-mode').filter({ hasText: 'Developer Mode' }),
safeModeBadge: () => page.locator('.safe-mode').filter({ hasText: 'Safe Mode' }),
sandboxModeSelector: () => page.getByTestId('sandbox-mode-selector'),
safeModeRadio: () => page.getByLabel('Safe Mode'),
developerModeRadio: () => page.getByLabel('Developer Mode(use only if'),
jsSandboxHeading: () => page.getByText('JavaScript Sandbox'),
@@ -109,16 +108,10 @@ export const setSandboxMode = async (page: Page, collectionName: string, mode: '
await sidebarCollection.click();
// Check if there's already a mode selected - if so, we need to click the badge to open settings tab
const developerBadgeVisible = await sandboxLocators.developerModeBadge().isVisible().catch(() => false);
const safeBadgeVisible = await sandboxLocators.safeModeBadge().isVisible().catch(() => false);
const sandboxBadgeVisible = await sandboxLocators.sandboxModeSelector().isVisible().catch(() => false);
// If a badge exists, click it to open the security settings tab
if (developerBadgeVisible || safeBadgeVisible) {
if (developerBadgeVisible) {
await sandboxLocators.developerModeBadge().click();
} else {
await sandboxLocators.safeModeBadge().click();
}
if (sandboxBadgeVisible) {
await sandboxLocators.sandboxModeSelector().click();
// Wait for the security settings tab to be active
await sandboxLocators.jsSandboxHeading().waitFor({ state: 'visible', timeout: 10000 });