rusackas commented on code in PR #40818: URL: https://github.com/apache/superset/pull/40818#discussion_r3375820692
########## superset-frontend/playwright/tests/dashboard/mixed-chart-dashboard-filters.spec.ts: ########## @@ -0,0 +1,203 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Regression for #29519: a dashboard-level filter that is in scope for a Mixed + * (mixed_timeseries) chart should apply to BOTH of the chart's queries — Query + * A and Query B — not just Query A. + * + * A Mixed chart issues a single query context with two queries + * (queries[0] = A, queries[1] = B). This test creates a Mixed chart, puts it on + * a dashboard behind a native filter scoped to the chart, loads the dashboard, + * and inspects the outgoing POST /api/v1/chart/data payload to assert the filter + * is present in both queries. + * + * CI green => both queries inherit the dashboard filter (contract holds); + * merging closes #29519 and guards against regressions. + * CI red => Query B dropped the filter; the bug is live in the Mixed chart + * query-building path (plugin-chart-echarts/src/MixedTimeseries). + */ +import { testWithAssets, expect } from '../../helpers/fixtures'; +import { apiPost, apiPut } from '../../helpers/api/requests'; +import { apiPostDashboard } from '../../helpers/api/dashboard'; +import { DashboardPage } from '../../pages/DashboardPage'; + +const DATASET_NAME = 'birth_names'; +const FILTER_COLUMN = 'gender'; +const FILTER_VALUE = 'boy'; + +async function findDatasetIdByName(page: any, name: string): Promise<number> { Review Comment: Good call — there was actually already a shared `getDatasetByName` helper in `playwright/helpers/api/dataset.ts` (the same one `createTestChart` uses), so I dropped the inline `findDatasetIdByName` and reused that instead. Bonus: it kills the `page: any`. Done in 31434db. ########## superset-frontend/playwright/tests/dashboard/mixed-chart-dashboard-filters.spec.ts: ########## @@ -0,0 +1,203 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Regression for #29519: a dashboard-level filter that is in scope for a Mixed + * (mixed_timeseries) chart should apply to BOTH of the chart's queries — Query + * A and Query B — not just Query A. + * + * A Mixed chart issues a single query context with two queries + * (queries[0] = A, queries[1] = B). This test creates a Mixed chart, puts it on + * a dashboard behind a native filter scoped to the chart, loads the dashboard, + * and inspects the outgoing POST /api/v1/chart/data payload to assert the filter + * is present in both queries. + * + * CI green => both queries inherit the dashboard filter (contract holds); + * merging closes #29519 and guards against regressions. + * CI red => Query B dropped the filter; the bug is live in the Mixed chart + * query-building path (plugin-chart-echarts/src/MixedTimeseries). + */ +import { testWithAssets, expect } from '../../helpers/fixtures'; +import { apiPost, apiPut } from '../../helpers/api/requests'; +import { apiPostDashboard } from '../../helpers/api/dashboard'; +import { DashboardPage } from '../../pages/DashboardPage'; + +const DATASET_NAME = 'birth_names'; +const FILTER_COLUMN = 'gender'; +const FILTER_VALUE = 'boy'; + +async function findDatasetIdByName(page: any, name: string): Promise<number> { + const query = `(filters:!((col:table_name,opr:eq,value:'${name}')))`; + const resp = await page.request.get(`api/v1/dataset/?q=${query}`); + const body = await resp.json(); + if (!body.result?.length) { + throw new Error(`Dataset ${name} not found`); + } + return body.result[0].id; +} + +testWithAssets( + 'Mixed chart applies dashboard filter to both queries (#29519)', + async ({ page, testAssets }) => { + const datasetId = await findDatasetIdByName(page, DATASET_NAME); + + const chartParams = { Review Comment: I went back and forth on this one. I looked at how the sibling dashboard specs handle it (e.g. `clear-all-filters.spec.ts`) and they keep the per-test viz `params` inline at the point of chart creation — there is no shared fixtures location for chart params in the playwright suite, and this `chartParams` object is single-use and tightly coupled to this specific mixed_timeseries repro. Pulling it into a separate file would scatter the test's context for no reuse benefit, so I lean toward leaving it inline for locality. Happy to extract it if you feel strongly, though — leaving this thread open for you. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
