diff --git a/packages/grid/src/mouse-handlers/GridColumnSeparatorMouseHandler.ts b/packages/grid/src/mouse-handlers/GridColumnSeparatorMouseHandler.ts index 83b52eed29..14126cbf90 100644 --- a/packages/grid/src/mouse-handlers/GridColumnSeparatorMouseHandler.ts +++ b/packages/grid/src/mouse-handlers/GridColumnSeparatorMouseHandler.ts @@ -20,7 +20,7 @@ class GridColumnSeparatorMouseHandler extends GridSeparatorMouseHandler { return null; } - const { x, y, columnHeaderDepth } = gridPoint; + const { x, y, columnHeaderDepth: depth } = gridPoint; const { modelColumns } = metrics; @@ -31,18 +31,13 @@ class GridColumnSeparatorMouseHandler extends GridSeparatorMouseHandler { theme ); - // TODO #695: Allow resizing of column groups as well. Right now just allow resizing from base columns - if ( - separatorIndex == null || - columnHeaderDepth == null || - columnHeaderDepth > 0 - ) { + if (separatorIndex == null || depth == null) { return null; } const columnIndex = modelColumns.get(separatorIndex); if (columnIndex != null) { - return { index: separatorIndex, depth: 0 }; + return { index: separatorIndex, depth }; } return null; diff --git a/tests/table.spec.ts b/tests/table.spec.ts index 2b71907d90..0f20df0ca9 100644 --- a/tests/table.spec.ts +++ b/tests/table.spec.ts @@ -4,6 +4,7 @@ import { openTable, getColumnSeparatorPosition, dragColumnSeparator, + markerAtCoordinates, } from './utils'; async function waitForLoadingDone(page: Page) { @@ -272,3 +273,48 @@ test.describe('column separators', () => { ); }); }); + +test.describe('column group separators', () => { + test.beforeEach(async ({ page }) => { + await gotoPage(page, ''); + // Open table with column groups for group separator testing + await openTable(page, 'simple_table_header_group'); + }); + + test('change color on hover on level 0', async ({ page }) => { + // Test hover on the parent of the column "X" (column 0, depth 1) + const separatorPos = await getColumnSeparatorPosition(page, 0, 1); + + // Move mouse to separator position to test hover interaction + await page.mouse.move(separatorPos.x, separatorPos.y); + await markerAtCoordinates(page, separatorPos.x, separatorPos.y); + await page.waitForTimeout(100); + + // Take a screenshot to verify hover state + await expect(page.locator('.iris-grid-panel .iris-grid')).toHaveScreenshot( + 'column-group-separator-hover.png' + ); + }); + + test('resize column group on mouse drag', async ({ page }) => { + // Perform drag operation to resize "All" group (last column = 2, depth = 0) + await dragColumnSeparator(page, 2, 50, 0); + await page.waitForTimeout(200); + + // Take screenshot to verify visual changes + await expect(page.locator('.iris-grid-panel .iris-grid')).toHaveScreenshot( + 'column-group-resized-after-drag.png' + ); + }); + + test('resize nested column groups at depth 1', async ({ page }) => { + // Perform resize of "YandZ" group (last column = 2, depth = 1) + await dragColumnSeparator(page, 2, -20, 1); + await page.waitForTimeout(200); + + // Take screenshot to verify depth 1 resize + await expect(page.locator('.iris-grid-panel .iris-grid')).toHaveScreenshot( + 'nested-group-separator-depth-1-resized.png' + ); + }); +}); diff --git a/tests/table.spec.ts-snapshots/column-group-resized-after-drag-chromium-linux.png b/tests/table.spec.ts-snapshots/column-group-resized-after-drag-chromium-linux.png new file mode 100644 index 0000000000..7c2909a26e Binary files /dev/null and b/tests/table.spec.ts-snapshots/column-group-resized-after-drag-chromium-linux.png differ diff --git a/tests/table.spec.ts-snapshots/column-group-resized-after-drag-firefox-linux.png b/tests/table.spec.ts-snapshots/column-group-resized-after-drag-firefox-linux.png new file mode 100644 index 0000000000..0f797dc858 Binary files /dev/null and b/tests/table.spec.ts-snapshots/column-group-resized-after-drag-firefox-linux.png differ diff --git a/tests/table.spec.ts-snapshots/column-group-resized-after-drag-webkit-linux.png b/tests/table.spec.ts-snapshots/column-group-resized-after-drag-webkit-linux.png new file mode 100644 index 0000000000..00c5199d98 Binary files /dev/null and b/tests/table.spec.ts-snapshots/column-group-resized-after-drag-webkit-linux.png differ diff --git a/tests/table.spec.ts-snapshots/column-group-separator-hover-chromium-linux.png b/tests/table.spec.ts-snapshots/column-group-separator-hover-chromium-linux.png new file mode 100644 index 0000000000..399e8b178a Binary files /dev/null and b/tests/table.spec.ts-snapshots/column-group-separator-hover-chromium-linux.png differ diff --git a/tests/table.spec.ts-snapshots/column-group-separator-hover-firefox-linux.png b/tests/table.spec.ts-snapshots/column-group-separator-hover-firefox-linux.png new file mode 100644 index 0000000000..a0627af401 Binary files /dev/null and b/tests/table.spec.ts-snapshots/column-group-separator-hover-firefox-linux.png differ diff --git a/tests/table.spec.ts-snapshots/column-group-separator-hover-webkit-linux.png b/tests/table.spec.ts-snapshots/column-group-separator-hover-webkit-linux.png new file mode 100644 index 0000000000..71567613c6 Binary files /dev/null and b/tests/table.spec.ts-snapshots/column-group-separator-hover-webkit-linux.png differ diff --git a/tests/table.spec.ts-snapshots/nested-group-separator-depth-1-resized-chromium-linux.png b/tests/table.spec.ts-snapshots/nested-group-separator-depth-1-resized-chromium-linux.png new file mode 100644 index 0000000000..3924ac1a1a Binary files /dev/null and b/tests/table.spec.ts-snapshots/nested-group-separator-depth-1-resized-chromium-linux.png differ diff --git a/tests/table.spec.ts-snapshots/nested-group-separator-depth-1-resized-firefox-linux.png b/tests/table.spec.ts-snapshots/nested-group-separator-depth-1-resized-firefox-linux.png new file mode 100644 index 0000000000..8791c0f9b6 Binary files /dev/null and b/tests/table.spec.ts-snapshots/nested-group-separator-depth-1-resized-firefox-linux.png differ diff --git a/tests/table.spec.ts-snapshots/nested-group-separator-depth-1-resized-webkit-linux.png b/tests/table.spec.ts-snapshots/nested-group-separator-depth-1-resized-webkit-linux.png new file mode 100644 index 0000000000..80fa139d58 Binary files /dev/null and b/tests/table.spec.ts-snapshots/nested-group-separator-depth-1-resized-webkit-linux.png differ diff --git a/tests/utils.ts b/tests/utils.ts index a33287705b..4def47b035 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -466,6 +466,40 @@ export async function dragColumnSeparator( await page.waitForTimeout(100); } +/** + * Creating a visible element at the specified coordinates. + * Useful for debugging tests that involve mouse movement. + * @param page Test page + * @param x X coordinate + * @param y Y coordinate + * @param size Size of the marker circle + */ +export async function markerAtCoordinates( + page: Page, + x: number, + y: number, + color = 'red', + size = 4 +): Promise { + await page.evaluate( + ({ x, y, color, size }) => { + const marker = document.createElement('div'); + Object.assign(marker.style, { + position: 'fixed', + top: `${y - size / 2}px`, + left: `${x - size / 2}px`, + pointerEvents: 'none', + backgroundColor: color, + width: `${size}px`, + height: `${size}px`, + borderRadius: '50%', + }); + document.body.appendChild(marker); + }, + { x, y, color, size } + ); +} + export default { gotoPage, generateVarName,