Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(e2e): drop delete, duplicate, sharing and terraform specs (#129696)

Georges-Antoine Assiac92aca40a8b
diff --git a/playwright/e2e/product-analytics/dashboards.spec.ts b/playwright/e2e/product-analytics/dashboards.spec.ts
index 6ed96b9e87d7..521ed5679fd6 100644
--- a/playwright/e2e/product-analytics/dashboards.spec.ts
+++ b/playwright/e2e/product-analytics/dashboards.spec.ts
@@ -238,82 +238,6 @@ test.describe('Dashboards', () => {
await expect(dashboard.variableButtons.first()).toContainText('99')
})
})
-
- test('Deleting a dashboard navigates to the dashboards list', async ({ page }) => {
- const dashboard = new DashboardPage(page)
- const dashboardName = randomString('dash-delete')
-
- await test.step('create a dashboard', async () => {
- await dashboard.createNew(dashboardName)
- await expect(page).toHaveURL(/\/dashboard\/\d+/)
- })
-
- await test.step('delete the dashboard', async () => {
- await dashboard.deleteDashboard()
- })
-
- await test.step('verify navigation to dashboards list (not "Not found")', async () => {
- await expect(page).toHaveURL(/\/dashboard(#panel=[a-z]+)?$/)
- await expect(page.getByText('Not found')).not.toBeVisible()
- // Reload so the list is rebuilt from the server, which excludes deleted
- // dashboards. The in-memory dashboardsModel can keep a stale row visible
- // (the list selector doesn't filter `deleted`, and an in-flight load can
- // re-merge it after delayedDeleteDashboard prunes it), so an unscoped or
- // even table-scoped assertion against live state is racy. Scope to the
- // table to exclude the "deleted" toast, which also contains the name.
- await page.reload()
- await expect(page.getByTestId('dashboards-table')).toBeVisible()
- await expect(page.getByTestId('dashboards-table').getByText(dashboardName)).not.toBeVisible()
- })
- })
-
- test('Deleting an insight from dashboard redirects back', async ({ page }) => {
- test.setTimeout(120_000)
- const dashboard = new DashboardPage(page)
- const insight = new InsightPage(page)
- const insightName = randomString('dash-trends')
-
- await test.step('create a saved Trends insight', async () => {
- await createSavedTrendsInsight(page, insightName, workspace!)
- })
-
- await test.step('create a dashboard with an insight', async () => {
- await dashboard.createNew()
- await dashboard.addInsightToNewDashboard(insightName)
- await expect(dashboard.insightCards).toBeVisible()
- })
-
- await test.step('open the insight from the dashboard', async () => {
- await dashboard.openFirstTileMenu()
- await dashboard.selectTileMenuOption('Edit')
- await expect(page).toHaveURL(/\/insights\/.+\/edit(?:\?|$)/)
- // Wait for the insight to fully load before interacting with the
- // side panel — InsightPanelDangerZone only renders the delete
- // button once the insight data is available in the store.
- await expect(insight.saveButton).toContainText('No changes')
- })
-
- await test.step('open the info panel and click delete', async () => {
- await insight.openInfoPanel()
- await insight.clickDeleteInsight()
- await expect(page.locator('.LemonModal').filter({ hasText: 'Delete insight?' })).toBeVisible()
- })
-
- await test.step('cancel the dialog and verify we stay on the insight', async () => {
- await insight.cancelDeleteDialog()
- await expect(page).toHaveURL(/edit/)
- })
-
- await test.step('click delete again and confirm', async () => {
- await insight.clickDeleteInsight()
- await insight.confirmDeleteDialog()
- })
-
- await test.step('verify redirect to the dashboard with no insight cards', async () => {
- await expect(page).toHaveURL(/\/dashboard\//)
- await expect(dashboard.insightCards).toHaveCount(0)
- })
- })
})
test.describe('Dashboard compact cards and inline editing', () => {
diff --git a/playwright/e2e/product-analytics/insights-list.spec.ts b/playwright/e2e/product-analytics/insights-list.spec.ts
index d84ad3e75950..f131efa3db7a 100644
--- a/playwright/e2e/product-analytics/insights-list.spec.ts
+++ b/playwright/e2e/product-analytics/insights-list.spec.ts
@@ -42,32 +42,4 @@ test.describe('Insights list', () => {
await expect(insight.topBarName).toContainText(insightName, { timeout: 15_000 })
})
})
-
- test('Can delete an insight from the list', async ({ page }) => {
- const insight = new InsightPage(page)
- const insightName = randomString('to-delete')
-
- await test.step('create an insight', async () => {
- await insight.goToNewTrends()
- await insight.trends.waitForChart()
- await insight.editName(insightName)
- await insight.save()
- })
-
- await test.step('delete the insight via row menu', async () => {
- await insight.goToList()
- await page.getByPlaceholder('Search').fill(insightName)
- await expect(page.getByText(insightName)).toBeVisible()
- await page.locator('table tbody tr').first().hover()
- await page.locator('table tbody tr').first().getByTestId('more-button').click()
- await page.getByRole('button', { name: 'Delete' }).click()
-
- const dialog = page.locator('.LemonModal').filter({ hasText: 'Delete insight?' })
- await dialog.getByRole('button', { name: 'Delete' }).click()
- })
-
- await test.step('verify the insight is removed', async () => {
- await expect(page.getByText('There are no insights matching')).toBeVisible()
- })
- })
})
diff --git a/playwright/e2e/product-analytics/insights/insight-side-panel.spec.ts b/playwright/e2e/product-analytics/insights/insight-side-panel.spec.ts
index f5875318bb7a..ce4cda39b3e8 100644
--- a/playwright/e2e/product-analytics/insights/insight-side-panel.spec.ts
+++ b/playwright/e2e/product-analytics/insights/insight-side-panel.spec.ts
@@ -1,59 +1,20 @@
-import { NodeKind } from '../../../../frontend/src/queries/schema/schema-general'
import { InsightPage } from '../../../page-models/insightPage'
import { PlaywrightWorkspaceSetupResult, expect, test } from '../../../utils/workspace-test-base'
test.describe('Insight side panel actions', () => {
let workspace: PlaywrightWorkspaceSetupResult | null = null
- let insightUrl: string
test.beforeAll(async ({ playwrightSetup }) => {
workspace = await playwrightSetup.createWorkspace({
use_current_time: true,
skip_onboarding: true,
- insights: [
- {
- name: 'Side Panel Test Insight',
- query: {
- kind: NodeKind.InsightVizNode,
- source: {
- kind: NodeKind.TrendsQuery,
- series: [{ kind: NodeKind.EventsNode, event: '$pageview' }],
- },
- },
- },
- ],
})
- const shortId = workspace!.created_insights![0].short_id
- insightUrl = `/project/${workspace!.team_id}/insights/${shortId}`
})
test.beforeEach(async ({ page, playwrightSetup }) => {
await playwrightSetup.login(page, workspace!)
})
- test('Duplicate insight from side panel', async ({ page }) => {
- const insight = new InsightPage(page)
-
- await test.step('create and save insight', async () => {
- await insight.goToNewTrends()
- await insight.trends.waitForChart()
- await insight.editName('Side Panel Duplicate Test')
- await insight.save()
- })
-
- await test.step('open side panel and click duplicate', async () => {
- await insight.openInfoPanel()
- const duplicateButton = page.getByTestId('insight-duplicate-button')
- await expect(duplicateButton).toBeVisible()
- await duplicateButton.click()
- })
-
- await test.step('navigated to new insight in edit mode with (copy) name', async () => {
- await page.waitForURL(/\/edit/)
- await expect(insight.topBarName).toContainText('Side Panel Duplicate Test (copy)')
- })
- })
-
test('View source toggle enters edit mode and shows query editor', async ({ page }) => {
const insight = new InsightPage(page)
@@ -78,50 +39,4 @@ test.describe('Insight side panel actions', () => {
await expect(page.getByTestId('query-editor')).toBeVisible()
})
})
-
- test('Open sharing modal from side panel', async ({ page }) => {
- const insight = new InsightPage(page)
-
- await test.step('navigate to seeded insight', async () => {
- await page.goto(insightUrl)
- })
-
- await test.step('click share and verify sharing modal opens', async () => {
- await insight.openInfoPanel()
- await page.getByTestId('insight-share-button').click()
- const modal = page.getByTestId('insight-sharing-modal')
- await expect(modal).toBeVisible()
- await expect(modal.getByTestId('sharing-switch')).toBeVisible()
- })
-
- await test.step('toggle sharing on and verify share link appears', async () => {
- const modal = page.getByTestId('insight-sharing-modal')
- await modal.getByTestId('sharing-switch').click()
- await expect(modal.getByTestId('sharing-link-button')).toBeVisible()
- })
- })
-
- test('Export insight as Terraform and download the file', async ({ page }) => {
- const insight = new InsightPage(page)
-
- await test.step('navigate to seeded insight', async () => {
- await page.goto(insightUrl)
- })
-
- await test.step('open terraform modal and wait for HCL to load', async () => {
- await insight.openInfoPanel()
- await page.getByTestId('insight-manage-terraform').click()
- const modal = page.getByTestId('insight-terraform-modal')
- await expect(modal).toBeVisible()
- await expect(modal.getByText('resource "posthog_')).toBeVisible({ timeout: 10_000 })
- })
-
- await test.step('click download and verify the .tf file', async () => {
- const modal = page.getByTestId('insight-terraform-modal')
- const downloadPromise = page.waitForEvent('download')
- await modal.getByRole('button', { name: /Download.*\.tf/ }).click()
- const download = await downloadPromise
- expect(download.suggestedFilename()).toMatch(/\.tf$/)
- })
- })
})
diff --git a/playwright/page-models/dashboardPage.ts b/playwright/page-models/dashboardPage.ts
index 5790d9bca510..242fef6f36ef 100644
--- a/playwright/page-models/dashboardPage.ts
+++ b/playwright/page-models/dashboardPage.ts
@@ -153,15 +153,6 @@ export class DashboardPage {
.not.toBe(sourceDashboardId)
}
- async deleteDashboard(): Promise<void> {
- await this.openInfoPanel()
- await this.page.getByRole('button', { name: 'Delete dashboard' }).click()
-
- const modal = this.page.locator('.LemonModal').filter({ hasText: 'Delete dashboard' })
- await expect(modal).toBeVisible()
- await this.page.getByTestId('dashboard-delete-submit').click()
- }
-
async setDateFilter(option: string): Promise<void> {
const dataAttr = `date-filter-${option.toLowerCase().replace(/\s+/g, '-')}`
await this.dateFilter.click()
diff --git a/playwright/page-models/insightPage.ts b/playwright/page-models/insightPage.ts
index 632d64356e3c..1dd363ad72e1 100644
--- a/playwright/page-models/insightPage.ts
+++ b/playwright/page-models/insightPage.ts
@@ -253,31 +253,6 @@ export class InsightPage {
.catch(() => undefined)
}
- async clickDeleteInsight(): Promise<void> {
- // The delete button is rendered via createPortal into scenePanelElement.
- // There are two portal targets: a hidden inline panel (Navigation.tsx,
- // display: none for insights) and the visible side panel (SidePanelInfo).
- // After opening the Info tab the portal content moves from the inline
- // panel to the side panel via useEffect. Scope the locator to #side-panel
- // so we wait for the button in the visible container, not the hidden one.
- const deleteButton = this.page.locator('#side-panel').getByTestId('insight-delete')
- await deleteButton.waitFor({ state: 'visible' })
- await deleteButton.click()
- }
-
- async confirmDeleteDialog(): Promise<void> {
- const dialog = this.page.locator('.LemonModal').filter({ hasText: 'Delete insight?' })
- await expect(dialog).toBeVisible()
- await dialog.getByRole('button', { name: 'Delete' }).click()
- }
-
- async cancelDeleteDialog(): Promise<void> {
- const dialog = this.page.locator('.LemonModal').filter({ hasText: 'Delete insight?' })
- await expect(dialog).toBeVisible()
- await dialog.getByRole('button', { name: 'Cancel' }).click()
- await expect(dialog).not.toBeVisible()
- }
-
async saveAsNew(name: string): Promise<void> {
const originalUrl = this.page.url()
await this.page.locator('[data-attr="insight-save-dropdown"]').click()
diff --git a/products/dashboards/frontend/deleteDashboardLogic.test.ts b/products/dashboards/frontend/deleteDashboardLogic.test.ts
new file mode 100644
index 000000000000..3aa91e212b8f
--- /dev/null
+++ b/products/dashboards/frontend/deleteDashboardLogic.test.ts
@@ -0,0 +1,36 @@
+import { router } from 'kea-router'
+import { expectLogic } from 'kea-test-utils'
+
+import { urls } from 'scenes/urls'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { deleteDashboardLogic } from './deleteDashboardLogic'
+
+describe('deleteDashboardLogic', () => {
+ beforeEach(() => {
+ useMocks({
+ get: {
+ '/api/environments/:team_id/dashboards/': { count: 0, results: [] },
+ },
+ patch: {
+ '/api/environments/:team_id/dashboards/:id/': { id: 7, name: 'To delete', deleted: true },
+ },
+ })
+ initKeaTests()
+ })
+
+ it('sends the user from the deleted dashboard to the dashboards list', async () => {
+ router.actions.push(urls.dashboard(7))
+ const logic = deleteDashboardLogic()
+ logic.mount()
+
+ logic.actions.showDeleteDashboardModal(7)
+ logic.actions.submitDeleteDashboard()
+
+ await expectLogic(logic).toFinishAllListeners()
+ expect(router.values.location.pathname).toMatch(new RegExp(`${urls.dashboards()}$`))
+ expect(logic.values.deleteDashboardModalVisible).toBe(false)
+ })
+})