@malloy-publisher/sdk 0.16.1 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -50
- package/dist/{RenderedResult-vyM2wQbC.es.js → RenderedResult-CYJ2Y9Fm.es.js} +9 -9
- package/dist/{RenderedResult-DTM9o4Ql.cjs.js → RenderedResult-hRvgFMAF.cjs.js} +1 -1
- package/dist/ServerProvider-DeVejmVr.cjs.js +1 -0
- package/dist/{ServerProvider-lAZ5ZdQS.es.js → ServerProvider-DzzfVDg_.es.js} +1491 -1878
- package/dist/builder/index.cjs.js +12 -12
- package/dist/builder/index.es.js +4 -9
- package/dist/client/api.d.ts +312 -693
- 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 +130 -141
- package/dist/components/Dashboard/DashboardGrid.d.ts +1 -1
- package/dist/components/Model/ExplorerPage.d.ts +1 -3
- package/dist/components/Model/Model.d.ts +1 -4
- package/dist/components/Model/ModelExplorer.d.ts +1 -2
- package/dist/components/Package/reportQueries.d.ts +2 -4
- package/dist/components/Report/Report.d.ts +20 -9
- package/dist/components/{legacy → Report}/malloynb/CellRunnerView.d.ts +13 -16
- package/dist/components/Report/malloynb/MalloynbReport.d.ts +11 -0
- package/dist/components/{legacy → Report}/malloynb/cellKind.d.ts +1 -1
- package/dist/components/ServerProvider.d.ts +1 -3
- package/dist/components/drill/drillClauses.d.ts +8 -9
- package/dist/components/drill/rowsTarget.d.ts +7 -9
- package/dist/components/legacy/index.d.ts +3 -7
- package/dist/components/modelPage.d.ts +2 -5
- package/dist/hooks/useModelGivens.d.ts +2 -2
- package/dist/hooks/useQueryResult.d.ts +7 -0
- package/dist/index.cjs.js +33 -33
- package/dist/index.es.js +8807 -8903
- package/dist/{useCompiledDocument-2huaKTJN.cjs.js → useCompiledDocument-BCr-xB_i.cjs.js} +5 -5
- package/dist/{useCompiledDocument-CSXZufFO.es.js → useCompiledDocument-E0tU5KzP.es.js} +268 -275
- package/package.json +1 -1
- package/src/components/Dashboard/DashboardGrid.tsx +1 -1
- package/src/components/Dashboard/DashboardTile.spec.tsx +3 -2
- package/src/components/Dashboard/DownloadRowsCsv.tsx +2 -0
- package/src/components/Dashboard/RowsDialog.actions.spec.tsx +2 -1
- package/src/components/Model/ExplorerPage.tsx +1 -3
- package/src/components/Model/Model.tsx +1 -4
- package/src/components/Model/ModelExplorer.tsx +1 -2
- package/src/components/ModelViewer/useRunQuery.spec.ts +2 -2
- package/src/components/ModelViewer/useRunQuery.ts +2 -0
- package/src/components/Package/Package.tsx +1 -5
- package/src/components/Package/reportQueries.ts +3 -15
- package/src/components/Report/Report.malloynb.spec.tsx +230 -0
- package/src/components/Report/Report.spec.tsx +429 -38
- package/src/components/Report/Report.telemetry.spec.tsx +51 -10
- package/src/components/Report/Report.tsx +63 -44
- package/src/components/{legacy → Report}/malloynb/CellRunnerView.spec.tsx +11 -44
- package/src/components/{legacy → Report}/malloynb/CellRunnerView.tsx +63 -107
- package/src/components/Report/malloynb/MalloynbReport.tsx +110 -0
- package/src/components/{legacy → Report}/malloynb/cellKind.ts +5 -4
- package/src/components/ReportBuilder/EditorSurface.tsx +3 -3
- package/src/components/ReportBuilder/ReportBuilder.spec.tsx +2 -2
- package/src/components/ReportBuilder/ReportEditor.notebook.spec.tsx +0 -4
- package/src/components/ReportBuilder/ReportEditor.queryVersion.spec.tsx +0 -1
- package/src/components/ReportBuilder/ReportEditor.resourceUri.spec.tsx +3 -3
- package/src/components/ReportBuilder/ReportEditor.tsx +1 -1
- package/src/components/ReportBuilder/loadMalloy.ts +1 -4
- package/src/components/ReportBuilder/useSaveChannel.ts +1 -6
- package/src/components/ServerProvider.tsx +0 -4
- package/src/components/drill/drillClauses.ts +8 -9
- package/src/components/drill/rowsTarget.ts +7 -9
- package/src/components/index.ts +2 -3
- package/src/components/legacy/index.ts +3 -7
- package/src/components/modelPage.ts +2 -5
- package/src/hooks/useDimensionalFilterRangeData.ts +2 -0
- package/src/hooks/useGivensState.ts +8 -8
- package/src/hooks/useModelGivens.ts +2 -2
- package/src/hooks/useQueryResult.ts +30 -16
- package/src/hooks/useRawQueryData.ts +2 -0
- package/src/hooks/useSuggestOptions.ts +2 -0
- package/test/README.md +4 -4
- package/dist/ServerProvider-DpOy4_Kf.cjs.js +0 -1
- package/dist/components/legacy/Dashboard.d.ts +0 -68
- package/dist/components/legacy/malloynb/MalloynbCells.d.ts +0 -13
- package/dist/components/legacy/malloynb/Notebook.d.ts +0 -15
- package/dist/components/legacy/queryKeys.d.ts +0 -8
- package/src/components/legacy/Dashboard.spec.tsx +0 -242
- package/src/components/legacy/Dashboard.tsx +0 -181
- package/src/components/legacy/malloynb/MalloynbCells.tsx +0 -88
- package/src/components/legacy/malloynb/Notebook.layout.spec.tsx +0 -103
- package/src/components/legacy/malloynb/Notebook.served.spec.tsx +0 -84
- package/src/components/legacy/malloynb/Notebook.spec.tsx +0 -223
- package/src/components/legacy/malloynb/Notebook.tsx +0 -46
- package/src/components/legacy/queryKeys.ts +0 -26
- /package/dist/components/{legacy → Report}/malloynb/NotebookCell.d.ts +0 -0
- /package/dist/components/{legacy → Report}/malloynb/runPlan.d.ts +0 -0
- /package/dist/components/{legacy → Report}/malloynb/types.d.ts +0 -0
- /package/src/components/{legacy → Report}/malloynb/NotebookCell.tsx +0 -0
- /package/src/components/{legacy → Report}/malloynb/cellKind.spec.ts +0 -0
- /package/src/components/{legacy → Report}/malloynb/runPlan.spec.ts +0 -0
- /package/src/components/{legacy → Report}/malloynb/runPlan.ts +0 -0
- /package/src/components/{legacy → Report}/malloynb/types.ts +0 -0
package/package.json
CHANGED
|
@@ -185,7 +185,7 @@ export const readingOrder = (tile: GridTile) =>
|
|
|
185
185
|
* The composite dashboard's grid: the column track, and each tile's place on
|
|
186
186
|
* it.
|
|
187
187
|
*
|
|
188
|
-
* Shared by the READER (
|
|
188
|
+
* Shared by the READER (`DashboardView`) and the BUILDER, which is the whole
|
|
189
189
|
* point of it being a component rather than a rule each surface applies. An
|
|
190
190
|
* author arranging a dashboard is arranging the thing a reader will open, so
|
|
191
191
|
* the two cannot be allowed to lay tiles out even slightly differently; a
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* The tile's own query key, asserted directly rather than through `
|
|
5
|
+
* The tile's own query key, asserted directly rather than through `DashboardView`.
|
|
6
6
|
*
|
|
7
7
|
* `DashboardTile` is exported from the package root, so a host can mount one
|
|
8
8
|
* itself, and `versionId` has to land in both the request and the key from the
|
|
@@ -31,6 +31,7 @@ const executeQueryModel = mock(
|
|
|
31
31
|
_modelPath: string,
|
|
32
32
|
_request: { versionId?: string },
|
|
33
33
|
_includeHidden?: boolean,
|
|
34
|
+
_versionId?: string,
|
|
34
35
|
_options?: { signal?: AbortSignal },
|
|
35
36
|
) => pending(),
|
|
36
37
|
);
|
|
@@ -138,7 +139,7 @@ it("puts the filter warning under the heading and above the result", () => {
|
|
|
138
139
|
|
|
139
140
|
// The request's own signal, as react-query handed it to `executeQueryModel`.
|
|
140
141
|
const signalOf = (call: number) =>
|
|
141
|
-
executeQueryModel.mock.calls[call][
|
|
142
|
+
executeQueryModel.mock.calls[call][6]?.signal as AbortSignal;
|
|
142
143
|
|
|
143
144
|
it("cancels a tile's request when the tile goes away", async () => {
|
|
144
145
|
const { unmount } = render(tileAt("v1"), { wrapper: serverWrapper });
|
|
@@ -33,6 +33,7 @@ const executeQueryModel = mock(
|
|
|
33
33
|
versionId?: string;
|
|
34
34
|
},
|
|
35
35
|
_includeHidden?: boolean,
|
|
36
|
+
_versionId?: string,
|
|
36
37
|
_options?: { signal?: AbortSignal },
|
|
37
38
|
): Promise<unknown> => pending(),
|
|
38
39
|
);
|
|
@@ -243,7 +244,7 @@ it("cancels a download in flight when the dialog closes", async () => {
|
|
|
243
244
|
await act(async () => {
|
|
244
245
|
fireEvent.click(screen.getByRole("button", { name: /Download CSV/ }));
|
|
245
246
|
});
|
|
246
|
-
const options = executeQueryModel.mock.calls.at(-1)![
|
|
247
|
+
const options = executeQueryModel.mock.calls.at(-1)![6];
|
|
247
248
|
expect(options?.signal?.aborted).toBe(false);
|
|
248
249
|
unmount();
|
|
249
250
|
expect(options?.signal?.aborted).toBe(true);
|
|
@@ -31,9 +31,7 @@ import { useModelData } from "./useModelData";
|
|
|
31
31
|
/**
|
|
32
32
|
* The model page on a server whose `PUBLISHER_MODEL_PAGE` is `explorer`, the
|
|
33
33
|
* default: the Malloy Explorer over the model's sources, and its named
|
|
34
|
-
* queries.
|
|
35
|
-
* through `@malloydata/malloy-interfaces`, which puts a string value in
|
|
36
|
-
* unescaped, so a drilled value holding a double quote rewrites its query.
|
|
34
|
+
* queries.
|
|
37
35
|
*/
|
|
38
36
|
export function ExplorerPage({
|
|
39
37
|
onChange,
|
|
@@ -61,10 +61,7 @@ function CopyLinkButton() {
|
|
|
61
61
|
* `viewer` server never flashes the Explorer.
|
|
62
62
|
*
|
|
63
63
|
* - `explorer`, the default: the Malloy Explorer over the model's sources
|
|
64
|
-
* ({@link ExplorerPage}), and its named queries.
|
|
65
|
-
* queries it builds back to Malloy text through
|
|
66
|
-
* `@malloydata/malloy-interfaces`, whose string escaping is a TODO, so a
|
|
67
|
-
* drilled value holding a double quote rewrites its query.
|
|
64
|
+
* ({@link ExplorerPage}), and its named queries.
|
|
68
65
|
* - `viewer`: the model viewer ({@link ModelViewer}) with a Copy link action
|
|
69
66
|
* on its heading. Each source's views, measures, calculations, dimensions
|
|
70
67
|
* and joins, the model's named queries, and the givens they read. It writes
|
|
@@ -71,8 +71,7 @@ export interface ModelExplorerProps {
|
|
|
71
71
|
* `givens` alone says which parameters to write but not which to REMOVE, so
|
|
72
72
|
* a host that guesses by deleting everything it did not just receive
|
|
73
73
|
* deletes the unrelated parameters it has no business touching. Same
|
|
74
|
-
* contract as `
|
|
75
|
-
* alike.
|
|
74
|
+
* contract as `Report`, so a host can treat every surface alike.
|
|
76
75
|
*/
|
|
77
76
|
onGivensChange?: (
|
|
78
77
|
givens: Record<string, string>,
|
|
@@ -35,7 +35,7 @@ describe("runQueryOptions", () => {
|
|
|
35
35
|
const { options, executeQueryModel } = call(true);
|
|
36
36
|
await options.queryFn({});
|
|
37
37
|
expect(executeQueryModel.mock.calls[0][4]).toBe(true);
|
|
38
|
-
expect(executeQueryModel.mock.calls[0][
|
|
38
|
+
expect(executeQueryModel.mock.calls[0][6]).toEqual({ signal: undefined });
|
|
39
39
|
expect(options.queryKey.at(-1)).toBe("off-surface");
|
|
40
40
|
});
|
|
41
41
|
|
|
@@ -43,7 +43,7 @@ describe("runQueryOptions", () => {
|
|
|
43
43
|
const { options, executeQueryModel } = call(undefined);
|
|
44
44
|
await options.queryFn({});
|
|
45
45
|
expect(executeQueryModel.mock.calls[0][4]).toBeUndefined();
|
|
46
|
-
expect(executeQueryModel.mock.calls[0][
|
|
46
|
+
expect(executeQueryModel.mock.calls[0][6]).toEqual({ signal: undefined });
|
|
47
47
|
expect(options.queryKey).not.toContain("off-surface");
|
|
48
48
|
expect(options.queryKey).toEqual(call(false).options.queryKey);
|
|
49
49
|
});
|
|
@@ -206,6 +206,8 @@ export function runQueryOptions({
|
|
|
206
206
|
}),
|
|
207
207
|
},
|
|
208
208
|
run.includeHiddenFilesAndSources ? true : undefined,
|
|
209
|
+
// versionId: carried in the body.
|
|
210
|
+
undefined,
|
|
209
211
|
{ signal },
|
|
210
212
|
);
|
|
211
213
|
run.onQueryRun?.({ outcome: "success", durationMs: durationMs() });
|
|
@@ -486,11 +486,7 @@ export default function Package({
|
|
|
486
486
|
onClose={() => setCreating(false)}
|
|
487
487
|
onCreated={(created) => {
|
|
488
488
|
setCreating(false);
|
|
489
|
-
invalidateReportQueries(
|
|
490
|
-
queryClient,
|
|
491
|
-
environmentName,
|
|
492
|
-
packageName,
|
|
493
|
-
);
|
|
489
|
+
invalidateReportQueries(queryClient);
|
|
494
490
|
void queryClient.invalidateQueries({ queryKey: ["models"] });
|
|
495
491
|
openDocument({
|
|
496
492
|
path: created.path,
|
|
@@ -2,24 +2,12 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import type { QueryClient } from "@tanstack/react-query";
|
|
5
|
-
import { legacyReportQueryKeys } from "../legacy/queryKeys";
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Drop every cached read of a package's reports after a write changed them:
|
|
9
|
-
* each report's manifest
|
|
10
|
-
* whose listings a layout switch moves a report between. With `modelPath`,
|
|
11
|
-
* the one report's own cached reads too.
|
|
8
|
+
* each report's manifest and the package's report listing.
|
|
12
9
|
*/
|
|
13
|
-
export function invalidateReportQueries(
|
|
14
|
-
|
|
15
|
-
environmentName: string,
|
|
16
|
-
packageName: string,
|
|
17
|
-
modelPath?: string,
|
|
18
|
-
): void {
|
|
19
|
-
for (const queryKey of [
|
|
20
|
-
["report"],
|
|
21
|
-
["reports"],
|
|
22
|
-
...legacyReportQueryKeys(environmentName, packageName, modelPath),
|
|
23
|
-
])
|
|
10
|
+
export function invalidateReportQueries(queryClient: QueryClient): void {
|
|
11
|
+
for (const queryKey of [["report"], ["reports"]])
|
|
24
12
|
void queryClient.invalidateQueries({ queryKey });
|
|
25
13
|
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
// DEPRECATED FEATURE COVERAGE — delete together with
|
|
5
|
+
// `.malloynb` notebooks (see RELEASE_NOTES deprecations).
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* What a `.malloynb`'s cells offer around their results, drawn by `Report`:
|
|
9
|
+
* the cell's "Data sources" dialog, which is the Malloy Explorer and so is
|
|
10
|
+
* offered only where the server's model page allows it and opens on the
|
|
11
|
+
* report's current values; the copy-link icon on a leading markdown cell; and
|
|
12
|
+
* suggest queries pinned to the version the report was opened at.
|
|
13
|
+
*/
|
|
14
|
+
import { beforeEach, expect, it, mock } from "bun:test";
|
|
15
|
+
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
16
|
+
import type { ReactNode } from "react";
|
|
17
|
+
import {
|
|
18
|
+
cacheKeys,
|
|
19
|
+
clearCache,
|
|
20
|
+
mockServerProvider,
|
|
21
|
+
pending,
|
|
22
|
+
serverWrapper,
|
|
23
|
+
} from "../../../test/serverProvider";
|
|
24
|
+
import type { ReportManifest } from "../../client";
|
|
25
|
+
|
|
26
|
+
const PATH = "notebooks/ops.malloynb";
|
|
27
|
+
|
|
28
|
+
const NOTEBOOK = {
|
|
29
|
+
path: PATH,
|
|
30
|
+
name: "ops",
|
|
31
|
+
layout: "linear",
|
|
32
|
+
editable: false,
|
|
33
|
+
notebook: {
|
|
34
|
+
format: "malloynb",
|
|
35
|
+
notebookCells: [
|
|
36
|
+
{ type: "markdown", text: "Ops prose" },
|
|
37
|
+
{
|
|
38
|
+
type: "code",
|
|
39
|
+
text: "import { orders } from './orders.malloy'",
|
|
40
|
+
// What makes the cell's "Data sources" icon appear.
|
|
41
|
+
newSources: [JSON.stringify({ name: "orders" })],
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
sources: [
|
|
45
|
+
{
|
|
46
|
+
name: "orders",
|
|
47
|
+
givens: [
|
|
48
|
+
{
|
|
49
|
+
name: "REGION",
|
|
50
|
+
control: "select",
|
|
51
|
+
suggest: { source: "orders", dimension: "region" },
|
|
52
|
+
},
|
|
53
|
+
// Plain text, so the dialog test can type a value directly.
|
|
54
|
+
{ name: "TENANT", type: "string" },
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
} as ReportManifest;
|
|
60
|
+
|
|
61
|
+
let manifest: ReportManifest = NOTEBOOK;
|
|
62
|
+
const getReport = mock(() => Promise.resolve({ data: manifest }));
|
|
63
|
+
const executeQueryModel = mock(
|
|
64
|
+
(
|
|
65
|
+
_environmentName: string,
|
|
66
|
+
_packageName: string,
|
|
67
|
+
_modelPath: string,
|
|
68
|
+
_request: { versionId?: string },
|
|
69
|
+
): Promise<never> => pending(),
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// The Explorer itself is lazy, WASM-backed and not under test: only what the
|
|
73
|
+
// cell hands it is, so the stub records its props.
|
|
74
|
+
const dataSourcesDialogProps = mock(
|
|
75
|
+
(_props: {
|
|
76
|
+
open: boolean;
|
|
77
|
+
startingGivens?: Record<string, string>;
|
|
78
|
+
data?: { givens?: { name?: string }[] };
|
|
79
|
+
}) => {},
|
|
80
|
+
);
|
|
81
|
+
mock.module("../Model/ModelExplorerDialog", () => ({
|
|
82
|
+
ModelExplorerDialog: (props: {
|
|
83
|
+
open: boolean;
|
|
84
|
+
startingGivens?: Record<string, string>;
|
|
85
|
+
data?: { givens?: { name?: string }[] };
|
|
86
|
+
}) => {
|
|
87
|
+
dataSourcesDialogProps(props);
|
|
88
|
+
return null as ReactNode;
|
|
89
|
+
},
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
// The server's /status answer: the model page a test switches to `viewer`.
|
|
93
|
+
const serverContext: { modelPage?: string; isLoadingStatus?: boolean } = {};
|
|
94
|
+
mockServerProvider(
|
|
95
|
+
{
|
|
96
|
+
reports: { getReport },
|
|
97
|
+
models: { executeQueryModel, getModel: () => pending() },
|
|
98
|
+
},
|
|
99
|
+
serverContext,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// Imported after the stub is registered: a static import would hoist above it.
|
|
103
|
+
const { Report } = await import("./Report");
|
|
104
|
+
|
|
105
|
+
const URI = "publisher://environments/env/packages/pkg";
|
|
106
|
+
|
|
107
|
+
beforeEach(() => {
|
|
108
|
+
manifest = NOTEBOOK;
|
|
109
|
+
clearCache();
|
|
110
|
+
getReport.mockClear();
|
|
111
|
+
executeQueryModel.mockClear();
|
|
112
|
+
dataSourcesDialogProps.mockClear();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("runs its suggest queries on the notebook's path, at the version it was opened at", async () => {
|
|
116
|
+
render(<Report resourceUri={`${URI}?versionId=v2`} path={PATH} />, {
|
|
117
|
+
wrapper: serverWrapper,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
await waitFor(() => expect(executeQueryModel).toHaveBeenCalled());
|
|
121
|
+
expect(executeQueryModel.mock.calls[0][2]).toBe(PATH);
|
|
122
|
+
expect(executeQueryModel.mock.calls[0][3].versionId).toBe("v2");
|
|
123
|
+
expect(cacheKeys("givenSuggest")[0]).toContain('"v2"');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("sends no version on a suggest query when the report was opened without one", async () => {
|
|
127
|
+
render(<Report resourceUri={URI} path={PATH} />, {
|
|
128
|
+
wrapper: serverWrapper,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
await waitFor(() => expect(executeQueryModel).toHaveBeenCalled());
|
|
132
|
+
expect(executeQueryModel.mock.calls[0][3].versionId).toBeUndefined();
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("opens a cell's 'Data sources' dialog with the report's current values", async () => {
|
|
136
|
+
render(<Report resourceUri={URI} path={PATH} />, {
|
|
137
|
+
wrapper: serverWrapper,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// The control sits in its filter button's popover.
|
|
141
|
+
fireEvent.click(await screen.findByRole("button", { name: /^TENANT: / }));
|
|
142
|
+
const input = (await screen.findByLabelText("TENANT")) as HTMLInputElement;
|
|
143
|
+
fireEvent.change(input, { target: { value: "acme" } });
|
|
144
|
+
// The control re-renders with the value before the dialog opens, or the
|
|
145
|
+
// click lands on a render that has not carried it yet.
|
|
146
|
+
await waitFor(() => expect(input.value).toBe("acme"));
|
|
147
|
+
|
|
148
|
+
fireEvent.click(await screen.findByLabelText("Data sources"));
|
|
149
|
+
|
|
150
|
+
await waitFor(() =>
|
|
151
|
+
expect(dataSourcesDialogProps.mock.calls.at(-1)?.[0]?.open).toBe(true),
|
|
152
|
+
);
|
|
153
|
+
const lastCall = dataSourcesDialogProps.mock.calls.at(-1)?.[0];
|
|
154
|
+
expect(lastCall?.startingGivens).toEqual({ TENANT: "acme" });
|
|
155
|
+
// The values alone render nothing: the dialog needs the declarations too.
|
|
156
|
+
expect(lastCall?.data?.givens?.map((given) => given.name)).toContain(
|
|
157
|
+
"TENANT",
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// A server with PUBLISHER_MODEL_PAGE=viewer takes the Explorer out of the
|
|
162
|
+
// Console, and the "Data sources" dialog is the Explorer.
|
|
163
|
+
it("offers no 'Data sources' dialog on a server whose model page is the viewer", async () => {
|
|
164
|
+
serverContext.modelPage = "viewer";
|
|
165
|
+
try {
|
|
166
|
+
render(<Report resourceUri={URI} path={PATH} />, {
|
|
167
|
+
wrapper: serverWrapper,
|
|
168
|
+
});
|
|
169
|
+
await screen.findByText("Ops prose");
|
|
170
|
+
await waitFor(() => expect(executeQueryModel).toHaveBeenCalled());
|
|
171
|
+
expect(screen.queryByLabelText("Data sources")).toBeNull();
|
|
172
|
+
expect(dataSourcesDialogProps).not.toHaveBeenCalledWith(
|
|
173
|
+
expect.objectContaining({ open: true }),
|
|
174
|
+
);
|
|
175
|
+
} finally {
|
|
176
|
+
delete serverContext.modelPage;
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Nor while /status loads: until the server has said which page it shows, a
|
|
181
|
+
// viewer server must not offer the Explorer even briefly.
|
|
182
|
+
it("offers no 'Data sources' dialog while /status loads", async () => {
|
|
183
|
+
serverContext.isLoadingStatus = true;
|
|
184
|
+
try {
|
|
185
|
+
render(<Report resourceUri={URI} path={PATH} />, {
|
|
186
|
+
wrapper: serverWrapper,
|
|
187
|
+
});
|
|
188
|
+
await screen.findByText("Ops prose");
|
|
189
|
+
await waitFor(() => expect(executeQueryModel).toHaveBeenCalled());
|
|
190
|
+
expect(screen.queryByLabelText("Data sources")).toBeNull();
|
|
191
|
+
} finally {
|
|
192
|
+
delete serverContext.isLoadingStatus;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it("offers the 'Data sources' dialog once the server allows it", async () => {
|
|
197
|
+
render(<Report resourceUri={URI} path={PATH} />, {
|
|
198
|
+
wrapper: serverWrapper,
|
|
199
|
+
});
|
|
200
|
+
expect(await screen.findByLabelText("Data sources")).toBeTruthy();
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("puts the copy-link icon on a leading markdown cell", async () => {
|
|
204
|
+
render(<Report resourceUri={URI} path={PATH} />, {
|
|
205
|
+
wrapper: serverWrapper,
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
await screen.findByText("Ops prose");
|
|
209
|
+
expect(screen.getAllByTestId("LinkOutlinedIcon")).toHaveLength(1);
|
|
210
|
+
expect(screen.getByRole("button", { name: "Copy link" })).toBeTruthy();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it("keeps the copy-link icon off a notebook that opens with a code cell", async () => {
|
|
214
|
+
manifest = {
|
|
215
|
+
...NOTEBOOK,
|
|
216
|
+
notebook: {
|
|
217
|
+
format: "malloynb",
|
|
218
|
+
notebookCells: [
|
|
219
|
+
{ type: "code", text: "import { orders } from './orders.malloy'" },
|
|
220
|
+
{ type: "markdown", text: "Later prose" },
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
} as ReportManifest;
|
|
224
|
+
render(<Report resourceUri={URI} path={PATH} />, {
|
|
225
|
+
wrapper: serverWrapper,
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
await screen.findByText("Later prose");
|
|
229
|
+
expect(screen.queryAllByTestId("LinkOutlinedIcon")).toHaveLength(0);
|
|
230
|
+
});
|