mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
fix: folder docs edit button style (#7630)
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
import styled from 'styled-components';
|
||||
|
||||
const StyledWrapper = styled.div`
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
position: relative;
|
||||
|
||||
.editing-mode {
|
||||
cursor: pointer;
|
||||
color: ${(props) => props.theme.colors.text.yellow};
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
background: ${(props) => props.theme.bg};
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import { test, expect } from '../../../playwright';
|
||||
import { buildCommonLocators } from '../../utils/page/locators';
|
||||
import { createCollection, createFolder, closeAllCollections } from '../../utils/page/actions';
|
||||
|
||||
test.describe('Folder docs sticky edit/preview button', () => {
|
||||
test.afterEach(async ({ page }) => {
|
||||
await closeAllCollections(page);
|
||||
});
|
||||
|
||||
test('edit/preview button should remain visible when scrolling folder docs', async ({ page, createTmpDir }) => {
|
||||
const tmpDir = await createTmpDir('folder-docs-sticky');
|
||||
const locators = buildCommonLocators(page);
|
||||
|
||||
// Create collection and folder
|
||||
await createCollection(page, 'sticky-docs-test', tmpDir);
|
||||
await createFolder(page, 'test-folder', 'sticky-docs-test');
|
||||
|
||||
// Click on the folder to open folder settings
|
||||
await locators.sidebar.folder('test-folder').click();
|
||||
|
||||
// Navigate to the Docs tab
|
||||
const docsTab = locators.paneTabs.folderSettingsTab('docs');
|
||||
await docsTab.click();
|
||||
|
||||
// The editing-mode toggle should show "Edit" initially
|
||||
const editToggle = page.locator('.editing-mode');
|
||||
await expect(editToggle).toBeVisible();
|
||||
await expect(editToggle).toHaveText('Edit');
|
||||
|
||||
// Click "Edit" to enter editing mode
|
||||
await editToggle.click();
|
||||
await expect(editToggle).toHaveText('Preview');
|
||||
|
||||
// Type long content into the CodeMirror editor to make it scrollable
|
||||
const codeMirror = page.locator('.CodeMirror');
|
||||
await codeMirror.click();
|
||||
const longContent = Array.from({ length: 60 }, (_, i) => `Line ${i + 1}: Some documentation content to make this area scrollable.`).join('\n');
|
||||
await page.locator('.CodeMirror textarea').fill(longContent);
|
||||
|
||||
// Save the docs
|
||||
await page.getByRole('button', { name: 'Save' }).click();
|
||||
|
||||
// Switch to preview mode to see rendered markdown
|
||||
await editToggle.click();
|
||||
await expect(editToggle).toHaveText('Edit');
|
||||
|
||||
// Get the StyledWrapper (parent of editing-mode) which is the scroll container
|
||||
const scrollContainer = editToggle.locator('..');
|
||||
|
||||
// Scroll down within the docs container
|
||||
await scrollContainer.evaluate((el) => {
|
||||
el.scrollTop = el.scrollHeight;
|
||||
});
|
||||
|
||||
// The edit/preview toggle should still be visible due to sticky positioning
|
||||
await expect(editToggle).toBeVisible();
|
||||
await expect(editToggle).toBeInViewport();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user