Files
bruno/tests/preferences/default-collection-location/default-collection-location.spec.js
gopu-bruno 6d86c76b21 feat: inline create collection and workspace editor (#7324)
* feat: inline create collection and workspace editor

* refactor: use inline collection creation from workspace overview

* fix: improve inline collection creation UX from workspace overview

* fix: update E2E tests for inline collection creation flow

* fix: update default location test for inline collection creation flow

* fix: derive inline workspace/collection names from filesystem

* feat: inline workspace create form manage workspace

* feat: prefill create modal with name

* fix: minor code style fixes

---------

Co-authored-by: naman-bruno <naman@usebruno.com>
2026-03-04 13:25:30 +05:30

111 lines
4.5 KiB
JavaScript

import { test, expect } from '../../../playwright';
test.describe('Default Location Feature', () => {
test('Should hydrate the default location from preferences', async ({ pageWithUserData: page }) => {
// open preferences tab
await page.locator('.preferences-button').click();
// wait for preferences tab to be visible
await page.waitForTimeout(500);
// navigate to General tab
await page.getByRole('tab', { name: 'General' }).click();
// verify the default location is pre-filled
const defaultLocationInput = page.locator('.default-location-input');
await expect(defaultLocationInput).toHaveValue('/tmp/bruno-collections');
});
test('Should save a valid default location', async ({ pageWithUserData: page }) => {
// open preferences tab
await page.locator('.preferences-button').click();
// wait for preferences tab to be visible
await page.waitForTimeout(500);
// navigate to General tab
await page.getByRole('tab', { name: 'General' }).click();
// set a default location (readonly input, remove readonly then fill)
const defaultLocationInput = page.locator('.default-location-input');
await defaultLocationInput.evaluate((el) => {
const input = el;
input.removeAttribute('readonly');
input.readOnly = false;
});
await defaultLocationInput.fill('/tmp/bruno-collections');
// wait for auto-save to complete (debounce is 500ms)
await page.waitForTimeout(1000);
});
test('Should use default location in Create Collection modal', async ({ pageWithUserData: page }) => {
// test Create Collection modal
await page.getByTestId('collections-header-add-menu').click();
await page.locator('.tippy-box .dropdown-item').filter({ hasText: 'Create collection' }).click();
// Wait for inline creator to appear, then click the cog button to open advanced modal
const inlineCreator = page.locator('.inline-collection-creator');
await inlineCreator.waitFor({ state: 'visible', timeout: 5000 });
await inlineCreator.locator('.cog-btn').click();
// Wait for modal to be visible
await page.locator('.bruno-modal').waitFor({ state: 'visible' });
// verify the default location is pre-filled
// Scope to the modal to avoid conflict with preferences tab
const collectionLocationInput = page.locator('.bruno-modal').getByLabel('Location', { exact: true });
await expect(collectionLocationInput).toBeVisible();
const inputValue = await collectionLocationInput.inputValue();
await expect(collectionLocationInput).toHaveValue('/tmp/bruno-collections', { timeout: 5000 });
// cancel the collection creation
await page.locator('.bruno-modal').getByRole('button', { name: 'Cancel' }).click();
});
test('Should use default location in Clone Collection modal', async ({ pageWithUserData: page }) => {
// open the clone collection modal
const collection = page.locator('.collection-name').first();
await collection.hover();
await collection.locator('.collection-actions .icon').click();
await page.locator('.dropdown-item').filter({ hasText: 'Clone' }).click();
// Wait for modal to be visible
await page.locator('.bruno-modal').waitFor({ state: 'visible' });
// verify the default location is pre-filled
// Scope to the modal to avoid conflict with preferences tab
const cloneLocationInput = page.locator('.bruno-modal').getByLabel('Location', { exact: true });
await expect(cloneLocationInput).toBeVisible();
await expect(cloneLocationInput).toHaveValue('/tmp/bruno-collections', { timeout: 5000 });
// cancel the clone operation
await page.locator('.bruno-modal').getByRole('button', { name: 'Cancel' }).click();
});
test('Should save empty default location', async ({ pageWithUserData: page }) => {
// open preferences tab
await page.locator('.preferences-button').click();
// wait for preferences tab to be visible
await page.waitForTimeout(500);
// navigate to General tab
await page.getByRole('tab', { name: 'General' }).click();
// clear the default location field (readonly input, remove readonly then clear)
const defaultLocationInput = page.locator('.default-location-input');
await defaultLocationInput.evaluate((el) => {
const input = el;
input.removeAttribute('readonly');
input.readOnly = false;
});
await defaultLocationInput.clear();
// wait for auto-save to complete (debounce is 500ms)
await page.waitForTimeout(1000);
});
});