Files
bruno/tests/request/save/save.spec.ts
Abhishek S Lal 849465d62a Feat/v3 UI updates (#6618)
* style: enhance button layout and input styles across multiple components for improved UI consistency

* style: update RequestsNotLoaded component with new warning styles and enhance theme color definitions for status indicators

* refactor: update theme usage across components for consistency

- Changed color references from theme.brand to theme.primary.text in various StyledWrapper components.
- Added hover effects to enhance UI interactivity in CollectionSettings and FolderSettings.
- Removed unnecessary margin and padding adjustments in several components for cleaner layout.
- Improved accessibility by ensuring aria attributes are correctly set in MenuDropdown.
- Standardized styling for method indicators in RequestPane components.

These changes aim to create a more cohesive look and feel across the application while adhering to the updated theme guidelines.

* refactor: clean up method selector styling in NewRequest component

* chore: temp playwright test fixes

* refactor: update modal sizes across various components for consistency

- Changed modal size from "sm" to "md" in RenameWorkspace, CreateApiSpec, CloneCollection, DeleteCollectionItem, and RenameCollection components.
- Improved styling in HttpMethodSelector by adding padding for better layout.
- Updated theme color references in multiple theme files to use a new palette structure for consistency and maintainability.

* refactor: enhance styling and theme integration in TimelineItem components

- Updated HttpMethodSelector to clarify padding calculation in comments.
- Integrated theme colors for OAuth2 indicator and timestamp in TimelineItem for better visual consistency.
- Adjusted Method component to use uppercase styling for method display.
- Modified RelativeTime component to apply muted text color for improved readability.
- Updated INFO color in dark and light themes for better contrast and accessibility.

* refactor: remove duplicate import statements in theme files

- Cleaned up import statements in vscode.js and light-pastel.js by removing redundant lines for improved code clarity and maintainability.

* refactor: improve styling and theme integration in various components

- Added accent color and cursor style for checkbox inputs in Modal's StyledWrapper.
- Updated border-radius values in HttpMethodSelector and NewRequest StyledWrapper components to use theme variables for consistency.
- Introduced a new textbox class in NewRequest StyledWrapper for better styling control.
- Changed modal size from "sm" to "md" in CreateEnvironment for improved layout.

---------

Co-authored-by: Bijin A B <bijin@usebruno.com>
2026-01-02 16:48:47 +05:30

66 lines
2.8 KiB
TypeScript

import { test, expect, Locator, Page } from '../../../playwright';
import { closeAllCollections, createCollection } from '../../utils/page';
import { buildCommonLocators } from '../../utils/page/locators';
import { waitForPredicate } from '../../utils/wait';
const isRequestSaved = async (saveButton: Locator) => {
// Saved state uses the className cursor-default; unsaved uses cursor-pointer.
return await saveButton.locator('svg').evaluate((node) => (node as HTMLElement).classList.contains('cursor-default'));
};
const setup = async (page: Page, createTmpDir: (tag?: string | undefined) => Promise<string>) => {
await createCollection(page, 'source-collection', await createTmpDir('source-collection'));
const sourceCollection = page.locator('.collection-name').filter({ hasText: 'source-collection' });
await sourceCollection.hover();
await sourceCollection.locator('.collection-actions .icon').click();
await page.locator('.dropdown-item').filter({ hasText: 'New Request' }).click();
await page.getByPlaceholder('Request Name').fill('test-request');
await page.locator('#new-request-url .CodeMirror').click();
await page.locator('textarea').fill('https://echo.usebruno.com');
await page.getByRole('button', { name: 'Create' }).click();
await expect(page.locator('.collection-item-name').filter({ hasText: 'test-request' })).toBeVisible();
};
test.describe.serial('save requests', () => {
test.beforeAll(async ({ page }) => {
await closeAllCollections(page);
});
test('saves new http request', async ({ page, createTmpDir }) => {
// prep the collection by creating a new collection and a new http request
await setup(page, createTmpDir);
const locators = buildCommonLocators(page);
const originalUrl = 'https://echo.usebruno.com';
const replacementUrl = 'ws://localhost:8082';
const clearText = async (text: string) => {
for (let i = text.length; i > 0; i--) {
await page.keyboard.press('Backspace');
}
};
// Open the request tab
await page.locator('.collection-item-name').filter({ hasText: 'test-request' }).dblclick();
await expect(page.locator('.request-tab .tab-label').filter({ hasText: 'test-request' })).toBeVisible();
// remove the original url from the request
await page.locator('.input-container').filter({ hasText: originalUrl }).first().click();
await clearText(originalUrl);
// replace it with an arbitrary url
await page.keyboard.insertText(replacementUrl);
// check if the request is now unsaved
await expect(await isRequestSaved(locators.saveButton())).toBe(false);
// trigger a save
locators.saveButton().click();
// Wait for it to be saved
const result = await waitForPredicate(() => isRequestSaved(locators.saveButton()));
await expect(result).toBe(true);
});
});