|
| 1 | +/** |
| 2 | + * Selecting an at-prefixed JSON key breaks row details. |
| 3 | + * |
| 4 | + * When a displayed SELECT column is a JSON subcolumn whose key is not a bare |
| 5 | + * identifier (e.g. `ResourceAttributesJSON.`@request_id``), ClickHouse reports |
| 6 | + * the result column name without backticks (`ResourceAttributesJSON.@request_id`). |
| 7 | + * The row side panel rebuilds a WHERE clause from the displayed columns to fetch |
| 8 | + * the full row; before the fix it used that bare name verbatim, producing |
| 9 | + * invalid SQL that matched no rows, so the panel came up empty. |
| 10 | + * |
| 11 | + * This drives the real UI path against a JSON-column schema: select the |
| 12 | + * at-prefixed key, open the row, and confirm the detail panel is populated with |
| 13 | + * the selected event's values. |
| 14 | + */ |
| 15 | +import { SearchPage } from '../../page-objects/SearchPage'; |
| 16 | +import { |
| 17 | + INTERESTING_FILTER_KEYS_JSON_AT_KEY, |
| 18 | + INTERESTING_FILTER_KEYS_ROWS, |
| 19 | +} from '../../seed-clickhouse'; |
| 20 | +import { expect, test } from '../../utils/base-test'; |
| 21 | +import { INTERESTING_FILTER_KEYS_SOURCE_NAME } from '../../utils/constants'; |
| 22 | + |
| 23 | +const QUERY_TIMEOUT = 20_000; |
| 24 | + |
| 25 | +const [ROW1] = INTERESTING_FILTER_KEYS_ROWS; |
| 26 | + |
| 27 | +test.describe( |
| 28 | + 'Search: at-prefixed JSON key row details', |
| 29 | + { tag: ['@search', '@full-stack'] }, |
| 30 | + () => { |
| 31 | + test('opening a row with an at-prefixed JSON key in SELECT shows the event', async ({ |
| 32 | + page, |
| 33 | + }) => { |
| 34 | + const searchPage = new SearchPage(page); |
| 35 | + await searchPage.goto(); |
| 36 | + await searchPage.selectSource(INTERESTING_FILTER_KEYS_SOURCE_NAME); |
| 37 | + await searchPage.timePicker.selectRelativeTime('Last 1 hour'); |
| 38 | + |
| 39 | + await test.step('isolate a single row', async () => { |
| 40 | + await searchPage.performSearch(`ServiceName:"${ROW1.serviceName}"`); |
| 41 | + await expect(searchPage.getTableError()).toHaveCount(0); |
| 42 | + await expect(searchPage.table.getRows()).toHaveCount(1, { |
| 43 | + timeout: QUERY_TIMEOUT, |
| 44 | + }); |
| 45 | + }); |
| 46 | + |
| 47 | + await test.step('select the at-prefixed JSON key as a column', async () => { |
| 48 | + await searchPage.setCustomSELECT( |
| 49 | + `Timestamp, ServiceName, ResourceAttributesJSON.\`${INTERESTING_FILTER_KEYS_JSON_AT_KEY}\``, |
| 50 | + ); |
| 51 | + await searchPage.submitEmptySearch(); |
| 52 | + await expect(searchPage.getTableError()).toHaveCount(0); |
| 53 | + await expect(searchPage.table.getRows()).toHaveCount(1, { |
| 54 | + timeout: QUERY_TIMEOUT, |
| 55 | + }); |
| 56 | + }); |
| 57 | + |
| 58 | + await test.step('row details load the selected event', async () => { |
| 59 | + await searchPage.table.clickFirstRow(); |
| 60 | + await expect(searchPage.sidePanel.container).toBeVisible(); |
| 61 | + // Before the fix the detail WHERE dropped the key's backticks and |
| 62 | + // matched no rows, so the panel rendered empty with no error. |
| 63 | + await expect(searchPage.sidePanel.errorState).toHaveCount(0); |
| 64 | + |
| 65 | + await searchPage.sidePanel.openColumnValues(); |
| 66 | + await expect( |
| 67 | + searchPage.sidePanel.columnValue(ROW1.jsonAtKeyValue), |
| 68 | + ).toBeVisible({ timeout: QUERY_TIMEOUT }); |
| 69 | + await expect(searchPage.sidePanel.columnValue(ROW1.body)).toBeVisible(); |
| 70 | + }); |
| 71 | + }); |
| 72 | + }, |
| 73 | +); |
0 commit comments