@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
|
@@ -47,6 +47,7 @@ source: a is scoped_orders extend {
|
|
|
47
47
|
# label="By category"
|
|
48
48
|
view: by_cat is by_category
|
|
49
49
|
}`;
|
|
50
|
+
import { editInline } from "./testing/inline";
|
|
50
51
|
const withTitle = (title: string) =>
|
|
51
52
|
PACKAGE_FILE.replace('title="Storefront"', `title="${title}"`);
|
|
52
53
|
|
|
@@ -217,11 +218,7 @@ const button = (name: string | RegExp) =>
|
|
|
217
218
|
|
|
218
219
|
/** Rename the one tile, which is a non-structural edit and saves directly. */
|
|
219
220
|
const renameTile = (to: string, from = "By category") => {
|
|
220
|
-
|
|
221
|
-
fireEvent.change(screen.getByLabelText("Tile title"), {
|
|
222
|
-
target: { value: to },
|
|
223
|
-
});
|
|
224
|
-
fireEvent.keyDown(screen.getByLabelText("Tile title"), { key: "Escape" });
|
|
221
|
+
editInline(from, "Tile title", to);
|
|
225
222
|
};
|
|
226
223
|
|
|
227
224
|
/**
|
|
@@ -363,13 +360,27 @@ describe("DashboardEditor, when the host's store is the record", () => {
|
|
|
363
360
|
expect(opens[0]).toMatchObject({ from: "record" });
|
|
364
361
|
});
|
|
365
362
|
|
|
366
|
-
it("says where the record is,
|
|
363
|
+
it("says where the record is once, as the Save caption", async () => {
|
|
367
364
|
const storage = new FakeStorage(RECORD);
|
|
368
365
|
storage.documents.set(PATH, PACKAGE_FILE);
|
|
369
366
|
mount(storage);
|
|
367
|
+
await screen.findByText("Storefront");
|
|
370
368
|
expect(
|
|
371
|
-
await screen.
|
|
372
|
-
).
|
|
369
|
+
(await screen.findAllByText("Saved to the draft branch")).length,
|
|
370
|
+
).toBe(1);
|
|
371
|
+
expect(screen.queryByText(/embedded in/)).toBeNull();
|
|
372
|
+
expect(screen.queryByText(/host app/)).toBeNull();
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it("keeps the generic Save caption, once, when the workspace says nothing", async () => {
|
|
376
|
+
const { description: _omitted, ...bare } = RECORD;
|
|
377
|
+
const storage = new FakeStorage(bare as Workspace);
|
|
378
|
+
storage.documents.set(PATH, PACKAGE_FILE);
|
|
379
|
+
mount(storage);
|
|
380
|
+
await screen.findByText("Storefront");
|
|
381
|
+
expect(
|
|
382
|
+
screen.getAllByText("Saves to the app this is embedded in").length,
|
|
383
|
+
).toBe(1);
|
|
373
384
|
});
|
|
374
385
|
|
|
375
386
|
it("keeps a reader out when the record could not be read", async () => {
|
|
@@ -568,6 +579,39 @@ describe("DashboardEditor, after a save", () => {
|
|
|
568
579
|
expect(screen.queryByText(/changed since you opened it/)).toBeNull();
|
|
569
580
|
});
|
|
570
581
|
|
|
582
|
+
it("holds a new version back behind the banner while the save can still be undone, rather than remounting", async () => {
|
|
583
|
+
serverContext.mutable = true;
|
|
584
|
+
mount(new FakeStorage(BESIDE));
|
|
585
|
+
|
|
586
|
+
await screen.findByText("Storefront");
|
|
587
|
+
renameTile("Categories");
|
|
588
|
+
fireEvent.click(button("Save changes"));
|
|
589
|
+
await waitFor(() => expect(button("Saved")).toBeDefined());
|
|
590
|
+
await settle();
|
|
591
|
+
|
|
592
|
+
await packageChangedTo(withTitle("Elsewhere"));
|
|
593
|
+
expect(screen.getByText(/changed since you opened it/)).toBeDefined();
|
|
594
|
+
expect(screen.queryByText("Elsewhere")).toBeNull();
|
|
595
|
+
// Same mount: the history the save left is still there.
|
|
596
|
+
expect(screen.getByLabelText("Settings for Categories")).toBeDefined();
|
|
597
|
+
expect(button("Undo").hasAttribute("disabled")).toBe(false);
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
it("says loading a held version drops Undo save, not the edits, when nothing is unsaved", async () => {
|
|
601
|
+
serverContext.mutable = true;
|
|
602
|
+
mount(new FakeStorage(BESIDE));
|
|
603
|
+
|
|
604
|
+
await screen.findByText("Storefront");
|
|
605
|
+
renameTile("Categories");
|
|
606
|
+
fireEvent.click(button("Save changes"));
|
|
607
|
+
await waitFor(() => expect(button("Saved")).toBeDefined());
|
|
608
|
+
await settle();
|
|
609
|
+
|
|
610
|
+
await packageChangedTo(withTitle("Elsewhere"));
|
|
611
|
+
expect(screen.getByText(/drops Undo save/)).toBeDefined();
|
|
612
|
+
expect(screen.queryByText(/Your edits are still here/)).toBeNull();
|
|
613
|
+
});
|
|
614
|
+
|
|
571
615
|
it("offers a version another writer landed while the save was in flight", async () => {
|
|
572
616
|
// The case compare-and-swap exists for: this editor's write never comes
|
|
573
617
|
// back, because someone else's landed after it. Reading "the fetch does
|
|
@@ -582,6 +626,9 @@ describe("DashboardEditor, after a save", () => {
|
|
|
582
626
|
await settle();
|
|
583
627
|
|
|
584
628
|
await packageChangedTo(withTitle("Elsewhere"));
|
|
629
|
+
// Held while the save can still be undone, then loaded when asked.
|
|
630
|
+
expect(screen.getByText(/changed since you opened it/)).toBeDefined();
|
|
631
|
+
fireEvent.click(button("Load it"));
|
|
585
632
|
expect(await screen.findByText("Elsewhere")).toBeDefined();
|
|
586
633
|
});
|
|
587
634
|
|
|
@@ -598,6 +645,9 @@ describe("DashboardEditor, after a save", () => {
|
|
|
598
645
|
await settle();
|
|
599
646
|
|
|
600
647
|
await packageChangedTo(withTitle("Elsewhere"));
|
|
648
|
+
// Held while the save can still be undone, then loaded when asked.
|
|
649
|
+
expect(screen.getByText(/changed since you opened it/)).toBeDefined();
|
|
650
|
+
fireEvent.click(button("Load it"));
|
|
601
651
|
expect(await screen.findByText("Elsewhere")).toBeDefined();
|
|
602
652
|
});
|
|
603
653
|
});
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
5
|
+
import { beforeEach, describe, expect, it, mock } from "bun:test";
|
|
6
|
+
import { globalQueryClient } from "../../utils/queryClient";
|
|
7
|
+
import {
|
|
8
|
+
clearCache,
|
|
9
|
+
mockServerProvider,
|
|
10
|
+
pending,
|
|
11
|
+
serverWrapper,
|
|
12
|
+
} from "../../../test/serverProvider";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A dashboard created empty, on a server that takes writes: once a save puts
|
|
16
|
+
* its first tile in the package the server serves it, so the manifest (and the
|
|
17
|
+
* controls it carries) is fetched then, once.
|
|
18
|
+
*/
|
|
19
|
+
const PACKAGE_FILE = `## artifact { title="Storefront" tiles=["a -> by_cat"] } dashboard { columns=12 }
|
|
20
|
+
import { scoped_orders } from "../data_app.malloy"
|
|
21
|
+
|
|
22
|
+
source: a is scoped_orders extend {
|
|
23
|
+
# colspan=6
|
|
24
|
+
# label="By category"
|
|
25
|
+
view: by_cat is by_category
|
|
26
|
+
}`;
|
|
27
|
+
|
|
28
|
+
const served = PACKAGE_FILE.replace('tiles=["a -> by_cat"]', "tiles=[]");
|
|
29
|
+
|
|
30
|
+
const getModel = mock((_env: string, _pkg: string, path: string) =>
|
|
31
|
+
path === "broken.malloy"
|
|
32
|
+
? Promise.reject(new Error("reloading"))
|
|
33
|
+
: Promise.resolve({
|
|
34
|
+
data:
|
|
35
|
+
path === "dashboards/overview.malloy"
|
|
36
|
+
? { modelPath: path, sourceText: served }
|
|
37
|
+
: {
|
|
38
|
+
modelPath: path,
|
|
39
|
+
sources: [
|
|
40
|
+
{
|
|
41
|
+
name: "scoped_orders",
|
|
42
|
+
views: [
|
|
43
|
+
{ name: "by_category" },
|
|
44
|
+
{ name: "by_brand" },
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
sourceInfos: [
|
|
49
|
+
JSON.stringify({
|
|
50
|
+
name: "scoped_orders",
|
|
51
|
+
schema: {
|
|
52
|
+
fields: [
|
|
53
|
+
{
|
|
54
|
+
name: "cat",
|
|
55
|
+
kind: "dimension",
|
|
56
|
+
type: { kind: "string_type" },
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
const getDashboard = mock(() =>
|
|
66
|
+
Promise.resolve({
|
|
67
|
+
data: {
|
|
68
|
+
path: "dashboards/overview.malloy",
|
|
69
|
+
givens: [],
|
|
70
|
+
tiles: [],
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
74
|
+
const updateModelSource = mock(
|
|
75
|
+
(_env: string, _pkg: string, path: string, body: { source: string }) =>
|
|
76
|
+
Promise.resolve({
|
|
77
|
+
data: {
|
|
78
|
+
path,
|
|
79
|
+
contentHash: `hash-of-${body.source.length}`,
|
|
80
|
+
created: false,
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
);
|
|
84
|
+
const listDashboards = mock(() =>
|
|
85
|
+
Promise.resolve({ data: [{ name: "overview" }, { name: "regions" }] }),
|
|
86
|
+
);
|
|
87
|
+
const executeQueryModel = mock(() => pending());
|
|
88
|
+
// What the package publishes: the catalog is built from these, not from
|
|
89
|
+
// whatever file the dashboard imports.
|
|
90
|
+
const listModels = mock(() =>
|
|
91
|
+
Promise.resolve({ data: [{ path: "data_app.malloy" }] }),
|
|
92
|
+
);
|
|
93
|
+
mockServerProvider(
|
|
94
|
+
{
|
|
95
|
+
models: { getModel, executeQueryModel, listModels, updateModelSource },
|
|
96
|
+
dashboards: { getDashboard, listDashboards },
|
|
97
|
+
},
|
|
98
|
+
{ mutable: true },
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
// Imported after the stub is registered: a static import would hoist above it.
|
|
102
|
+
const { DashboardEditor } = await import("./DashboardEditor");
|
|
103
|
+
|
|
104
|
+
beforeEach(() => {
|
|
105
|
+
clearCache();
|
|
106
|
+
getDashboard.mockClear();
|
|
107
|
+
updateModelSource.mockClear();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const saveFirstTile = async () => {
|
|
111
|
+
fireEvent.click(
|
|
112
|
+
(
|
|
113
|
+
await screen.findAllByRole("button", {
|
|
114
|
+
name: "Add tile",
|
|
115
|
+
hidden: true,
|
|
116
|
+
})
|
|
117
|
+
)[0],
|
|
118
|
+
);
|
|
119
|
+
fireEvent.click(await screen.findByLabelText("View by_brand"));
|
|
120
|
+
fireEvent.click(screen.getByRole("button", { name: "Add tile" }));
|
|
121
|
+
fireEvent.click(
|
|
122
|
+
screen.getByRole("button", { name: "Save changes", hidden: true }),
|
|
123
|
+
);
|
|
124
|
+
await waitFor(() => expect(updateModelSource).toHaveBeenCalledTimes(1));
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const manifestQuery = () =>
|
|
128
|
+
globalQueryClient
|
|
129
|
+
.getQueryCache()
|
|
130
|
+
.findAll({ queryKey: ["dashboard-editor-manifest"] })[0];
|
|
131
|
+
|
|
132
|
+
describe("DashboardEditor, starting empty", () => {
|
|
133
|
+
it("stops asking for the manifest once an undone save leaves the file with no tile, and undoes against the save's hash", async () => {
|
|
134
|
+
render(
|
|
135
|
+
<DashboardEditor
|
|
136
|
+
environmentName="env"
|
|
137
|
+
packageName="pkg"
|
|
138
|
+
dashboardName="overview"
|
|
139
|
+
/>,
|
|
140
|
+
{ wrapper: serverWrapper },
|
|
141
|
+
);
|
|
142
|
+
await screen.findByText(/not served until it has a tile/);
|
|
143
|
+
await saveFirstTile();
|
|
144
|
+
await waitFor(() => expect(getDashboard).toHaveBeenCalledTimes(1));
|
|
145
|
+
expect(manifestQuery()?.isDisabled()).toBe(false);
|
|
146
|
+
const written = updateModelSource.mock.calls[0][3].source;
|
|
147
|
+
|
|
148
|
+
fireEvent.click(await screen.findByRole("button", { name: "Undo save" }));
|
|
149
|
+
await waitFor(() => expect(updateModelSource).toHaveBeenCalledTimes(2));
|
|
150
|
+
expect(updateModelSource).toHaveBeenCalledTimes(2);
|
|
151
|
+
const [, , , body] = updateModelSource.mock.calls[1];
|
|
152
|
+
expect(body.source).toBe(served);
|
|
153
|
+
expect((body as { expectedHash?: string }).expectedHash).toBe(
|
|
154
|
+
`hash-of-${written.length}`,
|
|
155
|
+
);
|
|
156
|
+
await waitFor(() => expect(manifestQuery()?.isDisabled()).toBe(true));
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("fetches the manifest once, after the save that gives it its first tile", async () => {
|
|
160
|
+
render(
|
|
161
|
+
<DashboardEditor
|
|
162
|
+
environmentName="env"
|
|
163
|
+
packageName="pkg"
|
|
164
|
+
dashboardName="overview"
|
|
165
|
+
/>,
|
|
166
|
+
{ wrapper: serverWrapper },
|
|
167
|
+
);
|
|
168
|
+
await screen.findByText(/not served until it has a tile/);
|
|
169
|
+
expect(getDashboard).not.toHaveBeenCalled();
|
|
170
|
+
|
|
171
|
+
fireEvent.click(
|
|
172
|
+
(
|
|
173
|
+
await screen.findAllByRole("button", {
|
|
174
|
+
name: "Add tile",
|
|
175
|
+
hidden: true,
|
|
176
|
+
})
|
|
177
|
+
)[0],
|
|
178
|
+
);
|
|
179
|
+
fireEvent.click(await screen.findByLabelText("View by_brand"));
|
|
180
|
+
fireEvent.click(screen.getByRole("button", { name: "Add tile" }));
|
|
181
|
+
fireEvent.click(
|
|
182
|
+
screen.getByRole("button", { name: "Save changes", hidden: true }),
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
await waitFor(() => expect(updateModelSource).toHaveBeenCalledTimes(1));
|
|
186
|
+
await waitFor(() => expect(getDashboard).toHaveBeenCalledTimes(1));
|
|
187
|
+
// Settled, and not asked again by a later render.
|
|
188
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
189
|
+
expect(getDashboard).toHaveBeenCalledTimes(1);
|
|
190
|
+
});
|
|
191
|
+
});
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { render, screen } from "@testing-library/react";
|
|
5
|
+
import { beforeEach, describe, expect, it, mock } from "bun:test";
|
|
6
|
+
import type { DashboardManifest } from "../../client";
|
|
7
|
+
import {
|
|
8
|
+
clearCache,
|
|
9
|
+
mockServerProvider,
|
|
10
|
+
pending,
|
|
11
|
+
serverWrapper,
|
|
12
|
+
} from "../../../test/serverProvider";
|
|
13
|
+
|
|
14
|
+
/** The builder warns on a tile that ignores some of the page's controls, as the read view does. */
|
|
15
|
+
let packageFile = "";
|
|
16
|
+
let served: Partial<DashboardManifest> = {};
|
|
17
|
+
|
|
18
|
+
const CATEGORY = {
|
|
19
|
+
name: "CATEGORY",
|
|
20
|
+
label: "Category",
|
|
21
|
+
type: "filter<string>",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const getModel = mock((_env: string, _pkg: string, path: string) =>
|
|
25
|
+
Promise.resolve({
|
|
26
|
+
data:
|
|
27
|
+
path === "dashboards/overview.malloy"
|
|
28
|
+
? { modelPath: path, sourceText: packageFile }
|
|
29
|
+
: { modelPath: path, sources: [], sourceInfos: [] },
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
32
|
+
const getDashboard = mock(() =>
|
|
33
|
+
Promise.resolve({
|
|
34
|
+
data: { path: "dashboards/overview.malloy", tiles: [], ...served },
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
mockServerProvider(
|
|
38
|
+
{
|
|
39
|
+
models: {
|
|
40
|
+
getModel,
|
|
41
|
+
executeQueryModel: mock(() => pending()),
|
|
42
|
+
listModels: mock(() => Promise.resolve({ data: [] })),
|
|
43
|
+
},
|
|
44
|
+
dashboards: {
|
|
45
|
+
getDashboard,
|
|
46
|
+
listDashboards: mock(() => Promise.resolve({ data: [] })),
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{ mutable: true },
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const { DashboardEditor } = await import("./DashboardEditor");
|
|
53
|
+
|
|
54
|
+
beforeEach(() => clearCache());
|
|
55
|
+
|
|
56
|
+
async function warnings(): Promise<Record<string, string>> {
|
|
57
|
+
render(
|
|
58
|
+
<DashboardEditor
|
|
59
|
+
environmentName="env"
|
|
60
|
+
packageName="pkg"
|
|
61
|
+
dashboardName="overview"
|
|
62
|
+
/>,
|
|
63
|
+
{ wrapper: serverWrapper },
|
|
64
|
+
);
|
|
65
|
+
await screen.findAllByLabelText(/^Tile /);
|
|
66
|
+
const tags = await screen
|
|
67
|
+
.findAllByTestId("tile-filter-tag", undefined, { timeout: 500 })
|
|
68
|
+
.catch(() => []);
|
|
69
|
+
return Object.fromEntries(
|
|
70
|
+
tags.map((tag) => [
|
|
71
|
+
tag.closest("[data-tile-key]")?.getAttribute("aria-label") ?? "",
|
|
72
|
+
tag.textContent ?? "",
|
|
73
|
+
]),
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
describe("DashboardEditor filter warnings", () => {
|
|
78
|
+
it("warns only on the tile the control does not reach", async () => {
|
|
79
|
+
packageFile = `## artifact { title="Storefront" tiles=["a -> by_cat", "a -> by_brand"] } dashboard { columns=12 }
|
|
80
|
+
import { scoped_orders } from "../data_app.malloy"
|
|
81
|
+
|
|
82
|
+
source: a is scoped_orders extend {
|
|
83
|
+
view: by_cat is by_category + { where: cat ~ $CATEGORY }
|
|
84
|
+
view: by_brand is by_brand_view
|
|
85
|
+
}`;
|
|
86
|
+
served = {
|
|
87
|
+
givens: [CATEGORY],
|
|
88
|
+
tiles: [
|
|
89
|
+
{ kind: "query", query: "a -> by_cat", givenNames: ["CATEGORY"] },
|
|
90
|
+
{ kind: "query", query: "a -> by_brand", givenNames: [] },
|
|
91
|
+
],
|
|
92
|
+
};
|
|
93
|
+
expect(await warnings()).toEqual({
|
|
94
|
+
"Tile by_brand": "Doesn't respond to Category",
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("does not warn on an unbound tile the saved file does not have yet", async () => {
|
|
99
|
+
packageFile = `## artifact { title="Storefront" tiles=["a -> by_cat", "a -> by_brand"] } dashboard { columns=12 }
|
|
100
|
+
import { scoped_orders } from "../data_app.malloy"
|
|
101
|
+
|
|
102
|
+
source: a is scoped_orders extend {
|
|
103
|
+
view: by_cat is by_category + { where: cat ~ $CATEGORY }
|
|
104
|
+
view: by_brand is by_brand_view
|
|
105
|
+
}`;
|
|
106
|
+
// The model's own source may read CATEGORY; only a saved compile can say.
|
|
107
|
+
served = { givens: [CATEGORY] };
|
|
108
|
+
expect(await warnings()).toEqual({});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("does not warn on a tile its extension's own where: scopes", async () => {
|
|
112
|
+
packageFile = `## artifact { title="Storefront" tiles=["a -> by_cat", "a -> by_brand"] } dashboard { columns=12 }
|
|
113
|
+
import { scoped_orders } from "../data_app.malloy"
|
|
114
|
+
|
|
115
|
+
source: a is scoped_orders extend {
|
|
116
|
+
where: cat ~ $CATEGORY
|
|
117
|
+
view: by_cat is by_category + { where: cat ~ $CATEGORY }
|
|
118
|
+
view: by_brand is by_brand_view
|
|
119
|
+
}`;
|
|
120
|
+
served = { givens: [CATEGORY] };
|
|
121
|
+
expect(await warnings()).toEqual({});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("does not warn about a filter just added on a local given the server has not compiled", async () => {
|
|
125
|
+
packageFile = `## artifact { title="Storefront" tiles=["a -> by_cat", "a -> by_brand"] } dashboard { columns=12 }
|
|
126
|
+
import { scoped_orders } from "../data_app.malloy"
|
|
127
|
+
|
|
128
|
+
given: BRAND :: filter<string> is f''
|
|
129
|
+
|
|
130
|
+
source: a is scoped_orders extend {
|
|
131
|
+
view: by_cat is by_category + { where: cat ~ $CATEGORY }
|
|
132
|
+
view: by_brand is by_brand_view + { where: brand ~ $BRAND }
|
|
133
|
+
}`;
|
|
134
|
+
// The served manifest predates BRAND.
|
|
135
|
+
served = { givens: [CATEGORY] };
|
|
136
|
+
expect(await warnings()).toEqual({
|
|
137
|
+
"Tile by_cat": "Doesn't respond to BRAND",
|
|
138
|
+
"Tile by_brand": "Doesn't respond to Category",
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("reads an inherited tile's applicability from the served manifest", async () => {
|
|
143
|
+
packageFile = `## artifact { title="Storefront" tiles=["a -> by_cat", "scoped_orders -> totals", "scoped_orders -> by_region"] } dashboard { columns=12 }
|
|
144
|
+
import { scoped_orders } from "../data_app.malloy"
|
|
145
|
+
|
|
146
|
+
source: a is scoped_orders extend {
|
|
147
|
+
view: by_cat is by_category + { where: cat ~ $CATEGORY }
|
|
148
|
+
}`;
|
|
149
|
+
served = {
|
|
150
|
+
givens: [CATEGORY],
|
|
151
|
+
tiles: [
|
|
152
|
+
{ kind: "query", query: "a -> by_cat", givenNames: ["CATEGORY"] },
|
|
153
|
+
{ kind: "query", query: "scoped_orders->totals", givenNames: [] },
|
|
154
|
+
// Unresolved: the whole row applies.
|
|
155
|
+
{ kind: "query", query: "scoped_orders -> by_region" },
|
|
156
|
+
],
|
|
157
|
+
};
|
|
158
|
+
expect(await warnings()).toEqual({
|
|
159
|
+
"Tile totals": "Doesn't respond to Category",
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
});
|