mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
fix: handle special characters in collection path for dotenv watcher (#7190)
* fix: handle special characters in collection path for dotenv watcher * fix
This commit is contained in:
@@ -100,10 +100,9 @@ class DotEnvWatcher {
|
||||
this.collectionWatchers.get(collectionPath).close();
|
||||
}
|
||||
|
||||
const dotEnvPattern = path.join(collectionPath, '.env*');
|
||||
|
||||
const watcher = chokidar.watch(dotEnvPattern, {
|
||||
const watcher = chokidar.watch(collectionPath, {
|
||||
...DEFAULT_WATCHER_OPTIONS,
|
||||
disableGlobbing: true,
|
||||
awaitWriteFinish: {
|
||||
stabilityThreshold: 80,
|
||||
pollInterval: 100
|
||||
@@ -151,10 +150,9 @@ class DotEnvWatcher {
|
||||
this.workspaceWatchers.get(workspacePath).close();
|
||||
}
|
||||
|
||||
const dotEnvPattern = path.join(workspacePath, '.env*');
|
||||
|
||||
const watcher = chokidar.watch(dotEnvPattern, {
|
||||
const watcher = chokidar.watch(workspacePath, {
|
||||
...DEFAULT_WATCHER_OPTIONS,
|
||||
disableGlobbing: true,
|
||||
awaitWriteFinish: {
|
||||
stabilityThreshold: 80,
|
||||
pollInterval: 250
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import { test, expect } from '../../../playwright';
|
||||
import { createCollection, createEnvironment, closeAllCollections } from '../../utils/page';
|
||||
|
||||
test.describe('DotEnv file in collection with special characters in path', () => {
|
||||
test.afterEach(async ({ page }) => {
|
||||
await closeAllCollections(page);
|
||||
});
|
||||
|
||||
test('should detect .env file in collection with brackets in collection name', async ({ page, createTmpDir }) => {
|
||||
const collectionName = 'My API (v2)';
|
||||
const tmpDir = await createTmpDir(collectionName);
|
||||
|
||||
await test.step('Create collection with brackets in name', async () => {
|
||||
await createCollection(page, collectionName, tmpDir);
|
||||
});
|
||||
|
||||
await test.step('Create a collection environment to access env settings', async () => {
|
||||
await createEnvironment(page, 'Test Env', 'collection');
|
||||
});
|
||||
|
||||
await test.step('Open environment config and create .env file', async () => {
|
||||
// Open the environment selector to see the .ENV FILES section
|
||||
await page.getByTestId('environment-selector-trigger').click();
|
||||
|
||||
// The .env Files section is collapsed by default — click to expand it
|
||||
const dotEnvSection = page.locator('.section-header').filter({ hasText: '.env Files' });
|
||||
await dotEnvSection.waitFor({ state: 'visible' });
|
||||
await dotEnvSection.click();
|
||||
|
||||
// Now click the + button to create a new .env file
|
||||
const addButton = dotEnvSection.locator('.section-actions button');
|
||||
await addButton.click();
|
||||
|
||||
// Type the .env file name and press Enter
|
||||
const nameInput = page.locator('.environment-name-input');
|
||||
await nameInput.press('Enter');
|
||||
|
||||
// Wait for success toast
|
||||
await expect(page.getByText('.env file created!')).toBeVisible();
|
||||
});
|
||||
|
||||
await test.step('Verify .env file is detected by watcher and shown in UI', async () => {
|
||||
const dotEnvBadge = page.locator('.section-header').filter({ hasText: '.env Files' }).locator('.section-badge');
|
||||
await expect(dotEnvBadge).toHaveText('1');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user