@malloy-publisher/sdk 0.10.6 → 0.11.0
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-BlYdT4lz.cjs.js → RenderedResult-C2r3Zkwl.cjs.js} +1 -1
- package/dist/{RenderedResult-B_sW7neX.es.js → RenderedResult-r3dg2xOJ.es.js} +2 -2
- package/dist/ServerProvider-CFHqDHFO.cjs.js +1 -0
- package/dist/{ServerProvider-BN399NH6.es.js → ServerProvider-DdGjhDhY.es.js} +2077 -1604
- package/dist/builder/index.cjs.js +1 -1
- package/dist/builder/index.es.js +3 -3
- package/dist/client/api.d.ts +673 -165
- 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 +101 -92
- package/dist/components/Materializations/Materializations.d.ts +8 -1
- package/dist/components/Package/Package.d.ts +15 -1
- package/dist/components/Package/VersionSwitch.d.ts +51 -0
- package/dist/components/Package/index.d.ts +2 -0
- package/dist/components/Package/usePackageVersions.d.ts +48 -0
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/hooks/useDimensionFiltersQuery.d.ts +2 -0
- package/dist/index.cjs.js +14 -14
- package/dist/index.es.js +8290 -7677
- package/dist/{useCompiledDocument-xJRD5DRP.es.js → useCompiledDocument-Bc0HuUtz.es.js} +3 -3
- package/dist/{useCompiledDocument-CyPOSStA.cjs.js → useCompiledDocument-QgySwHGA.cjs.js} +2 -2
- package/dist/utils/dataAppEmbed.d.ts +6 -1
- package/package.json +1 -1
- package/src/components/DataAppViewer/DataAppViewer.tsx +18 -5
- package/src/components/DocumentStorage/DocumentStorage.contract.spec.tsx +2 -0
- package/src/components/Environment/Packages.tsx +12 -5
- package/src/components/Environment/Packages.versions.spec.tsx +62 -0
- package/src/components/Materializations/Materializations.tsx +26 -6
- package/src/components/Materializations/Materializations.versions.spec.tsx +101 -0
- package/src/components/Package/Package.agents.spec.tsx +2 -0
- package/src/components/Package/Package.artifacts.spec.tsx +35 -0
- package/src/components/Package/Package.create.spec.tsx +37 -1
- package/src/components/Package/Package.notebooks.spec.tsx +2 -0
- package/src/components/Package/Package.spec.tsx +23 -11
- package/src/components/Package/Package.tsx +111 -20
- package/src/components/Package/VersionSwitch.spec.tsx +668 -0
- package/src/components/Package/VersionSwitch.tsx +779 -0
- package/src/components/Package/index.ts +7 -0
- package/src/components/Package/usePackageVersions.spec.tsx +78 -0
- package/src/components/Package/usePackageVersions.ts +146 -0
- package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +4 -2
- package/src/components/ReportBuilder/ReportEditor.authoritative.spec.tsx +5 -1
- package/src/components/ServerProvider.tsx +2 -0
- package/src/hooks/useDimensionFiltersFromSpec.ts +1 -0
- package/src/hooks/useDimensionFiltersQuery.ts +5 -1
- package/src/utils/dataAppEmbed.spec.ts +27 -0
- package/src/utils/dataAppEmbed.ts +11 -3
- package/src/utils/formatting.spec.ts +25 -0
- package/src/utils/formatting.ts +2 -1
- package/test/serverProvider.tsx +15 -0
- package/dist/ServerProvider-e2369oom.cjs.js +0 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A package with published versions is immutable, so the package list offers
|
|
6
|
+
* no Edit on it, only Delete. A package with no versions keeps both.
|
|
7
|
+
*/
|
|
8
|
+
import { beforeEach, expect, it, mock } from "bun:test";
|
|
9
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
10
|
+
import {
|
|
11
|
+
clearCache,
|
|
12
|
+
mockServerProvider,
|
|
13
|
+
serverWrapper,
|
|
14
|
+
} from "../../../test/serverProvider";
|
|
15
|
+
|
|
16
|
+
const listPackages = mock((_environmentName: string) =>
|
|
17
|
+
Promise.resolve({
|
|
18
|
+
data: [
|
|
19
|
+
{ name: "plain" },
|
|
20
|
+
{ name: "versioned", versionId: "1.1.0", latestVersion: "1.1.0" },
|
|
21
|
+
// Published under explicit promotion, before any version is latest.
|
|
22
|
+
{ name: "unpromoted", versionId: null, latestVersion: null },
|
|
23
|
+
],
|
|
24
|
+
}),
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
mockServerProvider({ packages: { listPackages } }, { mutable: true });
|
|
28
|
+
|
|
29
|
+
const { default: Packages } = await import("./Packages");
|
|
30
|
+
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
clearCache();
|
|
33
|
+
listPackages.mockClear();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
async function menuItemsFor(packageName: string): Promise<string[]> {
|
|
37
|
+
render(
|
|
38
|
+
<Packages
|
|
39
|
+
onSelectPackage={() => {}}
|
|
40
|
+
resourceUri="publisher://environments/env"
|
|
41
|
+
/>,
|
|
42
|
+
{ wrapper: serverWrapper },
|
|
43
|
+
);
|
|
44
|
+
fireEvent.click(
|
|
45
|
+
await screen.findByRole("button", {
|
|
46
|
+
name: `Package actions for ${packageName}`,
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
const items = await screen.findAllByRole("menuitem");
|
|
50
|
+
return items.map((item) => item.textContent ?? "");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
it("offers Edit and Delete on a package with no versions", async () => {
|
|
54
|
+
expect(await menuItemsFor("plain")).toEqual(["Edit", "Delete"]);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it.each([["versioned"], ["unpromoted"]])(
|
|
58
|
+
"offers only Delete on a package with published versions (%s)",
|
|
59
|
+
async (packageName) => {
|
|
60
|
+
expect(await menuItemsFor(packageName)).toEqual(["Delete"]);
|
|
61
|
+
},
|
|
62
|
+
);
|
|
@@ -31,6 +31,13 @@ const MATERIALIZATION_POLL_MS = 3000;
|
|
|
31
31
|
|
|
32
32
|
interface MaterializationsProps {
|
|
33
33
|
resourceUri: string;
|
|
34
|
+
/**
|
|
35
|
+
* The package has published versions, or whether it has is not known yet.
|
|
36
|
+
* A version's scope and schedule come from its own publisher.json, which
|
|
37
|
+
* never changes, so the scope and schedule controls are not offered; a new
|
|
38
|
+
* build still is.
|
|
39
|
+
*/
|
|
40
|
+
versioned?: boolean;
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
/**
|
|
@@ -41,10 +48,13 @@ interface MaterializationsProps {
|
|
|
41
48
|
*/
|
|
42
49
|
export default function Materializations({
|
|
43
50
|
resourceUri,
|
|
51
|
+
versioned = false,
|
|
44
52
|
}: MaterializationsProps) {
|
|
45
53
|
const { apiClients, mutable } = useServer();
|
|
46
54
|
const queryClient = useQueryClient();
|
|
47
|
-
|
|
55
|
+
// A pinned version lists, builds and stops its own runs; absent, `latest`.
|
|
56
|
+
const { environmentName, packageName, versionId } =
|
|
57
|
+
parseResourceUri(resourceUri);
|
|
48
58
|
const [notificationMessage, setNotificationMessage] = useState("");
|
|
49
59
|
const [selectedId, setSelectedId] = useState<string | null>(null);
|
|
50
60
|
|
|
@@ -55,11 +65,14 @@ export default function Materializations({
|
|
|
55
65
|
}
|
|
56
66
|
|
|
57
67
|
const listQuery = useQueryWithApiError({
|
|
58
|
-
queryKey: ["materializations", environmentName, packageName],
|
|
68
|
+
queryKey: ["materializations", environmentName, packageName, versionId],
|
|
59
69
|
queryFn: () =>
|
|
60
70
|
apiClients.materializations.listMaterializations(
|
|
61
71
|
environmentName,
|
|
62
72
|
packageName,
|
|
73
|
+
undefined,
|
|
74
|
+
undefined,
|
|
75
|
+
versionId,
|
|
63
76
|
),
|
|
64
77
|
refetchInterval: (query) => {
|
|
65
78
|
const payload = query.state.data as
|
|
@@ -75,9 +88,13 @@ export default function Materializations({
|
|
|
75
88
|
// The build plan is a property of the compiled package (Package.buildPlan),
|
|
76
89
|
// not of a historical run, so fetch it from the package for the detail view.
|
|
77
90
|
const packageQuery = useQueryWithApiError({
|
|
78
|
-
queryKey: ["package", environmentName, packageName],
|
|
91
|
+
queryKey: ["package", environmentName, packageName, versionId],
|
|
79
92
|
queryFn: () =>
|
|
80
|
-
apiClients.packages.getPackage(
|
|
93
|
+
apiClients.packages.getPackage(
|
|
94
|
+
environmentName,
|
|
95
|
+
packageName,
|
|
96
|
+
versionId,
|
|
97
|
+
),
|
|
81
98
|
});
|
|
82
99
|
|
|
83
100
|
const invalidateList = () =>
|
|
@@ -97,6 +114,7 @@ export default function Materializations({
|
|
|
97
114
|
packageName,
|
|
98
115
|
{
|
|
99
116
|
forceRefresh: opts.forceRefresh,
|
|
117
|
+
...(versionId !== undefined ? { versionId } : {}),
|
|
100
118
|
},
|
|
101
119
|
),
|
|
102
120
|
),
|
|
@@ -120,6 +138,7 @@ export default function Materializations({
|
|
|
120
138
|
packageName,
|
|
121
139
|
materialization.id as string,
|
|
122
140
|
MaterializationActionActionEnum.Stop,
|
|
141
|
+
versionId,
|
|
123
142
|
),
|
|
124
143
|
),
|
|
125
144
|
onSuccess() {
|
|
@@ -147,6 +166,7 @@ export default function Materializations({
|
|
|
147
166
|
packageName,
|
|
148
167
|
materialization.id as string,
|
|
149
168
|
dropTables,
|
|
169
|
+
versionId,
|
|
150
170
|
),
|
|
151
171
|
),
|
|
152
172
|
onSuccess() {
|
|
@@ -257,7 +277,7 @@ export default function Materializations({
|
|
|
257
277
|
action={
|
|
258
278
|
mutable && (
|
|
259
279
|
<Stack direction="row" spacing={1} alignItems="center">
|
|
260
|
-
{!orchestrated && (
|
|
280
|
+
{!orchestrated && !versioned && (
|
|
261
281
|
<ScopeButton
|
|
262
282
|
scope={scope}
|
|
263
283
|
// A schedule requires version scope, so the server
|
|
@@ -275,7 +295,7 @@ export default function Materializations({
|
|
|
275
295
|
}
|
|
276
296
|
/>
|
|
277
297
|
)}
|
|
278
|
-
{!orchestrated && (
|
|
298
|
+
{!orchestrated && !versioned && (
|
|
279
299
|
<SetScheduleDialog
|
|
280
300
|
currentSchedule={schedule}
|
|
281
301
|
isSubmitting={updateSchedule.isPending}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A pinned version's runs are that version's: the section lists them for it,
|
|
6
|
+
* and deleting one names it too, so the server refuses a run of another
|
|
7
|
+
* version (404) or of an archived one (410) rather than deleting by id alone.
|
|
8
|
+
*/
|
|
9
|
+
import { beforeEach, expect, it, mock } from "bun:test";
|
|
10
|
+
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
11
|
+
import {
|
|
12
|
+
clearCache,
|
|
13
|
+
mockServerProvider,
|
|
14
|
+
pending,
|
|
15
|
+
serverWrapper,
|
|
16
|
+
} from "../../../test/serverProvider";
|
|
17
|
+
|
|
18
|
+
const RUN = {
|
|
19
|
+
id: "run-1",
|
|
20
|
+
status: "MANIFEST_FILE_READY",
|
|
21
|
+
createdAt: "2026-10-01T00:00:00Z",
|
|
22
|
+
updatedAt: "2026-10-01T00:01:00Z",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const listMaterializations = mock(
|
|
26
|
+
(
|
|
27
|
+
_environmentName: string,
|
|
28
|
+
_packageName: string,
|
|
29
|
+
_limit?: number,
|
|
30
|
+
_offset?: number,
|
|
31
|
+
_versionId?: string,
|
|
32
|
+
) => Promise.resolve({ data: [RUN] }),
|
|
33
|
+
);
|
|
34
|
+
const deleteMaterialization = mock(
|
|
35
|
+
(
|
|
36
|
+
_environmentName: string,
|
|
37
|
+
_packageName: string,
|
|
38
|
+
_materializationId: string,
|
|
39
|
+
_dropTables?: boolean,
|
|
40
|
+
_versionId?: string,
|
|
41
|
+
) => Promise.resolve({ data: undefined }),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
mockServerProvider(
|
|
45
|
+
{
|
|
46
|
+
packages: { getPackage: pending },
|
|
47
|
+
materializations: { listMaterializations, deleteMaterialization },
|
|
48
|
+
},
|
|
49
|
+
{ mutable: true },
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const { default: Materializations } = await import("./Materializations");
|
|
53
|
+
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
clearCache();
|
|
56
|
+
listMaterializations.mockClear();
|
|
57
|
+
deleteMaterialization.mockClear();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
async function deleteTheRun(resourceUri: string) {
|
|
61
|
+
render(<Materializations resourceUri={resourceUri} />, {
|
|
62
|
+
wrapper: serverWrapper,
|
|
63
|
+
});
|
|
64
|
+
fireEvent.click(
|
|
65
|
+
await screen.findByRole("button", {
|
|
66
|
+
name: "Materialization actions for run-1",
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
69
|
+
fireEvent.click(
|
|
70
|
+
await screen.findByRole("menuitem", {
|
|
71
|
+
name: "Delete materialization run-1",
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
74
|
+
fireEvent.click(await screen.findByRole("button", { name: "Delete run" }));
|
|
75
|
+
await waitFor(() => expect(deleteMaterialization).toHaveBeenCalled());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
it("lists and deletes a pinned version's run by that version", async () => {
|
|
79
|
+
await deleteTheRun("publisher://environments/env/packages/pkg?versionId=v2");
|
|
80
|
+
|
|
81
|
+
expect(listMaterializations.mock.calls[0]?.[4]).toBe("v2");
|
|
82
|
+
expect(deleteMaterialization.mock.calls[0]).toEqual([
|
|
83
|
+
"env",
|
|
84
|
+
"pkg",
|
|
85
|
+
"run-1",
|
|
86
|
+
false,
|
|
87
|
+
"v2",
|
|
88
|
+
]);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("deletes with no version when none is pinned, as before", async () => {
|
|
92
|
+
await deleteTheRun("publisher://environments/env/packages/pkg");
|
|
93
|
+
|
|
94
|
+
expect(deleteMaterialization.mock.calls[0]).toEqual([
|
|
95
|
+
"env",
|
|
96
|
+
"pkg",
|
|
97
|
+
"run-1",
|
|
98
|
+
false,
|
|
99
|
+
undefined,
|
|
100
|
+
]);
|
|
101
|
+
});
|
|
@@ -9,12 +9,14 @@ import {
|
|
|
9
9
|
mockServerProvider,
|
|
10
10
|
pending,
|
|
11
11
|
serverWrapper,
|
|
12
|
+
noVersions,
|
|
12
13
|
} from "../../../test/serverProvider";
|
|
13
14
|
|
|
14
15
|
let agents: unknown[] | undefined;
|
|
15
16
|
|
|
16
17
|
mockServerProvider(
|
|
17
18
|
{
|
|
19
|
+
versions: noVersions,
|
|
18
20
|
packages: {
|
|
19
21
|
getPackage: () =>
|
|
20
22
|
Promise.resolve({
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
mockServerProvider,
|
|
11
11
|
pending,
|
|
12
12
|
serverWrapper,
|
|
13
|
+
noVersions,
|
|
13
14
|
} from "../../../test/serverProvider";
|
|
14
15
|
import type {
|
|
15
16
|
DocumentLocator,
|
|
@@ -18,12 +19,20 @@ import type {
|
|
|
18
19
|
import { DocumentStorageProvider } from "../DocumentStorage/DocumentStorageProvider";
|
|
19
20
|
|
|
20
21
|
let reports: { path: string; layout: string; title?: string }[] = [];
|
|
22
|
+
/** The package's versions: none (the listing answers 404) unless a test publishes some. */
|
|
23
|
+
let published: { id: string; latest: boolean; archiveStatus: string }[] = [];
|
|
21
24
|
const listReports = mock((_e: string, _p: string, _v?: string) =>
|
|
22
25
|
Promise.resolve({ data: reports }),
|
|
23
26
|
);
|
|
24
27
|
|
|
25
28
|
mockServerProvider(
|
|
26
29
|
{
|
|
30
|
+
versions: {
|
|
31
|
+
listPackageVersions: () =>
|
|
32
|
+
published.length > 0
|
|
33
|
+
? Promise.resolve({ data: published })
|
|
34
|
+
: noVersions.listPackageVersions(),
|
|
35
|
+
},
|
|
27
36
|
packages: { getPackage: pending },
|
|
28
37
|
reports: { listReports, getReport: pending },
|
|
29
38
|
models: { listModels: () => Promise.resolve({ data: [] }) },
|
|
@@ -72,6 +81,7 @@ const rows = async () => {
|
|
|
72
81
|
beforeEach(() => {
|
|
73
82
|
clearCache();
|
|
74
83
|
reports = [];
|
|
84
|
+
published = [];
|
|
75
85
|
onClick.mockClear();
|
|
76
86
|
listReports.mockClear();
|
|
77
87
|
});
|
|
@@ -165,6 +175,31 @@ it("treats a 404 on the reports list as none, without an error", async () => {
|
|
|
165
175
|
expect(screen.queryByText(/Could not list/)).toBeNull();
|
|
166
176
|
});
|
|
167
177
|
|
|
178
|
+
it("lists no drafts on a versioned package, where the builder could not save one", async () => {
|
|
179
|
+
const storage: DocumentStorage = {
|
|
180
|
+
listWorkspaces: async () => [
|
|
181
|
+
{ name: "browser", writeable: true, description: "This browser" },
|
|
182
|
+
],
|
|
183
|
+
listDocuments: async () => [
|
|
184
|
+
{ workspace: "browser", type: "grid", path: "env/pkg/d-one.malloy" },
|
|
185
|
+
],
|
|
186
|
+
getDocument: async () => {
|
|
187
|
+
throw new Error("absent");
|
|
188
|
+
},
|
|
189
|
+
saveDocument: async () => {},
|
|
190
|
+
deleteDocument: async () => {},
|
|
191
|
+
moveDocument: async () => {},
|
|
192
|
+
};
|
|
193
|
+
published = [{ id: "1.0.0", latest: true, archiveStatus: "unarchive" }];
|
|
194
|
+
reports = [{ path: "overview.malloy", layout: "grid" }];
|
|
195
|
+
mount(storage);
|
|
196
|
+
|
|
197
|
+
expect(await rows()).toEqual(["overviewgrid"]);
|
|
198
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
199
|
+
expect(screen.queryByRole("heading", { name: "Drafts" })).toBeNull();
|
|
200
|
+
expect(screen.queryByText("d-one.malloy")).toBeNull();
|
|
201
|
+
});
|
|
202
|
+
|
|
168
203
|
it("lists host drafts by path whatever layout they record, each opening its editor", async () => {
|
|
169
204
|
const draft = (type: "grid" | "linear", path: string): DocumentLocator => ({
|
|
170
205
|
workspace: "browser",
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
mockServerProvider,
|
|
21
21
|
pending,
|
|
22
22
|
serverWrapper,
|
|
23
|
+
noVersions,
|
|
23
24
|
} from "../../../test/serverProvider";
|
|
24
25
|
import {
|
|
25
26
|
DocumentNotFoundError,
|
|
@@ -66,8 +67,11 @@ const updateModelSource = mock((_env: string, _pkg: string, path: string) =>
|
|
|
66
67
|
|
|
67
68
|
// Mutated per test: the stub hands the same object to every render.
|
|
68
69
|
const context: Record<string, unknown> = { mutable: true };
|
|
70
|
+
/** How the versions listing answers: a package with none (404) unless a test says otherwise. */
|
|
71
|
+
let listVersions: () => Promise<unknown> = noVersions.listPackageVersions;
|
|
69
72
|
mockServerProvider(
|
|
70
73
|
{
|
|
74
|
+
versions: { listPackageVersions: () => listVersions() },
|
|
71
75
|
packages: { getPackage: pending },
|
|
72
76
|
reports: { listReports, getReport: pending },
|
|
73
77
|
models: { listModels, getModel, updateModelSource },
|
|
@@ -146,6 +150,7 @@ const NEW = { name: "Add report" } as const;
|
|
|
146
150
|
beforeEach(() => {
|
|
147
151
|
clearCache();
|
|
148
152
|
context.mutable = true;
|
|
153
|
+
listVersions = noVersions.listPackageVersions;
|
|
149
154
|
for (const fn of [
|
|
150
155
|
listModels,
|
|
151
156
|
listReports,
|
|
@@ -177,7 +182,11 @@ describe("who is offered New", () => {
|
|
|
177
182
|
context.mutable = false;
|
|
178
183
|
mount(fakeStorage([BROWSER]).storage);
|
|
179
184
|
await settled();
|
|
180
|
-
|
|
185
|
+
// A boolean, not the element: a failed toBeNull() on a happy-dom element
|
|
186
|
+
// formats its whole object graph, synchronously, on every poll.
|
|
187
|
+
await waitFor(() =>
|
|
188
|
+
expect(screen.queryByRole("button", NEW) === null).toBe(true),
|
|
189
|
+
);
|
|
181
190
|
});
|
|
182
191
|
|
|
183
192
|
it("the Console's browser workspace beside a writable server, written to the package", async () => {
|
|
@@ -241,6 +250,33 @@ describe("who is offered New", () => {
|
|
|
241
250
|
expect(screen.queryByRole("button", NEW)).toBeNull();
|
|
242
251
|
});
|
|
243
252
|
|
|
253
|
+
it("nothing while the versions listing is unanswered: a package with versions takes no writes", async () => {
|
|
254
|
+
listVersions = pending;
|
|
255
|
+
mount();
|
|
256
|
+
await settled();
|
|
257
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
258
|
+
expect(screen.queryByRole("button", NEW)).toBeNull();
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it("nothing when the versions listing failed, which the page says, with a retry", async () => {
|
|
262
|
+
listVersions = () =>
|
|
263
|
+
Promise.reject(
|
|
264
|
+
Object.assign(new Error("Request failed with status code 500"), {
|
|
265
|
+
response: { status: 500, data: { message: "boom" } },
|
|
266
|
+
}),
|
|
267
|
+
);
|
|
268
|
+
mount();
|
|
269
|
+
expect(
|
|
270
|
+
await screen.findByText(/Could not read this package's versions/),
|
|
271
|
+
).toBeDefined();
|
|
272
|
+
await settled();
|
|
273
|
+
expect(screen.queryByRole("button", NEW)).toBeNull();
|
|
274
|
+
// Once the listing answers, the package's writes are offered again.
|
|
275
|
+
listVersions = noVersions.listPackageVersions;
|
|
276
|
+
fireEvent.click(screen.getByRole("button", { name: "Retry" }));
|
|
277
|
+
expect(await screen.findAllByRole("button", NEW)).toHaveLength(1);
|
|
278
|
+
});
|
|
279
|
+
|
|
244
280
|
it("nothing while the host's workspaces are still being listed, and nothing when they cannot be", async () => {
|
|
245
281
|
mount(fakeStorage(new Error("backend down")).storage);
|
|
246
282
|
await settled();
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
mockServerProvider,
|
|
10
10
|
pending,
|
|
11
11
|
serverWrapper,
|
|
12
|
+
noVersions,
|
|
12
13
|
} from "../../../test/serverProvider";
|
|
13
14
|
|
|
14
15
|
let listed: { path: string; layout?: string; title?: string }[] = [];
|
|
@@ -23,6 +24,7 @@ const getReport = mock(
|
|
|
23
24
|
);
|
|
24
25
|
|
|
25
26
|
mockServerProvider({
|
|
27
|
+
versions: noVersions,
|
|
26
28
|
packages: { getPackage: pending },
|
|
27
29
|
reports: {
|
|
28
30
|
listReports: () => Promise.resolve({ data: listed }),
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* The reports listing
|
|
6
|
-
*
|
|
5
|
+
* The reports listing and the data apps listing follow the package's other
|
|
6
|
+
* listings: each names the version on screen, and is keyed on it.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* answers for the wrong version.
|
|
8
|
+
* Pinned as a pair, because the data apps were once left unversioned (their
|
|
9
|
+
* route declared no `versionId`), and the cost of that is a version's page
|
|
10
|
+
* listing, and linking to, `latest`'s apps.
|
|
12
11
|
*/
|
|
13
12
|
import { beforeEach, expect, it, mock } from "bun:test";
|
|
14
13
|
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
@@ -18,17 +17,20 @@ import {
|
|
|
18
17
|
mockServerProvider,
|
|
19
18
|
pending,
|
|
20
19
|
serverWrapper,
|
|
20
|
+
noVersions,
|
|
21
21
|
} from "../../../test/serverProvider";
|
|
22
22
|
|
|
23
23
|
const listReports = mock(
|
|
24
24
|
(_environmentName: string, _packageName: string, _versionId?: string) =>
|
|
25
25
|
pending(),
|
|
26
26
|
);
|
|
27
|
-
const listDataApps = mock(
|
|
28
|
-
|
|
27
|
+
const listDataApps = mock(
|
|
28
|
+
(_environmentName: string, _packageName: string, _versionId?: string) =>
|
|
29
|
+
pending(),
|
|
29
30
|
);
|
|
30
31
|
|
|
31
32
|
mockServerProvider({
|
|
33
|
+
versions: noVersions,
|
|
32
34
|
packages: { getPackage: pending },
|
|
33
35
|
models: { listModels: pending },
|
|
34
36
|
databases: { listDatabases: pending },
|
|
@@ -72,12 +74,22 @@ it("keys an unversioned listing beside the package's other listings", async () =
|
|
|
72
74
|
);
|
|
73
75
|
});
|
|
74
76
|
|
|
75
|
-
it("
|
|
77
|
+
it("lists a version's data apps, and keys the listing on it", async () => {
|
|
76
78
|
render(packageAt("v2"), { wrapper: serverWrapper });
|
|
77
79
|
|
|
78
80
|
await waitFor(() => expect(listDataApps).toHaveBeenCalled());
|
|
79
|
-
expect(listDataApps.mock.calls[0]).toEqual(["env", "pkg"]);
|
|
80
|
-
expect(cacheKeys("data-apps")[0]).
|
|
81
|
+
expect(listDataApps.mock.calls[0]).toEqual(["env", "pkg", "v2"]);
|
|
82
|
+
expect(cacheKeys("data-apps")[0]).toContain('"v2"');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("keys an unversioned data apps listing as DataAppViewer does", async () => {
|
|
86
|
+
render(packageAt(), { wrapper: serverWrapper });
|
|
87
|
+
|
|
88
|
+
await waitFor(() => expect(listDataApps).toHaveBeenCalled());
|
|
89
|
+
expect(listDataApps.mock.calls[0]).toEqual(["env", "pkg", undefined]);
|
|
90
|
+
expect(cacheKeys("data-apps")[0]).toBe(
|
|
91
|
+
'["data-apps","env","pkg",null,"http://localhost/api/v0"]',
|
|
92
|
+
);
|
|
81
93
|
});
|
|
82
94
|
|
|
83
95
|
it("says so when the reports listing fails, rather than showing none", async () => {
|