codeant-ai-for-open-source[bot] commented on code in PR #41550:
URL: https://github.com/apache/superset/pull/41550#discussion_r3691510636


##########
superset-frontend/playwright/tests/recently-archived/recently-archived.spec.ts:
##########
@@ -0,0 +1,223 @@
+/**
+ * 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.
+ */
+
+/**
+ * End-to-end coverage for the Archive (Recently-Archived) view.
+ *
+ * Requires the running instance to have the SOFT_DELETE feature flag enabled.
+ * The flag is off by default everywhere — including the docker dev stack — so
+ * these specs skip unless the instance opts in; in CI that is the dedicated
+ * "Soft-delete Tests" step in superset-e2e.yml, which boots its server with
+ * SUPERSET_FEATURE_SOFT_DELETE=true. Each test creates a disposable object via
+ * the authenticated REST API, soft-deletes it, then drives the real UI to
+ * restore it and asserts — via the API — that it is live again.
+ */
+import { test, expect, Page } from '@playwright/test';
+import { apiGet, apiPost } from '../../helpers/api/requests';
+import { extractIdFromResponse } from '../../helpers/api/assertions';
+import {
+  apiPostChart,
+  apiGetChart,
+  apiDeleteChart,
+} from '../../helpers/api/chart';
+import {
+  apiPostDashboard,
+  apiGetDashboard,
+  apiDeleteDashboard,
+} from '../../helpers/api/dashboard';
+import {
+  createTestVirtualDataset,
+  apiGetDataset,
+  apiDeleteDataset,
+} from '../../helpers/api/dataset';
+import { skipUnlessFeatureEnabled } from '../../helpers/featureFlags';
+
+test.beforeEach(async ({ page }) => {
+  await skipUnlessFeatureEnabled(page, 'SOFT_DELETE');
+});
+
+interface TypeConfig {
+  key: string;
+  label: string;
+  create: (page: Page, name: string) => Promise<number>;
+  softDelete: (page: Page, id: number) => Promise<{ ok: () => boolean }>;
+  status: (page: Page, id: number) => Promise<number>;
+}
+
+async function anyDatasetId(page: Page): Promise<number> {
+  const res = await apiGet(page, 'api/v1/dataset/?q=(page_size:1)');
+  const body = await res.json();
+  return body.result[0].id;
+}
+
+const TYPES: TypeConfig[] = [
+  {
+    key: 'dashboard',
+    label: 'Dashboard',
+    create: async (page, name) =>
+      extractIdFromResponse(
+        await apiPostDashboard(page, { dashboard_title: name }),
+      ),
+    softDelete: (page, id) => apiDeleteDashboard(page, id),
+    status: async (page, id) => (await apiGetDashboard(page, id)).status(),
+  },
+  {
+    key: 'chart',
+    label: 'Chart',
+    create: async (page, name) => {
+      const datasourceId = await anyDatasetId(page);
+      const res = await apiPostChart(page, {
+        slice_name: name,
+        datasource_id: datasourceId,
+        datasource_type: 'table',
+        viz_type: 'table',
+      });
+      return extractIdFromResponse(res);
+    },
+    softDelete: (page, id) => apiDeleteChart(page, id),
+    status: async (page, id) => (await apiGetChart(page, id)).status(),
+  },
+  {
+    key: 'dataset',
+    label: 'Dataset',
+    create: async (page, name) => {
+      const id = await createTestVirtualDataset(page, name);
+      if (!id) throw new Error('failed to create virtual dataset');
+      return id;
+    },
+    softDelete: (page, id) => apiDeleteDataset(page, id),
+    status: async (page, id) => (await apiGetDataset(page, id)).status(),
+  },
+];
+
+async function openArchive(page: Page, typeLabel: string, name: string) {
+  await page.goto('archived/');
+  await expect(page.getByTestId('archived-list-view')).toBeVisible();
+  // Select the object type, then narrow to the unique name. The antd Select's
+  // value chip overlays the combobox input, so force the click to open it, 
then
+  // pick the option from the portal listbox.
+  await page.getByRole('combobox', { name: 'Type' }).click({ force: true });
+  await page.getByRole('option', { name: typeLabel, exact: true }).click();
+  const search = page.getByPlaceholder(/type a value/i);
+  await search.click();
+  await search.fill(name);
+  await search.press('Enter');
+}
+
+for (const cfg of TYPES) {
+  test(`restores a soft-deleted ${cfg.key} from the archive`, async ({
+    page,
+  }) => {
+    const name = `e2e_archive_${cfg.key}_${Date.now()}`;
+    const id = await cfg.create(page, name);
+    expect(id, 'created id').toBeTruthy();
+
+    const del = await cfg.softDelete(page, id);
+    expect(del.ok(), 'soft-delete should succeed').toBeTruthy();
+
+    await openArchive(page, cfg.label, name);
+
+    // The archived row is listed; restore it (scope to the named row so any
+    // unrelated archived residue on the instance can't make the action 
ambiguous).
+    const row = page.getByRole('row').filter({ hasText: name });
+    await expect(row).toBeVisible();
+    await row.getByTestId('archived-row-restore').click();
+
+    // Success toast, and the object is live again per the API.
+    await expect(
+      page.getByText(`${name} restored successfully`, { exact: false }),
+    ).toBeVisible({ timeout: 15000 });
+    await expect.poll(() => cfg.status(page, id)).toBe(200);
+
+    // Cleanup: re-archive so it leaves the normal lists.
+    await cfg.softDelete(page, id);

Review Comment:
   **Suggestion:** Each test creates and archives a dashboard, chart, or 
dataset, but cleanup is performed only after all assertions succeed. Any failed 
API call, UI assertion, timeout, or test interruption leaves the soft-deleted 
fixture behind, and the shared CI instance can accumulate archived objects that 
affect later archive-list tests and retention behavior. Register the created 
IDs and perform cleanup in a test-level `finally` or `afterEach` regardless of 
failure. [missing cleanup]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Failed Playwright tests leave archived fixtures behind.
   - ⚠️ Shared archive listings accumulate unrelated test rows.
   - ⚠️ Retention tests can count stale soft-deleted fixtures.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=75b8f07703cc494b84dd3a6b316aba26&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=75b8f07703cc494b84dd3a6b316aba26&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/tests/recently-archived/recently-archived.spec.ts
   **Line:** 148:149
   **Comment:**
        *Missing Cleanup: Each test creates and archives a dashboard, chart, or 
dataset, but cleanup is performed only after all assertions succeed. Any failed 
API call, UI assertion, timeout, or test interruption leaves the soft-deleted 
fixture behind, and the shared CI instance can accumulate archived objects that 
affect later archive-list tests and retention behavior. Register the created 
IDs and perform cleanup in a test-level `finally` or `afterEach` regardless of 
failure.
   
   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%2F41550&comment_hash=d4880ab8a0d30eff3d02a2e9c590135f402f3e482eb39c359aed3996fe3815ec&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41550&comment_hash=d4880ab8a0d30eff3d02a2e9c590135f402f3e482eb39c359aed3996fe3815ec&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]

Reply via email to