Files
bruno/tests/preferences/default-collection-location/default-collection-location.spec.js
naman-bruno 3081c06964 update: modal styles (#6487)
* update modals styles

* chore: color and style improvements

* fix: tests

* fixes: tests

---------

Co-authored-by: Anoop M D <anoop.md1421@gmail.com>
2025-12-23 23:29:03 +05:30

95 lines
3.4 KiB
JavaScript

import { test, expect } from '../../../playwright';
test.describe('Default Collection Location Feature', () => {
test('Should hydrate the default location from preferences', async ({ pageWithUserData: page }) => {
// open preferences
await page.locator('.preferences-button').click();
// verify the default location is pre-filled
const defaultLocationInput = page.locator('.default-collection-location-input');
await expect(defaultLocationInput).toHaveValue('/tmp/bruno-collections');
// close the preferences
await page.getByTestId('modal-close-button').click();
// wait for 2 seconds
await page.waitForTimeout(2000);
});
test('Should save empty default location', async ({ pageWithUserData: page }) => {
// open preferences
await page.locator('.preferences-button').click();
// clear the default location field
const defaultLocationInput = page.locator('.default-collection-location-input');
await defaultLocationInput.clear();
// wait for auto-save to complete (debounce is 500ms)
await page.waitForTimeout(1000);
// close the preferences
await page.getByTestId('modal-close-button').click();
// wait for modal to close
await page.waitForTimeout(500);
});
test('Should save a valid default location', async ({ pageWithUserData: page }) => {
// open preferences
await page.locator('.preferences-button').click();
// set a default location
const defaultLocationInput = page.locator('.default-collection-location-input');
// fill the default location input
await defaultLocationInput.fill('/tmp/bruno-collections');
// wait for auto-save to complete (debounce is 500ms)
await page.waitForTimeout(1000);
// close the preferences
await page.getByTestId('modal-close-button').click();
// wait for modal to close
await page.waitForTimeout(500);
});
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();
// verify the default location is pre-filled (if location input is visible)
const collectionLocationInput = page.getByLabel('Location');
if (await collectionLocationInput.isVisible()) {
await expect(collectionLocationInput).toHaveValue('/tmp/bruno-collections');
}
// cancel the collection creation
await page.locator('.bruno-modal').getByRole('button', { name: 'Cancel' }).click();
// wait for 2 seconds
await page.waitForTimeout(2000);
});
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();
// verify the default location is pre-filled
const cloneLocationInput = page.getByLabel('Location');
if (await cloneLocationInput.isVisible()) {
await expect(cloneLocationInput).toHaveValue('/tmp/bruno-collections');
}
// cancel the clone operation
await page.locator('.bruno-modal').getByRole('button', { name: 'Cancel' }).click();
// wait for 2 seconds
await page.waitForTimeout(2000);
});
});