@marimo-team/islands 0.25.1-dev90 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ConnectedDataExplorerComponent-KVhjDMSe.js → ConnectedDataExplorerComponent-C2d9ysUI.js} +8 -9
- package/dist/{ErrorBoundary-D7_peFI9.js → ErrorBoundary-1wHWKFoG.js} +1 -1
- package/dist/{ImageComparisonComponent-Dlm5aWnH.js → ImageComparisonComponent-Cpfz30OZ.js} +51 -52
- package/dist/{abnfDiagram-VCTEODGH-CpN0FRda.js → abnfDiagram-VCTEODGH-AFhOQTt8.js} +3 -3
- package/dist/{architectureDiagram-5GKGNRK7-DDyj5SRB.js → architectureDiagram-5GKGNRK7-BngksAAQ.js} +5 -5
- package/dist/{blockDiagram-I7D4REHJ-BbXEXJRu.js → blockDiagram-I7D4REHJ-CvBmppdy.js} +9 -9
- package/dist/{c4Diagram-7LVT6UL2-DcLsbQmR.js → c4Diagram-7LVT6UL2-EceL4_jH.js} +7 -7
- package/dist/{cells-DYIkSxs6.js → cells-Cv93oav_.js} +4124 -4151
- package/dist/{channel-B5XnTarr.js → channel-z7HZXHwv.js} +1 -1
- package/dist/{chat-ui-BXj3uYjy.js → chat-ui-fVyVOhYN.js} +47 -47
- package/dist/{chunk-4HAMMTFA-D2qv8E0X.js → chunk-4HAMMTFA-BPTTOOC5.js} +5 -5
- package/dist/{chunk-75Z2AOVW-5_HsvXwr.js → chunk-75Z2AOVW-C4AOleKf.js} +1 -1
- package/dist/{chunk-DU6HZSFF-BUgAHvnM.js → chunk-DU6HZSFF-1TwWR6gh.js} +1 -1
- package/dist/{chunk-F27PBJKO-DHmYWZXr.js → chunk-F27PBJKO-DMI1PBe4.js} +1 -1
- package/dist/{chunk-GMAD6QVW-Czynz8aA.js → chunk-GMAD6QVW-vStrMz2P.js} +3 -3
- package/dist/{chunk-GVQU2GXP-yQEdulRS.js → chunk-GVQU2GXP-2HwWgs4u.js} +2 -2
- package/dist/{chunk-IMKFNOWR-BfwTebD0.js → chunk-IMKFNOWR-UOVZuZVn.js} +5 -5
- package/dist/{chunk-L3NEJ4N5-DwRWnDDK.js → chunk-L3NEJ4N5-RhC7i0I2.js} +5 -5
- package/dist/{chunk-OSK3NFVY-BBKU_Ign.js → chunk-OSK3NFVY-CZV09N-U.js} +6 -6
- package/dist/{chunk-P2QGCYS3-C0iGU29N.js → chunk-P2QGCYS3-0TAWai9C.js} +1 -1
- package/dist/{chunk-POPQ4Y6H-BCbS3Ozc.js → chunk-POPQ4Y6H-Cc3_56GX.js} +1 -1
- package/dist/{chunk-PWAF6VOD-CTFCL0jI.js → chunk-PWAF6VOD-lNxB9k8z.js} +1 -1
- package/dist/{chunk-SHT3W25Y-BspJEJ5H.js → chunk-SHT3W25Y-CrEPyWy1.js} +7 -7
- package/dist/{chunk-SVP7TREG-DX3rFNTe.js → chunk-SVP7TREG-uIyyySp6.js} +2 -2
- package/dist/{chunk-TICWLB2K-fVF7Uujg.js → chunk-TICWLB2K-DdXM3eg6.js} +5 -5
- package/dist/classDiagram-ZZMXUADV-BiATbBE4.js +30 -0
- package/dist/classDiagram-v2-VYDZK3BY-JnH97GYw.js +30 -0
- package/dist/{code-visibility-Cv2cG11L.js → code-visibility-DMcT7AsU.js} +17 -17
- package/dist/{common-DVOYsne0.js → common-B58G5YN_.js} +6726 -6430
- package/dist/{cynefinDiagram-5FMLGOSQ-CFQrqzSX.js → cynefinDiagram-5FMLGOSQ-zknaAsGy.js} +3 -3
- package/dist/{dagre-GXQ25YYZ-xHNAUTyG.js → dagre-GXQ25YYZ-BhMOoMGJ.js} +10 -10
- package/dist/{data-grid-overlay-editor--Egdzm1k.js → data-grid-overlay-editor-DUWqrgYI.js} +1 -1
- package/dist/{diagram-S7CK7UJ4-Bt1rPbAx.js → diagram-S7CK7UJ4-V5-Z-EDY.js} +4 -4
- package/dist/{diagram-UQ7AKVKN-D1sq5FoZ.js → diagram-UQ7AKVKN-qw8AjDal.js} +3 -3
- package/dist/{diagram-VSXAHHWV-BKpmG23x.js → diagram-VSXAHHWV-CR7BJygZ.js} +2 -2
- package/dist/{diagram-VX7I27RA-BMwGFVD6.js → diagram-VX7I27RA-DfuqFb1E.js} +5 -5
- package/dist/{diagram-Z3DM3KII--KLDR9Pl.js → diagram-Z3DM3KII-DpWwlYZB.js} +3 -3
- package/dist/{dist-BaHjhkpZ.js → dist-CcyKTBTF.js} +1 -1
- package/dist/{dropdown-menu-CZgjYSAh.js → dropdown-menu-CZy06LAq.js} +12 -12
- package/dist/{ebnfDiagram-PWID7BFC-WnG4cvSQ.js → ebnfDiagram-PWID7BFC-C20OnNMZ.js} +3 -3
- package/dist/{erDiagram-RLTQ6QDP-DhzKiYHc.js → erDiagram-RLTQ6QDP-DBXLWO9v.js} +12 -12
- package/dist/{error-entries-C0NsUqXl.js → error-entries-DLl0XqoW.js} +18 -18
- package/dist/{feedback-button-WVepiUsI.js → feedback-button-BmlXbdJI.js} +19 -19
- package/dist/flowDiagram-HODETNUW-DL52nMkt.js +16 -0
- package/dist/{formats-BR5iGb4s.js → formats-Cl_67ghI.js} +2 -2
- package/dist/{ganttDiagram-EL5Y4UJY-DbzEBLbl.js → ganttDiagram-EL5Y4UJY-cRRaDt88.js} +2 -2
- package/dist/{gitGraphDiagram-WWUBYQGX-BMf0iKi1.js → gitGraphDiagram-WWUBYQGX-Pox5k9-Y.js} +2 -2
- package/dist/{glide-data-editor-S0WTUxUP.js → glide-data-editor-DnxrqL3c.js} +5 -5
- package/dist/{globals-B0NGznoE.js → globals-C6IYCw1c.js} +1 -1
- package/dist/{html-to-image-CeYYvQNb.js → html-to-image-CmkwfNkf.js} +32 -31
- package/dist/{infoDiagram-27XIBGKW-BagtCX_5.js → infoDiagram-27XIBGKW-ntpxMfrq.js} +2 -2
- package/dist/{ishikawaDiagram-5VMMS53U-DByDehYy.js → ishikawaDiagram-5VMMS53U-BllIlHE5.js} +3 -3
- package/dist/{journeyDiagram-3NMN7TZE-D2LcKDUO.js → journeyDiagram-3NMN7TZE-EPJDPlt0.js} +2 -2
- package/dist/{kanban-definition-UXKFOSKX-BxwkbBI_.js → kanban-definition-UXKFOSKX-GYtNMjtS.js} +9 -9
- package/dist/{katex-C6D4cX_N.js → katex-BNCmKUol.js} +983 -1120
- package/dist/{useNumberFormatter-BfDpa21j.js → label-BslhXqL6.js} +108 -81
- package/dist/{loader-D2W4oM-3.js → loader-DEZSzvma.js} +253 -248
- package/dist/main.js +670 -661
- package/dist/{mermaid-DPNuhemn.js → mermaid-Dnzoxjt1.js} +49 -49
- package/dist/{mhchem-DWCF06w9.js → mhchem-BEc7A1or.js} +1 -1
- package/dist/{mindmap-definition-YA3MSWOX-Cgvojw3y.js → mindmap-definition-YA3MSWOX-Cth76xgH.js} +11 -11
- package/dist/{number-overlay-editor-5uyVnQ6u.js → number-overlay-editor-BO78Sr4W.js} +1 -1
- package/dist/{pegDiagram-XKGWAZYB-DahHhYyN.js → pegDiagram-XKGWAZYB-Cu4uOXii.js} +3 -3
- package/dist/{pieDiagram-E7YTZNPT-CCtX0oCK.js → pieDiagram-E7YTZNPT-Bh3eDa9s.js} +3 -3
- package/dist/{process-output-BCTjlyuH.js → process-output-CYN5E-iO.js} +2 -2
- package/dist/{quadrantDiagram-AXDQQJYC-DftINo6g.js → quadrantDiagram-AXDQQJYC--kqzFC3w.js} +1 -1
- package/dist/{railroadDiagram-O6MQD6OU-Du5NsPUb.js → railroadDiagram-O6MQD6OU-DG-M6Rnc.js} +3 -3
- package/dist/{react-vega-5AcMW8gG.js → react-vega-ewj7q_U5.js} +1 -1
- package/dist/{requirementDiagram-BXWQKSXE-0pmmxL6_.js → requirementDiagram-BXWQKSXE-DCwsThh0.js} +11 -11
- package/dist/{reveal-component-CKpvbtfe.js → reveal-component-C1yOCuj8.js} +744 -743
- package/dist/{sankeyDiagram-P5KCCOFB-CDKR5TJH.js → sankeyDiagram-P5KCCOFB-BdzhT0BM.js} +1 -1
- package/dist/{sequenceDiagram-WJ2MYXX4-DB-ChWwU.js → sequenceDiagram-WJ2MYXX4-CbXB1_PU.js} +4 -4
- package/dist/{spec-CAYwFeV6.js → spec-DQBRQSba.js} +123 -102
- package/dist/{stateDiagram-D77RDMKH-orN6AwMx.js → stateDiagram-D77RDMKH-A-Zf3Sb2.js} +13 -13
- package/dist/stateDiagram-v2-MP3YSRHH-D9YMnUGx.js +30 -0
- package/dist/style.css +1 -1
- package/dist/{swimlanes-42K2YHIH-BkSDcqDT.js → swimlanes-42K2YHIH-B_pMf0J4.js} +10 -10
- package/dist/swimlanesDiagram-VR7AAH4N-Ctgy-yGP.js +30 -0
- package/dist/{timeline-definition-24CTP7MA-BuqJUIRZ.js → timeline-definition-24CTP7MA-DTXFjTTM.js} +3 -3
- package/dist/{toDate-WXg1yLcI.js → toDate-C67bxMWn.js} +139 -111
- package/dist/{useDateFormatter-BRTPsUK7.js → useDateFormatter-BXQGu86d.js} +28 -49
- package/dist/{vega-component-D0QXopU8.js → vega-component-tFOzgarw.js} +12 -12
- package/dist/{vega-embed-container-CbnTccZi.js → vega-embed-container-sSR5hAsy.js} +2 -2
- package/dist/{vega-loader.browser-D95WfUcj.js → vega-loader.browser-DNST6uVf.js} +2 -2
- package/dist/{vennDiagram-4TSXK5OY-CTUlJ2PK.js → vennDiagram-4TSXK5OY-BPHjZo0R.js} +3 -3
- package/dist/{wardleyDiagram-VM6X3IG4-3evLUb0M.js → wardleyDiagram-VM6X3IG4-6fTLYBuD.js} +3 -3
- package/dist/{xychartDiagram-S5SC5T6Z-DL2E3K8-.js → xychartDiagram-S5SC5T6Z-BYjwjrzE.js} +5 -5
- package/package.json +1 -2
- package/src/__mocks__/common.ts +3 -3
- package/src/__tests__/CellStatus.test.tsx +1 -1
- package/src/__tests__/setup.ts +7 -7
- package/src/components/app-config/ai-config.tsx +2 -0
- package/src/components/app-config/optional-features.tsx +1 -1
- package/src/components/chat/chat-panel.tsx +19 -8
- package/src/components/data-table/TableTopBar.tsx +2 -2
- package/src/components/data-table/__tests__/export-actions.test.tsx +662 -0
- package/src/components/data-table/charts/__tests__/chart-panel.test.tsx +286 -0
- package/src/components/data-table/charts/charts.tsx +26 -13
- package/src/components/data-table/column-summary/chart-spec-model.tsx +4 -4
- package/src/components/data-table/data-table.tsx +1 -1
- package/src/components/data-table/export-actions.tsx +642 -176
- package/src/components/data-table/schemas.ts +25 -3
- package/src/components/dependency-graph/elements.ts +2 -2
- package/src/components/editor/__tests__/package-alert.test.tsx +140 -0
- package/src/components/editor/actions/__tests__/pair-with-agent.test.tsx +107 -0
- package/src/components/editor/actions/pair-with-agent.tsx +119 -0
- package/src/components/editor/actions/useNotebookActions.tsx +2 -1
- package/src/components/editor/ai/add-cell-with-ai.tsx +2 -0
- package/src/components/editor/ai/staged-cell-submission.ts +2 -2
- package/src/components/editor/ai/transport/chat-transport.tsx +1 -1
- package/src/components/editor/chrome/components/contribute-snippet-button.tsx +6 -1
- package/src/components/editor/connections/database/as-code.ts +44 -44
- package/src/components/editor/connections/storage/as-code.ts +3 -3
- package/src/components/editor/file-tree/requesting-tree.tsx +16 -13
- package/src/components/editor/navigation/clipboard.ts +2 -2
- package/src/components/editor/notebook-cell.tsx +2 -2
- package/src/components/editor/output/MarimoTracebackOutput.tsx +1 -1
- package/src/components/editor/output/VideoOutput.tsx +1 -1
- package/src/components/editor/output/ansi-reduce.ts +21 -17
- package/src/components/editor/output/console/ConsoleOutput.tsx +3 -3
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +59 -0
- package/src/components/editor/output/console/text-rendering.tsx +3 -1
- package/src/components/editor/package-alert.tsx +20 -7
- package/src/components/home/components.tsx +1 -0
- package/src/components/markdown/markdown-renderer.css +1 -1
- package/src/components/pages/run-page.tsx +1 -0
- package/src/components/slides/__tests__/minimap-actions.test.tsx +7 -7
- package/src/components/slides/__tests__/minimap.test.ts +12 -12
- package/src/components/slides/__tests__/slide-scroll-hint.test.tsx +8 -8
- package/src/components/static-html/__tests__/share-modal.test.tsx +154 -0
- package/src/components/static-html/__tests__/stage-for-publish.test.ts +111 -0
- package/src/components/static-html/share-modal.tsx +114 -144
- package/src/components/static-html/stage-for-publish.ts +56 -0
- package/src/components/static-html/static-banner.tsx +2 -2
- package/src/components/ui/links.tsx +6 -1
- package/src/components/ui/typography.tsx +16 -8
- package/src/core/ai/context/__tests__/registry.test.ts +31 -28
- package/src/core/ai/context/providers/cell-output.ts +8 -8
- package/src/core/ai/context/providers/datasource.ts +10 -7
- package/src/core/ai/context/providers/error.ts +7 -7
- package/src/core/ai/context/providers/file.ts +8 -8
- package/src/core/ai/context/providers/tables.ts +7 -7
- package/src/core/ai/context/providers/variable.ts +7 -7
- package/src/core/ai/context/registry.ts +18 -18
- package/src/core/ai/ids/ids.ts +5 -5
- package/src/core/ai/model-registry.ts +12 -9
- package/src/core/ai/staged-cells.ts +6 -6
- package/src/core/ai/tools/base.ts +6 -6
- package/src/core/ai/tools/edit-notebook-tool.ts +6 -6
- package/src/core/ai/tools/registry.ts +4 -4
- package/src/core/ai/tools/run-cells-tool.ts +7 -7
- package/src/core/ai/tools/sample-tool.ts +6 -6
- package/src/core/cells/__tests__/cells.test.ts +27 -0
- package/src/core/cells/cells.ts +2 -1
- package/src/core/codemirror/cells/debugger-decorations.ts +13 -7
- package/src/core/codemirror/cells/line-timing-decorations.ts +9 -9
- package/src/core/codemirror/cells/traceback-decorations.ts +7 -4
- package/src/core/codemirror/code-lens/extension.ts +13 -13
- package/src/core/codemirror/copilot/__tests__/language-server.test.ts +6 -6
- package/src/core/codemirror/copilot/__tests__/transport.test.ts +12 -12
- package/src/core/codemirror/copilot/language-server.ts +13 -13
- package/src/core/codemirror/copilot/transport.ts +1 -1
- package/src/core/codemirror/find-replace/search-highlight.ts +5 -5
- package/src/core/codemirror/go-to-definition/underline.ts +3 -3
- package/src/core/codemirror/keymaps/vim.ts +3 -3
- package/src/core/codemirror/language/languages/markdown.ts +8 -8
- package/src/core/codemirror/language/languages/python.ts +7 -7
- package/src/core/codemirror/language/languages/sql/completion-builder.ts +5 -5
- package/src/core/codemirror/language/languages/sql/completion-store.ts +4 -4
- package/src/core/codemirror/language/languages/sql/sql.ts +21 -21
- package/src/core/codemirror/lsp/__tests__/transports.test.ts +10 -10
- package/src/core/codemirror/lsp/federated-lsp.ts +29 -27
- package/src/core/codemirror/lsp/notebook-lsp.ts +21 -21
- package/src/core/codemirror/misc/__tests__/dnd.test.ts +10 -10
- package/src/core/codemirror/misc/__tests__/paste.test.ts +7 -4
- package/src/core/codemirror/reactive-references/extension.ts +3 -3
- package/src/core/codemirror/rtc/loro/awareness.ts +12 -12
- package/src/core/codemirror/rtc/loro/sync.ts +5 -5
- package/src/core/codemirror/vim/cursor-visibility.ts +3 -3
- package/src/core/dom/ui-element.ts +5 -5
- package/src/core/dom/uiregistry.ts +10 -10
- package/src/core/hotkeys/hotkeys.ts +9 -9
- package/src/core/islands/__tests__/bridge.test.ts +4 -4
- package/src/core/islands/__tests__/test-utils.tsx +4 -4
- package/src/core/islands/bridge.ts +85 -82
- package/src/core/islands/components/web-components.tsx +7 -7
- package/src/core/islands/worker/__tests__/controller.test.ts +1 -1
- package/src/core/islands/worker/controller.ts +6 -3
- package/src/core/islands/worker-factory.ts +2 -2
- package/src/core/kernel/RuntimeState.ts +4 -4
- package/src/core/kernel/__tests__/session.test.ts +110 -1
- package/src/core/kernel/session.ts +46 -15
- package/src/core/lsp/__tests__/transport.test.ts +19 -19
- package/src/core/lsp/transport.ts +5 -5
- package/src/core/network/CachingRequestRegistry.ts +2 -2
- package/src/core/network/DeferredRequestRegistry.ts +4 -4
- package/src/core/network/__tests__/export-asset-url.test.ts +45 -0
- package/src/core/network/export-asset-url.ts +19 -0
- package/src/core/network/requests-network.ts +2 -7
- package/src/core/runtime/runtime.ts +25 -20
- package/src/core/static/virtual-file-tracker.ts +5 -5
- package/src/core/wasm/__tests__/bridge.test.ts +2 -2
- package/src/core/wasm/bridge.ts +132 -133
- package/src/core/wasm/router.ts +5 -5
- package/src/core/wasm/store.ts +4 -4
- package/src/core/wasm/worker/bootstrap.ts +8 -5
- package/src/core/wasm/worker/message-buffer.ts +3 -3
- package/src/core/websocket/transports/__tests__/ws.test.ts +8 -8
- package/src/core/websocket/transports/basic.ts +15 -8
- package/src/core/websocket/transports/sse.ts +7 -7
- package/src/core/websocket/transports/transport.ts +3 -3
- package/src/core/websocket/transports/ws.ts +9 -7
- package/src/css/globals.css +18 -21
- package/src/css/katex.min.css +260 -241
- package/src/hooks/__tests__/useOverflowDetection.test.tsx +5 -5
- package/src/hooks/__tests__/useResizeObserver.test.tsx +12 -12
- package/src/plugins/core/registerReactComponent.tsx +5 -5
- package/src/plugins/core/sidebar-element.tsx +2 -2
- package/src/plugins/impl/ButtonPlugin.tsx +3 -3
- package/src/plugins/impl/CheckboxPlugin.tsx +3 -3
- package/src/plugins/impl/CodeEditorPlugin.tsx +3 -3
- package/src/plugins/impl/DatePickerPlugin.tsx +3 -3
- package/src/plugins/impl/DateRangePlugin.tsx +3 -3
- package/src/plugins/impl/DateTimePickerPlugin.tsx +3 -3
- package/src/plugins/impl/DictPlugin.tsx +3 -3
- package/src/plugins/impl/DropdownPlugin.tsx +3 -3
- package/src/plugins/impl/FileUploadPlugin.tsx +3 -3
- package/src/plugins/impl/MatrixPlugin.tsx +4 -4
- package/src/plugins/impl/MicrophonePlugin.tsx +3 -3
- package/src/plugins/impl/MultiselectPlugin.tsx +3 -3
- package/src/plugins/impl/NumberPlugin.tsx +3 -3
- package/src/plugins/impl/RadioPlugin.tsx +9 -5
- package/src/plugins/impl/RangeSliderPlugin.tsx +3 -3
- package/src/plugins/impl/RefreshPlugin.tsx +3 -3
- package/src/plugins/impl/SliderPlugin.tsx +3 -3
- package/src/plugins/impl/SwitchPlugin.tsx +3 -3
- package/src/plugins/impl/TabsPlugin.tsx +3 -3
- package/src/plugins/impl/TextAreaPlugin.tsx +3 -3
- package/src/plugins/impl/TextInputPlugin.tsx +3 -3
- package/src/plugins/impl/__tests__/MatrixPlugin.test.tsx +2 -2
- package/src/plugins/impl/anywidget/model.ts +10 -10
- package/src/plugins/impl/anywidget/registry.ts +12 -9
- package/src/plugins/impl/anywidget/runtime.ts +11 -9
- package/src/plugins/impl/anywidget/widget-binding.ts +6 -6
- package/src/plugins/impl/image-comparison/ImageComparisonComponent.tsx +7 -6
- package/src/plugins/impl/matplotlib/MatplotlibPlugin.tsx +3 -3
- package/src/plugins/impl/matplotlib/__tests__/matplotlib-renderer.test.ts +2 -2
- package/src/plugins/impl/matplotlib/matplotlib-renderer.ts +2 -2
- package/src/plugins/impl/mpl-interactive/mpl-websocket-shim.ts +10 -10
- package/src/plugins/impl/panel/utils.ts +5 -5
- package/src/plugins/impl/plotly/PlotlyPlugin.tsx +3 -3
- package/src/plugins/impl/vega/VegaPlugin.tsx +3 -3
- package/src/plugins/impl/vega/__tests__/use-vega-container-remeasure.test.ts +7 -7
- package/src/plugins/impl/vega/__tests__/utils.test.ts +16 -1
- package/src/plugins/impl/vega/__tests__/vega.test.ts +37 -0
- package/src/plugins/impl/vega/loader.ts +23 -1
- package/src/plugins/impl/vega/utils.ts +5 -4
- package/src/plugins/layout/AccordionPlugin.tsx +3 -3
- package/src/plugins/layout/CalloutPlugin.tsx +3 -3
- package/src/plugins/layout/ImageComparisonPlugin.tsx +5 -3
- package/src/plugins/layout/JsonOutputPlugin.tsx +3 -3
- package/src/plugins/layout/MimeRenderPlugin.tsx +3 -3
- package/src/plugins/layout/NavigationMenuPlugin.tsx +3 -3
- package/src/plugins/layout/OutlinePlugin.tsx +3 -3
- package/src/plugins/layout/ProgressPlugin.tsx +3 -3
- package/src/plugins/layout/RoutesPlugin.tsx +6 -8
- package/src/plugins/layout/StatPlugin.tsx +3 -3
- package/src/plugins/layout/TexPlugin.tsx +3 -3
- package/src/plugins/layout/carousel/CarouselPlugin.tsx +4 -4
- package/src/plugins/layout/mermaid/MermaidPlugin.tsx +3 -3
- package/src/utils/Deferred.ts +6 -6
- package/src/utils/async-capture-tracker.ts +10 -7
- package/src/utils/errors.ts +5 -5
- package/src/utils/id-tree.tsx +83 -80
- package/src/utils/lru.ts +1 -1
- package/src/utils/multi-map.ts +14 -12
- package/src/utils/paths.ts +6 -6
- package/src/utils/pluralize.ts +3 -3
- package/src/utils/progress.ts +6 -6
- package/src/utils/python-poet/poet.ts +14 -14
- package/src/utils/routes.ts +4 -2
- package/src/utils/semaphore.ts +6 -6
- package/src/utils/storage/storage.ts +6 -6
- package/src/utils/storage/typed.ts +16 -12
- package/src/utils/time.ts +9 -9
- package/src/utils/timed-cache.ts +4 -4
- package/src/utils/tracer.ts +9 -6
- package/dist/classDiagram-ZZMXUADV-Fe-V14Sc.js +0 -30
- package/dist/classDiagram-v2-VYDZK3BY-xTDg7lOs.js +0 -30
- package/dist/flowDiagram-HODETNUW-6dMdB8pR.js +0 -16
- package/dist/katex-DFBiSucW.js +0 -21840
- package/dist/label-BJ49YTvk.js +0 -30
- package/dist/stateDiagram-v2-MP3YSRHH-o05_rJN8.js +0 -30
- package/dist/swimlanesDiagram-VR7AAH4N-D_nFQfRc.js +0 -30
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
act,
|
|
5
|
+
fireEvent,
|
|
6
|
+
render,
|
|
7
|
+
screen,
|
|
8
|
+
waitFor,
|
|
9
|
+
within,
|
|
10
|
+
} from "@testing-library/react";
|
|
11
|
+
import { createStore, Provider } from "jotai";
|
|
12
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
13
|
+
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
14
|
+
import { toast } from "@/components/ui/use-toast";
|
|
15
|
+
import { viewStateAtom, type AppMode } from "@/core/mode";
|
|
16
|
+
import { copyToClipboard } from "@/utils/copy";
|
|
17
|
+
import { downloadByURL } from "@/utils/download";
|
|
18
|
+
import { jsonToMarkdown } from "@/utils/json/json-parser";
|
|
19
|
+
import { downloadSizeLimitAtom } from "../download-policy/atoms";
|
|
20
|
+
import { ExportActions, type ExportActionProps } from "../export-actions";
|
|
21
|
+
|
|
22
|
+
const mocks = vi.hoisted(() => ({
|
|
23
|
+
handleInstallPackages: vi.fn(),
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
vi.mock("@/core/packages/useInstallPackage", () => ({
|
|
27
|
+
useInstallPackages: () => ({
|
|
28
|
+
handleInstallPackages: mocks.handleInstallPackages,
|
|
29
|
+
}),
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
vi.mock("@/utils/copy", () => ({
|
|
33
|
+
copyToClipboard: vi.fn().mockResolvedValue(undefined),
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
vi.mock("@/utils/download", () => ({
|
|
37
|
+
downloadByURL: vi.fn(),
|
|
38
|
+
withLoadingToast: vi.fn(
|
|
39
|
+
async (_title: string, callback: () => Promise<unknown>) => callback(),
|
|
40
|
+
),
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
vi.mock("@/components/ui/use-toast", () => ({
|
|
44
|
+
toast: vi.fn(() => ({
|
|
45
|
+
dismiss: vi.fn(),
|
|
46
|
+
update: vi.fn(),
|
|
47
|
+
})),
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
const downloadAs = vi.fn<ExportActionProps["downloadAs"]>();
|
|
51
|
+
|
|
52
|
+
function renderExportActions(
|
|
53
|
+
props: Partial<ExportActionProps> = {},
|
|
54
|
+
sizeLimit: { limitBytes: number; unavailableMessage: string } | null = null,
|
|
55
|
+
mode: AppMode = "edit",
|
|
56
|
+
) {
|
|
57
|
+
const store = createStore();
|
|
58
|
+
store.set(downloadSizeLimitAtom, sizeLimit);
|
|
59
|
+
store.set(viewStateAtom, { mode, cellAnchor: null });
|
|
60
|
+
|
|
61
|
+
return render(
|
|
62
|
+
<Provider store={store}>
|
|
63
|
+
<TooltipProvider delayDuration={0}>
|
|
64
|
+
<ExportActions downloadAs={downloadAs} {...props} />
|
|
65
|
+
</TooltipProvider>
|
|
66
|
+
</Provider>,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function openDialog() {
|
|
71
|
+
fireEvent.click(screen.getByTestId("export-button"));
|
|
72
|
+
return screen.findByRole("dialog", { name: "Export table" });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
describe("ExportActions dialog", () => {
|
|
76
|
+
beforeEach(() => {
|
|
77
|
+
vi.clearAllMocks();
|
|
78
|
+
downloadAs.mockResolvedValue({
|
|
79
|
+
url: "https://example.test/export",
|
|
80
|
+
filename: "table",
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
afterEach(() => {
|
|
85
|
+
vi.unstubAllGlobals();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("shows formats in the approved order with an options toggle where supported", async () => {
|
|
89
|
+
renderExportActions();
|
|
90
|
+
const dialog = await openDialog();
|
|
91
|
+
const list = within(dialog).getByRole("list", { name: "Export formats" });
|
|
92
|
+
const rows = within(list).getAllByRole("listitem");
|
|
93
|
+
|
|
94
|
+
expect(rows.map((row) => row.dataset.testid)).toEqual([
|
|
95
|
+
"export-row-csv",
|
|
96
|
+
"export-row-tsv",
|
|
97
|
+
"export-row-json",
|
|
98
|
+
"export-row-parquet",
|
|
99
|
+
"export-row-markdown",
|
|
100
|
+
]);
|
|
101
|
+
for (const label of ["CSV", "TSV", "JSON"]) {
|
|
102
|
+
expect(
|
|
103
|
+
screen.getByRole("button", { name: `${label} options` }),
|
|
104
|
+
).toHaveAttribute("aria-expanded", "false");
|
|
105
|
+
}
|
|
106
|
+
for (const label of ["Parquet", "Markdown"]) {
|
|
107
|
+
expect(
|
|
108
|
+
screen.queryByRole("button", { name: `${label} options` }),
|
|
109
|
+
).not.toBeInTheDocument();
|
|
110
|
+
}
|
|
111
|
+
expect(within(dialog).queryByRole("group")).not.toBeInTheDocument();
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("expands one options panel at a time", async () => {
|
|
115
|
+
renderExportActions();
|
|
116
|
+
const dialog = await openDialog();
|
|
117
|
+
|
|
118
|
+
fireEvent.click(screen.getByRole("button", { name: "CSV options" }));
|
|
119
|
+
expect(
|
|
120
|
+
within(dialog).getByRole("group", { name: "CSV options" }),
|
|
121
|
+
).toBeInTheDocument();
|
|
122
|
+
expect(screen.getByRole("combobox", { name: "Delimiter" })).toHaveValue(
|
|
123
|
+
",",
|
|
124
|
+
);
|
|
125
|
+
expect(screen.getByRole("combobox", { name: "Encoding" })).toHaveValue(
|
|
126
|
+
"utf-8",
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
fireEvent.click(screen.getByRole("button", { name: "JSON options" }));
|
|
130
|
+
expect(
|
|
131
|
+
within(dialog).queryByRole("group", { name: "CSV options" }),
|
|
132
|
+
).not.toBeInTheDocument();
|
|
133
|
+
expect(
|
|
134
|
+
within(dialog).getByRole("group", { name: "JSON options" }),
|
|
135
|
+
).toBeInTheDocument();
|
|
136
|
+
expect(
|
|
137
|
+
screen.getByRole("switch", { name: "Escape non-ASCII" }),
|
|
138
|
+
).toBeChecked();
|
|
139
|
+
|
|
140
|
+
fireEvent.click(screen.getByRole("button", { name: "JSON options" }));
|
|
141
|
+
expect(within(dialog).queryByRole("group")).not.toBeInTheDocument();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("sends only changed CSV options with a download", async () => {
|
|
145
|
+
renderExportActions();
|
|
146
|
+
await openDialog();
|
|
147
|
+
expect(screen.getByTestId("export-summary-csv")).toHaveTextContent(
|
|
148
|
+
"Comma · UTF-8",
|
|
149
|
+
);
|
|
150
|
+
expect(screen.queryByTestId("export-summary-parquet")).toBeNull();
|
|
151
|
+
|
|
152
|
+
fireEvent.click(screen.getByRole("button", { name: "CSV options" }));
|
|
153
|
+
fireEvent.change(screen.getByRole("combobox", { name: "Delimiter" }), {
|
|
154
|
+
target: { value: ";" },
|
|
155
|
+
});
|
|
156
|
+
fireEvent.change(screen.getByRole("combobox", { name: "Encoding" }), {
|
|
157
|
+
target: { value: "utf-8-sig" },
|
|
158
|
+
});
|
|
159
|
+
expect(screen.getByTestId("export-summary-csv")).toHaveTextContent(
|
|
160
|
+
"Semicolon · UTF-8 with BOM",
|
|
161
|
+
);
|
|
162
|
+
fireEvent.click(screen.getByRole("button", { name: "Download CSV" }));
|
|
163
|
+
|
|
164
|
+
await waitFor(() => {
|
|
165
|
+
expect(downloadByURL).toHaveBeenCalled();
|
|
166
|
+
});
|
|
167
|
+
expect(downloadAs).toHaveBeenCalledWith({
|
|
168
|
+
format: "csv",
|
|
169
|
+
options: { separator: ";", encoding: "utf-8-sig" },
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it("keeps the delimiter but drops the encoding for a CSV copy", async () => {
|
|
174
|
+
vi.stubGlobal(
|
|
175
|
+
"fetch",
|
|
176
|
+
vi.fn().mockResolvedValue({
|
|
177
|
+
ok: true,
|
|
178
|
+
text: vi.fn().mockResolvedValue("name;value\n"),
|
|
179
|
+
}),
|
|
180
|
+
);
|
|
181
|
+
renderExportActions();
|
|
182
|
+
await openDialog();
|
|
183
|
+
|
|
184
|
+
fireEvent.click(screen.getByRole("button", { name: "CSV options" }));
|
|
185
|
+
fireEvent.change(screen.getByRole("combobox", { name: "Delimiter" }), {
|
|
186
|
+
target: { value: ";" },
|
|
187
|
+
});
|
|
188
|
+
fireEvent.change(screen.getByRole("combobox", { name: "Encoding" }), {
|
|
189
|
+
target: { value: "latin-1" },
|
|
190
|
+
});
|
|
191
|
+
fireEvent.click(screen.getByRole("button", { name: "Copy CSV" }));
|
|
192
|
+
|
|
193
|
+
await waitFor(() => {
|
|
194
|
+
expect(copyToClipboard).toHaveBeenCalledWith("name;value\n");
|
|
195
|
+
});
|
|
196
|
+
expect(downloadAs).toHaveBeenCalledWith({
|
|
197
|
+
format: "csv",
|
|
198
|
+
options: { separator: ";" },
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("sends the JSON escape setting only when turned off", async () => {
|
|
203
|
+
renderExportActions();
|
|
204
|
+
await openDialog();
|
|
205
|
+
|
|
206
|
+
fireEvent.click(screen.getByRole("button", { name: "JSON options" }));
|
|
207
|
+
fireEvent.click(screen.getByRole("switch", { name: "Escape non-ASCII" }));
|
|
208
|
+
fireEvent.click(screen.getByRole("button", { name: "Download JSON" }));
|
|
209
|
+
|
|
210
|
+
await waitFor(() => {
|
|
211
|
+
expect(downloadByURL).toHaveBeenCalled();
|
|
212
|
+
});
|
|
213
|
+
expect(downloadAs).toHaveBeenCalledWith({
|
|
214
|
+
format: "json",
|
|
215
|
+
options: { ensure_ascii: false },
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it("resets options and panels when the dialog closes", async () => {
|
|
220
|
+
renderExportActions();
|
|
221
|
+
let dialog = await openDialog();
|
|
222
|
+
|
|
223
|
+
fireEvent.click(screen.getByRole("button", { name: "CSV options" }));
|
|
224
|
+
fireEvent.change(screen.getByRole("combobox", { name: "Delimiter" }), {
|
|
225
|
+
target: { value: "|" },
|
|
226
|
+
});
|
|
227
|
+
fireEvent.click(within(dialog).getByRole("button", { name: "Close" }));
|
|
228
|
+
await waitFor(() => {
|
|
229
|
+
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
dialog = await openDialog();
|
|
233
|
+
expect(within(dialog).queryByRole("group")).not.toBeInTheDocument();
|
|
234
|
+
fireEvent.click(screen.getByRole("button", { name: "Download CSV" }));
|
|
235
|
+
await waitFor(() => {
|
|
236
|
+
expect(downloadAs).toHaveBeenCalledWith({ format: "csv" });
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("opens without showing an action tooltip", async () => {
|
|
241
|
+
renderExportActions();
|
|
242
|
+
const dialog = await openDialog();
|
|
243
|
+
await act(async () => {
|
|
244
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
expect(dialog).toHaveFocus();
|
|
248
|
+
expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it("uses named icon buttons and reserves unavailable actions", async () => {
|
|
252
|
+
renderExportActions();
|
|
253
|
+
await openDialog();
|
|
254
|
+
|
|
255
|
+
for (const format of ["CSV", "TSV", "JSON"]) {
|
|
256
|
+
expect(
|
|
257
|
+
screen.getByRole("button", { name: `Download ${format}` }),
|
|
258
|
+
).toBeEnabled();
|
|
259
|
+
expect(
|
|
260
|
+
screen.getByRole("button", { name: `Copy ${format}` }),
|
|
261
|
+
).toBeEnabled();
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
expect(
|
|
265
|
+
screen.getByRole("button", { name: "Download Parquet" }),
|
|
266
|
+
).toBeEnabled();
|
|
267
|
+
expect(screen.getByRole("button", { name: "Copy Parquet" })).toBeDisabled();
|
|
268
|
+
expect(
|
|
269
|
+
screen.getByRole("button", { name: "Download Markdown" }),
|
|
270
|
+
).toBeDisabled();
|
|
271
|
+
expect(screen.getByRole("button", { name: "Copy Markdown" })).toBeEnabled();
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it.each([
|
|
275
|
+
["CSV", "csv"],
|
|
276
|
+
["TSV", "tsv"],
|
|
277
|
+
["JSON", "json"],
|
|
278
|
+
["Parquet", "parquet"],
|
|
279
|
+
] as const)(
|
|
280
|
+
"downloads %s with its existing URL contract",
|
|
281
|
+
async (label, format) => {
|
|
282
|
+
downloadAs.mockResolvedValue({
|
|
283
|
+
url: "https://example.test/export?token=abc",
|
|
284
|
+
filename: "table.source",
|
|
285
|
+
});
|
|
286
|
+
renderExportActions();
|
|
287
|
+
await openDialog();
|
|
288
|
+
|
|
289
|
+
fireEvent.click(
|
|
290
|
+
screen.getByRole("button", { name: `Download ${label}` }),
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
await waitFor(() => {
|
|
294
|
+
expect(downloadByURL).toHaveBeenCalledWith(
|
|
295
|
+
`https://example.test/export?token=abc&download=1&filename=table.${format}`,
|
|
296
|
+
`table.${format}`,
|
|
297
|
+
);
|
|
298
|
+
});
|
|
299
|
+
expect(downloadAs).toHaveBeenCalledWith({ format });
|
|
300
|
+
expect(toast).toHaveBeenCalledWith({
|
|
301
|
+
title: `${label} download started`,
|
|
302
|
+
});
|
|
303
|
+
expect(screen.getByRole("dialog")).toBeInTheDocument();
|
|
304
|
+
},
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
it("keeps data URLs unchanged", async () => {
|
|
308
|
+
downloadAs.mockResolvedValue({
|
|
309
|
+
url: "data:text/csv;base64,YQ==",
|
|
310
|
+
filename: "table",
|
|
311
|
+
});
|
|
312
|
+
renderExportActions();
|
|
313
|
+
await openDialog();
|
|
314
|
+
|
|
315
|
+
fireEvent.click(screen.getByRole("button", { name: "Download CSV" }));
|
|
316
|
+
|
|
317
|
+
await waitFor(() => {
|
|
318
|
+
expect(downloadByURL).toHaveBeenCalledWith(
|
|
319
|
+
"data:text/csv;base64,YQ==",
|
|
320
|
+
"table.csv",
|
|
321
|
+
);
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it.each([
|
|
326
|
+
{
|
|
327
|
+
label: "CSV",
|
|
328
|
+
sourceFormat: "csv" as const,
|
|
329
|
+
sourceText: "name,value\nalpha,1\n",
|
|
330
|
+
expectedText: "name,value\nalpha,1\n",
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
label: "TSV",
|
|
334
|
+
sourceFormat: "tsv" as const,
|
|
335
|
+
sourceText: "name\tvalue\nalpha\t1\n",
|
|
336
|
+
expectedText: "name\tvalue\nalpha\t1\n",
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
label: "JSON",
|
|
340
|
+
sourceFormat: "json" as const,
|
|
341
|
+
sourceText: JSON.stringify([{ name: "alpha", value: 1 }]),
|
|
342
|
+
expectedText: JSON.stringify([{ name: "alpha", value: 1 }], null, 2),
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
label: "Markdown",
|
|
346
|
+
sourceFormat: "json" as const,
|
|
347
|
+
sourceText: JSON.stringify([{ name: "alpha", value: 1 }]),
|
|
348
|
+
expectedText: jsonToMarkdown([{ name: "alpha", value: 1 }]),
|
|
349
|
+
},
|
|
350
|
+
])(
|
|
351
|
+
"copies $label with its existing conversion",
|
|
352
|
+
async ({ label, sourceFormat, sourceText, expectedText }) => {
|
|
353
|
+
vi.stubGlobal(
|
|
354
|
+
"fetch",
|
|
355
|
+
vi.fn().mockResolvedValue({
|
|
356
|
+
ok: true,
|
|
357
|
+
text: vi.fn().mockResolvedValue(sourceText),
|
|
358
|
+
}),
|
|
359
|
+
);
|
|
360
|
+
renderExportActions();
|
|
361
|
+
await openDialog();
|
|
362
|
+
|
|
363
|
+
fireEvent.click(screen.getByRole("button", { name: `Copy ${label}` }));
|
|
364
|
+
|
|
365
|
+
await waitFor(() => {
|
|
366
|
+
expect(copyToClipboard).toHaveBeenCalledWith(expectedText);
|
|
367
|
+
});
|
|
368
|
+
expect(downloadAs).toHaveBeenCalledWith({ format: sourceFormat });
|
|
369
|
+
expect(toast).toHaveBeenCalledWith({ title: "Copied to clipboard" });
|
|
370
|
+
await waitFor(() => {
|
|
371
|
+
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
|
372
|
+
});
|
|
373
|
+
},
|
|
374
|
+
);
|
|
375
|
+
|
|
376
|
+
it("shows the failure inside the affected format row", async () => {
|
|
377
|
+
downloadAs.mockRejectedValueOnce(new Error("Kernel disconnected"));
|
|
378
|
+
renderExportActions();
|
|
379
|
+
await openDialog();
|
|
380
|
+
|
|
381
|
+
fireEvent.click(screen.getByRole("button", { name: "Download JSON" }));
|
|
382
|
+
|
|
383
|
+
const alert = await screen.findByRole("alert");
|
|
384
|
+
expect(screen.getByTestId("export-row-json")).toContainElement(alert);
|
|
385
|
+
expect(screen.getByTestId("export-row-csv")).not.toContainElement(alert);
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
it("shows download request failures inside the dialog", async () => {
|
|
389
|
+
downloadAs.mockRejectedValueOnce(new Error("Kernel disconnected"));
|
|
390
|
+
renderExportActions();
|
|
391
|
+
await openDialog();
|
|
392
|
+
|
|
393
|
+
fireEvent.click(screen.getByRole("button", { name: "Download CSV" }));
|
|
394
|
+
|
|
395
|
+
const alert = await screen.findByRole("alert");
|
|
396
|
+
expect(alert).toHaveTextContent("Failed to download");
|
|
397
|
+
expect(alert).toHaveTextContent("Kernel disconnected");
|
|
398
|
+
expect(downloadByURL).not.toHaveBeenCalled();
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
it("shows file delivery failures inside the dialog", async () => {
|
|
402
|
+
vi.mocked(downloadByURL).mockImplementationOnce(() => {
|
|
403
|
+
throw new Error("Download blocked");
|
|
404
|
+
});
|
|
405
|
+
renderExportActions();
|
|
406
|
+
await openDialog();
|
|
407
|
+
|
|
408
|
+
fireEvent.click(screen.getByRole("button", { name: "Download CSV" }));
|
|
409
|
+
|
|
410
|
+
const alert = await screen.findByRole("alert");
|
|
411
|
+
expect(alert).toHaveTextContent("Failed to download");
|
|
412
|
+
expect(alert).toHaveTextContent("Download blocked");
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
it("shows fetch failures inside the dialog", async () => {
|
|
416
|
+
vi.stubGlobal(
|
|
417
|
+
"fetch",
|
|
418
|
+
vi.fn().mockResolvedValue({
|
|
419
|
+
ok: false,
|
|
420
|
+
statusText: "Forbidden",
|
|
421
|
+
}),
|
|
422
|
+
);
|
|
423
|
+
renderExportActions();
|
|
424
|
+
await openDialog();
|
|
425
|
+
|
|
426
|
+
fireEvent.click(screen.getByRole("button", { name: "Copy CSV" }));
|
|
427
|
+
|
|
428
|
+
const alert = await screen.findByRole("alert");
|
|
429
|
+
expect(alert).toHaveTextContent("Failed to copy to clipboard");
|
|
430
|
+
expect(alert).toHaveTextContent("Forbidden");
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
it("shows clipboard failures inside the dialog", async () => {
|
|
434
|
+
vi.stubGlobal(
|
|
435
|
+
"fetch",
|
|
436
|
+
vi.fn().mockResolvedValue({
|
|
437
|
+
ok: true,
|
|
438
|
+
text: vi.fn().mockResolvedValue("name\nalpha\n"),
|
|
439
|
+
}),
|
|
440
|
+
);
|
|
441
|
+
vi.mocked(copyToClipboard).mockRejectedValueOnce(
|
|
442
|
+
new Error("Clipboard permission denied"),
|
|
443
|
+
);
|
|
444
|
+
renderExportActions();
|
|
445
|
+
await openDialog();
|
|
446
|
+
|
|
447
|
+
fireEvent.click(screen.getByRole("button", { name: "Copy CSV" }));
|
|
448
|
+
|
|
449
|
+
const alert = await screen.findByRole("alert");
|
|
450
|
+
expect(alert).toHaveTextContent("Failed to copy to clipboard");
|
|
451
|
+
expect(alert).toHaveTextContent("Clipboard permission denied");
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
it("shows backend failures before success fields", async () => {
|
|
455
|
+
downloadAs.mockResolvedValueOnce({
|
|
456
|
+
url: "https://example.test/partial",
|
|
457
|
+
filename: "partial",
|
|
458
|
+
error: "Export was rejected",
|
|
459
|
+
});
|
|
460
|
+
renderExportActions();
|
|
461
|
+
await openDialog();
|
|
462
|
+
|
|
463
|
+
fireEvent.click(screen.getByRole("button", { name: "Download JSON" }));
|
|
464
|
+
|
|
465
|
+
const alert = await screen.findByRole("alert");
|
|
466
|
+
expect(alert).toHaveTextContent("Export was rejected");
|
|
467
|
+
expect(downloadByURL).not.toHaveBeenCalled();
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
it("installs missing packages and retries the same action", async () => {
|
|
471
|
+
downloadAs
|
|
472
|
+
.mockResolvedValueOnce({
|
|
473
|
+
url: "",
|
|
474
|
+
filename: "",
|
|
475
|
+
error: "Parquet export requires pyarrow.",
|
|
476
|
+
missing_packages: ["pyarrow"],
|
|
477
|
+
})
|
|
478
|
+
.mockResolvedValueOnce({
|
|
479
|
+
url: "https://example.test/export",
|
|
480
|
+
filename: "table",
|
|
481
|
+
});
|
|
482
|
+
renderExportActions();
|
|
483
|
+
await openDialog();
|
|
484
|
+
|
|
485
|
+
fireEvent.click(screen.getByRole("button", { name: "Download Parquet" }));
|
|
486
|
+
|
|
487
|
+
const alert = await screen.findByRole("alert");
|
|
488
|
+
expect(alert).toHaveTextContent("Parquet export requires pyarrow.");
|
|
489
|
+
fireEvent.click(
|
|
490
|
+
within(alert).getByRole("button", { name: "Install pyarrow" }),
|
|
491
|
+
);
|
|
492
|
+
expect(mocks.handleInstallPackages).toHaveBeenCalledWith(
|
|
493
|
+
["pyarrow"],
|
|
494
|
+
expect.any(Function),
|
|
495
|
+
);
|
|
496
|
+
|
|
497
|
+
const onInstall = mocks.handleInstallPackages.mock
|
|
498
|
+
.calls[0][1] as () => void;
|
|
499
|
+
onInstall();
|
|
500
|
+
|
|
501
|
+
await waitFor(() => {
|
|
502
|
+
expect(downloadAs).toHaveBeenCalledTimes(2);
|
|
503
|
+
expect(downloadByURL).toHaveBeenCalledWith(
|
|
504
|
+
"https://example.test/export?download=1&filename=table.parquet",
|
|
505
|
+
"table.parquet",
|
|
506
|
+
);
|
|
507
|
+
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it("hides package details and installation in read mode", async () => {
|
|
512
|
+
downloadAs.mockResolvedValueOnce({
|
|
513
|
+
url: "",
|
|
514
|
+
filename: "",
|
|
515
|
+
error: "Install pyarrow to export Parquet.",
|
|
516
|
+
missing_packages: ["pyarrow"],
|
|
517
|
+
});
|
|
518
|
+
renderExportActions({}, null, "read");
|
|
519
|
+
await openDialog();
|
|
520
|
+
|
|
521
|
+
fireEvent.click(screen.getByRole("button", { name: "Download Parquet" }));
|
|
522
|
+
|
|
523
|
+
const alert = await screen.findByRole("alert");
|
|
524
|
+
expect(alert).toHaveTextContent(
|
|
525
|
+
"Parquet export isn't available in this notebook",
|
|
526
|
+
);
|
|
527
|
+
expect(alert).not.toHaveTextContent("pyarrow");
|
|
528
|
+
expect(within(alert).queryByRole("button")).not.toBeInTheDocument();
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
it("clears stale failures before a new action and after close", async () => {
|
|
532
|
+
downloadAs.mockRejectedValueOnce(new Error("First failure"));
|
|
533
|
+
renderExportActions();
|
|
534
|
+
let dialog = await openDialog();
|
|
535
|
+
|
|
536
|
+
fireEvent.click(screen.getByRole("button", { name: "Download CSV" }));
|
|
537
|
+
expect(await screen.findByRole("alert")).toHaveTextContent("First failure");
|
|
538
|
+
|
|
539
|
+
fireEvent.click(screen.getByRole("button", { name: "Download JSON" }));
|
|
540
|
+
await waitFor(() => {
|
|
541
|
+
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
|
|
542
|
+
expect(downloadByURL).toHaveBeenCalled();
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
downloadAs.mockRejectedValueOnce(new Error("Second failure"));
|
|
546
|
+
fireEvent.click(screen.getByRole("button", { name: "Download CSV" }));
|
|
547
|
+
expect(await screen.findByRole("alert")).toHaveTextContent(
|
|
548
|
+
"Second failure",
|
|
549
|
+
);
|
|
550
|
+
|
|
551
|
+
fireEvent.click(within(dialog).getByRole("button", { name: "Close" }));
|
|
552
|
+
await waitFor(() => {
|
|
553
|
+
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
|
554
|
+
});
|
|
555
|
+
dialog = await openDialog();
|
|
556
|
+
expect(within(dialog).queryByRole("alert")).not.toBeInTheDocument();
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
it("ignores a late failure from an earlier action", async () => {
|
|
560
|
+
let rejectFirst: (reason: Error) => void = () => undefined;
|
|
561
|
+
downloadAs
|
|
562
|
+
.mockImplementationOnce(
|
|
563
|
+
() =>
|
|
564
|
+
new Promise((_, reject) => {
|
|
565
|
+
rejectFirst = reject;
|
|
566
|
+
}),
|
|
567
|
+
)
|
|
568
|
+
.mockResolvedValueOnce({
|
|
569
|
+
url: "https://example.test/export",
|
|
570
|
+
filename: "table",
|
|
571
|
+
});
|
|
572
|
+
renderExportActions();
|
|
573
|
+
await openDialog();
|
|
574
|
+
|
|
575
|
+
fireEvent.click(screen.getByRole("button", { name: "Download CSV" }));
|
|
576
|
+
fireEvent.click(screen.getByRole("button", { name: "Download JSON" }));
|
|
577
|
+
await waitFor(() => {
|
|
578
|
+
expect(downloadByURL).toHaveBeenCalled();
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
await act(async () => {
|
|
582
|
+
rejectFirst(new Error("Late failure"));
|
|
583
|
+
});
|
|
584
|
+
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
it("ignores a late failure after the dialog closes", async () => {
|
|
588
|
+
let rejectDownload: (reason: Error) => void = () => undefined;
|
|
589
|
+
downloadAs.mockImplementationOnce(
|
|
590
|
+
() =>
|
|
591
|
+
new Promise((_, reject) => {
|
|
592
|
+
rejectDownload = reject;
|
|
593
|
+
}),
|
|
594
|
+
);
|
|
595
|
+
renderExportActions();
|
|
596
|
+
const dialog = await openDialog();
|
|
597
|
+
|
|
598
|
+
fireEvent.click(screen.getByRole("button", { name: "Download CSV" }));
|
|
599
|
+
fireEvent.click(within(dialog).getByRole("button", { name: "Close" }));
|
|
600
|
+
await waitFor(() => {
|
|
601
|
+
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
|
602
|
+
});
|
|
603
|
+
await openDialog();
|
|
604
|
+
|
|
605
|
+
await act(async () => {
|
|
606
|
+
rejectDownload(new Error("Late failure"));
|
|
607
|
+
});
|
|
608
|
+
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
it("closes with the close button and restores trigger focus", async () => {
|
|
612
|
+
renderExportActions();
|
|
613
|
+
const trigger = screen.getByTestId("export-button");
|
|
614
|
+
const dialog = await openDialog();
|
|
615
|
+
|
|
616
|
+
fireEvent.click(within(dialog).getByRole("button", { name: "Close" }));
|
|
617
|
+
|
|
618
|
+
await waitFor(() => {
|
|
619
|
+
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
|
620
|
+
expect(trigger).toHaveFocus();
|
|
621
|
+
});
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
it("closes with Escape and restores trigger focus", async () => {
|
|
625
|
+
renderExportActions();
|
|
626
|
+
const trigger = screen.getByTestId("export-button");
|
|
627
|
+
trigger.focus();
|
|
628
|
+
const dialog = await openDialog();
|
|
629
|
+
const closeButton = within(dialog).getByRole("button", { name: "Close" });
|
|
630
|
+
closeButton.focus();
|
|
631
|
+
|
|
632
|
+
fireEvent.keyDown(closeButton, { key: "Escape" });
|
|
633
|
+
|
|
634
|
+
await waitFor(() => {
|
|
635
|
+
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
|
636
|
+
expect(trigger).toHaveFocus();
|
|
637
|
+
});
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
it.each([
|
|
641
|
+
{
|
|
642
|
+
name: "the size check is pending",
|
|
643
|
+
props: { sizeBytesIsLoading: true },
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
name: "the export is over the host limit",
|
|
647
|
+
props: { sizeBytes: 101 },
|
|
648
|
+
},
|
|
649
|
+
])("keeps the trigger disabled when $name", ({ props }) => {
|
|
650
|
+
renderExportActions(props, {
|
|
651
|
+
limitBytes: 100,
|
|
652
|
+
unavailableMessage: "This export is too large.",
|
|
653
|
+
});
|
|
654
|
+
const trigger = screen.getByTestId("export-button");
|
|
655
|
+
|
|
656
|
+
expect(trigger).toBeDisabled();
|
|
657
|
+
expect(trigger).toHaveClass("print:hidden");
|
|
658
|
+
expect(trigger.parentElement).toHaveAttribute("tabindex", "0");
|
|
659
|
+
fireEvent.click(trigger);
|
|
660
|
+
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
|
661
|
+
});
|
|
662
|
+
});
|