@malloy-publisher/sdk 0.9.0 → 0.9.2
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/{Dashboard-H1kJlDFo.es.js → DashboardTile-BFcxdv7R.es.js} +15918 -17760
- package/dist/DashboardTile-sg8LjUk8.cjs.js +137 -0
- package/dist/RenderedResult-B48wAjM8.cjs.js +141 -0
- package/dist/{RenderedResult-BRgIgxWh.es.js → RenderedResult-CBLHr32C.es.js} +193 -183
- package/dist/{ServerProvider-Boxrv6Ym.es.js → ServerProvider-DCV8BUWD.es.js} +529 -521
- package/dist/ServerProvider-HRqT3w1C.cjs.js +1 -0
- package/dist/builder/index.cjs.js +146 -58
- package/dist/builder/index.es.js +9076 -6479
- package/dist/builder-entry.d.ts +4 -0
- package/dist/client/api.d.ts +82 -48
- package/dist/client/configuration.d.ts +1 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.es.js +84 -82
- package/dist/components/Dashboard/Dashboard.d.ts +8 -15
- package/dist/components/Dashboard/DashboardGrid.d.ts +23 -6
- package/dist/components/Dashboard/DashboardTile.d.ts +10 -1
- package/dist/components/Dashboard/DashboardView.d.ts +36 -0
- package/dist/components/Dashboard/TileCard.d.ts +15 -4
- package/dist/components/Dashboard/TileFilterTag.d.ts +12 -0
- package/dist/components/Dashboard/index.d.ts +3 -0
- package/dist/components/Dashboard/telemetry.d.ts +15 -3
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +8 -1
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +16 -5
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +29 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +48 -21
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +17 -4
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +2 -10
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +2 -2
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +3 -1
- package/dist/components/DashboardBuilder/InlineMarkdown.d.ts +18 -0
- package/dist/components/DashboardBuilder/InlineText.d.ts +19 -0
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +15 -0
- package/dist/components/DashboardBuilder/SaveNotice.d.ts +27 -0
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +19 -7
- package/dist/components/DashboardBuilder/SourceViewPicker.d.ts +9 -0
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +7 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +14 -12
- package/dist/components/DashboardBuilder/TileMenu.d.ts +11 -3
- package/dist/components/DashboardBuilder/annotationText.d.ts +4 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +4 -0
- package/dist/components/DashboardBuilder/changedTile.d.ts +7 -0
- package/dist/components/DashboardBuilder/chartLine.d.ts +33 -0
- package/dist/components/DashboardBuilder/controls.d.ts +2 -2
- package/dist/components/DashboardBuilder/document.d.ts +42 -26
- package/dist/components/DashboardBuilder/documentSession.d.ts +100 -0
- package/dist/components/DashboardBuilder/legacyNotebook.d.ts +73 -0
- package/dist/components/DashboardBuilder/loadMalloy.d.ts +15 -0
- package/dist/components/DashboardBuilder/malloyText.d.ts +45 -5
- package/dist/components/DashboardBuilder/malloyTree.d.ts +119 -0
- package/dist/components/DashboardBuilder/newDashboard.d.ts +3 -1
- package/dist/components/DashboardBuilder/openDraft.d.ts +10 -0
- package/dist/components/DashboardBuilder/preview.d.ts +24 -4
- package/dist/components/DashboardBuilder/readDocument.d.ts +4 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +16 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +14 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +13 -13
- package/dist/components/DashboardBuilder/spliceResult.d.ts +11 -0
- package/dist/components/DashboardBuilder/tagParse.d.ts +24 -0
- package/dist/components/DashboardBuilder/telemetry.d.ts +43 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +3 -1
- package/dist/components/DashboardBuilder/testing/inline.d.ts +4 -0
- package/dist/components/DashboardBuilder/useBuilderSession.d.ts +89 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +9 -6
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +17 -55
- package/dist/components/DashboardBuilder/useDocumentEditor.d.ts +105 -0
- package/dist/components/DashboardBuilder/useExitGuard.d.ts +19 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +3 -3
- package/dist/components/DocumentCreate/canRetry.d.ts +6 -0
- package/dist/components/DocumentCreate/createDocument.d.ts +58 -0
- package/dist/components/DocumentCreate/documentPath.d.ts +10 -0
- package/dist/components/DocumentCreate/events.d.ts +10 -0
- package/dist/components/DocumentCreate/exportedSources.d.ts +7 -0
- package/dist/components/DocumentCreate/guards.d.ts +12 -0
- package/dist/components/DocumentCreate/index.d.ts +6 -0
- package/dist/components/DocumentCreate/newNotebook.d.ts +9 -0
- package/dist/components/DocumentCreate/useDocumentChoices.d.ts +32 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +2 -1
- package/dist/components/NarrowEditGate.d.ts +8 -0
- package/dist/components/Notebook/Notebook.d.ts +1 -1
- package/dist/components/Package/NewDocumentDialog.d.ts +33 -0
- package/dist/components/Package/Package.d.ts +1 -0
- package/dist/components/Package/documentLocation.d.ts +28 -0
- package/dist/components/Package/index.d.ts +4 -0
- package/dist/components/Package/useDocumentLocation.d.ts +12 -0
- package/dist/components/PackageSection.d.ts +2 -2
- package/dist/components/RenderedResult/RenderedResult.d.ts +2 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +8 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +3 -1
- package/dist/components/RenderedResult/resultSizing.d.ts +9 -1
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/UnsavedChangesDialog.d.ts +9 -0
- package/dist/components/given/GivensPanel.d.ts +2 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useNarrowScreen.d.ts +4 -0
- package/dist/hooks/useQueryResult.d.ts +2 -0
- package/dist/hooks/useSettled.d.ts +14 -0
- package/dist/index.cjs.js +23 -24
- package/dist/index.es.js +9714 -7072
- package/dist/text/index.cjs.js +1 -0
- package/dist/text/index.d.ts +2 -0
- package/dist/text/index.es.js +6 -0
- package/dist/text-entry-BJwltZiy.cjs.js +7 -0
- package/dist/text-entry-CbbBcZl8.es.js +196 -0
- package/dist/text-entry.d.ts +2 -0
- package/dist/utils/clock.d.ts +2 -0
- package/package.json +10 -1
- package/src/builder-entry.ts +35 -0
- package/src/components/Dashboard/Dashboard.tsx +27 -278
- package/src/components/Dashboard/DashboardGrid.tsx +68 -7
- package/src/components/Dashboard/DashboardTile.spec.tsx +24 -0
- package/src/components/Dashboard/DashboardTile.tsx +31 -4
- package/src/components/Dashboard/DashboardView.spec.tsx +212 -0
- package/src/components/Dashboard/DashboardView.tsx +352 -0
- package/src/components/Dashboard/RowsDialog.tsx +1 -1
- package/src/components/Dashboard/TileCard.tsx +44 -10
- package/src/components/Dashboard/TileFilterTag.spec.tsx +73 -0
- package/src/components/Dashboard/TileFilterTag.tsx +78 -0
- package/src/components/Dashboard/defaultTileSpan.spec.ts +32 -0
- package/src/components/Dashboard/index.ts +3 -0
- package/src/components/Dashboard/telemetry.ts +16 -5
- package/src/components/DashboardBuilder/AddTileDialog.spec.tsx +88 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +137 -111
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +85 -27
- package/src/components/DashboardBuilder/ChartPicker.render.spec.tsx +25 -0
- package/src/components/DashboardBuilder/ChartPicker.spec.ts +77 -0
- package/src/components/DashboardBuilder/ChartPicker.tsx +153 -0
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +205 -0
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +192 -0
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +329 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +363 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +194 -0
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +157 -0
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +124 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +103 -78
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +177 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +610 -315
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +58 -8
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +191 -0
- package/src/components/DashboardBuilder/DashboardEditor.filterTag.spec.tsx +162 -0
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +316 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +56 -10
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +5 -22
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +96 -14
- package/src/components/DashboardBuilder/DashboardEditor.tsx +482 -332
- package/src/components/DashboardBuilder/DiffDialog.spec.tsx +25 -0
- package/src/components/DashboardBuilder/DiffDialog.tsx +5 -24
- package/src/components/DashboardBuilder/DrillDialog.tsx +1 -1
- package/src/components/DashboardBuilder/FilterDialog.tsx +10 -3
- package/src/components/DashboardBuilder/FilterStrip.tsx +26 -4
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +184 -0
- package/src/components/DashboardBuilder/InlineText.tsx +106 -0
- package/src/components/DashboardBuilder/NotebookEditor.tsx +44 -0
- package/src/components/DashboardBuilder/SaveNotice.tsx +113 -0
- package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +87 -0
- package/src/components/DashboardBuilder/SettingsPopover.tsx +225 -67
- package/src/components/DashboardBuilder/SourceViewPicker.tsx +122 -0
- package/src/components/DashboardBuilder/TextTileBody.tsx +28 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +89 -115
- package/src/components/DashboardBuilder/TileMenu.tsx +168 -90
- package/src/components/DashboardBuilder/annotationText.spec.ts +33 -0
- package/src/components/DashboardBuilder/annotationText.ts +17 -0
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +248 -0
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +41 -0
- package/src/components/DashboardBuilder/catalog.aggregate.spec.ts +49 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +2 -0
- package/src/components/DashboardBuilder/catalog.ts +61 -21
- package/src/components/DashboardBuilder/changedTile.spec.ts +46 -0
- package/src/components/DashboardBuilder/changedTile.ts +28 -0
- package/src/components/DashboardBuilder/chartLine.spec.ts +180 -0
- package/src/components/DashboardBuilder/chartLine.ts +121 -0
- package/src/components/DashboardBuilder/controls.spec.ts +21 -10
- package/src/components/DashboardBuilder/controls.ts +22 -8
- package/src/components/DashboardBuilder/document.ts +53 -5
- package/src/components/DashboardBuilder/documentSession.spec.ts +209 -0
- package/src/components/DashboardBuilder/documentSession.ts +257 -0
- package/src/components/DashboardBuilder/emptyStart.spec.ts +131 -0
- package/src/components/DashboardBuilder/invariants.spec.ts +6 -2
- package/src/components/DashboardBuilder/legacyNotebook.chart.spec.ts +77 -0
- package/src/components/DashboardBuilder/legacyNotebook.convert.spec.ts +630 -0
- package/src/components/DashboardBuilder/legacyNotebook.read.spec.ts +338 -0
- package/src/components/DashboardBuilder/legacyNotebook.ts +1117 -0
- package/src/components/DashboardBuilder/loadMalloy.spec.ts +80 -0
- package/src/components/DashboardBuilder/loadMalloy.ts +39 -0
- package/src/components/DashboardBuilder/malloyText.spec.ts +48 -0
- package/src/components/DashboardBuilder/malloyText.ts +181 -27
- package/src/components/DashboardBuilder/malloyTree.ts +155 -7
- package/src/components/DashboardBuilder/newDashboard.spec.ts +46 -2
- package/src/components/DashboardBuilder/newDashboard.ts +30 -3
- package/src/components/DashboardBuilder/openDraft.ts +52 -0
- package/src/components/DashboardBuilder/preview.shapes.spec.ts +75 -0
- package/src/components/DashboardBuilder/preview.spec.ts +159 -12
- package/src/components/DashboardBuilder/preview.ts +83 -9
- package/src/components/DashboardBuilder/readDocument.spec.ts +139 -27
- package/src/components/DashboardBuilder/readDocument.ts +130 -44
- package/src/components/DashboardBuilder/readForEditor.spec.ts +80 -0
- package/src/components/DashboardBuilder/readForEditor.ts +47 -0
- package/src/components/DashboardBuilder/scannerShapes.spec.ts +14 -13
- package/src/components/DashboardBuilder/sortable.spec.ts +65 -0
- package/src/components/DashboardBuilder/sortable.tsx +2 -12
- package/src/components/DashboardBuilder/spliceDocument.chart.spec.ts +340 -0
- package/src/components/DashboardBuilder/spliceDocument.imports.spec.ts +167 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +229 -94
- package/src/components/DashboardBuilder/spliceDocument.ts +762 -130
- package/src/components/DashboardBuilder/spliceResult.ts +15 -0
- package/src/components/DashboardBuilder/statementExtent.spec.ts +33 -30
- package/src/components/DashboardBuilder/tagParse.spec.ts +149 -0
- package/src/components/DashboardBuilder/tagParse.ts +103 -0
- package/src/components/DashboardBuilder/telemetry.ts +47 -0
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +197 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +16 -1
- package/src/components/DashboardBuilder/testing/inline.ts +25 -0
- package/src/components/DashboardBuilder/textTiles.spec.ts +718 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +335 -0
- package/src/components/DashboardBuilder/useBuilderSession.ts +292 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +65 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.spec.tsx +60 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +36 -10
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +16 -13
- package/src/components/DashboardBuilder/useDashboardEditor.ts +54 -181
- package/src/components/DashboardBuilder/useDocumentEditor.spec.ts +565 -0
- package/src/components/DashboardBuilder/useDocumentEditor.ts +399 -0
- package/src/components/DashboardBuilder/useExitGuard.spec.ts +159 -0
- package/src/components/DashboardBuilder/useExitGuard.ts +89 -0
- package/src/components/DashboardBuilder/useFilterForm.existing.spec.tsx +41 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +24 -2
- package/src/components/DashboardBuilder/useFilterForm.ts +41 -13
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +28 -5
- package/src/components/DashboardBuilder/useTileReorder.ts +5 -7
- package/src/components/DocumentCreate/canRetry.spec.ts +32 -0
- package/src/components/DocumentCreate/canRetry.ts +19 -0
- package/src/components/DocumentCreate/createDocument.spec.ts +310 -0
- package/src/components/DocumentCreate/createDocument.ts +159 -0
- package/src/components/DocumentCreate/documentPath.ts +40 -0
- package/src/components/DocumentCreate/events.ts +15 -0
- package/src/components/DocumentCreate/exportedSources.ts +25 -0
- package/src/components/DocumentCreate/guards.ts +45 -0
- package/src/components/DocumentCreate/index.ts +27 -0
- package/src/components/DocumentCreate/newNotebook.spec.ts +156 -0
- package/src/components/DocumentCreate/newNotebook.ts +44 -0
- package/src/components/DocumentCreate/useDocumentChoices.spec.tsx +138 -0
- package/src/components/DocumentCreate/useDocumentChoices.ts +113 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +2 -1
- package/src/components/Model/ModelExplorer.spec.tsx +2 -2
- package/src/components/Model/SourcesExplorer.tsx +2 -4
- package/src/components/NarrowEditGate.spec.tsx +73 -0
- package/src/components/NarrowEditGate.tsx +29 -0
- package/src/components/Notebook/Notebook.layout.spec.tsx +94 -0
- package/src/components/Notebook/Notebook.tsx +66 -27
- package/src/components/Package/NewDocumentDialog.spec.tsx +749 -0
- package/src/components/Package/NewDocumentDialog.tsx +401 -0
- package/src/components/Package/Package.artifacts.spec.tsx +190 -0
- package/src/components/Package/Package.create.spec.tsx +380 -0
- package/src/components/Package/Package.notebooks.spec.tsx +18 -0
- package/src/components/Package/Package.tsx +366 -171
- package/src/components/Package/documentLocation.spec.ts +81 -0
- package/src/components/Package/documentLocation.ts +55 -0
- package/src/components/Package/index.ts +13 -0
- package/src/components/Package/useDocumentLocation.ts +59 -0
- package/src/components/PackageSection.tsx +2 -2
- package/src/components/RenderedResult/RenderedResult.tsx +18 -1
- package/src/components/RenderedResult/ResultContainer.tsx +44 -11
- package/src/components/RenderedResult/ResultPanel.tsx +4 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +68 -0
- package/src/components/RenderedResult/resultSizing.ts +14 -3
- package/src/components/ServerProvider.tsx +2 -1
- package/src/components/UnsavedChangesDialog.spec.tsx +70 -0
- package/src/components/UnsavedChangesDialog.tsx +49 -0
- package/src/components/given/GivensPanel.spec.tsx +6 -6
- package/src/components/given/GivensPanel.tsx +3 -3
- package/src/components/index.ts +2 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useNarrowScreen.ts +21 -0
- package/src/hooks/useQueryResult.ts +16 -0
- package/src/hooks/useSettled.spec.ts +41 -0
- package/src/hooks/useSettled.ts +27 -0
- package/src/mainEntry.spec.ts +145 -0
- package/src/text-entry.ts +12 -0
- package/src/textEntry.spec.ts +118 -0
- package/src/utils/clock.spec.ts +12 -0
- package/src/utils/clock.ts +6 -0
- package/vite.config.ts +4 -0
- package/dist/Dashboard-ChyylkTD.cjs.js +0 -136
- package/dist/RenderedResult-AJPMUkAD.cjs.js +0 -135
- package/dist/ServerProvider-CXrOKD6g.cjs.js +0 -1
- package/dist/components/DashboardBuilder/useTileResize.d.ts +0 -29
- package/dist/components/Package/NewDashboardDialog.d.ts +0 -18
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +0 -121
- package/src/components/DashboardBuilder/useTileResize.ts +0 -110
- package/src/components/Package/NewDashboardDialog.spec.tsx +0 -129
- package/src/components/Package/NewDashboardDialog.tsx +0 -265
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
+
act,
|
|
5
6
|
fireEvent,
|
|
6
7
|
render,
|
|
7
8
|
screen,
|
|
@@ -12,6 +13,7 @@ import { describe, expect, it, mock } from "bun:test";
|
|
|
12
13
|
import type { DashboardEvent } from "../Dashboard/telemetry";
|
|
13
14
|
import { DashboardBuilder } from "./DashboardBuilder";
|
|
14
15
|
import { openDocument } from "./testing/fixtures";
|
|
16
|
+
import { closeMenu, editInline } from "./testing/inline";
|
|
15
17
|
|
|
16
18
|
const SOURCE = `## artifact { title="Storefront" tiles=["a -> by_cat", "a -> by_brand"] } dashboard { columns=12 }
|
|
17
19
|
import "../data_app.malloy"
|
|
@@ -53,19 +55,15 @@ const tile = (name: string) => screen.getByLabelText(`Tile ${name}`);
|
|
|
53
55
|
const selectTile = (name: string) => fireEvent.click(tile(name));
|
|
54
56
|
|
|
55
57
|
/**
|
|
56
|
-
* Retitle a tile
|
|
58
|
+
* Retitle a tile where it is shown.
|
|
57
59
|
*
|
|
58
60
|
* The one on-tile edit a test can drive by clicking. Width and position are
|
|
59
61
|
* dragged, which needs real element geometry that jsdom does not provide, a
|
|
60
62
|
* tile's row is set by dragging it into a gap, and filters are configured
|
|
61
63
|
* only from the strip under the header.
|
|
62
64
|
*/
|
|
63
|
-
const retitle = (title: string, next: string) =>
|
|
64
|
-
|
|
65
|
-
const field = screen.getByLabelText("Tile title");
|
|
66
|
-
fireEvent.change(field, { target: { value: next } });
|
|
67
|
-
fireEvent.keyDown(field, { key: "Escape" });
|
|
68
|
-
};
|
|
65
|
+
const retitle = (title: string, next: string) =>
|
|
66
|
+
editInline(title, "Tile title", next);
|
|
69
67
|
/**
|
|
70
68
|
* A named button, hidden or not. A window's exit transition never ends under
|
|
71
69
|
* the test runner, so once any window has been open the rest of the page reads
|
|
@@ -150,19 +148,6 @@ describe("DashboardBuilder", () => {
|
|
|
150
148
|
expect(written).not.toContain("$CATEGORY");
|
|
151
149
|
});
|
|
152
150
|
|
|
153
|
-
it("offers no resize for a tile the model owns", async () => {
|
|
154
|
-
const source = `## artifact { title="T" tiles=["orders -> by_brand"] }\nimport { orders } from '../orders.malloy'`;
|
|
155
|
-
const document = await openDocument(source);
|
|
156
|
-
render(<DashboardBuilder source={source} document={document} />);
|
|
157
|
-
selectTile("by_brand");
|
|
158
|
-
// Its tags live on the model's source, which the builder does not write,
|
|
159
|
-
// so it gets no resize handle — offering one would offer a drag the
|
|
160
|
-
// writer then refuses. It keeps its grip: order is this file's own
|
|
161
|
-
// `tiles=[…]` array, which it owns for every tile.
|
|
162
|
-
expect(within(tile("by_brand")).queryByLabelText(/^Resize /)).toBeNull();
|
|
163
|
-
expect(within(tile("by_brand")).getByLabelText(/^Move /)).toBeDefined();
|
|
164
|
-
});
|
|
165
|
-
|
|
166
151
|
// `renderTile` hands over the WHOLE tile, card and heading included, because
|
|
167
152
|
// a real `DashboardTile` draws both. Filling a card of ours would show a card
|
|
168
153
|
// in a card under two titles, which is the opposite of the point.
|
|
@@ -254,7 +239,7 @@ describe("DashboardBuilder: the dashboard's filters", () => {
|
|
|
254
239
|
);
|
|
255
240
|
await waitFor(() => expect(written).toBeDefined());
|
|
256
241
|
expect(written).toContain(
|
|
257
|
-
'# label="Brand" control=select suggest { source=scoped_orders dimension=brand }\n' +
|
|
242
|
+
'# label="Brand" control=select suggest { source=scoped_orders dimension="brand" }\n' +
|
|
258
243
|
"given: BRAND :: filter<string> is f''",
|
|
259
244
|
);
|
|
260
245
|
expect(written).toContain(
|
|
@@ -301,6 +286,30 @@ describe("DashboardBuilder: the dashboard's filters", () => {
|
|
|
301
286
|
expect(written).not.toContain("given: SINCE");
|
|
302
287
|
});
|
|
303
288
|
|
|
289
|
+
it("takes a control off from the × on its chip, the same outcome as its window's Remove", async () => {
|
|
290
|
+
let written: string | undefined;
|
|
291
|
+
const source = SOURCE.replace(
|
|
292
|
+
'import "../data_app.malloy"',
|
|
293
|
+
'import "../data_app.malloy"\n\n# label="Category"\ngiven: CATEGORY :: filter<string> is f\'\'',
|
|
294
|
+
);
|
|
295
|
+
const document = await openDocument(source);
|
|
296
|
+
render(
|
|
297
|
+
<DashboardBuilder
|
|
298
|
+
source={source}
|
|
299
|
+
document={document}
|
|
300
|
+
onSave={(next) => {
|
|
301
|
+
written = next;
|
|
302
|
+
}}
|
|
303
|
+
/>,
|
|
304
|
+
);
|
|
305
|
+
fireEvent.click(screen.getByLabelText("Remove filter CATEGORY"));
|
|
306
|
+
expect(screen.queryByLabelText("Edit filter CATEGORY")).toBeNull();
|
|
307
|
+
fireEvent.click(button("Save changes"));
|
|
308
|
+
await waitFor(() => expect(written).toBeDefined());
|
|
309
|
+
expect(written).not.toContain("CATEGORY");
|
|
310
|
+
expect(written).toContain("view: by_cat is by_category\n");
|
|
311
|
+
});
|
|
312
|
+
|
|
304
313
|
it("takes a control it declared off the dashboard, bindings and all", async () => {
|
|
305
314
|
let written: string | undefined;
|
|
306
315
|
const source = SOURCE.replace(
|
|
@@ -502,9 +511,7 @@ describe("DashboardBuilder: tiles added and removed", () => {
|
|
|
502
511
|
const submitDialog = (name: string) =>
|
|
503
512
|
fireEvent.click(screen.getByRole("button", { name, hidden: false }));
|
|
504
513
|
|
|
505
|
-
|
|
506
|
-
// the file cannot say whose comment sits beside them.
|
|
507
|
-
it("adds a tile from the catalog, and saves it through the diff", async () => {
|
|
514
|
+
it("adds a tile from the catalog, and saves it at once", async () => {
|
|
508
515
|
let written: string | undefined;
|
|
509
516
|
await mountWithCatalog((source) => {
|
|
510
517
|
written = source;
|
|
@@ -520,13 +527,8 @@ describe("DashboardBuilder: tiles added and removed", () => {
|
|
|
520
527
|
fireEvent.click(
|
|
521
528
|
screen.getByRole("button", { name: "Save changes", hidden: true }),
|
|
522
529
|
);
|
|
523
|
-
await waitFor(() =>
|
|
524
|
-
expect(screen.getByLabelText("File changes")).toBeDefined(),
|
|
525
|
-
);
|
|
526
|
-
// Nothing written until the diff is approved.
|
|
527
|
-
expect(written).toBeUndefined();
|
|
528
|
-
fireEvent.click(screen.getByRole("button", { name: "Save this" }));
|
|
529
530
|
await waitFor(() => expect(written).toBeDefined());
|
|
531
|
+
expect(await screen.findByText(/Added a tile/)).toBeDefined();
|
|
530
532
|
expect(written).toContain(
|
|
531
533
|
'tiles=["a -> by_cat", "a -> by_brand", "a -> sales_by_state_tile"]',
|
|
532
534
|
);
|
|
@@ -535,7 +537,7 @@ describe("DashboardBuilder: tiles added and removed", () => {
|
|
|
535
537
|
);
|
|
536
538
|
});
|
|
537
539
|
|
|
538
|
-
it("removes a tile from its menu, and saves it
|
|
540
|
+
it("removes a tile from its menu, and saves it at once", async () => {
|
|
539
541
|
let written: string | undefined;
|
|
540
542
|
await mountWithCatalog((source) => {
|
|
541
543
|
written = source;
|
|
@@ -547,11 +549,8 @@ describe("DashboardBuilder: tiles added and removed", () => {
|
|
|
547
549
|
fireEvent.click(
|
|
548
550
|
screen.getByRole("button", { name: "Save changes", hidden: true }),
|
|
549
551
|
);
|
|
550
|
-
await waitFor(() =>
|
|
551
|
-
expect(screen.getByLabelText("File changes")).toBeDefined(),
|
|
552
|
-
);
|
|
553
|
-
fireEvent.click(screen.getByRole("button", { name: "Save this" }));
|
|
554
552
|
await waitFor(() => expect(written).toBeDefined());
|
|
553
|
+
expect(await screen.findByText(/Removed 1 tile/)).toBeDefined();
|
|
555
554
|
expect(written).toContain('tiles=["a -> by_brand"]');
|
|
556
555
|
expect(written).not.toContain("view: by_cat");
|
|
557
556
|
// The comment above the removed tile is still in the file.
|
|
@@ -559,47 +558,47 @@ describe("DashboardBuilder: tiles added and removed", () => {
|
|
|
559
558
|
" // Kept, because a splice never rewrites what it did not change.",
|
|
560
559
|
);
|
|
561
560
|
});
|
|
561
|
+
});
|
|
562
562
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
await
|
|
566
|
-
written = source;
|
|
567
|
-
});
|
|
563
|
+
describe("DashboardBuilder: the last tile", () => {
|
|
564
|
+
it("cannot be removed while the saved dashboard has tiles, and says why on screen", async () => {
|
|
565
|
+
await mount();
|
|
568
566
|
fireEvent.click(screen.getByLabelText("Settings for By category"));
|
|
569
567
|
fireEvent.click(screen.getByRole("button", { name: "Remove tile" }));
|
|
570
|
-
fireEvent.click(
|
|
571
|
-
|
|
572
|
-
);
|
|
573
|
-
|
|
574
|
-
|
|
568
|
+
fireEvent.click(screen.getByLabelText("Settings for by_brand"));
|
|
569
|
+
const remove = screen.getByRole("button", { name: /Remove tile/ });
|
|
570
|
+
expect(remove.getAttribute("aria-disabled")).toBe("true");
|
|
571
|
+
const reason = screen.getByText(
|
|
572
|
+
"A saved dashboard needs at least one tile.",
|
|
575
573
|
);
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
expect(
|
|
579
|
-
screen.getByRole("button", { name: "Save changes", hidden: true }),
|
|
580
|
-
).toBeDefined();
|
|
574
|
+
expect(remove.getAttribute("aria-describedby")).toBe(reason.id);
|
|
575
|
+
fireEvent.click(remove);
|
|
576
|
+
expect(screen.getByLabelText("Tile by_brand")).toBeDefined();
|
|
581
577
|
});
|
|
582
578
|
});
|
|
583
579
|
|
|
584
580
|
describe("DashboardBuilder: a tile's own settings", () => {
|
|
585
|
-
it("retitles a tile
|
|
581
|
+
it("retitles a tile where it is shown, one history entry per commit", async () => {
|
|
586
582
|
await mount();
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
fireEvent.keyDown(screen.getByLabelText("Tile title"), { key: "Escape" });
|
|
583
|
+
editInline("By category", "Tile title", "Revenue by category");
|
|
584
|
+
editInline(
|
|
585
|
+
"Add a subtitle",
|
|
586
|
+
"Tile subtitle",
|
|
587
|
+
"Net of returns",
|
|
588
|
+
"Enter",
|
|
589
|
+
tile("by_cat"),
|
|
590
|
+
);
|
|
596
591
|
expect(
|
|
597
592
|
within(tile("by_cat")).getByText("Revenue by category"),
|
|
598
593
|
).toBeDefined();
|
|
599
594
|
expect(within(tile("by_cat")).getByText("Net of returns")).toBeDefined();
|
|
600
595
|
fireEvent.click(button("Undo"));
|
|
601
|
-
expect(within(tile("by_cat")).getByText("By category")).toBeDefined();
|
|
602
596
|
expect(within(tile("by_cat")).queryByText("Net of returns")).toBeNull();
|
|
597
|
+
expect(
|
|
598
|
+
within(tile("by_cat")).getByText("Revenue by category"),
|
|
599
|
+
).toBeDefined();
|
|
600
|
+
fireEvent.click(button("Undo"));
|
|
601
|
+
expect(within(tile("by_cat")).getByText("By category")).toBeDefined();
|
|
603
602
|
});
|
|
604
603
|
|
|
605
604
|
it("offers no title to a tile the model owns", async () => {
|
|
@@ -609,6 +608,9 @@ describe("DashboardBuilder: a tile's own settings", () => {
|
|
|
609
608
|
fireEvent.click(screen.getByLabelText("Settings for by_brand"));
|
|
610
609
|
expect(screen.queryByLabelText("Tile title")).toBeNull();
|
|
611
610
|
expect(screen.getByText(/Declared on its source/)).toBeDefined();
|
|
611
|
+
// Nor does its title open into a field on the tile.
|
|
612
|
+
fireEvent.click(screen.getByText("by_brand"));
|
|
613
|
+
expect(screen.queryByLabelText("Tile title")).toBeNull();
|
|
612
614
|
});
|
|
613
615
|
});
|
|
614
616
|
|
|
@@ -619,7 +621,7 @@ describe("DashboardBuilder: widths and the page's own settings", () => {
|
|
|
619
621
|
const third = screen.getByRole("button", { name: "Width ⅓" });
|
|
620
622
|
fireEvent.click(third);
|
|
621
623
|
expect(third.getAttribute("aria-pressed")).toBe("true");
|
|
622
|
-
|
|
624
|
+
closeMenu();
|
|
623
625
|
// 12 columns, a third is 4.
|
|
624
626
|
expect(itemStyleOf("by_cat")).toContain("grid-column: span 4");
|
|
625
627
|
expect(itemStyleOf("by_brand")).toContain("grid-column: span 6");
|
|
@@ -630,24 +632,22 @@ describe("DashboardBuilder: widths and the page's own settings", () => {
|
|
|
630
632
|
await mount((source) => {
|
|
631
633
|
saved = source;
|
|
632
634
|
});
|
|
633
|
-
fireEvent.click(
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
});
|
|
637
|
-
fireEvent.change(screen.getByLabelText("Dashboard description"), {
|
|
635
|
+
fireEvent.click(screen.getByText("Add a description"));
|
|
636
|
+
const description = screen.getByLabelText("Markdown");
|
|
637
|
+
fireEvent.change(description, {
|
|
638
638
|
target: { value: "What sold, and where." },
|
|
639
639
|
});
|
|
640
|
+
// Escape is Done: the text commits.
|
|
641
|
+
fireEvent.keyDown(description, { key: "Escape" });
|
|
642
|
+
expect(screen.getByText("What sold, and where.")).toBeDefined();
|
|
643
|
+
|
|
644
|
+
fireEvent.click(button("Settings"));
|
|
640
645
|
fireEvent.click(screen.getByLabelText("Run as controls change"));
|
|
641
646
|
// Closing commits, once.
|
|
642
|
-
fireEvent.keyDown(screen.getByLabelText("
|
|
643
|
-
|
|
644
|
-
|
|
647
|
+
fireEvent.keyDown(screen.getByLabelText("Show as"), { key: "Escape" });
|
|
648
|
+
|
|
649
|
+
editInline("Storefront", "Dashboard title", "Storefront, weekly");
|
|
645
650
|
expect(screen.getByText("Storefront, weekly")).toBeDefined();
|
|
646
|
-
// The popover's own field still holds the text (its exit transition
|
|
647
|
-
// never ends under the test runner), so look for the page's copy.
|
|
648
|
-
expect(
|
|
649
|
-
screen.getAllByText("What sold, and where.").length,
|
|
650
|
-
).toBeGreaterThan(0);
|
|
651
651
|
|
|
652
652
|
fireEvent.click(button("Save changes"));
|
|
653
653
|
await waitFor(() => expect(saved).not.toBe(""));
|
|
@@ -689,7 +689,7 @@ source: a is scoped_orders extend {
|
|
|
689
689
|
/>,
|
|
690
690
|
);
|
|
691
691
|
fireEvent.click(screen.getByLabelText("Settings for x"));
|
|
692
|
-
fireEvent.click(button("
|
|
692
|
+
fireEvent.click(button("Drill-through…"));
|
|
693
693
|
|
|
694
694
|
fireEvent.mouseDown(
|
|
695
695
|
screen.getByRole("combobox", { name: /Clicks go to/, hidden: true }),
|
|
@@ -724,7 +724,7 @@ source: a is scoped_orders extend {
|
|
|
724
724
|
it("explains itself when the source declares no dimension here", async () => {
|
|
725
725
|
await mount();
|
|
726
726
|
fireEvent.click(screen.getByLabelText("Settings for By category"));
|
|
727
|
-
fireEvent.click(button("
|
|
727
|
+
fireEvent.click(button("Drill-through…"));
|
|
728
728
|
expect(
|
|
729
729
|
screen.getByText(/declares no dimensions of its own/),
|
|
730
730
|
).toBeDefined();
|
|
@@ -749,9 +749,10 @@ describe("DashboardBuilder: keyboard", () => {
|
|
|
749
749
|
expect(within(tile("by_cat")).getByText("Renamed")).toBeDefined();
|
|
750
750
|
|
|
751
751
|
// Typing in a field is typing, not editing the document.
|
|
752
|
-
fireEvent.click(screen.
|
|
752
|
+
fireEvent.click(screen.getByText("Renamed"));
|
|
753
753
|
const field = screen.getByLabelText("Tile title");
|
|
754
754
|
fireEvent.keyDown(field, { key: "z", ctrlKey: true, metaKey: true });
|
|
755
|
+
fireEvent.keyDown(field, { key: "Escape" });
|
|
755
756
|
expect(within(tile("by_cat")).getByText("Renamed")).toBeDefined();
|
|
756
757
|
});
|
|
757
758
|
|
|
@@ -764,6 +765,30 @@ describe("DashboardBuilder: keyboard", () => {
|
|
|
764
765
|
fireEvent.keyDown(window, { key: "ArrowRight" });
|
|
765
766
|
expect(itemStyleOf("by_cat")).toContain("grid-column: span 7");
|
|
766
767
|
});
|
|
768
|
+
|
|
769
|
+
it("leaves a tile's width alone while the arrow keys move it", async () => {
|
|
770
|
+
await mount();
|
|
771
|
+
selectTile("by_cat");
|
|
772
|
+
// happy-dom has no Web Animations; the sensor asks for them on pickup.
|
|
773
|
+
Object.assign(document, { getAnimations: () => [] });
|
|
774
|
+
Object.assign(Element.prototype, { getAnimations: () => [] });
|
|
775
|
+
const grip = within(tile("by_cat")).getByLabelText(/^Move /);
|
|
776
|
+
grip.focus();
|
|
777
|
+
fireEvent.keyDown(grip, { key: " ", code: "Space" });
|
|
778
|
+
// The drag clone is the proof the pickup landed.
|
|
779
|
+
await waitFor(() =>
|
|
780
|
+
expect(screen.getAllByLabelText("Tile by_cat")).toHaveLength(2),
|
|
781
|
+
);
|
|
782
|
+
// The drag-start state commits a frame after the clone appears.
|
|
783
|
+
await act(async () => {});
|
|
784
|
+
fireEvent.keyDown(grip, { key: "ArrowRight", code: "ArrowRight" });
|
|
785
|
+
// A cancel, not a drop: a drop re-commits the drag-start width and would hide a nudge.
|
|
786
|
+
fireEvent.keyDown(grip, { key: "Escape", code: "Escape" });
|
|
787
|
+
await waitFor(() =>
|
|
788
|
+
expect(screen.getAllByLabelText("Tile by_cat")).toHaveLength(1),
|
|
789
|
+
);
|
|
790
|
+
expect(itemStyleOf("by_cat")).toContain("grid-column: span 6");
|
|
791
|
+
});
|
|
767
792
|
});
|
|
768
793
|
|
|
769
794
|
describe("DashboardBuilder: history", () => {
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
act,
|
|
6
|
+
fireEvent,
|
|
7
|
+
render,
|
|
8
|
+
renderHook,
|
|
9
|
+
screen,
|
|
10
|
+
waitFor,
|
|
11
|
+
within,
|
|
12
|
+
} from "@testing-library/react";
|
|
13
|
+
import { describe, expect, it } from "bun:test";
|
|
14
|
+
import { DashboardBuilder } from "./DashboardBuilder";
|
|
15
|
+
import { isTextTile } from "./document";
|
|
16
|
+
import { openDocument } from "./testing/fixtures";
|
|
17
|
+
import { TEXT_TILE_PLACEHOLDER } from "./TextTileBody";
|
|
18
|
+
import { useDashboardEditor } from "./useDashboardEditor";
|
|
19
|
+
|
|
20
|
+
const SOURCE = `## artifact { title="Storefront" tiles=[intro { kind=text colspan=12 }, "a -> by_cat", empty { kind=text }] } dashboard { columns=12 }
|
|
21
|
+
import "../data_app.malloy"
|
|
22
|
+
|
|
23
|
+
##|(markdown) intro
|
|
24
|
+
# Welcome
|
|
25
|
+
|
|
26
|
+
Read **this** first, then [the docs](https://example.com/docs).
|
|
27
|
+
|##
|
|
28
|
+
|
|
29
|
+
##|(markdown) empty
|
|
30
|
+
|##
|
|
31
|
+
|
|
32
|
+
source: a is scoped_orders extend {
|
|
33
|
+
# colspan=12
|
|
34
|
+
view: by_cat is by_category
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
const catalog = {
|
|
39
|
+
sources: [
|
|
40
|
+
{
|
|
41
|
+
name: "scoped_orders",
|
|
42
|
+
modelPath: "data_app.malloy",
|
|
43
|
+
views: [{ name: "sales_by_state" }],
|
|
44
|
+
givens: [],
|
|
45
|
+
fields: [],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const mount = async (onSave?: (source: string) => void) => {
|
|
51
|
+
const document = await openDocument(SOURCE);
|
|
52
|
+
return render(
|
|
53
|
+
<DashboardBuilder
|
|
54
|
+
source={SOURCE}
|
|
55
|
+
document={document}
|
|
56
|
+
catalog={catalog}
|
|
57
|
+
{...(onSave ? { onSave } : {})}
|
|
58
|
+
/>,
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const tile = (name: string) => screen.getByLabelText(`Tile ${name}`);
|
|
63
|
+
const button = (name: string) =>
|
|
64
|
+
screen.getByRole("button", { name, hidden: true });
|
|
65
|
+
|
|
66
|
+
describe("DashboardBuilder: text tiles", () => {
|
|
67
|
+
it("draws a text tile's markdown, and a hint while it is empty", async () => {
|
|
68
|
+
await mount();
|
|
69
|
+
expect(
|
|
70
|
+
within(tile("intro")).getByRole("heading", { name: "Welcome" }),
|
|
71
|
+
).toBeDefined();
|
|
72
|
+
expect(within(tile("intro")).getByText("this")).toBeDefined();
|
|
73
|
+
expect(
|
|
74
|
+
within(tile("empty")).getByText(TEXT_TILE_PLACEHOLDER),
|
|
75
|
+
).toBeDefined();
|
|
76
|
+
expect(
|
|
77
|
+
within(tile("intro")).queryByText(TEXT_TILE_PLACEHOLDER),
|
|
78
|
+
).toBeNull();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("does not follow a link inside a tile being arranged", async () => {
|
|
82
|
+
await mount();
|
|
83
|
+
const link = within(tile("intro")).getByRole("link", {
|
|
84
|
+
name: "the docs",
|
|
85
|
+
});
|
|
86
|
+
// fireEvent returns false when the default action was prevented.
|
|
87
|
+
expect(fireEvent.click(link)).toBe(false);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("adds an empty text tile from the Add dialog, and saves its block and entry", async () => {
|
|
91
|
+
let written: string | undefined;
|
|
92
|
+
await mount((source) => {
|
|
93
|
+
written = source;
|
|
94
|
+
});
|
|
95
|
+
fireEvent.click(button("Add tile"));
|
|
96
|
+
fireEvent.click(screen.getByRole("button", { name: "Text" }));
|
|
97
|
+
fireEvent.click(screen.getByRole("button", { name: "Add text" }));
|
|
98
|
+
expect(
|
|
99
|
+
within(tile("text_1")).getByText(TEXT_TILE_PLACEHOLDER),
|
|
100
|
+
).toBeDefined();
|
|
101
|
+
|
|
102
|
+
fireEvent.click(button("Save changes"));
|
|
103
|
+
await waitFor(() => expect(written).toBeDefined());
|
|
104
|
+
expect(written).toContain(
|
|
105
|
+
'tiles=[intro { kind=text colspan=12 }, "a -> by_cat", empty { kind=text }, text_1 { kind=text colspan=12 }]',
|
|
106
|
+
);
|
|
107
|
+
expect(written).toContain("##|(markdown) text_1\n|##");
|
|
108
|
+
// What was there is untouched.
|
|
109
|
+
expect(written).toContain("##|(markdown) intro\n# Welcome");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("names each new text tile for the first free number", async () => {
|
|
113
|
+
await mount();
|
|
114
|
+
for (const expected of ["text_1", "text_2"]) {
|
|
115
|
+
fireEvent.click(button("Add tile"));
|
|
116
|
+
fireEvent.click(screen.getByRole("button", { name: "Text" }));
|
|
117
|
+
fireEvent.click(screen.getByRole("button", { name: "Add text" }));
|
|
118
|
+
expect(tile(expected)).toBeDefined();
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("sets a text tile's width from its menu, which offers no title or chart", async () => {
|
|
123
|
+
let written: string | undefined;
|
|
124
|
+
await mount((source) => {
|
|
125
|
+
written = source;
|
|
126
|
+
});
|
|
127
|
+
fireEvent.click(screen.getByLabelText("Settings for intro"));
|
|
128
|
+
expect(screen.queryByLabelText("Tile title")).toBeNull();
|
|
129
|
+
expect(screen.queryByText("Drill-through…")).toBeNull();
|
|
130
|
+
fireEvent.click(screen.getByRole("button", { name: "Width ½" }));
|
|
131
|
+
fireEvent.keyDown(screen.getByRole("button", { name: "Width ½" }), {
|
|
132
|
+
key: "Escape",
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
fireEvent.click(button("Save changes"));
|
|
136
|
+
await waitFor(() => expect(written).toBeDefined());
|
|
137
|
+
expect(written).toContain("intro { kind=text colspan=6 }");
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("removes a text tile from its menu, block and entry together", async () => {
|
|
141
|
+
let written: string | undefined;
|
|
142
|
+
await mount((source) => {
|
|
143
|
+
written = source;
|
|
144
|
+
});
|
|
145
|
+
fireEvent.click(screen.getByLabelText("Settings for intro"));
|
|
146
|
+
fireEvent.click(screen.getByRole("button", { name: "Remove tile" }));
|
|
147
|
+
expect(screen.queryByLabelText("Tile intro")).toBeNull();
|
|
148
|
+
|
|
149
|
+
fireEvent.click(button("Save changes"));
|
|
150
|
+
await waitFor(() => expect(written).toBeDefined());
|
|
151
|
+
expect(written).toContain('tiles=["a -> by_cat", empty { kind=text }]');
|
|
152
|
+
expect(written).not.toContain("##|(markdown) intro");
|
|
153
|
+
expect(written).toContain("##|(markdown) empty");
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("edits a text tile's markdown through the document, and writes the block", async () => {
|
|
157
|
+
const document = await openDocument(SOURCE);
|
|
158
|
+
const view = renderHook(() =>
|
|
159
|
+
useDashboardEditor({ source: SOURCE, document, onSave: () => {} }),
|
|
160
|
+
);
|
|
161
|
+
act(() =>
|
|
162
|
+
view.result.current.update((draft) => {
|
|
163
|
+
const intro = draft.tiles.find(isTextTile);
|
|
164
|
+
if (intro) intro.markdown = "# Welcome back";
|
|
165
|
+
}),
|
|
166
|
+
);
|
|
167
|
+
let outcome: { ok: boolean } | undefined;
|
|
168
|
+
await act(async () => {
|
|
169
|
+
outcome = await view.result.current.save();
|
|
170
|
+
});
|
|
171
|
+
expect(outcome?.ok).toBe(true);
|
|
172
|
+
expect(view.result.current.source).toContain(
|
|
173
|
+
"##|(markdown) intro\n# Welcome back\n|##",
|
|
174
|
+
);
|
|
175
|
+
expect(view.result.current.source).not.toContain("Read **this** first");
|
|
176
|
+
});
|
|
177
|
+
});
|