@@ -259,5 +259,81 @@ test.describe('Search', { tag: '@search' }, () => {
259259 expect ( rowCount ) . toBeGreaterThan ( 0 ) ;
260260 } ) ;
261261 } ) ;
262+
263+ test ( 'Histogram drag-to-zoom preserves custom SELECT columns' , async ( {
264+ page,
265+ } ) => {
266+ const CUSTOM_SELECT = 'Timestamp, ServiceName, Body as message, SeverityText' ;
267+
268+ await test . step ( 'Perform initial search' , async ( ) => {
269+ await expect ( page . locator ( '[data-testid="search-form"]' ) ) . toBeVisible ( ) ;
270+ await page . locator ( '[data-testid="search-submit-button"]' ) . click ( ) ;
271+ await page . waitForLoadState ( 'networkidle' ) ;
272+ } ) ;
273+
274+ await test . step ( 'Setup custom SELECT columns' , async ( ) => {
275+ // The SELECT field is the first CodeMirror editor (index 0)
276+ const selectEditor = page . locator ( '.cm-content' ) . first ( ) ;
277+ await expect ( selectEditor ) . toBeVisible ( ) ;
278+
279+ // Select all and replace with custom columns
280+ await selectEditor . click ( { clickCount : 3 } ) ;
281+ await page . keyboard . type ( CUSTOM_SELECT ) ;
282+ } ) ;
283+
284+ await test . step ( 'Search with custom columns and wait for histogram' , async ( ) => {
285+ await page . locator ( '[data-testid="search-submit-button"]' ) . click ( ) ;
286+ await page . waitForLoadState ( 'networkidle' ) ;
287+
288+ // Wait for histogram to render with data
289+ await expect (
290+ page . locator ( '.recharts-responsive-container' ) . first ( )
291+ ) . toBeVisible ( ) ;
292+ } ) ;
293+
294+ await test . step ( 'Drag on histogram to select time range' , async ( ) => {
295+ const chartSurface = page . locator ( '.recharts-surface' ) . first ( ) ;
296+ await expect ( chartSurface ) . toBeVisible ( ) ;
297+
298+ const box = await chartSurface . boundingBox ( ) ;
299+ expect ( box ) . toBeTruthy ( ) ;
300+
301+ // Drag from 25% to 75% of chart width to zoom into a time range
302+ const startX = box ! . x + box ! . width * 0.25 ;
303+ const endX = box ! . x + box ! . width * 0.75 ;
304+ const y = box ! . y + box ! . height / 2 ;
305+
306+ await page . mouse . move ( startX , y ) ;
307+ await page . mouse . down ( ) ;
308+ await page . mouse . move ( endX , y , { steps : 10 } ) ;
309+ await page . mouse . up ( ) ;
310+
311+ // Wait for the zoom operation to complete
312+ await page . waitForLoadState ( 'networkidle' ) ;
313+ } ) ;
314+
315+ await test . step ( 'Verify custom SELECT columns are preserved' , async ( ) => {
316+ // Check URL parameters
317+ const url = page . url ( ) ;
318+ expect ( url , 'URL should contain select parameter' ) . toContain ( 'select=' ) ;
319+ expect ( url , 'URL should contain alias "message"' ) . toContain ( 'message' ) ;
320+
321+ // Verify SELECT editor content
322+ const selectEditor = page . locator ( '.cm-content' ) . first ( ) ;
323+ await expect ( selectEditor ) . toBeVisible ( ) ;
324+ const selectValue = await selectEditor . textContent ( ) ;
325+
326+ expect ( selectValue , 'SELECT should contain alias' ) . toContain ( 'Body as message' ) ;
327+ expect ( selectValue , 'SELECT should contain SeverityText' ) . toContain ( 'SeverityText' ) ;
328+ } ) ;
329+
330+ await test . step ( 'Verify search results are still displayed' , async ( ) => {
331+ const searchResultsTable = page . locator ( '[data-testid="search-results-table"]' ) ;
332+ await expect ( searchResultsTable , 'Search results table should be visible' ) . toBeVisible ( ) ;
333+
334+ const rowCount = await searchResultsTable . locator ( 'tr' ) . count ( ) ;
335+ expect ( rowCount , 'Should have search results' ) . toBeGreaterThan ( 0 ) ;
336+ } ) ;
337+ } ) ;
262338 } ) ;
263339} ) ;
0 commit comments