@malloy-publisher/sdk 0.9.9 → 0.9.11
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-BlNoIiSi.cjs.js +153 -0
- package/dist/{RenderedResult-BHuJpdSn.es.js → RenderedResult-Cmx8sX8d.es.js} +102 -102
- package/dist/ServerProvider-BOgiW8MX.cjs.js +1 -0
- package/dist/{ServerProvider-CQy4jVYK.es.js → ServerProvider-azXLkk1q.es.js} +619 -586
- package/dist/builder/index.cjs.js +78 -130
- package/dist/builder/index.es.js +7440 -6727
- package/dist/builder-entry.d.ts +3 -0
- package/dist/client/api.d.ts +26 -22
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/AppDialog.d.ts +9 -1
- package/dist/components/Dashboard/DashboardGrid.d.ts +14 -15
- package/dist/components/Dashboard/DashboardTile.d.ts +8 -1
- package/dist/components/Dashboard/DashboardView.d.ts +22 -23
- package/dist/components/Dashboard/TileCard.d.ts +10 -3
- package/dist/components/Dashboard/useStuck.d.ts +22 -0
- package/dist/components/DocumentCreate/newNotebook.d.ts +9 -5
- package/dist/components/DocumentCreate/useDocumentChoices.d.ts +6 -0
- package/dist/components/Package/PackageProblems.d.ts +14 -0
- package/dist/components/RemoveBadge.d.ts +40 -0
- package/dist/components/Report/Report.d.ts +13 -4
- package/dist/components/Report/ReportPage.d.ts +60 -0
- package/dist/components/Report/layoutRules.d.ts +32 -0
- package/dist/components/Report/reportQuery.d.ts +30 -0
- package/dist/components/Report/telemetry.d.ts +0 -2
- package/dist/components/ReportBuilder/AddTileDialog.d.ts +22 -3
- package/dist/components/ReportBuilder/BuilderBar.d.ts +17 -0
- package/dist/components/ReportBuilder/BuilderDialogs.d.ts +7 -6
- package/dist/components/ReportBuilder/BuilderGrid.d.ts +10 -4
- package/dist/components/ReportBuilder/BuilderHeader.d.ts +4 -7
- package/dist/components/ReportBuilder/BuilderToolbar.d.ts +88 -0
- package/dist/components/ReportBuilder/DrillDialog.d.ts +3 -1
- package/dist/components/ReportBuilder/EditorSurface.d.ts +7 -9
- package/dist/components/ReportBuilder/FilterDialog.d.ts +3 -1
- package/dist/components/ReportBuilder/FilterStrip.d.ts +30 -6
- package/dist/components/ReportBuilder/InlineMarkdown.d.ts +4 -4
- package/dist/components/ReportBuilder/ReportBuilder.d.ts +49 -12
- package/dist/components/ReportBuilder/ReportEditor.d.ts +53 -3
- package/dist/components/ReportBuilder/TextTileBody.d.ts +2 -5
- package/dist/components/ReportBuilder/TileFrame.d.ts +10 -4
- package/dist/components/ReportBuilder/TileMenu.d.ts +19 -11
- package/dist/components/ReportBuilder/ViewPicker.d.ts +53 -0
- package/dist/components/ReportBuilder/addTileToDocument.d.ts +24 -3
- package/dist/components/ReportBuilder/builderControls.d.ts +60 -0
- package/dist/components/ReportBuilder/catalog.d.ts +2 -4
- package/dist/components/ReportBuilder/inlineEdit.d.ts +9 -10
- package/dist/components/ReportBuilder/localGiven.d.ts +12 -0
- package/dist/components/ReportBuilder/preview.d.ts +17 -2
- package/dist/components/ReportBuilder/readDocument.d.ts +0 -2
- package/dist/components/ReportBuilder/readForEditor.d.ts +2 -7
- package/dist/components/ReportBuilder/reportTag.d.ts +11 -1
- package/dist/components/ReportBuilder/sortable.d.ts +4 -3
- package/dist/components/ReportBuilder/testing/inline.d.ts +5 -1
- package/dist/components/ReportBuilder/useBuilderSelection.d.ts +0 -1
- package/dist/components/ReportBuilder/useBuilderSession.d.ts +21 -12
- package/dist/components/ReportBuilder/useDocumentEditor.d.ts +2 -6
- package/dist/components/ReportBuilder/useExitGuard.d.ts +3 -0
- package/dist/components/ReportBuilder/useFilterForm.d.ts +3 -1
- package/dist/components/ReportBuilder/useOpenedDocument.d.ts +0 -4
- package/dist/components/ReportBuilder/useReportDraft.d.ts +66 -0
- package/dist/components/ReportBuilder/useReportEditor.d.ts +0 -9
- package/dist/components/ReportBuilder/useTileEditing.d.ts +6 -3
- package/dist/components/ReportBuilder/viewAnnotations.d.ts +9 -0
- package/dist/components/ReportBuilder/widthLabel.d.ts +6 -0
- package/dist/components/ServerProvider.d.ts +9 -0
- package/dist/components/controlTokens.d.ts +45 -0
- package/dist/components/drill/markDrillableCells.d.ts +1 -1
- package/dist/components/given/FilterButton.d.ts +35 -0
- package/dist/components/given/GivensPanel.d.ts +2 -1
- package/dist/components/given/filterEditing.d.ts +54 -0
- package/dist/components/given/filterSummary.d.ts +9 -0
- package/dist/components/given/paramCodec.d.ts +11 -0
- package/dist/components/given/required.d.ts +25 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/legacy/index.d.ts +1 -1
- package/dist/components/{Report/CellReport.d.ts → legacy/malloynb/CellRunnerView.d.ts} +9 -17
- package/dist/components/legacy/{MalloynbCells.d.ts → malloynb/MalloynbCells.d.ts} +3 -3
- package/dist/components/legacy/{Notebook.d.ts → malloynb/Notebook.d.ts} +1 -1
- package/dist/components/{Notebook → legacy/malloynb}/NotebookCell.d.ts +3 -3
- package/dist/components/legacy/malloynb/cellKind.d.ts +5 -0
- package/dist/components/{Notebook → legacy/malloynb}/types.d.ts +1 -1
- package/dist/components/styles.d.ts +0 -2
- package/dist/hooks/useQueryResult.d.ts +7 -0
- package/dist/index.cjs.js +16 -19
- package/dist/index.es.js +8324 -7769
- package/dist/theme/ThemeContext.d.ts +8 -1
- package/dist/theme/classes.d.ts +49 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/types.d.ts +7 -0
- package/dist/theme/ui.d.ts +75 -0
- package/dist/{useCompiledDocument-1dgF5CC9.es.js → useCompiledDocument-7j5cBjQd.es.js} +8768 -7912
- package/dist/useCompiledDocument-B21sVbb4.cjs.js +141 -0
- package/package.json +2 -2
- package/src/builder-entry.ts +9 -0
- package/src/components/AppDialog.tsx +23 -0
- package/src/components/Dashboard/DashboardGrid.tsx +39 -17
- package/src/components/Dashboard/DashboardTile.tsx +19 -2
- package/src/components/Dashboard/DashboardView.spec.tsx +216 -15
- package/src/components/Dashboard/DashboardView.tsx +136 -105
- package/src/components/Dashboard/RowsDialog.tsx +1 -2
- package/src/components/Dashboard/TileCard.tsx +28 -10
- package/src/components/Dashboard/defaultTileSpan.spec.ts +24 -0
- package/src/components/Dashboard/useStuck.ts +49 -0
- package/src/components/DocumentCreate/newNotebook.spec.ts +8 -6
- package/src/components/DocumentCreate/newNotebook.ts +26 -12
- package/src/components/DocumentCreate/useDocumentChoices.ts +19 -2
- package/src/components/Package/NewDocumentDialog.spec.tsx +76 -59
- package/src/components/Package/NewDocumentDialog.tsx +383 -119
- package/src/components/Package/Package.artifacts.spec.tsx +1 -1
- package/src/components/Package/Package.create.spec.tsx +7 -6
- package/src/components/Package/Package.tsx +10 -7
- package/src/components/Package/PackageProblems.spec.tsx +41 -0
- package/src/components/Package/PackageProblems.tsx +95 -0
- package/src/components/Prose.tsx +12 -7
- package/src/components/RemoveBadge.tsx +94 -0
- package/src/components/RenderedResult/RenderedResult.tsx +5 -9
- package/src/components/RenderedResult/ResultPanel.tsx +59 -3
- package/src/components/Report/Report.spec.tsx +50 -32
- package/src/components/Report/Report.telemetry.spec.tsx +0 -45
- package/src/components/Report/Report.tsx +45 -77
- package/src/components/Report/ReportPage.tsx +168 -0
- package/src/components/Report/layoutRules.spec.ts +35 -0
- package/src/components/Report/layoutRules.ts +55 -0
- package/src/components/Report/reportQuery.ts +53 -0
- package/src/components/Report/telemetry.ts +0 -2
- package/src/components/ReportBuilder/AddTileDialog.spec.tsx +76 -41
- package/src/components/ReportBuilder/AddTileDialog.tsx +368 -133
- package/src/components/ReportBuilder/BuilderBar.tsx +599 -0
- package/src/components/ReportBuilder/BuilderDialogs.tsx +30 -39
- package/src/components/ReportBuilder/BuilderGrid.tsx +43 -31
- package/src/components/ReportBuilder/BuilderHeader.tsx +63 -75
- package/src/components/ReportBuilder/BuilderToolbar.tsx +95 -9
- package/src/components/ReportBuilder/DrillDialog.tsx +240 -128
- package/src/components/ReportBuilder/EditorSurface.tsx +345 -69
- package/src/components/ReportBuilder/FilterDialog.tsx +516 -166
- package/src/components/ReportBuilder/FilterStrip.tsx +129 -150
- package/src/components/ReportBuilder/InlineMarkdown.tsx +71 -45
- package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +35 -40
- package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +491 -0
- package/src/components/ReportBuilder/ReportBuilder.exit.spec.tsx +2 -4
- package/src/components/ReportBuilder/ReportBuilder.inline.spec.tsx +13 -16
- package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +27 -118
- package/src/components/ReportBuilder/ReportBuilder.openDraft.spec.tsx +12 -5
- package/src/components/ReportBuilder/ReportBuilder.sources.spec.tsx +2 -10
- package/src/components/ReportBuilder/ReportBuilder.spec.tsx +41 -36
- package/src/components/ReportBuilder/ReportBuilder.textTiles.spec.tsx +22 -15
- package/src/components/ReportBuilder/ReportBuilder.tsx +292 -116
- package/src/components/ReportBuilder/ReportEditor.emptyStart.spec.tsx +2 -1
- package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +312 -0
- package/src/components/ReportBuilder/ReportEditor.notebook.spec.tsx +26 -75
- package/src/components/ReportBuilder/ReportEditor.package.spec.tsx +6 -2
- package/src/components/ReportBuilder/ReportEditor.resourceUri.spec.tsx +3 -2
- package/src/components/ReportBuilder/ReportEditor.spec.tsx +2 -4
- package/src/components/ReportBuilder/ReportEditor.textSource.spec.tsx +93 -13
- package/src/components/ReportBuilder/ReportEditor.tsx +104 -14
- package/src/components/ReportBuilder/TextTileBody.tsx +6 -7
- package/src/components/ReportBuilder/TileFrame.tsx +212 -75
- package/src/components/ReportBuilder/TileMenu.tsx +248 -142
- package/src/components/ReportBuilder/ViewPicker.tsx +349 -0
- package/src/components/ReportBuilder/addTile.compile.spec.ts +1 -1
- package/src/components/ReportBuilder/addTileToDocument.spec.ts +102 -3
- package/src/components/ReportBuilder/addTileToDocument.ts +122 -25
- package/src/components/ReportBuilder/builderControls.ts +164 -0
- package/src/components/ReportBuilder/builderReport.ts +1 -2
- package/src/components/ReportBuilder/catalog.ts +10 -26
- package/src/components/ReportBuilder/inlineEdit.tsx +22 -54
- package/src/components/ReportBuilder/localGiven.ts +56 -0
- package/src/components/ReportBuilder/newDashboard.spec.ts +2 -3
- package/src/components/ReportBuilder/preview.spec.ts +125 -5
- package/src/components/ReportBuilder/preview.ts +60 -44
- package/src/components/ReportBuilder/readDocument.spec.ts +16 -22
- package/src/components/ReportBuilder/readDocument.ts +14 -11
- package/src/components/ReportBuilder/readForEditor.spec.ts +12 -41
- package/src/components/ReportBuilder/readForEditor.ts +4 -26
- package/src/components/ReportBuilder/reportTag.ts +28 -7
- package/src/components/ReportBuilder/sortable.tsx +15 -7
- package/src/components/ReportBuilder/spliceDocument.imports.spec.ts +1 -1
- package/src/components/ReportBuilder/tagParse.spec.ts +0 -40
- package/src/components/ReportBuilder/testing/inline.ts +25 -5
- package/src/components/ReportBuilder/testing/reportLayoutParity.json +13 -8
- package/src/components/ReportBuilder/textTiles.spec.ts +7 -6
- package/src/components/ReportBuilder/useBuilderSelection.ts +35 -0
- package/src/components/ReportBuilder/useBuilderSession.spec.ts +2 -2
- package/src/components/ReportBuilder/useBuilderSession.ts +21 -13
- package/src/components/ReportBuilder/useDocumentEditor.spec.ts +0 -58
- package/src/components/ReportBuilder/useDocumentEditor.ts +3 -16
- package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +26 -0
- package/src/components/ReportBuilder/useEditorCatalog.ts +7 -2
- package/src/components/ReportBuilder/useExitGuard.ts +16 -0
- package/src/components/ReportBuilder/useFilterForm.spec.tsx +17 -0
- package/src/components/ReportBuilder/useFilterForm.ts +5 -1
- package/src/components/ReportBuilder/useOpenedDocument.ts +0 -2
- package/src/components/ReportBuilder/useReportDraft.spec.ts +149 -0
- package/src/components/ReportBuilder/useReportDraft.ts +292 -0
- package/src/components/ReportBuilder/useReportEditor.ts +3 -12
- package/src/components/ReportBuilder/useSaveChannel.ts +0 -1
- package/src/components/ReportBuilder/useTileEditing.ts +43 -12
- package/src/components/ReportBuilder/viewAnnotations.ts +29 -0
- package/src/components/ReportBuilder/widthLabel.spec.ts +25 -0
- package/src/components/ReportBuilder/widthLabel.ts +26 -0
- package/src/components/ServerProvider.tsx +11 -0
- package/src/components/controlTokens.ts +47 -0
- package/src/components/drill/markDrillableCells.ts +2 -1
- package/src/components/given/FilterButton.spec.tsx +143 -0
- package/src/components/given/FilterButton.tsx +478 -0
- package/src/components/given/GivenInput.spec.tsx +47 -0
- package/src/components/given/GivenInput.tsx +20 -2
- package/src/components/given/GivensPanel.spec.tsx +11 -3
- package/src/components/given/GivensPanel.tsx +45 -44
- package/src/components/given/filterEditing.ts +60 -0
- package/src/components/given/filterSummary.spec.ts +108 -0
- package/src/components/given/filterSummary.ts +109 -0
- package/src/components/given/paramCodec.ts +1 -1
- package/src/components/given/required.spec.ts +60 -0
- package/src/components/given/required.ts +78 -0
- package/src/components/index.ts +9 -0
- package/src/components/legacy/Dashboard.spec.tsx +3 -1
- package/src/components/legacy/index.ts +1 -1
- package/src/components/{Report/CellReport.spec.tsx → legacy/malloynb/CellRunnerView.spec.tsx} +53 -57
- package/src/components/{Report/CellReport.tsx → legacy/malloynb/CellRunnerView.tsx} +122 -136
- package/src/components/legacy/{MalloynbCells.tsx → malloynb/MalloynbCells.tsx} +6 -6
- package/src/components/legacy/{Notebook.layout.spec.tsx → malloynb/Notebook.layout.spec.tsx} +16 -7
- package/src/components/legacy/malloynb/Notebook.served.spec.tsx +84 -0
- package/src/components/legacy/{Notebook.spec.tsx → malloynb/Notebook.spec.tsx} +5 -3
- package/src/components/legacy/{Notebook.tsx → malloynb/Notebook.tsx} +9 -7
- package/src/components/{Notebook → legacy/malloynb}/NotebookCell.tsx +70 -150
- package/src/components/legacy/malloynb/cellKind.spec.ts +33 -0
- package/src/components/legacy/malloynb/cellKind.ts +24 -0
- package/src/components/{Notebook → legacy/malloynb}/types.ts +1 -1
- package/src/components/styles.ts +0 -18
- package/src/hooks/useGivensState.ts +7 -3
- package/src/hooks/useQueryResult.placeholder.spec.ts +44 -0
- package/src/hooks/useQueryResult.ts +26 -1
- package/src/theme/ThemeContext.tsx +21 -1
- package/src/theme/classes.ts +52 -0
- package/src/theme/index.ts +8 -0
- package/src/theme/resolveTheme.ts +3 -0
- package/src/theme/types.ts +7 -0
- package/src/theme/ui.spec.tsx +91 -0
- package/src/theme/ui.ts +115 -0
- package/dist/RenderedResult-Bw7EQc42.cjs.js +0 -153
- package/dist/ServerProvider-B0dUY8be.cjs.js +0 -1
- package/dist/components/Notebook/cellKind.d.ts +0 -20
- package/dist/components/Report/LinearReport.d.ts +0 -18
- package/dist/components/ReportBuilder/SourceViewPicker.d.ts +0 -9
- package/dist/components/ReportBuilder/legacyNotebook.d.ts +0 -73
- package/dist/components/ReportBuilder/useConversionConfirm.d.ts +0 -20
- package/dist/useCompiledDocument-BKyRnXmA.cjs.js +0 -141
- package/src/components/Notebook/cellKind.spec.ts +0 -199
- package/src/components/Notebook/cellKind.ts +0 -74
- package/src/components/Report/LinearReport.tsx +0 -71
- package/src/components/ReportBuilder/SourceViewPicker.tsx +0 -122
- package/src/components/ReportBuilder/legacyNotebook.chart.spec.ts +0 -77
- package/src/components/ReportBuilder/legacyNotebook.convert.spec.ts +0 -626
- package/src/components/ReportBuilder/legacyNotebook.read.spec.ts +0 -338
- package/src/components/ReportBuilder/legacyNotebook.ts +0 -1122
- package/src/components/ReportBuilder/useConversionConfirm.ts +0 -55
- package/src/components/legacy/Notebook.served.spec.tsx +0 -183
- /package/dist/components/{Notebook → legacy/malloynb}/runPlan.d.ts +0 -0
- /package/src/components/{Notebook → legacy/malloynb}/runPlan.spec.ts +0 -0
- /package/src/components/{Notebook → legacy/malloynb}/runPlan.ts +0 -0
package/src/components/{Report/CellReport.spec.tsx → legacy/malloynb/CellRunnerView.spec.tsx}
RENAMED
|
@@ -1,57 +1,39 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
+
// DEPRECATED FEATURE COVERAGE — delete together with
|
|
5
|
+
// `.malloynb` notebooks (see RELEASE_NOTES deprecations).
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
|
-
* What a
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* the happy path is `Report.spec`'s.
|
|
8
|
+
* What a `.malloynb` shows when something fails: a cell the server refuses
|
|
9
|
+
* says why in that cell and leaves the others running, and cells that could
|
|
10
|
+
* not be read at all say so in place of the cells.
|
|
9
11
|
*/
|
|
10
|
-
import {
|
|
11
|
-
afterEach,
|
|
12
|
-
beforeEach,
|
|
13
|
-
describe,
|
|
14
|
-
expect,
|
|
15
|
-
it,
|
|
16
|
-
mock,
|
|
17
|
-
spyOn,
|
|
18
|
-
} from "bun:test";
|
|
12
|
+
import { afterEach, beforeEach, describe, expect, it, spyOn } from "bun:test";
|
|
19
13
|
import { render, screen, waitFor } from "@testing-library/react";
|
|
20
14
|
import {
|
|
21
15
|
clearCache,
|
|
22
16
|
mockServerProvider,
|
|
23
17
|
serverWrapper,
|
|
24
|
-
} from "
|
|
25
|
-
import type { RawNotebook } from "
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
(
|
|
31
|
-
_environmentName: string,
|
|
32
|
-
_packageName: string,
|
|
33
|
-
_modelPath: string,
|
|
34
|
-
request: { query?: string },
|
|
35
|
-
) => answer(request.query ?? ""),
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
mockServerProvider({
|
|
39
|
-
models: { executeQueryModel, getModel: () => new Promise(() => {}) },
|
|
40
|
-
});
|
|
18
|
+
} from "../../../../test/serverProvider";
|
|
19
|
+
import type { RawNotebook } from "../../../client";
|
|
20
|
+
import type { CellRunner } from "./CellRunnerView";
|
|
21
|
+
|
|
22
|
+
// Cells run through the runner each test hands in, never the server.
|
|
23
|
+
mockServerProvider({ models: { getModel: () => new Promise(() => {}) } });
|
|
41
24
|
|
|
42
25
|
// Imported after the stub is registered: a static import would hoist above it.
|
|
43
|
-
const {
|
|
26
|
+
const { CellRunnerView } = await import("./CellRunnerView");
|
|
44
27
|
|
|
45
|
-
const URI = "publisher://environments/env/packages/pkg/models/review.
|
|
28
|
+
const URI = "publisher://environments/env/packages/pkg/models/review.malloynb";
|
|
46
29
|
|
|
47
|
-
const cells = (...queries: string[]): RawNotebook =>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}) as RawNotebook;
|
|
30
|
+
const cells = (...queries: string[]): RawNotebook => ({
|
|
31
|
+
format: "malloynb",
|
|
32
|
+
notebookCells: [
|
|
33
|
+
{ type: "markdown", text: "Intro prose" },
|
|
34
|
+
...queries.map((text) => ({ type: "code" as const, text })),
|
|
35
|
+
],
|
|
36
|
+
});
|
|
55
37
|
|
|
56
38
|
/** A rejection shaped like axios's, carrying the server's `{message}`. */
|
|
57
39
|
const refused = (message: string) =>
|
|
@@ -59,11 +41,20 @@ const refused = (message: string) =>
|
|
|
59
41
|
response: { data: { message } },
|
|
60
42
|
});
|
|
61
43
|
|
|
44
|
+
/** A runner that answers each cell's code with `answer`, and records the order it was asked in. */
|
|
45
|
+
function runner(answer: (code: string) => Promise<unknown>) {
|
|
46
|
+
const asked: number[] = [];
|
|
47
|
+
const runCell: CellRunner = ({ cell, index }) => {
|
|
48
|
+
asked.push(index);
|
|
49
|
+
return answer(cell.text ?? "") as ReturnType<CellRunner>;
|
|
50
|
+
};
|
|
51
|
+
return { asked, runCell };
|
|
52
|
+
}
|
|
53
|
+
|
|
62
54
|
// A failed cell is logged as well as shown; the log is not under test.
|
|
63
55
|
let quiet: { mockRestore(): void } | undefined;
|
|
64
56
|
beforeEach(() => {
|
|
65
57
|
clearCache();
|
|
66
|
-
executeQueryModel.mockClear();
|
|
67
58
|
quiet = spyOn(console, "error").mockImplementation(() => {});
|
|
68
59
|
});
|
|
69
60
|
afterEach(() => quiet?.mockRestore());
|
|
@@ -86,10 +77,15 @@ describe("a cell that fails", () => {
|
|
|
86
77
|
"The server did not say why.",
|
|
87
78
|
],
|
|
88
79
|
])("says why with %s, in that cell", async (_name, error, shown) => {
|
|
89
|
-
|
|
90
|
-
render(
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
const { runCell } = runner(() => Promise.reject(error));
|
|
81
|
+
render(
|
|
82
|
+
<CellRunnerView
|
|
83
|
+
resourceUri={URI}
|
|
84
|
+
notebook={cells("run: a -> v")}
|
|
85
|
+
runCell={runCell}
|
|
86
|
+
/>,
|
|
87
|
+
{ wrapper: serverWrapper },
|
|
88
|
+
);
|
|
93
89
|
|
|
94
90
|
expect(
|
|
95
91
|
await screen.findByText("This cell could not be run."),
|
|
@@ -99,23 +95,23 @@ describe("a cell that fails", () => {
|
|
|
99
95
|
});
|
|
100
96
|
|
|
101
97
|
it("still runs and shows the other cells", async () => {
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
const { asked, runCell } = runner((code) =>
|
|
99
|
+
code === "run: bad -> v"
|
|
104
100
|
? Promise.reject(refused("no such source"))
|
|
105
|
-
: Promise.resolve({
|
|
101
|
+
: Promise.resolve({}),
|
|
102
|
+
);
|
|
106
103
|
render(
|
|
107
|
-
<
|
|
104
|
+
<CellRunnerView
|
|
108
105
|
resourceUri={URI}
|
|
109
106
|
notebook={cells("run: bad -> v", "run: good -> v")}
|
|
107
|
+
runCell={runCell}
|
|
110
108
|
/>,
|
|
111
109
|
{ wrapper: serverWrapper },
|
|
112
110
|
);
|
|
113
111
|
|
|
114
112
|
expect(await screen.findByText("no such source")).toBeTruthy();
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
expect.objectContaining({ query: "run: good -> v" }),
|
|
118
|
-
]);
|
|
113
|
+
// The markdown cell is index 0 and never runs.
|
|
114
|
+
expect(asked).toEqual([1, 2]);
|
|
119
115
|
expect(screen.getAllByText("This cell could not be run.")).toHaveLength(
|
|
120
116
|
1,
|
|
121
117
|
);
|
|
@@ -138,16 +134,16 @@ describe("cells that could not be read", () => {
|
|
|
138
134
|
{ wrapper: serverWrapper },
|
|
139
135
|
);
|
|
140
136
|
|
|
141
|
-
it("names the
|
|
137
|
+
it("names the notebook that does not exist", () => {
|
|
142
138
|
view({ status: 404, message: "Not found" });
|
|
143
|
-
expect(screen.getByText("env > pkg > review.
|
|
139
|
+
expect(screen.getByText("env > pkg > review.malloynb")).toBeTruthy();
|
|
144
140
|
expect(screen.getByText(/not found\./)).toBeTruthy();
|
|
145
141
|
});
|
|
146
142
|
|
|
147
|
-
it("shows any other failure with the
|
|
143
|
+
it("shows any other failure with the notebook it was reading", async () => {
|
|
148
144
|
view({ status: 500, message: "The package did not load" });
|
|
149
145
|
await waitFor(() =>
|
|
150
|
-
expect(screen.getByText("env > pkg > review.
|
|
146
|
+
expect(screen.getByText("env > pkg > review.malloynb")).toBeTruthy(),
|
|
151
147
|
);
|
|
152
148
|
expect(screen.getByText("The package did not load")).toBeTruthy();
|
|
153
149
|
expect(screen.queryByText(/not found\./)).toBeNull();
|
|
@@ -1,28 +1,42 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated `.malloynb` only. The cell runner behind the deprecated
|
|
6
|
+
* `Notebook`: it runs a `.malloynb` notebook's code cells through the
|
|
7
|
+
* deprecated `…/notebooks/*` routes and draws them on the shared report page.
|
|
8
|
+
* Nothing outside `legacy/malloynb/` imports it (eslint enforces this), and it
|
|
9
|
+
* is deleted with the `.malloynb` format. A `.malloy` report is always tiles,
|
|
10
|
+
* drawn by `DashboardView`.
|
|
11
|
+
*/
|
|
12
|
+
|
|
4
13
|
import "@malloydata/malloy-explorer/styles.css";
|
|
5
|
-
import {
|
|
14
|
+
import { Typography } from "@mui/material";
|
|
6
15
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
-
import type { NotebookCell as RawCell, RawNotebook } from "
|
|
8
|
-
import type { GivenValue } from "
|
|
9
|
-
import { useDocumentControls } from "
|
|
10
|
-
import { useModelGivens } from "
|
|
11
|
-
import { GIVEN_SETTLE_MS } from "
|
|
12
|
-
import { parseResourceUri } from "
|
|
13
|
-
import { ApiErrorDisplay, type ApiError } from "
|
|
14
|
-
import type { NavigationClick } from "
|
|
15
|
-
import type { DrillNavigation } from "
|
|
16
|
-
import { GivensPanel } from "
|
|
17
|
-
import { givensToParams, givensToRequest } from "
|
|
18
|
-
import { Loading, LOADING_COPY } from "
|
|
19
|
-
import { cellRuns } from "
|
|
20
|
-
import { NotebookCell } from "
|
|
21
|
-
import { planRun } from "
|
|
22
|
-
import type { EnhancedNotebookCell } from "
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
16
|
+
import type { NotebookCell as RawCell, RawNotebook } from "../../../client";
|
|
17
|
+
import type { GivenValue } from "../../../hooks/givenValue";
|
|
18
|
+
import { useDocumentControls } from "../../../hooks/useDocumentControls";
|
|
19
|
+
import { useModelGivens } from "../../../hooks/useModelGivens";
|
|
20
|
+
import { GIVEN_SETTLE_MS } from "../../../hooks/useSettled";
|
|
21
|
+
import { parseResourceUri } from "../../../utils/formatting";
|
|
22
|
+
import { ApiErrorDisplay, type ApiError } from "../../ApiErrorDisplay";
|
|
23
|
+
import type { NavigationClick } from "../../click_helper";
|
|
24
|
+
import type { DrillNavigation } from "../../drill";
|
|
25
|
+
import { GivensPanel } from "../../given";
|
|
26
|
+
import { givensToParams, givensToRequest } from "../../given/paramCodec";
|
|
27
|
+
import { Loading, LOADING_COPY } from "../../Loading";
|
|
28
|
+
import { cellRuns } from "./cellKind";
|
|
29
|
+
import { NotebookCell } from "./NotebookCell";
|
|
30
|
+
import { planRun } from "./runPlan";
|
|
31
|
+
import type { EnhancedNotebookCell } from "./types";
|
|
32
|
+
import { failureCategory, useReportEvents } from "../../Report/telemetry";
|
|
33
|
+
import { Prose } from "../../Prose";
|
|
34
|
+
import {
|
|
35
|
+
ReportHeader,
|
|
36
|
+
ReportPage,
|
|
37
|
+
StickyControls,
|
|
38
|
+
TextTileFrame,
|
|
39
|
+
} from "../../Report/ReportPage";
|
|
26
40
|
|
|
27
41
|
// Maximum number of concurrent cell executions to avoid overwhelming the server
|
|
28
42
|
const MAX_CONCURRENT = 4;
|
|
@@ -61,6 +75,9 @@ export type CellRunner = (
|
|
|
61
75
|
export interface CellReportProps {
|
|
62
76
|
/** `publisher://…/models/<path>`: the report, and the model its cells run against. */
|
|
63
77
|
resourceUri: string;
|
|
78
|
+
/** The report's title and description, drawn in the header every report has. */
|
|
79
|
+
title?: string;
|
|
80
|
+
description?: string;
|
|
64
81
|
maxResultSize?: number;
|
|
65
82
|
/**
|
|
66
83
|
* Parameter values from the host, typically its URL query parameters: the
|
|
@@ -117,6 +134,8 @@ export interface CellReportProps {
|
|
|
117
134
|
*/
|
|
118
135
|
export function CellRunnerView({
|
|
119
136
|
resourceUri,
|
|
137
|
+
title,
|
|
138
|
+
description,
|
|
120
139
|
maxResultSize = 0,
|
|
121
140
|
givens,
|
|
122
141
|
onGivensChange,
|
|
@@ -465,123 +484,90 @@ export function CellRunnerView({
|
|
|
465
484
|
|
|
466
485
|
const shownCells =
|
|
467
486
|
enhancedCells.length > 0 ? enhancedCells : notebook?.notebookCells || [];
|
|
468
|
-
// A
|
|
469
|
-
const copyLinkIndex =
|
|
470
|
-
notebook?.format === "malloy"
|
|
471
|
-
? shownCells.findIndex((cell) => cell.type === "markdown")
|
|
472
|
-
: 0;
|
|
487
|
+
// A .malloynb keeps the copy-link icon on its first cell.
|
|
488
|
+
const copyLinkIndex = 0;
|
|
473
489
|
|
|
474
490
|
return (
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
// controls see the document ARRIVE as they do when it is fetched: that
|
|
557
|
-
// arrival is what reports the file's starting values to the host's URL
|
|
558
|
-
// (`useGivensState` seeds its record from the first render).
|
|
559
|
-
const [mounted, setMounted] = useState(false);
|
|
560
|
-
useEffect(() => setMounted(true), []);
|
|
561
|
-
const runCell = useCallback<CellRunner>(
|
|
562
|
-
async ({ cell, givens, declaredTypes, signal }) => ({
|
|
563
|
-
result: (
|
|
564
|
-
await apiClients.models.executeQueryModel(
|
|
565
|
-
environmentName,
|
|
566
|
-
packageName,
|
|
567
|
-
modelPath,
|
|
568
|
-
{
|
|
569
|
-
query: cell.text,
|
|
570
|
-
givens: givensToRequest(givens, declaredTypes),
|
|
571
|
-
versionId,
|
|
572
|
-
},
|
|
573
|
-
undefined,
|
|
574
|
-
{ signal },
|
|
575
|
-
)
|
|
576
|
-
).data.result,
|
|
577
|
-
}),
|
|
578
|
-
[apiClients.models, environmentName, packageName, modelPath, versionId],
|
|
579
|
-
);
|
|
580
|
-
return (
|
|
581
|
-
<CellRunnerView
|
|
582
|
-
{...props}
|
|
583
|
-
notebook={mounted ? held : undefined}
|
|
584
|
-
runCell={runCell}
|
|
585
|
-
/>
|
|
491
|
+
// The page every report draws, whatever its format: the header, the
|
|
492
|
+
// pinned row of filter buttons, then the cells as prose and tiles.
|
|
493
|
+
<ReportPage
|
|
494
|
+
// Cells read top to bottom, so a report of cells is linear.
|
|
495
|
+
layout="linear"
|
|
496
|
+
header={
|
|
497
|
+
title || description ? (
|
|
498
|
+
<ReportHeader
|
|
499
|
+
title={title ?? ""}
|
|
500
|
+
description={
|
|
501
|
+
description ? (
|
|
502
|
+
<TextTileFrame>
|
|
503
|
+
<Prose variant="document">{description}</Prose>
|
|
504
|
+
</TextTileFrame>
|
|
505
|
+
) : undefined
|
|
506
|
+
}
|
|
507
|
+
/>
|
|
508
|
+
) : null
|
|
509
|
+
}
|
|
510
|
+
controls={
|
|
511
|
+
controls.panel.givens.length > 0 ? (
|
|
512
|
+
<StickyControls>
|
|
513
|
+
<GivensPanel {...controls.panel} layout="bar" />
|
|
514
|
+
</StickyControls>
|
|
515
|
+
) : undefined
|
|
516
|
+
}
|
|
517
|
+
>
|
|
518
|
+
{!isSuccess && !isError && (
|
|
519
|
+
<Loading text={LOADING_COPY.opening("report")} />
|
|
520
|
+
)}
|
|
521
|
+
|
|
522
|
+
{isSuccess &&
|
|
523
|
+
shownCells.map((cell, index) => (
|
|
524
|
+
<NotebookCell
|
|
525
|
+
cell={cell as EnhancedNotebookCell}
|
|
526
|
+
key={index}
|
|
527
|
+
showCopyLink={index === copyLinkIndex}
|
|
528
|
+
resourceUri={resourceUri}
|
|
529
|
+
maxResultSize={maxResultSize}
|
|
530
|
+
isExecuting={isExecuting}
|
|
531
|
+
givens={cellStartingGivens}
|
|
532
|
+
givenSpecs={declaredGivens}
|
|
533
|
+
// Distinct from `isExecuting`: the cell's spinner is
|
|
534
|
+
// gated on `!cell.result`, so feeding this through it
|
|
535
|
+
// showed nothing on a re-run, which is the only case
|
|
536
|
+
// the settle window has to signal.
|
|
537
|
+
pendingRerun={runScheduled}
|
|
538
|
+
onNavigate={onNavigate}
|
|
539
|
+
onDrillNavigate={onDrillNavigate}
|
|
540
|
+
onDrillSelf={
|
|
541
|
+
declaredGivens.length > 0 ? onDrillSelf : undefined
|
|
542
|
+
}
|
|
543
|
+
canDrillSelf={canDrillSelf}
|
|
544
|
+
/>
|
|
545
|
+
))}
|
|
546
|
+
|
|
547
|
+
{isError && error?.status === 404 && (
|
|
548
|
+
<Typography variant="body2" sx={{ color: "text.secondary" }}>
|
|
549
|
+
<code>{`${environmentName} > ${packageName} > ${notebookPath}`}</code>{" "}
|
|
550
|
+
not found.
|
|
551
|
+
</Typography>
|
|
552
|
+
)}
|
|
553
|
+
|
|
554
|
+
{isError && error?.status !== 404 && (
|
|
555
|
+
<ApiErrorDisplay
|
|
556
|
+
error={error as ApiError}
|
|
557
|
+
context={`${environmentName} > ${packageName} > ${notebookPath}`}
|
|
558
|
+
/>
|
|
559
|
+
)}
|
|
560
|
+
|
|
561
|
+
{executionError && (
|
|
562
|
+
<ApiErrorDisplay
|
|
563
|
+
error={{
|
|
564
|
+
message: executionError.message,
|
|
565
|
+
status: 500,
|
|
566
|
+
name: "ExecutionError",
|
|
567
|
+
}}
|
|
568
|
+
context="Notebook Execution"
|
|
569
|
+
/>
|
|
570
|
+
)}
|
|
571
|
+
</ReportPage>
|
|
586
572
|
);
|
|
587
573
|
}
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import { useCallback } from "react";
|
|
5
|
-
import type { RawNotebook } from "
|
|
6
|
-
import { useQueryWithApiError } from "
|
|
7
|
-
import { parseResourceUri } from "
|
|
8
|
-
import { givensToRequest } from "
|
|
5
|
+
import type { RawNotebook } from "../../../client";
|
|
6
|
+
import { useQueryWithApiError } from "../../../hooks/useQueryWithApiError";
|
|
7
|
+
import { parseResourceUri } from "../../../utils/formatting";
|
|
8
|
+
import { givensToRequest } from "../../given/paramCodec";
|
|
9
9
|
import {
|
|
10
10
|
CellRunnerView,
|
|
11
11
|
type CellReportProps,
|
|
12
12
|
type CellRunner,
|
|
13
|
-
} from "
|
|
14
|
-
import { useServer } from "
|
|
13
|
+
} from "./CellRunnerView";
|
|
14
|
+
import { useServer } from "../../ServerProvider";
|
|
15
15
|
|
|
16
16
|
/** The deprecated notebook read, one cache entry per URI however many components ask. */
|
|
17
17
|
export function useNotebookQuery(resourceUri: string) {
|
package/src/components/legacy/{Notebook.layout.spec.tsx → malloynb/Notebook.layout.spec.tsx}
RENAMED
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
mockServerProvider,
|
|
9
9
|
pending,
|
|
10
10
|
serverWrapper,
|
|
11
|
-
} from "
|
|
12
|
-
import type { RawNotebook } from "
|
|
11
|
+
} from "../../../../test/serverProvider";
|
|
12
|
+
import type { RawNotebook } from "../../../client";
|
|
13
13
|
|
|
14
14
|
const LAYOUT = {
|
|
15
15
|
format: "malloy",
|
|
@@ -56,14 +56,22 @@ beforeEach(() => {
|
|
|
56
56
|
executeQueryModel.mockClear();
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
it("renders a layout notebook as a
|
|
59
|
+
it("renders a layout notebook as a grid report draws its tiles", async () => {
|
|
60
60
|
const { container } = render(
|
|
61
61
|
<Notebook resourceUri="publisher://environments/env/packages/pkg/models/notebooks/tour.malloy" />,
|
|
62
62
|
{ wrapper: serverWrapper },
|
|
63
63
|
);
|
|
64
64
|
|
|
65
65
|
expect((await screen.findByText("intro")).tagName).toBe("STRONG");
|
|
66
|
-
|
|
66
|
+
// Text as prose, a query tile in a card: the same look as a grid.
|
|
67
|
+
expect(
|
|
68
|
+
(await screen.findByText("intro"))
|
|
69
|
+
.closest("[data-chrome]")
|
|
70
|
+
?.getAttribute("data-chrome"),
|
|
71
|
+
).toBe("none");
|
|
72
|
+
await waitFor(() =>
|
|
73
|
+
expect(container.querySelector('[data-chrome="card"]')).not.toBeNull(),
|
|
74
|
+
);
|
|
67
75
|
// Tiles run through the model query endpoint, not the cell endpoint.
|
|
68
76
|
await waitFor(() => expect(executeQueryModel).toHaveBeenCalled());
|
|
69
77
|
expect(executeQueryModel.mock.calls[0]?.[2]).toBe("notebooks/tour.malloy");
|
|
@@ -79,16 +87,17 @@ it("shows a layout notebook's title and description above its tiles", async () =
|
|
|
79
87
|
|
|
80
88
|
expect(
|
|
81
89
|
(await screen.findByRole("heading", { name: "Tour title" })).tagName,
|
|
82
|
-
|
|
90
|
+
// The page's main heading: the report title is the page.
|
|
91
|
+
).toBe("H1");
|
|
83
92
|
expect((await screen.findByText("description")).tagName).toBe("STRONG");
|
|
84
93
|
});
|
|
85
94
|
|
|
86
|
-
it("
|
|
95
|
+
it("titles an untitled layout notebook with its name, as a grid report does", async () => {
|
|
87
96
|
render(
|
|
88
97
|
<Notebook resourceUri="publisher://environments/env/packages/pkg/models/notebooks/tour.malloy" />,
|
|
89
98
|
{ wrapper: serverWrapper },
|
|
90
99
|
);
|
|
91
100
|
|
|
92
101
|
await screen.findByText("intro");
|
|
93
|
-
expect(screen.
|
|
102
|
+
expect(screen.getByRole("heading", { name: "tour" })).toBeDefined();
|
|
94
103
|
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { beforeEach, describe, expect, it, mock } from "bun:test";
|
|
5
|
+
import { render, screen, waitFor } from "@testing-library/react";
|
|
6
|
+
import {
|
|
7
|
+
clearCache,
|
|
8
|
+
mockServerProvider,
|
|
9
|
+
pending,
|
|
10
|
+
serverWrapper,
|
|
11
|
+
} from "../../../../test/serverProvider";
|
|
12
|
+
import type { RawNotebook } from "../../../client";
|
|
13
|
+
|
|
14
|
+
const SERVED = {
|
|
15
|
+
format: "malloynb",
|
|
16
|
+
notebookCells: [
|
|
17
|
+
{ type: "markdown", text: "Served prose" },
|
|
18
|
+
{ type: "code", text: 'import { orders } from "../orders.malloy"' },
|
|
19
|
+
{ type: "code", text: "run: orders -> by_month" },
|
|
20
|
+
],
|
|
21
|
+
} as RawNotebook;
|
|
22
|
+
|
|
23
|
+
let current: RawNotebook = SERVED;
|
|
24
|
+
const getNotebook = mock(() => Promise.resolve({ data: current }));
|
|
25
|
+
const executeNotebookCell = mock(
|
|
26
|
+
(
|
|
27
|
+
_env: string,
|
|
28
|
+
_pkg: string,
|
|
29
|
+
_path: string,
|
|
30
|
+
_index: number,
|
|
31
|
+
): Promise<never> => pending(),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
mockServerProvider({
|
|
35
|
+
notebooks: { getNotebook, executeNotebookCell },
|
|
36
|
+
models: { executeQueryModel: () => pending() },
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const { default: Notebook } = await import("./Notebook");
|
|
40
|
+
|
|
41
|
+
const URI =
|
|
42
|
+
"publisher://environments/env/packages/pkg/models/notebooks/ops.malloynb";
|
|
43
|
+
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
current = SERVED;
|
|
46
|
+
clearCache();
|
|
47
|
+
getNotebook.mockClear();
|
|
48
|
+
executeNotebookCell.mockClear();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("runs every code cell of a .malloynb", async () => {
|
|
52
|
+
render(<Notebook resourceUri={URI} />, { wrapper: serverWrapper });
|
|
53
|
+
|
|
54
|
+
await waitFor(() =>
|
|
55
|
+
expect(executeNotebookCell.mock.calls.map((call) => call[3])).toEqual([
|
|
56
|
+
1, 2,
|
|
57
|
+
]),
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("puts the copy-link icon on a leading markdown cell", async () => {
|
|
62
|
+
render(<Notebook resourceUri={URI} />, { wrapper: serverWrapper });
|
|
63
|
+
|
|
64
|
+
await screen.findByText("Served prose");
|
|
65
|
+
expect(screen.getAllByTestId("LinkOutlinedIcon")).toHaveLength(1);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// DEPRECATED FEATURE COVERAGE — delete together with
|
|
69
|
+
// `.malloynb` notebooks (see RELEASE_NOTES deprecations).
|
|
70
|
+
describe("deprecated: .malloynb notebooks", () => {
|
|
71
|
+
it("keeps the copy-link icon off a .malloynb that opens with a code cell", async () => {
|
|
72
|
+
current = {
|
|
73
|
+
format: "malloynb",
|
|
74
|
+
notebookCells: [
|
|
75
|
+
{ type: "code", text: "import { orders } from '../orders.malloy'" },
|
|
76
|
+
{ type: "markdown", text: "Legacy prose" },
|
|
77
|
+
],
|
|
78
|
+
} as RawNotebook;
|
|
79
|
+
render(<Notebook resourceUri={URI} />, { wrapper: serverWrapper });
|
|
80
|
+
|
|
81
|
+
await screen.findByText("Legacy prose");
|
|
82
|
+
expect(screen.queryAllByTestId("LinkOutlinedIcon")).toHaveLength(0);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
mockServerProvider,
|
|
20
20
|
pending,
|
|
21
21
|
serverWrapper,
|
|
22
|
-
} from "
|
|
23
|
-
import type { RawNotebook } from "
|
|
22
|
+
} from "../../../../test/serverProvider";
|
|
23
|
+
import type { RawNotebook } from "../../../client";
|
|
24
24
|
|
|
25
25
|
const NOTEBOOK: RawNotebook = {
|
|
26
26
|
notebookCells: [
|
|
@@ -91,7 +91,7 @@ const dataSourcesDialogProps = mock(
|
|
|
91
91
|
data?: { givens?: { name?: string }[] };
|
|
92
92
|
}) => {},
|
|
93
93
|
);
|
|
94
|
-
mock.module("
|
|
94
|
+
mock.module("../../Model/ModelExplorerDialog", () => ({
|
|
95
95
|
ModelExplorerDialog: (props: {
|
|
96
96
|
open: boolean;
|
|
97
97
|
startingGivens?: Record<string, string>;
|
|
@@ -141,6 +141,8 @@ it("sends none when the notebook was opened without one", async () => {
|
|
|
141
141
|
it("opens a cell's 'Data sources' dialog with the notebook's current values", async () => {
|
|
142
142
|
render(<Notebook resourceUri={URI} />, { wrapper: serverWrapper });
|
|
143
143
|
|
|
144
|
+
// The control sits in its filter button's popover.
|
|
145
|
+
fireEvent.click(await screen.findByRole("button", { name: /^TENANT: / }));
|
|
144
146
|
const input = (await screen.findByLabelText("TENANT")) as HTMLInputElement;
|
|
145
147
|
fireEvent.change(input, { target: { value: "acme" } });
|
|
146
148
|
// Wait for the control's own re-render before opening the dialog: without
|