@malloy-publisher/sdk 0.9.2 → 0.9.4
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/{RenderedResult-CBLHr32C.es.js → RenderedResult-DwB0-9Yx.es.js} +118 -119
- package/dist/{RenderedResult-B48wAjM8.cjs.js → RenderedResult-hKjFEqaN.cjs.js} +2 -2
- package/dist/{ServerProvider-DCV8BUWD.es.js → ServerProvider-CcSrGaRN.es.js} +1281 -1142
- package/dist/ServerProvider-Gbf1YPOP.cjs.js +1 -0
- package/dist/builder/index.cjs.js +112 -115
- package/dist/builder/index.es.js +11766 -11502
- package/dist/builder-entry.d.ts +1 -1
- package/dist/client/api.d.ts +170 -9
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +93 -89
- package/dist/client-entry.d.ts +2 -0
- package/dist/components/ApiErrorDisplay.d.ts +11 -0
- package/dist/components/AppDialog.d.ts +6 -6
- package/dist/components/Dashboard/DashboardGrid.d.ts +18 -3
- package/dist/components/Dashboard/DashboardTile.d.ts +12 -2
- package/dist/components/Dashboard/DashboardView.d.ts +38 -3
- package/dist/components/Dashboard/TileCard.d.ts +16 -2
- package/dist/components/Dashboard/dropValueUrlTags.d.ts +6 -0
- package/dist/components/Dashboard/index.d.ts +3 -2
- package/dist/components/Dashboard/telemetry.d.ts +2 -1
- package/dist/components/Dashboard/textSource.d.ts +19 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +7 -8
- package/dist/components/DashboardBuilder/BuilderDialogs.d.ts +25 -0
- package/dist/components/DashboardBuilder/BuilderGrid.d.ts +31 -0
- package/dist/components/DashboardBuilder/BuilderHeader.d.ts +17 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +14 -17
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +3 -1
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +15 -7
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +28 -2
- package/dist/components/DashboardBuilder/EditorSurface.d.ts +33 -0
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +6 -4
- package/dist/components/DashboardBuilder/InlineText.d.ts +1 -1
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +1 -1
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +4 -1
- package/dist/components/DashboardBuilder/TileFrame.d.ts +43 -6
- package/dist/components/DashboardBuilder/TileMenu.d.ts +6 -8
- package/dist/components/DashboardBuilder/builderReport.d.ts +13 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +0 -18
- package/dist/components/DashboardBuilder/documentSession.d.ts +2 -2
- package/dist/components/DashboardBuilder/imports.d.ts +19 -0
- package/dist/components/DashboardBuilder/inlineEdit.d.ts +18 -0
- package/dist/components/DashboardBuilder/readDocument.d.ts +3 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +1 -1
- package/dist/components/DashboardBuilder/sortable.d.ts +2 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +2 -0
- package/dist/components/DashboardBuilder/testing/resize.d.ts +7 -0
- package/dist/components/DashboardBuilder/tileDisplayTitle.d.ts +7 -0
- package/dist/components/DashboardBuilder/useBuilderSelection.d.ts +53 -0
- package/dist/components/DashboardBuilder/useBuilderSession.d.ts +4 -7
- package/dist/components/DashboardBuilder/useControlBindings.d.ts +30 -0
- package/dist/components/DashboardBuilder/useConversionConfirm.d.ts +20 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +2 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +3 -1
- package/dist/components/DashboardBuilder/useHostCopy.d.ts +26 -0
- package/dist/components/DashboardBuilder/useOpenDraftCommit.d.ts +17 -0
- package/dist/components/DashboardBuilder/useOpenedDocument.d.ts +71 -0
- package/dist/components/DashboardBuilder/useSaveChannel.d.ts +50 -0
- package/dist/components/DashboardBuilder/useTileEditing.d.ts +33 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +32 -0
- package/dist/components/Loading.d.ts +13 -0
- package/dist/components/Notebook/NotebookCell.d.ts +1 -5
- package/dist/components/Package/Package.d.ts +16 -1
- package/dist/components/Package/index.d.ts +1 -1
- package/dist/components/Prose.d.ts +1 -1
- package/dist/components/RenderedResult/loadRenderer.d.ts +7 -0
- package/dist/components/given/paramCodec.d.ts +8 -1
- package/dist/components/index.d.ts +1 -2
- package/dist/components/styles.d.ts +4 -4
- package/dist/hooks/givenValue.d.ts +6 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useCompiledDocument.d.ts +23 -0
- package/dist/hooks/useDocumentControls.d.ts +6 -1
- package/dist/hooks/useNearViewport.d.ts +16 -0
- package/dist/hooks/useQueryWithApiError.d.ts +7 -2
- package/dist/hooks/useSuggestOptions.d.ts +9 -2
- package/dist/index.cjs.js +14 -14
- package/dist/index.es.js +9760 -10363
- package/dist/text/index.es.js +1 -1
- package/dist/{text-entry-CbbBcZl8.es.js → text-entry-CA0LZ1xL.es.js} +8 -8
- package/dist/text-entry.d.ts +1 -1
- package/dist/theme/accent.d.ts +29 -0
- package/dist/theme/buildVegaThemeOverride.d.ts +3 -3
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/keys.d.ts +1 -1
- package/dist/theme/motion.d.ts +31 -0
- package/dist/theme/readChartAnnotations.d.ts +1 -1
- package/dist/theme/resolveTheme.d.ts +4 -4
- package/dist/theme/types.d.ts +33 -5
- package/dist/{DashboardTile-BFcxdv7R.es.js → useCompiledDocument-BU6d8FPp.es.js} +6978 -6289
- package/dist/useCompiledDocument-pOg2W-Yt.cjs.js +142 -0
- package/package.json +11 -11
- package/src/builder-entry.ts +1 -0
- package/src/client-entry.ts +8 -0
- package/src/clientEntry.spec.ts +17 -0
- package/src/components/ApiErrorDisplay.tsx +37 -18
- package/src/components/AppDialog.tsx +8 -7
- package/src/components/Dashboard/Dashboard.spec.tsx +3 -32
- package/src/components/Dashboard/Dashboard.tsx +2 -2
- package/src/components/Dashboard/DashboardGrid.tsx +23 -5
- package/src/components/Dashboard/DashboardTile.spec.tsx +97 -2
- package/src/components/Dashboard/DashboardTile.tsx +95 -31
- package/src/components/Dashboard/DashboardView.spec.tsx +156 -0
- package/src/components/Dashboard/DashboardView.tsx +165 -89
- package/src/components/Dashboard/RowsDialog.tsx +3 -2
- package/src/components/Dashboard/TileCard.tsx +17 -2
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +177 -0
- package/src/components/Dashboard/dropValueUrlTags.ts +108 -0
- package/src/components/Dashboard/index.ts +11 -2
- package/src/components/Dashboard/telemetry.ts +2 -1
- package/src/components/Dashboard/textSource.spec.ts +36 -0
- package/src/components/Dashboard/textSource.ts +39 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +16 -56
- package/src/components/DashboardBuilder/BuilderDialogs.tsx +162 -0
- package/src/components/DashboardBuilder/BuilderGrid.tsx +245 -0
- package/src/components/DashboardBuilder/BuilderHeader.tsx +107 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +86 -113
- package/src/components/DashboardBuilder/ChartPicker.tsx +4 -1
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +5 -5
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +74 -83
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +62 -18
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +55 -108
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +10 -62
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +50 -57
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +53 -40
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +10 -8
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +227 -704
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +32 -52
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +1 -50
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +12 -18
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +4 -24
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +4 -4
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +8 -13
- package/src/components/DashboardBuilder/DashboardEditor.textSource.spec.tsx +317 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +142 -820
- package/src/components/DashboardBuilder/DrillDialog.tsx +2 -2
- package/src/components/DashboardBuilder/EditorSurface.tsx +471 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +13 -8
- package/src/components/DashboardBuilder/FilterStrip.tsx +117 -79
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +7 -9
- package/src/components/DashboardBuilder/InlineText.tsx +23 -17
- package/src/components/DashboardBuilder/NotebookEditor.tsx +3 -3
- package/src/components/DashboardBuilder/TextTileBody.tsx +5 -2
- package/src/components/DashboardBuilder/TileFrame.tsx +255 -90
- package/src/components/DashboardBuilder/TileMenu.tsx +41 -91
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +1 -1
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +9 -4
- package/src/components/DashboardBuilder/builderReport.ts +74 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +0 -44
- package/src/components/DashboardBuilder/catalog.ts +0 -36
- package/src/components/DashboardBuilder/controls.spec.ts +1 -1
- package/src/components/DashboardBuilder/controls.ts +1 -1
- package/src/components/DashboardBuilder/documentSession.ts +3 -2
- package/src/components/DashboardBuilder/imports.spec.ts +61 -0
- package/src/components/DashboardBuilder/imports.ts +93 -0
- package/src/components/DashboardBuilder/inlineEdit.tsx +78 -0
- package/src/components/DashboardBuilder/legacyNotebook.ts +1 -1
- package/src/components/DashboardBuilder/malloyTree.ts +5 -1
- package/src/components/DashboardBuilder/newDashboard.ts +1 -1
- package/src/components/DashboardBuilder/preview.ts +1 -1
- package/src/components/DashboardBuilder/readDocument.spec.ts +36 -0
- package/src/components/DashboardBuilder/readDocument.ts +10 -4
- package/src/components/DashboardBuilder/readForEditor.ts +7 -2
- package/src/components/DashboardBuilder/sortable.spec.ts +25 -1
- package/src/components/DashboardBuilder/sortable.tsx +11 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +8 -3
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +62 -6
- package/src/components/DashboardBuilder/testing/documentKindRule.json +40 -0
- package/src/components/DashboardBuilder/testing/inline.ts +1 -1
- package/src/components/DashboardBuilder/testing/resize.ts +48 -0
- package/src/components/DashboardBuilder/testing/urlRenderTags.json +62 -0
- package/src/components/DashboardBuilder/textTiles.spec.ts +43 -1
- package/src/components/DashboardBuilder/tileDisplayTitle.ts +13 -0
- package/src/components/DashboardBuilder/useBuilderSelection.ts +121 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +0 -85
- package/src/components/DashboardBuilder/useBuilderSession.ts +6 -43
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +32 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +11 -1
- package/src/components/DashboardBuilder/useControlBindings.ts +152 -0
- package/src/components/DashboardBuilder/useConversionConfirm.ts +55 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +5 -2
- package/src/components/DashboardBuilder/useDraft.ts +15 -2
- package/src/components/DashboardBuilder/useHostCopy.ts +104 -0
- package/src/components/DashboardBuilder/useOpenDraftCommit.ts +47 -0
- package/src/components/DashboardBuilder/useOpenedDocument.ts +314 -0
- package/src/components/DashboardBuilder/useSaveChannel.ts +275 -0
- package/src/components/DashboardBuilder/useTileEditing.ts +141 -0
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +146 -0
- package/src/components/DashboardBuilder/useTileResize.ts +133 -0
- package/src/components/DataAppViewer/DataAppViewer.tsx +7 -4
- package/src/components/DocumentCreate/guards.ts +1 -1
- package/src/components/Environment/Environment.tsx +0 -10
- package/src/components/Loading.tsx +14 -0
- package/src/components/Model/Model.tsx +16 -9
- package/src/components/Model/ModelExplorer.tsx +2 -2
- package/src/components/Notebook/Notebook.tsx +6 -2
- package/src/components/Notebook/NotebookCell.tsx +90 -215
- package/src/components/Package/Package.artifacts.spec.tsx +8 -12
- package/src/components/Package/Package.create.spec.tsx +22 -1
- package/src/components/Package/Package.tsx +51 -27
- package/src/components/Package/index.ts +1 -1
- package/src/components/Prose.spec.tsx +37 -0
- package/src/components/Prose.tsx +35 -5
- package/src/components/RenderedResult/RenderedResult.tsx +5 -7
- package/src/components/RenderedResult/ResultContainer.tsx +7 -2
- package/src/components/RenderedResult/ResultPanel.tsx +20 -5
- package/src/components/RenderedResult/loadRenderer.ts +42 -0
- package/src/components/given/GivenInput.spec.tsx +5 -5
- package/src/components/given/GivenInput.tsx +46 -38
- package/src/components/given/GivensPanel.tsx +2 -8
- package/src/components/given/paramCodec.ts +27 -1
- package/src/components/index.ts +1 -2
- package/src/components/styles.ts +4 -5
- package/src/hooks/givenValue.ts +9 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useCompiledDocument.spec.tsx +86 -0
- package/src/hooks/useCompiledDocument.ts +59 -0
- package/src/hooks/useDimensionalFilterRangeData.ts +3 -1
- package/src/hooks/useDocumentControls.ts +13 -1
- package/src/hooks/useNearViewport.spec.tsx +150 -0
- package/src/hooks/useNearViewport.ts +102 -0
- package/src/hooks/useQueryResult.ts +7 -1
- package/src/hooks/useQueryWithApiError.ts +10 -3
- package/src/hooks/useRawQueryData.ts +3 -1
- package/src/hooks/useSuggestOptions.dom.spec.ts +40 -1
- package/src/hooks/useSuggestOptions.ts +42 -10
- package/src/text-entry.ts +1 -1
- package/src/textEntry.spec.ts +2 -8
- package/src/theme/accent.spec.ts +116 -0
- package/src/theme/accent.ts +148 -0
- package/src/theme/buildTableCssVars.spec.ts +24 -0
- package/src/theme/buildTableCssVars.ts +1 -2
- package/src/theme/buildVegaThemeOverride.spec.ts +38 -2
- package/src/theme/buildVegaThemeOverride.ts +5 -5
- package/src/theme/defaults.ts +34 -0
- package/src/theme/index.ts +9 -0
- package/src/theme/keys.ts +6 -0
- package/src/theme/motion.ts +44 -0
- package/src/theme/readChartAnnotations.spec.ts +18 -0
- package/src/theme/readChartAnnotations.ts +1 -1
- package/src/theme/resolveTheme.spec.ts +73 -0
- package/src/theme/resolveTheme.ts +61 -20
- package/src/theme/types.ts +30 -5
- package/src/utils/queryClient.ts +8 -0
- package/dist/DashboardTile-sg8LjUk8.cjs.js +0 -137
- package/dist/ServerProvider-HRqT3w1C.cjs.js +0 -1
- package/dist/components/Dashboard/DashboardBar.d.ts +0 -21
- package/dist/components/Dashboard/ExploreDialog.d.ts +0 -20
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +0 -7
- package/dist/components/DashboardBuilder/SaveNotice.d.ts +0 -27
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +0 -32
- package/dist/components/DashboardBuilder/diff.d.ts +0 -35
- package/src/components/Dashboard/DashboardBar.tsx +0 -88
- package/src/components/Dashboard/ExploreDialog.tsx +0 -89
- package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +0 -194
- package/src/components/DashboardBuilder/DiffDialog.spec.tsx +0 -25
- package/src/components/DashboardBuilder/DiffDialog.tsx +0 -103
- package/src/components/DashboardBuilder/SaveNotice.tsx +0 -113
- package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +0 -87
- package/src/components/DashboardBuilder/SettingsPopover.tsx +0 -326
- package/src/components/DashboardBuilder/diff.spec.ts +0 -44
- package/src/components/DashboardBuilder/diff.ts +0 -93
- /package/dist/{components/DashboardBuilder → utils}/malloyText.d.ts +0 -0
- /package/src/{components/DashboardBuilder → utils}/malloyText.spec.ts +0 -0
- /package/src/{components/DashboardBuilder → utils}/malloyText.ts +0 -0
|
@@ -72,6 +72,46 @@ const undo = () => fireEvent.click(button("Undo"));
|
|
|
72
72
|
afterEach(cleanup);
|
|
73
73
|
|
|
74
74
|
describe("click-to-edit text", () => {
|
|
75
|
+
it("selects a tile when keyboard focus lands in it, as a press does", async () => {
|
|
76
|
+
await mount();
|
|
77
|
+
fireEvent.focus(screen.getByLabelText("Settings for By category"));
|
|
78
|
+
expect(
|
|
79
|
+
screen.getByLabelText("Tile by_cat").getAttribute("aria-current"),
|
|
80
|
+
).toBe("true");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("keeps the selection when Escape cancels a title being typed", async () => {
|
|
84
|
+
await mount();
|
|
85
|
+
fireEvent.pointerDown(screen.getByLabelText("Tile by_cat"));
|
|
86
|
+
fireEvent.click(screen.getByText("By category"));
|
|
87
|
+
const field = screen.getByLabelText("Tile title");
|
|
88
|
+
fireEvent.keyDown(field, { key: "Escape" });
|
|
89
|
+
expect(
|
|
90
|
+
screen.getByLabelText("Tile by_cat").getAttribute("aria-current"),
|
|
91
|
+
).toBe("true");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("announces the save state for a screen reader", async () => {
|
|
95
|
+
await mount({ onSave: () => {} });
|
|
96
|
+
expect(screen.getByText("All changes saved")).toBeDefined();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("selects the description or a tile, never both", async () => {
|
|
100
|
+
await mount();
|
|
101
|
+
const description = screen.getByLabelText("Description");
|
|
102
|
+
fireEvent.pointerDown(description);
|
|
103
|
+
expect(description.getAttribute("aria-current")).toBe("true");
|
|
104
|
+
fireEvent.pointerDown(screen.getByLabelText("Tile by_cat"));
|
|
105
|
+
expect(description.getAttribute("aria-current")).toBe("false");
|
|
106
|
+
expect(
|
|
107
|
+
screen.getByLabelText("Tile by_cat").getAttribute("aria-current"),
|
|
108
|
+
).toBe("true");
|
|
109
|
+
fireEvent.pointerDown(description);
|
|
110
|
+
expect(
|
|
111
|
+
screen.getByLabelText("Tile by_cat").getAttribute("aria-current"),
|
|
112
|
+
).toBe("false");
|
|
113
|
+
});
|
|
114
|
+
|
|
75
115
|
it("opens on a click, commits on Enter, and is one undo step", async () => {
|
|
76
116
|
await mount();
|
|
77
117
|
editInline("By category", "Tile title", "Revenue");
|
|
@@ -122,9 +162,9 @@ describe("click-to-edit text", () => {
|
|
|
122
162
|
await mount();
|
|
123
163
|
expect(within(tile("by_cat")).getByText("Add a subtitle")).toBeDefined();
|
|
124
164
|
// An unlabelled tile shows the name it falls back to.
|
|
125
|
-
expect(within(tile("by_brand")).getByText("
|
|
165
|
+
expect(within(tile("by_brand")).getByText("By brand")).toBeDefined();
|
|
126
166
|
editInline("By category", "Tile title", "");
|
|
127
|
-
expect(within(tile("by_cat")).getByText("
|
|
167
|
+
expect(within(tile("by_cat")).getByText("By cat")).toBeDefined();
|
|
128
168
|
});
|
|
129
169
|
|
|
130
170
|
it("edits the page's title and description in place", async () => {
|
|
@@ -142,17 +182,17 @@ describe("click-to-edit text", () => {
|
|
|
142
182
|
expect(screen.getByText("Storefront")).toBeDefined();
|
|
143
183
|
});
|
|
144
184
|
|
|
145
|
-
it("has no title or subtitle fields in the tile menu, and
|
|
185
|
+
it("has no title or subtitle fields in the tile menu, and no page settings window", async () => {
|
|
146
186
|
await mount();
|
|
147
187
|
fireEvent.click(screen.getByLabelText("Settings for By category"));
|
|
148
188
|
expect(screen.queryByLabelText("Tile title")).toBeNull();
|
|
149
189
|
expect(screen.queryByLabelText("Tile subtitle")).toBeNull();
|
|
150
|
-
expect(button("Drill
|
|
151
|
-
fireEvent.keyDown(button("
|
|
152
|
-
|
|
190
|
+
expect(button("Drill")).toBeDefined();
|
|
191
|
+
fireEvent.keyDown(button("Delete"), { key: "Escape" });
|
|
192
|
+
// There is no page settings window at all: the title and description
|
|
193
|
+
// are edited on the page.
|
|
194
|
+
expect(screen.queryByRole("button", { name: "Settings" })).toBeNull();
|
|
153
195
|
expect(screen.queryByLabelText("Dashboard title")).toBeNull();
|
|
154
|
-
expect(screen.queryByLabelText("Dashboard description")).toBeNull();
|
|
155
|
-
expect(screen.getByLabelText("Grid width")).toBeDefined();
|
|
156
196
|
});
|
|
157
197
|
});
|
|
158
198
|
|
|
@@ -232,7 +272,7 @@ describe("click-to-edit markdown in a text tile", () => {
|
|
|
232
272
|
fireEvent.change(field, { target: { value: "Typed in place" } });
|
|
233
273
|
fireEvent.keyDown(field, { key: "Escape" });
|
|
234
274
|
|
|
235
|
-
fireEvent.click(button("Save
|
|
275
|
+
fireEvent.click(button("Save"));
|
|
236
276
|
await waitFor(() => expect(written).toBeDefined());
|
|
237
277
|
expect(written).toContain("##|(markdown) text_1\nTyped in place\n|##");
|
|
238
278
|
});
|
|
@@ -299,9 +339,15 @@ describe("undo and redo point at the tile they changed", () => {
|
|
|
299
339
|
});
|
|
300
340
|
|
|
301
341
|
describe("the save target", () => {
|
|
302
|
-
|
|
342
|
+
/** Save's tooltip text, once hovered. */
|
|
343
|
+
const saveTooltip = async () => {
|
|
344
|
+
fireEvent.mouseOver(screen.getByRole("button", { name: /Save/ }));
|
|
345
|
+
return (await screen.findByRole("tooltip")).textContent;
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
it("is Save's tooltip", async () => {
|
|
303
349
|
await mount({ onSave: () => {} });
|
|
304
|
-
expect(
|
|
350
|
+
expect(await saveTooltip()).toBe("Saves to the package file");
|
|
305
351
|
});
|
|
306
352
|
|
|
307
353
|
it("is the workspace's own words when it supplies them", async () => {
|
|
@@ -310,20 +356,18 @@ describe("the save target", () => {
|
|
|
310
356
|
savesTo: "host",
|
|
311
357
|
saveLabel: "Saved to this draft",
|
|
312
358
|
});
|
|
313
|
-
expect(
|
|
314
|
-
expect(screen.queryByText(/embedded in/)).toBeNull();
|
|
359
|
+
expect(await saveTooltip()).toBe("Saved to this draft");
|
|
315
360
|
});
|
|
316
361
|
|
|
317
362
|
it("is a generic line, without the word host, when the workspace says nothing", async () => {
|
|
318
363
|
await mount({ onSave: () => {}, savesTo: "host" });
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
).
|
|
322
|
-
expect(screen.queryByText(/host/i)).toBeNull();
|
|
364
|
+
const text = await saveTooltip();
|
|
365
|
+
expect(text).toBe("Saves to the app this is embedded in");
|
|
366
|
+
expect(text).not.toMatch(/host/i);
|
|
323
367
|
});
|
|
324
368
|
|
|
325
369
|
it("is absent when there is nowhere to save", async () => {
|
|
326
370
|
await mount();
|
|
327
|
-
expect(screen.
|
|
371
|
+
expect(screen.queryByRole("button", { name: /^Save/ })).toBeNull();
|
|
328
372
|
});
|
|
329
373
|
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
+
act,
|
|
5
6
|
cleanup,
|
|
6
7
|
fireEvent,
|
|
7
8
|
render,
|
|
@@ -15,7 +16,7 @@ import { DashboardBuilder } from "./DashboardBuilder";
|
|
|
15
16
|
import { readForEditor } from "./readForEditor";
|
|
16
17
|
import { openDocument } from "./testing/fixtures";
|
|
17
18
|
import type { BuilderEvent } from "./telemetry";
|
|
18
|
-
import {
|
|
19
|
+
import { editInline } from "./testing/inline";
|
|
19
20
|
|
|
20
21
|
const NOTEBOOK = `## artifact { kind=notebook title="Review" tiles=[intro { kind=text }, "a -> by_cat"] }
|
|
21
22
|
import "../data_app.malloy"
|
|
@@ -87,12 +88,20 @@ const mountText = async (
|
|
|
87
88
|
);
|
|
88
89
|
|
|
89
90
|
describe("DashboardBuilder: a notebook is one column", () => {
|
|
90
|
-
it("
|
|
91
|
+
it("draws its text and description bare, as the notebook reader does", async () => {
|
|
91
92
|
await mountText(NOTEBOOK);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
expect(
|
|
95
|
-
|
|
93
|
+
for (const card of document.querySelectorAll("[data-chrome]"))
|
|
94
|
+
expect(card.getAttribute("data-chrome")).toBe("none");
|
|
95
|
+
expect(document.querySelectorAll("[data-chrome]").length).toBeGreaterThan(
|
|
96
|
+
0,
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("offers no width: no resize edge, no width presets", async () => {
|
|
101
|
+
await mountText(NOTEBOOK);
|
|
102
|
+
expect(
|
|
103
|
+
screen.queryByRole("separator", { name: /^Width of / }),
|
|
104
|
+
).toBeNull();
|
|
96
105
|
fireEvent.click(screen.getByLabelText("Settings for intro"));
|
|
97
106
|
expect(screen.queryByRole("button", { name: "Width ½" })).toBeNull();
|
|
98
107
|
fireEvent.click(screen.getByLabelText("Settings for by_cat"));
|
|
@@ -120,29 +129,25 @@ describe("DashboardBuilder: a notebook is one column", () => {
|
|
|
120
129
|
expect(screen.queryByLabelText("Tile width")).toBeNull();
|
|
121
130
|
fireEvent.click(screen.getByLabelText("View sales_by_state"));
|
|
122
131
|
fireEvent.click(screen.getByRole("button", { name: "Add tile" }));
|
|
123
|
-
fireEvent.click(button("Save
|
|
132
|
+
fireEvent.click(button("Save"));
|
|
124
133
|
await waitFor(() => expect(written).toBeDefined());
|
|
125
134
|
expect(written).toContain("view: sales_by_state_tile is sales_by_state");
|
|
126
135
|
expect(written).not.toContain("colspan");
|
|
127
136
|
expect(written).not.toContain("columns");
|
|
128
137
|
});
|
|
129
138
|
|
|
130
|
-
it("
|
|
139
|
+
it("describes the Add tile dialog the same way for either kind", async () => {
|
|
131
140
|
await mountText(NOTEBOOK, { withCatalog: true });
|
|
132
141
|
fireEvent.click(button("Add tile"));
|
|
133
142
|
expect(
|
|
134
|
-
screen.getByText(
|
|
135
|
-
"A tile shows one view of one source this notebook imports.",
|
|
136
|
-
),
|
|
143
|
+
screen.getByText("A tile shows one view of a source in this package."),
|
|
137
144
|
).toBeDefined();
|
|
138
145
|
cleanup();
|
|
139
146
|
|
|
140
147
|
await mountText(DASHBOARD, { withCatalog: true });
|
|
141
148
|
fireEvent.click(button("Add tile"));
|
|
142
149
|
expect(
|
|
143
|
-
screen.getByText(
|
|
144
|
-
"A tile shows one view of one source this dashboard imports.",
|
|
145
|
-
),
|
|
150
|
+
screen.getByText("A tile shows one view of a source in this package."),
|
|
146
151
|
).toBeDefined();
|
|
147
152
|
});
|
|
148
153
|
|
|
@@ -157,7 +162,7 @@ describe("DashboardBuilder: a notebook is one column", () => {
|
|
|
157
162
|
fireEvent.click(screen.getByLabelText("Insert tile after intro"));
|
|
158
163
|
fireEvent.click(screen.getByRole("button", { name: "Text" }));
|
|
159
164
|
fireEvent.click(screen.getByRole("button", { name: "Add text" }));
|
|
160
|
-
fireEvent.click(button("Save
|
|
165
|
+
fireEvent.click(button("Save"));
|
|
161
166
|
await waitFor(() => expect(written).toBeDefined());
|
|
162
167
|
expect(written).toContain(
|
|
163
168
|
'tiles=[intro { kind=text }, text_1 { kind=text }, "a -> by_cat"]',
|
|
@@ -177,7 +182,7 @@ describe("DashboardBuilder: a notebook is one column", () => {
|
|
|
177
182
|
fireEvent.click(screen.getByLabelText("Add tile at the end"));
|
|
178
183
|
fireEvent.click(screen.getByRole("button", { name: "Text" }));
|
|
179
184
|
fireEvent.click(screen.getByRole("button", { name: "Add text" }));
|
|
180
|
-
fireEvent.click(button("Save
|
|
185
|
+
fireEvent.click(button("Save"));
|
|
181
186
|
await waitFor(() => expect(written).toBeDefined());
|
|
182
187
|
expect(written).toContain(
|
|
183
188
|
'tiles=[intro { kind=text }, "a -> by_cat", text_1 { kind=text }]',
|
|
@@ -193,8 +198,8 @@ describe("DashboardBuilder: a notebook is one column", () => {
|
|
|
193
198
|
it("reports notebook events, with the cell count", async () => {
|
|
194
199
|
const onEvent = mock((_event: BuilderEvent) => {});
|
|
195
200
|
await mountText(NOTEBOOK, { onSave: () => {}, onEvent });
|
|
196
|
-
editInline("
|
|
197
|
-
fireEvent.click(button("Save
|
|
201
|
+
editInline("By cat", "Tile title", "Categories");
|
|
202
|
+
fireEvent.click(button("Save"));
|
|
198
203
|
await waitFor(() => expect(onEvent).toHaveBeenCalledTimes(1));
|
|
199
204
|
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
200
205
|
type: "notebook.saved",
|
|
@@ -206,48 +211,11 @@ describe("DashboardBuilder: a notebook is one column", () => {
|
|
|
206
211
|
});
|
|
207
212
|
});
|
|
208
213
|
|
|
209
|
-
describe("DashboardBuilder:
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
it("turns a dashboard into a notebook in place, and drops its width", async () => {
|
|
217
|
-
let written: string | undefined;
|
|
218
|
-
await mountText(DASHBOARD, {
|
|
219
|
-
onSave: (source) => {
|
|
220
|
-
written = source;
|
|
221
|
-
},
|
|
222
|
-
});
|
|
223
|
-
fireEvent.click(screen.getByLabelText("Settings for by_cat"));
|
|
224
|
-
expect(screen.getByRole("button", { name: "Width ½" })).toBeDefined();
|
|
225
|
-
closeMenu();
|
|
226
|
-
showAs("Notebook");
|
|
227
|
-
// The menu follows the toggle at once.
|
|
228
|
-
fireEvent.click(screen.getByLabelText("Settings for by_cat"));
|
|
229
|
-
expect(screen.queryByRole("button", { name: "Width ½" })).toBeNull();
|
|
230
|
-
closeMenu();
|
|
231
|
-
fireEvent.click(button("Save changes"));
|
|
232
|
-
await waitFor(() => expect(written).toBeDefined());
|
|
233
|
-
expect(written).toContain("kind=notebook");
|
|
234
|
-
expect(written).not.toContain("columns");
|
|
235
|
-
// Everything else in the file is where it was.
|
|
236
|
-
expect(written).toContain("source: a is scoped_orders extend {");
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
it("turns a notebook back into a dashboard", async () => {
|
|
240
|
-
let written: string | undefined;
|
|
241
|
-
await mountText(NOTEBOOK, {
|
|
242
|
-
onSave: (source) => {
|
|
243
|
-
written = source;
|
|
244
|
-
},
|
|
245
|
-
});
|
|
246
|
-
showAs("Dashboard");
|
|
247
|
-
fireEvent.click(button("Save changes"));
|
|
248
|
-
await waitFor(() => expect(written).toBeDefined());
|
|
249
|
-
expect(written).not.toContain("kind=notebook");
|
|
250
|
-
expect(written).toContain('title="Review"');
|
|
214
|
+
describe("DashboardBuilder: a document's kind", () => {
|
|
215
|
+
it("is fixed once created: there is no switch between dashboard and notebook", async () => {
|
|
216
|
+
await mountText(DASHBOARD, { onSave: () => {} });
|
|
217
|
+
expect(screen.queryByRole("button", { name: "Settings" })).toBeNull();
|
|
218
|
+
expect(screen.queryByLabelText("Show as")).toBeNull();
|
|
251
219
|
});
|
|
252
220
|
});
|
|
253
221
|
|
|
@@ -255,7 +223,6 @@ describe("DashboardBuilder: a notebook in the cell format", () => {
|
|
|
255
223
|
const open = async (
|
|
256
224
|
options: {
|
|
257
225
|
onSave?: (source: string) => void;
|
|
258
|
-
onExit?: () => void;
|
|
259
226
|
onEvent?: (event: BuilderEvent) => void;
|
|
260
227
|
onDirtyChange?: (dirty: boolean) => void;
|
|
261
228
|
} = {},
|
|
@@ -279,10 +246,10 @@ describe("DashboardBuilder: a notebook in the cell format", () => {
|
|
|
279
246
|
await open({ onSave: () => {}, onDirtyChange });
|
|
280
247
|
expect(
|
|
281
248
|
screen.getByText(
|
|
282
|
-
/This notebook is in the cell format\. Saving rewrites it as a layout notebook, and a named query run once becomes that tile's view
|
|
249
|
+
/This notebook is in the cell format\. Saving rewrites it as a layout notebook, and a named query run once becomes that tile's view\./,
|
|
283
250
|
),
|
|
284
251
|
).toBeDefined();
|
|
285
|
-
expect(button("Save
|
|
252
|
+
expect(button("Save")).toBeDefined();
|
|
286
253
|
// Each tile says why it has no preview yet, beside the view it will run.
|
|
287
254
|
expect(
|
|
288
255
|
screen.getAllByText("Preview appears after you Save"),
|
|
@@ -294,31 +261,41 @@ describe("DashboardBuilder: a notebook in the cell format", () => {
|
|
|
294
261
|
expect(onDirtyChange).toHaveBeenLastCalledWith(false);
|
|
295
262
|
});
|
|
296
263
|
|
|
297
|
-
it("
|
|
298
|
-
const
|
|
299
|
-
await open({ onSave: () =>
|
|
300
|
-
fireEvent.click(button("
|
|
301
|
-
expect(
|
|
302
|
-
|
|
264
|
+
it("asks before Save converts the file, and writes it once confirmed", async () => {
|
|
265
|
+
const writes: string[] = [];
|
|
266
|
+
await open({ onSave: (source) => void writes.push(source) });
|
|
267
|
+
fireEvent.click(button("Save"));
|
|
268
|
+
expect(
|
|
269
|
+
await screen.findByText(
|
|
270
|
+
/Saving rewrites this notebook in the tile layout/,
|
|
271
|
+
),
|
|
272
|
+
).toBeDefined();
|
|
273
|
+
expect(writes).toHaveLength(0);
|
|
274
|
+
fireEvent.click(button("Convert and save"));
|
|
275
|
+
await waitFor(() => expect(writes).toHaveLength(1));
|
|
303
276
|
});
|
|
304
277
|
|
|
305
|
-
it("
|
|
306
|
-
const
|
|
307
|
-
await open({ onSave: () =>
|
|
308
|
-
|
|
309
|
-
fireEvent.click(
|
|
310
|
-
|
|
311
|
-
expect(
|
|
278
|
+
it("writes nothing when the conversion is cancelled", async () => {
|
|
279
|
+
const writes: string[] = [];
|
|
280
|
+
await open({ onSave: (source) => void writes.push(source) });
|
|
281
|
+
fireEvent.click(button("Save"));
|
|
282
|
+
fireEvent.click(await screen.findByRole("button", { name: "Cancel" }));
|
|
283
|
+
await act(async () => {});
|
|
284
|
+
expect(writes).toHaveLength(0);
|
|
285
|
+
expect(button("Save")).toBeDefined();
|
|
312
286
|
});
|
|
313
287
|
|
|
314
|
-
it("saves the conversion
|
|
288
|
+
it("saves the conversion exactly as converted", async () => {
|
|
315
289
|
const writes: string[] = [];
|
|
316
290
|
const onEvent = mock((_event: BuilderEvent) => {});
|
|
317
291
|
const conversion = await open({
|
|
318
292
|
onSave: (source) => void writes.push(source),
|
|
319
293
|
onEvent,
|
|
320
294
|
});
|
|
321
|
-
fireEvent.click(button("Save
|
|
295
|
+
fireEvent.click(button("Save"));
|
|
296
|
+
fireEvent.click(
|
|
297
|
+
await screen.findByRole("button", { name: "Convert and save" }),
|
|
298
|
+
);
|
|
322
299
|
await waitFor(() => expect(writes).toHaveLength(1));
|
|
323
300
|
// Nothing was edited, so the file written is the conversion itself.
|
|
324
301
|
expect(writes[0]).toBe(conversion.to);
|
|
@@ -329,35 +306,5 @@ describe("DashboardBuilder: a notebook in the cell format", () => {
|
|
|
329
306
|
expect(
|
|
330
307
|
screen.queryByText(/This notebook is in the cell format/),
|
|
331
308
|
).toBeNull();
|
|
332
|
-
|
|
333
|
-
fireEvent.click(await screen.findByRole("button", { name: "Undo save" }));
|
|
334
|
-
await waitFor(() => expect(writes).toHaveLength(2));
|
|
335
|
-
expect(writes[1]).toBe(LEGACY);
|
|
336
|
-
// Back to conversion-pending: the banner and Save return.
|
|
337
|
-
expect(
|
|
338
|
-
await screen.findByText(/This notebook is in the cell format/),
|
|
339
|
-
).toBeDefined();
|
|
340
|
-
expect(button("Save changes")).toBeDefined();
|
|
341
|
-
expect(onEvent.mock.calls.map(([event]) => event.type)).toEqual([
|
|
342
|
-
"notebook.saved",
|
|
343
|
-
"notebook.save_undone",
|
|
344
|
-
]);
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
it("keeps the edits made before the save through its undo", async () => {
|
|
348
|
-
const writes: string[] = [];
|
|
349
|
-
await open({ onSave: (source) => void writes.push(source) });
|
|
350
|
-
editInline("Revenue by month", "Tile title", "Monthly revenue");
|
|
351
|
-
fireEvent.click(button("Save changes"));
|
|
352
|
-
await waitFor(() => expect(writes).toHaveLength(1));
|
|
353
|
-
expect(writes[0]).toContain('# label="Monthly revenue"');
|
|
354
|
-
|
|
355
|
-
fireEvent.click(await screen.findByRole("button", { name: "Undo save" }));
|
|
356
|
-
await waitFor(() => expect(writes).toHaveLength(2));
|
|
357
|
-
expect(writes[1]).toBe(LEGACY);
|
|
358
|
-
expect(screen.getByLabelText("Tile revenue_by_month")).toBeDefined();
|
|
359
|
-
expect(
|
|
360
|
-
screen.getByLabelText("Settings for Monthly revenue"),
|
|
361
|
-
).toBeDefined();
|
|
362
309
|
});
|
|
363
310
|
});
|
|
@@ -23,7 +23,6 @@ source: a is scoped_orders extend {
|
|
|
23
23
|
|
|
24
24
|
const mount = async (
|
|
25
25
|
options: {
|
|
26
|
-
onExit?: () => void;
|
|
27
26
|
onSave?: (source: string) => Promise<void> | void;
|
|
28
27
|
onDirtyChange?: (dirty: boolean) => void;
|
|
29
28
|
} = {},
|
|
@@ -33,7 +32,6 @@ const mount = async (
|
|
|
33
32
|
<DashboardBuilder
|
|
34
33
|
source={SOURCE}
|
|
35
34
|
document={document}
|
|
36
|
-
{...(options.onExit ? { onExit: options.onExit } : {})}
|
|
37
35
|
{...(options.onSave ? { onSave: options.onSave } : {})}
|
|
38
36
|
{...(options.onDirtyChange
|
|
39
37
|
? { onDirtyChange: options.onDirtyChange }
|
|
@@ -56,53 +54,16 @@ const type = (field: HTMLElement, value: string) =>
|
|
|
56
54
|
afterEach(cleanup);
|
|
57
55
|
|
|
58
56
|
describe("DashboardBuilder: an open inline draft", () => {
|
|
59
|
-
it("
|
|
60
|
-
const
|
|
61
|
-
await mount({ onExit, onSave: async () => {} });
|
|
62
|
-
type(openDescription(), "Half-typed");
|
|
63
|
-
fireEvent.click(button("Close"));
|
|
64
|
-
expect(screen.getByRole("dialog")).toBeDefined();
|
|
65
|
-
expect(onExit).not.toHaveBeenCalled();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("exits at once when the open markdown field is unchanged", async () => {
|
|
69
|
-
const onExit = mock(() => {});
|
|
70
|
-
await mount({ onExit, onSave: async () => {} });
|
|
71
|
-
openDescription();
|
|
72
|
-
fireEvent.click(button("Close"));
|
|
73
|
-
expect(onExit).toHaveBeenCalledTimes(1);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("asks when the markdown draft is one the writer would refuse", async () => {
|
|
77
|
-
const onExit = mock(() => {});
|
|
78
|
-
await mount({ onExit, onSave: async () => {} });
|
|
79
|
-
type(openDescription(), "# not ok\n|##");
|
|
80
|
-
expect(screen.getByText(/would close the text early/)).toBeDefined();
|
|
81
|
-
fireEvent.click(button("Close"));
|
|
82
|
-
expect(screen.getByRole("dialog")).toBeDefined();
|
|
83
|
-
expect(onExit).not.toHaveBeenCalled();
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("does not ask after the draft is committed and saved", async () => {
|
|
87
|
-
const onExit = mock(() => {});
|
|
57
|
+
it("is clean again once the committed draft is saved, and stays open", async () => {
|
|
58
|
+
const onDirtyChange = mock((_dirty: boolean) => {});
|
|
88
59
|
const onSave = mock(async (_source: string) => {});
|
|
89
|
-
await mount({
|
|
60
|
+
await mount({ onSave, onDirtyChange });
|
|
90
61
|
type(openDescription(), "Committed");
|
|
91
62
|
fireEvent.click(button("Done"));
|
|
92
|
-
fireEvent.click(button("Save
|
|
93
|
-
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
63
|
+
fireEvent.click(button("Save"));
|
|
94
64
|
await waitFor(() => expect(button("Saved")).toBeDefined());
|
|
95
|
-
|
|
96
|
-
expect(
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it("does not ask after Cancel drops the draft", async () => {
|
|
100
|
-
const onExit = mock(() => {});
|
|
101
|
-
await mount({ onExit, onSave: async () => {} });
|
|
102
|
-
type(openDescription(), "Dropped");
|
|
103
|
-
fireEvent.click(button("Cancel"));
|
|
104
|
-
fireEvent.click(button("Close"));
|
|
105
|
-
expect(onExit).toHaveBeenCalledTimes(1);
|
|
65
|
+
expect(onSave).toHaveBeenCalledTimes(1);
|
|
66
|
+
expect(onDirtyChange.mock.calls.at(-1)?.[0]).toBe(false);
|
|
106
67
|
});
|
|
107
68
|
|
|
108
69
|
it("reports the draft through onDirtyChange, and clears it on Cancel", async () => {
|
|
@@ -133,25 +94,12 @@ describe("DashboardBuilder: an open inline draft", () => {
|
|
|
133
94
|
}
|
|
134
95
|
});
|
|
135
96
|
|
|
136
|
-
it("Save
|
|
137
|
-
const onExit = mock(() => {});
|
|
97
|
+
it("Save commits the open markdown draft into the saved file, and stays open", async () => {
|
|
138
98
|
const onSave = mock(async (_source: string) => {});
|
|
139
|
-
await mount({
|
|
99
|
+
await mount({ onSave });
|
|
140
100
|
type(openDescription(), "Kept words");
|
|
141
|
-
fireEvent.click(button("
|
|
142
|
-
|
|
143
|
-
await waitFor(() => expect(onExit).toHaveBeenCalledTimes(1));
|
|
144
|
-
expect(onSave).toHaveBeenCalledTimes(1);
|
|
101
|
+
fireEvent.click(button("Save"));
|
|
102
|
+
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
145
103
|
expect(onSave.mock.calls[0]?.[0]).toContain("Kept words");
|
|
146
104
|
});
|
|
147
|
-
|
|
148
|
-
it("asks before exiting with a typed, uncommitted title", async () => {
|
|
149
|
-
const onExit = mock(() => {});
|
|
150
|
-
await mount({ onExit, onSave: async () => {} });
|
|
151
|
-
fireEvent.click(screen.getByText("By category"));
|
|
152
|
-
type(screen.getByLabelText("Tile title"), "Renamed");
|
|
153
|
-
fireEvent.click(button("Close"));
|
|
154
|
-
expect(screen.getByRole("dialog")).toBeDefined();
|
|
155
|
-
expect(onExit).not.toHaveBeenCalled();
|
|
156
|
-
});
|
|
157
105
|
});
|
|
@@ -49,76 +49,69 @@ const mount = async (onSave: (source: string) => void) =>
|
|
|
49
49
|
/>,
|
|
50
50
|
);
|
|
51
51
|
|
|
52
|
-
const
|
|
52
|
+
const save = () =>
|
|
53
|
+
fireEvent.click(screen.getByRole("button", { name: "Save", hidden: true }));
|
|
54
|
+
|
|
55
|
+
/** Add a tile on `name`'s one view through the add-tile picker. */
|
|
56
|
+
const addTileOn = (name: string) => {
|
|
53
57
|
fireEvent.click(
|
|
54
|
-
screen.getByRole("button", { name: "
|
|
58
|
+
screen.getByRole("button", { name: "Add tile", hidden: true }),
|
|
59
|
+
);
|
|
60
|
+
fireEvent.mouseDown(
|
|
61
|
+
screen.getByRole("combobox", { name: /Source/, hidden: true }),
|
|
55
62
|
);
|
|
56
|
-
const closeSettings = () =>
|
|
57
|
-
fireEvent.keyDown(screen.getByLabelText("Show as"), { key: "Escape" });
|
|
58
|
-
const save = () =>
|
|
59
63
|
fireEvent.click(
|
|
60
|
-
|
|
64
|
+
within(
|
|
65
|
+
screen.getAllByRole("listbox", { hidden: true }).at(-1)!,
|
|
66
|
+
).getByRole("option", { name: new RegExp(`^${name}`), hidden: true }),
|
|
61
67
|
);
|
|
68
|
+
fireEvent.click(screen.getByLabelText("View by_x"));
|
|
69
|
+
fireEvent.click(
|
|
70
|
+
screen.getByRole("button", { name: "Add tile", hidden: false }),
|
|
71
|
+
);
|
|
72
|
+
};
|
|
62
73
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
await mount(() => {});
|
|
68
|
-
openSettings();
|
|
69
|
-
const sources = screen.getByLabelText("Sources");
|
|
70
|
-
expect(within(sources).getByText("scoped_orders")).toBeDefined();
|
|
71
|
-
expect(screen.queryByLabelText("Remove source scoped_orders")).toBeNull();
|
|
72
|
-
expect(screen.getByLabelText("Remove source spare")).toBeDefined();
|
|
74
|
+
const written = async (pick: string) => {
|
|
75
|
+
let text: string | undefined;
|
|
76
|
+
await mount((source) => {
|
|
77
|
+
text = source;
|
|
73
78
|
});
|
|
79
|
+
addTileOn(pick);
|
|
80
|
+
save();
|
|
81
|
+
await waitFor(() => expect(text).toBeDefined());
|
|
82
|
+
return text as string;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
afterEach(cleanup);
|
|
74
86
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
await
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
openSettings();
|
|
81
|
-
fireEvent.click(screen.getByLabelText("Remove source spare"));
|
|
82
|
-
closeSettings();
|
|
83
|
-
save();
|
|
84
|
-
await waitFor(() => expect(written).toBeDefined());
|
|
85
|
-
expect(written).toBe(
|
|
86
|
-
NOTEBOOK.replace('import { spare } from "../spare.malloy"\n', ""),
|
|
87
|
+
describe("adding a tile brings its source in", () => {
|
|
88
|
+
it("adds no import for a source the file already imports", async () => {
|
|
89
|
+
const text = await written("spare");
|
|
90
|
+
expect(text).toContain(
|
|
91
|
+
'import { scoped_orders } from "../data_app.malloy"\nimport { spare } from "../spare.malloy"\n\n',
|
|
87
92
|
);
|
|
93
|
+
expect(text.match(/^import /gm)).toHaveLength(2);
|
|
88
94
|
});
|
|
89
95
|
|
|
90
|
-
it("
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
written = text;
|
|
94
|
-
});
|
|
95
|
-
openSettings();
|
|
96
|
-
const add = () =>
|
|
97
|
-
screen.getByRole("combobox", { name: /Add a source/, hidden: true });
|
|
98
|
-
fireEvent.mouseDown(add());
|
|
99
|
-
const options = within(
|
|
100
|
-
screen.getAllByRole("listbox", { hidden: true }).at(-1)!,
|
|
101
|
-
).getAllByRole("option", { hidden: true });
|
|
102
|
-
// Imported sources and the shared includes in dashboards/ are not on offer.
|
|
103
|
-
expect(options.map((o) => o.textContent)).toEqual([
|
|
104
|
-
"regionsdata_app.malloy",
|
|
105
|
-
"eventsevents.malloy",
|
|
106
|
-
]);
|
|
107
|
-
fireEvent.click(options[0]);
|
|
108
|
-
fireEvent.mouseDown(add());
|
|
109
|
-
fireEvent.click(
|
|
110
|
-
within(
|
|
111
|
-
screen.getAllByRole("listbox", { hidden: true }).at(-1)!,
|
|
112
|
-
).getByRole("option", { name: /events/, hidden: true }),
|
|
113
|
-
);
|
|
114
|
-
closeSettings();
|
|
115
|
-
save();
|
|
116
|
-
await waitFor(() => expect(written).toBeDefined());
|
|
117
|
-
expect(written).toContain(
|
|
96
|
+
it("joins a source to its model's existing import", async () => {
|
|
97
|
+
const text = await written("regions");
|
|
98
|
+
expect(text).toContain(
|
|
118
99
|
'import { scoped_orders, regions } from "../data_app.malloy"',
|
|
119
100
|
);
|
|
120
|
-
expect(
|
|
101
|
+
expect(text.match(/^import /gm)).toHaveLength(2);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("gives a source from a model the file does not import a line of its own", async () => {
|
|
105
|
+
const text = await written("events");
|
|
106
|
+
expect(text).toContain(
|
|
121
107
|
'import { spare } from "../spare.malloy"\nimport { events } from "../events.malloy"\n',
|
|
122
108
|
);
|
|
123
109
|
});
|
|
110
|
+
|
|
111
|
+
it("offers no Settings to edit sources by hand", async () => {
|
|
112
|
+
await mount(() => {});
|
|
113
|
+
expect(
|
|
114
|
+
screen.queryByRole("button", { name: "Settings", hidden: true }),
|
|
115
|
+
).toBeNull();
|
|
116
|
+
});
|
|
124
117
|
});
|