: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(sql-editor): stabilize save as stories (#125171)
Jovan Sakovic377a33afdd0c
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex f92164cdd950..5d1d268fe40b 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -10923,17 +10923,17 @@ snapshots:scenes-app-data-warehouse-sql-editor--edited-insight--light:hash: v1.k794b7964.4d82d9cdfe87cff9433e16065df0ac1c7cfbf51388d337bd24b13a04865880f6.VGun-U0ZZYvjeWi568gNuYLIHD11weOqChXy4Kp0shUscenes-app-data-warehouse-sql-editor--edited-insight-legacy-save-menu--dark:- hash: v1.k794b7964.e6974bfaaec7000e4993f9b00b3ec07c75518435f3a63abebd6eee147083ce0f.Ep9O78gdgJyVw4Uv8H0CVTfCkUpW2Px8qZRZfUXDSR0+ hash: v1.k794b7964.283d2701e0828866afe1195ca9d5316a8ec310aa921cf4764a1651bb22ddf080.4kqn_ty62FPSA3EzcoKqmOJuOlcC7iQ4m01pm9MFgGwscenes-app-data-warehouse-sql-editor--edited-insight-legacy-save-menu--light:- hash: v1.k794b7964.5f5955cf8adfb190dfd69dcb45539774ca034f10f2d9c842bbddd7ae47513a1a._AImCwGFDraUyz-iLlG53aXfViHCjR2OntqV9pkjj5U+ hash: v1.k794b7964.9727727afc6c13ae2772ef78be62a9c486bfea84e38b25432ad5e24ea64c16cb.jqum7eQzUBe0zMfbQQ98c2OV8KMVeG1Eocz6h868Yn8scenes-app-data-warehouse-sql-editor--edited-insight-legacy-save-menu-quill--dark:hash: v1.k794b7964.92cd356343020b382840007a73499c68ec5117d843f5ad2f0481dfcee0a8a914.aOMfXD77ciS9e-KvOoBgI2pE5tze1sgj6Wa5W5CfcL0scenes-app-data-warehouse-sql-editor--edited-insight-legacy-save-menu-quill--light:hash: v1.k794b7964.eab8a94bb1a2ac2b979c271af97e818d52ca4005777fb2ecdb985e02840ca062.Is5PNt7xU2JKVOKWYBIAJl1bAEYJ3hGGKUSsKx0djI4scenes-app-data-warehouse-sql-editor--edited-insight-save-as-flow--dark:- hash: v1.k794b7964.ecf3ef6892eecb09a1a8d96e8662adf9cb21af9cc2b505918a8807ca9c3cb7a0.TptjO98cT9OL4B1t96GQyB7BceyBaC8ivMg6KTcykkc+ hash: v1.k794b7964.330a40979d8c3347c1761f4bbf2a18d703783019c8696bfaa19e54e547ae8851.7SSyMsA6xW47IhKWDtuxRkiV0ttmLd7qRuqemioUlr4scenes-app-data-warehouse-sql-editor--edited-insight-save-as-flow--light:- hash: v1.k794b7964.70913d3b128c5f2c1e2ba68fb22df44ed41d2e271ac025e2375e0b80f87b7107.cnAXfM2tAQ6GU6MpfwDeIi5rVrpzAUeTUCjHqMNqa94+ hash: v1.k794b7964.8947d947fbfc434f55108afb4dd16db13a07647c6a8793a535566dd6435303f1.nWb8OvFpjAB-yjZNSFSzSZeFl5JDwhWTZc6Ues0wTXcscenes-app-data-warehouse-sql-editor--edited-insight-save-as-flow-quill--dark:hash: v1.k794b7964.5e4b885ff8e3d06362c87620665f206e15ab38d1598b01b856dd24d0b60d5ecb.RfnAoKVmvRo-65Z_iBI63kbxS9JP_Xi4O6i9meOy5q0scenes-app-data-warehouse-sql-editor--edited-insight-save-as-flow-quill--light:diff --git a/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx b/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsxindex b2e19306034e..9d755518bf46 100644--- a/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx+++ b/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx@@ -245,7 +245,7 @@ const meta: Meta = {// is pressed locally — see its comment.)pageUrl: urls.sqlEditor({ query: SAMPLE_SQL }),testOptions: {- waitForSelector: '.monaco-editor',+ waitForSelector: '.CodeEditor[data-editor-ready="true"]',viewport: { width: 1600, height: 900 },},},@@ -255,21 +255,26 @@ export default metatype Story = StoryObj<{}>export const TopToolsPerServer: Story = {}-// Leaves the save menu open so the snapshot shows the chooser.-// The scene re-renders the toolbar while it loads, which can drop an early click, so this retries until the menu stays open.+const waitForEditor = async (canvasElement: HTMLElement): Promise<void> => {+ await waitFor(() => expect(canvasElement.querySelector('.CodeEditor[data-editor-ready="true"]')).toBeVisible(), {+ timeout: 30000,+ })+}++// Keep the app shell at viewport height so snapshot capture does not resize and remount Monaco.+const pinEditorViewport = (): (() => void) => {+ document.body.classList.add('storybook-viewport-layout')+ return () => document.body.classList.remove('storybook-viewport-layout')+}++// Monaco takes focus when it mounts, so open the menu only after the editor is ready.const openSaveMenu: Story['play'] = async ({ canvasElement }) => {+ await waitForEditor(canvasElement)const body = within(canvasElement.ownerDocument.body)- await waitFor(- async () => {- if (!body.queryByText('Save query as')) {- const trigger = canvasElement.querySelector<HTMLElement>('[data-attr="sql-editor-save-options-button"]')- expect(trigger).toBeTruthy()- await userEvent.click(trigger!)- }- expect(body.getByText('Save query as')).toBeVisible()- },- { timeout: 30000, interval: 1000 }- )+ const trigger = canvasElement.querySelector<HTMLElement>('[data-attr="sql-editor-save-options-button"]')+ expect(trigger).toBeTruthy()+ await userEvent.click(trigger!)+ await waitFor(() => expect(body.getByText('Save query as')).toBeVisible())}// Waits for the insight to load and show its unsaved edit before it opens the save menu.@@ -283,6 +288,7 @@ const openEditedInsightSaveMenu: Story['play'] = async (context) => {}export const SaveAsFlowQuill: Story = {+ beforeEach: pinEditorViewport,parameters: {featureFlags: [FEATURE_FLAGS.SQL_EDITOR_SAVE_AS_CHOOSER, FEATURE_FLAGS.TODAY_RAIL_NAV],msw: {@@ -493,6 +499,7 @@ export const EditedInsight: Story = {msw: { mocks: discardMocks },},play: async ({ canvasElement }) => {+ await waitForEditor(canvasElement)const canvas = within(canvasElement)await canvas.findByRole('button', { name: 'Discard changes' }, { timeout: 15000 })await waitFor(() =>@@ -530,6 +537,7 @@ export const EditedInsight: Story = {}export const EditedInsightSaveAsFlow: Story = {+ beforeEach: pinEditorViewport,parameters: {featureFlags: [FEATURE_FLAGS.SQL_EDITOR_SAVE_AS_CHOOSER],pageUrl: `${urls.sqlEditor({ insightShortId: DISCARD_INSIGHT.short_id })}#q=SELECT%202`,@@ -539,6 +547,7 @@ export const EditedInsightSaveAsFlow: Story = {}export const EditedInsightSaveAsFlowQuill: Story = {+ beforeEach: pinEditorViewport,parameters: {featureFlags: [FEATURE_FLAGS.SQL_EDITOR_SAVE_AS_CHOOSER, FEATURE_FLAGS.TODAY_RAIL_NAV],pageUrl: `${urls.sqlEditor({ insightShortId: DISCARD_INSIGHT.short_id })}#q=SELECT%202`,@@ -548,12 +557,14 @@ export const EditedInsightSaveAsFlowQuill: Story = {}export const EditedInsightLegacySaveMenu: Story = {+ beforeEach: pinEditorViewport,parameters: {featureFlags: { [FEATURE_FLAGS.SQL_EDITOR_SAVE_AS_CHOOSER]: false },pageUrl: `${urls.sqlEditor({ insightShortId: DISCARD_INSIGHT.short_id })}#q=SELECT%202`,msw: { mocks: discardMocks },},play: async ({ canvasElement }) => {+ await waitForEditor(canvasElement)const canvas = within(canvasElement)await canvas.findByRole('button', { name: 'Discard changes' }, { timeout: 15000 })await userEvent.click(canvasElement.querySelector('[data-attr="sql-editor-save-options-button"]')!)