codeant-ai-for-open-source[bot] commented on code in PR #38165:
URL: https://github.com/apache/superset/pull/38165#discussion_r3471103470
##########
superset-frontend/playwright/pages/ExplorePage.ts:
##########
@@ -106,4 +113,53 @@ export class ExplorePage {
getVizSwitcher(): Locator {
return this.page.locator(ExplorePage.SELECTORS.VIZ_SWITCHER);
}
+
+ /**
+ * Expands the bottom data panel if it is currently collapsed.
+ * Safe to call when already expanded (no-op).
+ */
+ async expandDataPanel(): Promise<void> {
+ const expandButton = this.page.locator(
+ ExplorePage.SELECTORS.EXPAND_DATA_PANEL,
+ );
+ if (await expandButton.isVisible().catch(() => false)) {
+ await expandButton.click();
+ }
+ }
+
+ /**
+ * Opens the bottom data panel (if needed) and activates the "Results" tab.
+ */
+ async openResultsTab(): Promise<void> {
+ await this.expandDataPanel();
+ const resultsTab = this.page
+ .locator(ExplorePage.SELECTORS.SOUTH_PANE)
+ .locator(ExplorePage.SELECTORS.RESULTS_TAB);
+ await resultsTab.click();
+ }
Review Comment:
**Suggestion:** `openResultsTab()` always clicks the Results tab even when
it is already active. In `DataTablesPane`, clicking the active tab collapses
the panel, so this helper can close the data panel instead of opening it
(especially right after expanding a collapsed panel where Results is already
selected by default). Guard the click so it only runs when Results is not
already active. [logic error]
<details>
<summary><b>Severity Level:</b> Critical 🚨</summary>
```mdx
- ❌ Results tab Playwright test collapses panel instead of opening.
- ⚠️ Flaky or failing end-to-end coverage for Results reuse.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Run the Playwright spec
`superset-frontend/playwright/tests/experimental/explore/results-tab-reuse.spec.ts`,
which
constructs an `ExplorePage` and navigates to Explore (`ExplorePage.goto()`
at lines 13–18
of the snippet, using `ExplorePage` from
`superset-frontend/playwright/pages/ExplorePage.ts`).
2. Observe that `results-tab-reuse.spec.ts` calls `await
explorePage.openResultsTab();`
(lines 26–28 of the snippet), which in turn invokes
`ExplorePage.openResultsTab()` at
`superset-frontend/playwright/pages/ExplorePage.ts:133-139`.
3. When `openResultsTab()` runs, it first calls `expandDataPanel()`, which
clicks the
caret button with `aria-label="Expand data panel"` if visible
(`DataTablesPane` renders
this caret in `CollapseButton` with that aria-label at
`superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.tsx:161-185`),
causing `handleCollapseChange(true)` to set `panelOpen` to `true`
(`DataTablesPane.tsx:140-145`).
4. Immediately after expansion, `openResultsTab()` unconditionally clicks
the Results tab
(`[data-node-key="results"]`), which triggers `Tabs` `onTabClick` ->
`handleTabClick` in
`DataTablesPane.tsx:148-158`; since `panelOpen` is `true` and `activeTabKey`
is already
`ResultTypes.Results` (`useState` default at `DataTablesPane.tsx:92`), the
branch `else if
(tabKey === activeTabKey)` executes, calling `handleCollapseChange(false)`
and collapsing
the panel, so the AG Grid inside the Results pane is hidden and
`AgGrid.waitForRows()`
(which waits for visible rows in
`superset-frontend/playwright/components/core/AgGrid.ts:50-55`) can time out
or fail to
find a visible grid.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=ea5b4e0826444e0196a70fc45be07ea7&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=ea5b4e0826444e0196a70fc45be07ea7&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/playwright/pages/ExplorePage.ts
**Line:** 133:139
**Comment:**
*Logic Error: `openResultsTab()` always clicks the Results tab even
when it is already active. In `DataTablesPane`, clicking the active tab
collapses the panel, so this helper can close the data panel instead of opening
it (especially right after expanding a collapsed panel where Results is already
selected by default). Guard the click so it only runs when Results is not
already active.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38165&comment_hash=28f252d0de0899a15060901092402be9b18b3898f0ec6ffe78df5a99c7080f80&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38165&comment_hash=28f252d0de0899a15060901092402be9b18b3898f0ec6ffe78df5a99c7080f80&reaction=dislike'>👎</a>
--
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]