rusackas commented on code in PR #42328:
URL: https://github.com/apache/superset/pull/42328#discussion_r3650048320


##########
superset-frontend/playwright/tests/tools/capture-viz-thumbnails.spec.ts:
##########
@@ -0,0 +1,309 @@
+/**
+ * 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.
+ */
+/**
+ * Crawls every dashboard on the target instance and refreshes viz-picker
+ * gallery thumbnails from live example charts.
+ *
+ * This is a maintenance tool, not a test: charts are DISCOVERED via the
+ * API (dashboards -> charts), so it keeps working as example dashboards
+ * evolve. For each viz type found, one representative chart is rendered
+ * standalone at 512x512 and the plugin's `thumbnail.png` is overwritten.
+ * The only static piece is the viz type -> image path map below, which
+ * changes when plugins are added or moved — never when examples change.
+ * Viz types found on dashboards but missing from the map are reported at
+ * the end without failing the run.
+ *
+ * It only runs when CAPTURE_THUMBNAILS=1 is set, so the regular
+ * Playwright suites never execute it.
+ *
+ * Usage (requires a running Superset with examples loaded):
+ *   npm run playwright:thumbnails
+ *   VIZ_TYPES=bullet,rose npm run playwright:thumbnails   # subset
+ *
+ * Notes:
+ * - Only light-theme images are captured; `thumbnail-dark.png` variants
+ *   are left untouched.
+ * - New gallery images (e.g. the Line percent-change example) still need
+ *   to be registered in the plugin's metadata before they render in the
+ *   gallery; the capture logs a reminder for any non-thumbnail output.
+ */
+import * as fs from 'fs';
+import * as path from 'path';
+import { test, expect, Page } from '@playwright/test';
+
+const THUMBNAIL_SIZE = 512;
+const RENDERED_CHART_SELECTOR =
+  '[data-test="chart-container"]:has(svg, canvas, 
table):not(:has([data-test="loading-indicator"]))';

Review Comment:
   `ag-grid-table` is already in `TEXT_ONLY_VIZ_TYPES`, which routes it to 
`TEXT_RENDERED_CHART_SELECTOR` (no svg/canvas/table requirement) plus a longer 
settle — see the `textOnly` branch at capture-viz-thumbnails.spec.ts:313-317. 
Selector's not too restrictive for this case.



-- 
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]

Reply via email to