@canonical/maas-react-components 2.6.0 → 2.7.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/dist/@canonical/maas-react-components.es.js +536 -6755
- package/dist/QueryInput-D7uXzKgr.mjs +1648 -0
- package/dist/{src/lib/elements → elements}/ExternalLink/ExternalLink.d.ts +1 -2
- package/dist/index.d.ts +4 -2
- package/dist/{src/lib/sections → sections}/SidePanel/index.d.ts +1 -0
- package/dist/testing/expectTooltipOnHover.d.ts +4 -0
- package/dist/testing/index.d.ts +8 -0
- package/dist/testing/index.es.js +129 -0
- package/dist/testing/mockIsPending.d.ts +6 -0
- package/dist/testing/mockSidePanel.d.ts +7 -0
- package/dist/testing/renderHookWithProviders.d.ts +24 -0
- package/dist/testing/renderWithProviders.d.ts +32 -0
- package/dist/testing/setupMockServer.d.ts +13 -0
- package/dist/testing/spyOnMutation.d.ts +8 -0
- package/dist/testing/waitForLoading.d.ts +10 -0
- package/package.json +42 -10
- package/dist/@canonical/maas-react-components.umd.js +0 -55
- package/dist/src/constants.d.ts +0 -6
- package/dist/src/lib/index.d.ts +0 -4
- package/dist/src/types.d.ts +0 -7
- package/dist/src/utils.d.ts +0 -7
- package/dist/vitest-setup.d.ts +0 -0
- /package/dist/{src/lib/components → components}/DynamicTable/DynamicTable.d.ts +0 -0
- /package/dist/{src/lib/components → components}/DynamicTable/DynamicTable.stories.d.ts +0 -0
- /package/dist/{src/lib/components → components}/DynamicTable/DynamicTable.test.d.ts +0 -0
- /package/dist/{src/lib/components → components}/DynamicTable/index.d.ts +0 -0
- /package/dist/{src/lib/components → components}/FadeInDown/FadeInDown.d.ts +0 -0
- /package/dist/{src/lib/components → components}/FadeInDown/FadeInDown.test.d.ts +0 -0
- /package/dist/{src/lib/components → components}/FadeInDown/index.d.ts +0 -0
- /package/dist/{src/lib/components → components}/FileUpload/FileUpload.d.ts +0 -0
- /package/dist/{src/lib/components → components}/FileUpload/FileUpload.stories.d.ts +0 -0
- /package/dist/{src/lib/components → components}/FileUpload/FileUpload.test.d.ts +0 -0
- /package/dist/{src/lib/components → components}/FileUpload/hooks.d.ts +0 -0
- /package/dist/{src/lib/components → components}/FileUpload/index.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/GenericTable.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/GenericTable.stories.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/GenericTable.test.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/components/ColumnHeader/ColumnHeader.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/components/ColumnHeader/index.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/components/PaginationBar/ControlsBar/ControlsBar.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/components/PaginationBar/ControlsBar/index.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/components/PaginationBar/PaginationBar.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/components/PaginationBar/index.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/components/SortingIndicator/SortingIndicator.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/components/SortingIndicator/index.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/components/TableCheckbox/TableCheckbox.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/components/TableCheckbox/TableCheckbox.test.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/components/TableCheckbox/index.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/hooks/useTableExpansion.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/hooks/useTableGrouping.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/hooks/useTableKeyboardNavigation.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/hooks/useTableScrollHeight.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/hooks/useTableSorting.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/index.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/types.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/utils/processColumnDefs.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/utils/renderDataRows.d.ts +0 -0
- /package/dist/{src/lib/components → components}/GenericTable/utils/renderLoadingRows.d.ts +0 -0
- /package/dist/{src/lib/components → components}/MultiSelect/MultiSelect.d.ts +0 -0
- /package/dist/{src/lib/components → components}/MultiSelect/MultiSelect.stories.d.ts +0 -0
- /package/dist/{src/lib/components → components}/MultiSelect/MultiSelect.test.d.ts +0 -0
- /package/dist/{src/lib/components → components}/MultiSelect/index.d.ts +0 -0
- /package/dist/{src/lib/components → components}/NestedFormGroup/NestedFormGroup.d.ts +0 -0
- /package/dist/{src/lib/components → components}/NestedFormGroup/NestedFormGroup.stories.d.ts +0 -0
- /package/dist/{src/lib/components → components}/NestedFormGroup/NestedFormGroup.test.d.ts +0 -0
- /package/dist/{src/lib/components → components}/NestedFormGroup/index.d.ts +0 -0
- /package/dist/{src/lib/components → components}/Pagination/Pagination.d.ts +0 -0
- /package/dist/{src/lib/components → components}/Pagination/Pagination.stories.d.ts +0 -0
- /package/dist/{src/lib/components → components}/Pagination/Pagination.test.d.ts +0 -0
- /package/dist/{src/lib/components → components}/Pagination/PaginationContainer.test.d.ts +0 -0
- /package/dist/{src/lib/components → components}/Pagination/index.d.ts +0 -0
- /package/dist/{src/lib/components → components}/QueryInput/QueryInput.d.ts +0 -0
- /package/dist/{src/lib/components → components}/QueryInput/QueryInput.stories.d.ts +0 -0
- /package/dist/{src/lib/components → components}/QueryInput/QueryInput.test.d.ts +0 -0
- /package/dist/{src/lib/components → components}/QueryInput/index.d.ts +0 -0
- /package/dist/{src/lib/components → components}/Stepper/Stepper.d.ts +0 -0
- /package/dist/{src/lib/components → components}/Stepper/Stepper.stories.d.ts +0 -0
- /package/dist/{src/lib/components → components}/Stepper/Stepper.test.d.ts +0 -0
- /package/dist/{src/lib/components → components}/Stepper/index.d.ts +0 -0
- /package/dist/{src/lib/components → components}/TableCaption/TableCaption.d.ts +0 -0
- /package/dist/{src/lib/components → components}/TableCaption/TableCaption.stories.d.ts +0 -0
- /package/dist/{src/lib/components → components}/TableCaption/TableCaption.test.d.ts +0 -0
- /package/dist/{src/lib/components → components}/TableCaption/index.d.ts +0 -0
- /package/dist/{src/lib/components → components}/index.d.ts +0 -0
- /package/dist/{src/lib/elements → elements}/ExternalLink/ExternalLink.stories.d.ts +0 -0
- /package/dist/{src/lib/elements → elements}/ExternalLink/ExternalLink.test.d.ts +0 -0
- /package/dist/{src/lib/elements → elements}/ExternalLink/index.d.ts +0 -0
- /package/dist/{src/lib/elements → elements}/Meter/Meter.d.ts +0 -0
- /package/dist/{src/lib/elements → elements}/Meter/Meter.stories.d.ts +0 -0
- /package/dist/{src/lib/elements → elements}/Meter/Meter.test.d.ts +0 -0
- /package/dist/{src/lib/elements → elements}/Meter/index.d.ts +0 -0
- /package/dist/{src/lib/elements → elements}/Placeholder/Placeholder.d.ts +0 -0
- /package/dist/{src/lib/elements → elements}/Placeholder/Placeholder.stories.d.ts +0 -0
- /package/dist/{src/lib/elements → elements}/Placeholder/Placeholder.test.d.ts +0 -0
- /package/dist/{src/lib/elements → elements}/Placeholder/index.d.ts +0 -0
- /package/dist/{src/lib/elements → elements}/ProgressIndicator/ProgressIndicator.d.ts +0 -0
- /package/dist/{src/lib/elements → elements}/ProgressIndicator/ProgressIndicator.test.d.ts +0 -0
- /package/dist/{src/lib/elements → elements}/ProgressIndicator/index.d.ts +0 -0
- /package/dist/{src/lib/elements → elements}/index.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/ContentSection/ContentSection.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/ContentSection/ContentSection.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/ContentSection/ContentSection.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/ContentSection/index.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/FormSection/FormSection.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/FormSection/FormSection.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/FormSection/FormSection.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/FormSection/index.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/InputGroup/InputGroup.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/InputGroup/InputGroup.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/InputGroup/InputGroup.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/InputGroup/index.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Layout/Layout.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Layout/Layout.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Layout/components/DocumentTitle/DocumentTitle.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Layout/components/DocumentTitle/index.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Layout/index.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/MainToolbar/MainToolbar.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/MainToolbar/MainToolbar.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/MainToolbar/MainToolbar.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/MainToolbar/index.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Banner/Banner.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Banner/Banner.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Banner/Banner.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/CollapseToggle/CollapseToggle.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/CollapseToggle/CollapseToggle.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/CollapseToggle/CollapseToggle.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Content/Content.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Content/Content.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Content/Content.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Controls/Controls.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Controls/Controls.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Controls/Controls.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Drawer/Drawer.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Drawer/Drawer.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Drawer/Drawer.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Footer/Footer.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Footer/Footer.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Footer/Footer.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Header/Header.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Header/Header.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Header/Header.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Icon/Icon.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Icon/Icon.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Icon/Icon.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Item/Item.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Item/Item.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Item/Item.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Label/Label.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Label/Label.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Label/Label.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Link/Link.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Link/Link.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Link/Link.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/List/List.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/List/List.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/List/List.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Logo/Logo.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Logo/Logo.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Logo/Logo.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/LogoIcon/LogoIcon.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/LogoIcon/LogoIcon.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/LogoIcon/LogoIcon.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/LogoName/LogoName.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/LogoName/LogoName.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/LogoName/LogoName.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/LogoTag/LogoTag.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/LogoTag/LogoTag.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/LogoTag/LogoTag.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/LogoText/LogoText.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/LogoText/LogoText.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/MenuButton/MenuButton.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/MenuButton/MenuButton.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/MenuButton/MenuButton.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Navigation.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Navigation.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Navigation.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/NavigationBar.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Text/Text.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/Text/Text.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/Navigation/index.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/SidePanel/SidePanel.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/SidePanel/SidePanel.stories.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/SidePanel/SidePanel.test.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/SidePanel/SidePanelContextProvider/SidePanelContextProvider.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/SidePanel/utils.d.ts +0 -0
- /package/dist/{src/lib/sections → sections}/index.d.ts +0 -0
- /package/dist/{src/lib/utils → utils}/formatBytes/formatBytes.d.ts +0 -0
- /package/dist/{src/lib/utils → utils}/formatBytes/formatBytes.stories.d.ts +0 -0
- /package/dist/{src/lib/utils → utils}/formatBytes/formatBytes.test.d.ts +0 -0
- /package/dist/{src/lib/utils → utils}/formatBytes/index.d.ts +0 -0
- /package/dist/{src/lib/utils → utils}/index.d.ts +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LinkProps } from '@canonical/react-components';
|
|
2
|
-
|
|
3
|
-
type ExternalLinkProps = Pick<LinkProps, "children"> & Omit<RouterLinkProps, "children"> & {
|
|
2
|
+
type ExternalLinkProps = Omit<LinkProps, "href"> & {
|
|
4
3
|
to: string;
|
|
5
4
|
};
|
|
6
5
|
export declare const ExternalLink: ({ children, to, ...props }: ExternalLinkProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { expectTooltipOnHover } from './expectTooltipOnHover';
|
|
2
|
+
export { mockIsPending } from './mockIsPending';
|
|
3
|
+
export { mockSidePanel } from './mockSidePanel';
|
|
4
|
+
export { renderHookWithProviders } from './renderHookWithProviders';
|
|
5
|
+
export { renderWithProviders } from './renderWithProviders';
|
|
6
|
+
export { setupMockServer } from './setupMockServer';
|
|
7
|
+
export { spyOnMutation } from './spyOnMutation';
|
|
8
|
+
export { waitForLoading } from './waitForLoading';
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { screen as c, renderHook as v, render as h } from "@testing-library/react";
|
|
2
|
+
import u from "@testing-library/user-event";
|
|
3
|
+
import { vi as t } from "vitest";
|
|
4
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
5
|
+
import { QueryClient as f, QueryClientProvider as y } from "@tanstack/react-query";
|
|
6
|
+
import { c as k } from "../QueryInput-D7uXzKgr.mjs";
|
|
7
|
+
import "@canonical/react-components";
|
|
8
|
+
import "react";
|
|
9
|
+
import "classnames";
|
|
10
|
+
import "react-dropzone";
|
|
11
|
+
import "@tanstack/react-table";
|
|
12
|
+
import { createMemoryRouter as d, RouterProvider as m } from "react-router";
|
|
13
|
+
import { setupServer as P } from "msw/node";
|
|
14
|
+
const V = async (r, e) => {
|
|
15
|
+
if (expect(
|
|
16
|
+
c.queryByRole("tooltip", { name: e })
|
|
17
|
+
).not.toBeInTheDocument(), !r)
|
|
18
|
+
throw new Error("expectTooltipOnHover: the element was null or undefined");
|
|
19
|
+
await u.hover(r), r.querySelector("i") && await u.hover(r.querySelector("i")), await t.waitFor(
|
|
20
|
+
() => expect(c.getAllByRole("tooltip", { name: e })).toHaveLength(
|
|
21
|
+
1
|
|
22
|
+
)
|
|
23
|
+
);
|
|
24
|
+
}, F = () => {
|
|
25
|
+
t.doMock("@tanstack/react-query", async () => ({
|
|
26
|
+
...await t.importActual("@tanstack/react-query"),
|
|
27
|
+
useQuery: t.fn().mockReturnValueOnce({
|
|
28
|
+
data: null,
|
|
29
|
+
isPending: !0,
|
|
30
|
+
failureReason: void 0,
|
|
31
|
+
isFetched: !1
|
|
32
|
+
})
|
|
33
|
+
})), afterEach(() => {
|
|
34
|
+
t.doUnmock("@tanstack/react-query");
|
|
35
|
+
});
|
|
36
|
+
}, W = async () => {
|
|
37
|
+
const r = t.spyOn(
|
|
38
|
+
await import("../@canonical/maas-react-components.es.js"),
|
|
39
|
+
// the library's own barrel export
|
|
40
|
+
"useSidePanel"
|
|
41
|
+
), e = t.fn(), a = t.fn();
|
|
42
|
+
let n = !1;
|
|
43
|
+
const i = () => ({
|
|
44
|
+
isOpen: n,
|
|
45
|
+
title: "",
|
|
46
|
+
size: "regular",
|
|
47
|
+
component: null,
|
|
48
|
+
props: {},
|
|
49
|
+
openSidePanel: e,
|
|
50
|
+
closeSidePanel: a,
|
|
51
|
+
setSidePanelSize: t.fn()
|
|
52
|
+
});
|
|
53
|
+
return beforeEach(() => {
|
|
54
|
+
t.clearAllMocks(), n = !1, e.mockImplementation(() => {
|
|
55
|
+
n = !0, r.mockReturnValue(i());
|
|
56
|
+
}), a.mockImplementation(() => {
|
|
57
|
+
n = !1, r.mockReturnValue(i());
|
|
58
|
+
}), r.mockReturnValue(i());
|
|
59
|
+
}), { mockOpen: e, mockClose: a };
|
|
60
|
+
}, b = (r, e) => {
|
|
61
|
+
const a = new f({
|
|
62
|
+
defaultOptions: { queries: { retry: !1, staleTime: 1 / 0 } }
|
|
63
|
+
}), n = e == null ? void 0 : e.AdditionalProviders;
|
|
64
|
+
return {
|
|
65
|
+
result: v(r, {
|
|
66
|
+
wrapper: ({ children: i }) => /* @__PURE__ */ l(y, { client: a, children: /* @__PURE__ */ l(k, { children: n ? /* @__PURE__ */ l(n, { children: i }) : i }) })
|
|
67
|
+
}).result,
|
|
68
|
+
queryClient: a
|
|
69
|
+
};
|
|
70
|
+
}, L = (r, e) => {
|
|
71
|
+
const a = new f({
|
|
72
|
+
defaultOptions: { queries: { retry: !1, staleTime: 1 / 0 } }
|
|
73
|
+
}), n = d(
|
|
74
|
+
[{ path: (e == null ? void 0 : e.pattern) ?? "*", element: r }],
|
|
75
|
+
{ initialEntries: (e == null ? void 0 : e.initialEntries) || ["/"] }
|
|
76
|
+
), i = e == null ? void 0 : e.AdditionalProviders, s = h(/* @__PURE__ */ l(m, { router: n }), {
|
|
77
|
+
wrapper: ({ children: o }) => /* @__PURE__ */ l(y, { client: a, children: /* @__PURE__ */ l(k, { children: i ? /* @__PURE__ */ l(i, { children: o }) : o }) }),
|
|
78
|
+
...e
|
|
79
|
+
});
|
|
80
|
+
return { result: s, rerender: (o) => {
|
|
81
|
+
const p = d(
|
|
82
|
+
[{ path: (e == null ? void 0 : e.pattern) ?? "*", element: o }],
|
|
83
|
+
{ initialEntries: (e == null ? void 0 : e.initialEntries) || ["/"] }
|
|
84
|
+
);
|
|
85
|
+
return s.rerender(/* @__PURE__ */ l(m, { router: p }));
|
|
86
|
+
}, router: n };
|
|
87
|
+
}, Q = (r, e, ...a) => {
|
|
88
|
+
r.setConfig({ baseUrl: e });
|
|
89
|
+
const n = P(...a);
|
|
90
|
+
return beforeAll(() => {
|
|
91
|
+
n.listen({ onUnhandledRequest: "error" });
|
|
92
|
+
}), afterEach(() => {
|
|
93
|
+
n.resetHandlers();
|
|
94
|
+
}), afterAll(() => {
|
|
95
|
+
n.close();
|
|
96
|
+
}), n;
|
|
97
|
+
}, U = (r, e) => {
|
|
98
|
+
const a = t.fn();
|
|
99
|
+
return t.spyOn(r, e).mockImplementation(() => ({
|
|
100
|
+
mutate: a,
|
|
101
|
+
mutateAsync: t.fn(),
|
|
102
|
+
data: void 0,
|
|
103
|
+
variables: void 0,
|
|
104
|
+
error: null,
|
|
105
|
+
isError: !1,
|
|
106
|
+
isPending: !1,
|
|
107
|
+
isIdle: !0,
|
|
108
|
+
isSuccess: !1,
|
|
109
|
+
status: "idle",
|
|
110
|
+
reset: t.fn()
|
|
111
|
+
})), afterEach(() => {
|
|
112
|
+
t.clearAllMocks();
|
|
113
|
+
}), a;
|
|
114
|
+
}, z = async (r = "Loading", e) => await t.waitFor(
|
|
115
|
+
() => expect(
|
|
116
|
+
c.queryByText(new RegExp(r, "i"))
|
|
117
|
+
).not.toBeInTheDocument(),
|
|
118
|
+
e
|
|
119
|
+
);
|
|
120
|
+
export {
|
|
121
|
+
V as expectTooltipOnHover,
|
|
122
|
+
F as mockIsPending,
|
|
123
|
+
W as mockSidePanel,
|
|
124
|
+
b as renderHookWithProviders,
|
|
125
|
+
L as renderWithProviders,
|
|
126
|
+
Q as setupMockServer,
|
|
127
|
+
U as spyOnMutation,
|
|
128
|
+
z as waitForLoading
|
|
129
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spies on `useQuery` from `@tanstack/react-query` to return a pending state
|
|
3
|
+
* for the first call in each test. Uses `vi.spyOn` (via `vi.doMock`) rather
|
|
4
|
+
* than mocking the return value directly, since the module is already loaded.
|
|
5
|
+
*/
|
|
6
|
+
export declare const mockIsPending: () => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
+
/**
|
|
4
|
+
* Renders a hook with all test-relevant providers (query client and side
|
|
5
|
+
* panel).
|
|
6
|
+
*
|
|
7
|
+
* Any project-specific providers (e.g. a Redux `Provider`, a WebSocket
|
|
8
|
+
* context, etc.) should be supplied via the `AdditionalProviders` option -
|
|
9
|
+
* this library has no dependency on Redux or any other state management
|
|
10
|
+
* library.
|
|
11
|
+
*
|
|
12
|
+
* @typeParam T - The return type of the hook.
|
|
13
|
+
*/
|
|
14
|
+
export declare const renderHookWithProviders: <T>(hook: () => T, options?: Partial<{
|
|
15
|
+
initialEntries: string[];
|
|
16
|
+
AdditionalProviders: ComponentType<{
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
}>;
|
|
19
|
+
}>) => {
|
|
20
|
+
result: {
|
|
21
|
+
current: T;
|
|
22
|
+
};
|
|
23
|
+
queryClient: QueryClient;
|
|
24
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import { InitialEntry } from '@remix-run/router';
|
|
3
|
+
import { RenderOptions, RenderResult } from '@testing-library/react';
|
|
4
|
+
import { createMemoryRouter } from 'react-router';
|
|
5
|
+
/** The router instance returned by `createMemoryRouter` / `createBrowserRouter`. */
|
|
6
|
+
type DataRouter = ReturnType<typeof createMemoryRouter>;
|
|
7
|
+
/**
|
|
8
|
+
* Renders a component with all test-relevant providers (query client, side
|
|
9
|
+
* panel, and router).
|
|
10
|
+
*
|
|
11
|
+
* Any project-specific providers (e.g. a Redux `Provider`, a WebSocket
|
|
12
|
+
* context, etc.) should be supplied via the `AdditionalProviders` option -
|
|
13
|
+
* this library has no dependency on Redux or any other state management
|
|
14
|
+
* library.
|
|
15
|
+
*
|
|
16
|
+
* @param ui - The component to render.
|
|
17
|
+
* @param options - Rendering options including router entries and an
|
|
18
|
+
* `AdditionalProviders` wrapper for project-specific
|
|
19
|
+
* providers (e.g. a Redux `Provider`, WebSocketProvider).
|
|
20
|
+
*/
|
|
21
|
+
export declare const renderWithProviders: (ui: ReactNode, options?: Omit<RenderOptions, "wrapper"> & Partial<{
|
|
22
|
+
initialEntries: InitialEntry[];
|
|
23
|
+
pattern: string;
|
|
24
|
+
AdditionalProviders: ComponentType<{
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
}>;
|
|
27
|
+
}>) => {
|
|
28
|
+
result: RenderResult;
|
|
29
|
+
router: DataRouter;
|
|
30
|
+
rerender: (ui: ReactNode) => void;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RequestHandler } from 'msw';
|
|
2
|
+
/**
|
|
3
|
+
* Sets up an MSW mock server for use in tests.
|
|
4
|
+
*
|
|
5
|
+
* @param client - The Hey-API client instance (from `@/app/apiclient/client.gen` in maas-ui).
|
|
6
|
+
* @param baseUrl - The base URL to configure on the client.
|
|
7
|
+
* @param handlers - MSW request handlers.
|
|
8
|
+
*/
|
|
9
|
+
export declare const setupMockServer: (client: {
|
|
10
|
+
setConfig: (config: {
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
}) => void;
|
|
13
|
+
}, baseUrl: string, ...handlers: RequestHandler[]) => import('msw/node').SetupServer;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spies on a given mutation hook to observe the mutate function.
|
|
3
|
+
*
|
|
4
|
+
* @param obj - The module object that contains the hook.
|
|
5
|
+
* @param methodName - The name of the mutation hook to spy on.
|
|
6
|
+
* @returns A mock `mutate` function that can be observed with `expect`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const spyOnMutation: (obj: unknown, methodName: string) => import('vitest').Mock<(...args: any[]) => any>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Waits until the loading text is no longer present in the document.
|
|
3
|
+
*
|
|
4
|
+
* @param loadingText - Text to query for. Defaults to "Loading".
|
|
5
|
+
* @param options - Optional `vi.waitFor` options (`interval`, `timeout`).
|
|
6
|
+
*/
|
|
7
|
+
export declare const waitForLoading: (loadingText?: string, options?: {
|
|
8
|
+
interval?: number;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
}) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/maas-react-components",
|
|
3
3
|
"description": "React components for use in MAAS UI projects.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.7.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/canonical/maas-react-components.git"
|
|
@@ -10,14 +10,19 @@
|
|
|
10
10
|
"url": "https://github.com/canonical/maas-react-components/issues"
|
|
11
11
|
},
|
|
12
12
|
"homepage": "https://github.com/canonical/maas-react-components#readme",
|
|
13
|
-
"main": "./dist/@canonical/maas-react-components.
|
|
13
|
+
"main": "./dist/@canonical/maas-react-components.es.js",
|
|
14
14
|
"module": "./dist/@canonical/maas-react-components.es.js",
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"import": "./dist/@canonical/maas-react-components.es.js",
|
|
20
|
-
"
|
|
20
|
+
"default": "./dist/@canonical/maas-react-components.es.js"
|
|
21
|
+
},
|
|
22
|
+
"./testing": {
|
|
23
|
+
"types": "./dist/testing/index.d.ts",
|
|
24
|
+
"import": "./dist/testing/index.es.js",
|
|
25
|
+
"default": "./dist/testing/index.es.js"
|
|
21
26
|
},
|
|
22
27
|
"./dist/style.css": {
|
|
23
28
|
"import": "./dist/style.css",
|
|
@@ -27,6 +32,13 @@
|
|
|
27
32
|
"files": [
|
|
28
33
|
"dist"
|
|
29
34
|
],
|
|
35
|
+
"typesVersions": {
|
|
36
|
+
"*": {
|
|
37
|
+
"testing": [
|
|
38
|
+
"./dist/testing/index.d.ts"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
30
42
|
"license": "AGPL-3.0",
|
|
31
43
|
"scripts": {
|
|
32
44
|
"build": "tsc && vite build",
|
|
@@ -48,6 +60,7 @@
|
|
|
48
60
|
"devDependencies": {
|
|
49
61
|
"@commitlint/cli": "^19.0.0",
|
|
50
62
|
"@commitlint/config-conventional": "^19.0.0",
|
|
63
|
+
"@remix-run/router": "^1.23.3",
|
|
51
64
|
"@semantic-release/changelog": "^6.0.3",
|
|
52
65
|
"@semantic-release/git": "^10.0.1",
|
|
53
66
|
"@storybook/addon-a11y": "^8.6.12",
|
|
@@ -58,10 +71,11 @@
|
|
|
58
71
|
"@storybook/react": "^8.6.12",
|
|
59
72
|
"@storybook/react-vite": "^8.6.12",
|
|
60
73
|
"@storybook/theming": "^8.6.12",
|
|
74
|
+
"@tanstack/react-query": "^5.100.11",
|
|
61
75
|
"@testing-library/jest-dom": "^6.1.3",
|
|
62
76
|
"@testing-library/react": "^16.3.0",
|
|
63
77
|
"@testing-library/user-event": "^14.5.1",
|
|
64
|
-
"@types/react-dom": "19.1.3",
|
|
78
|
+
"@types/react-dom": "^19.1.3",
|
|
65
79
|
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
66
80
|
"@typescript-eslint/parser": "^7.0.0",
|
|
67
81
|
"@vitejs/plugin-react": "^4.1.0",
|
|
@@ -77,6 +91,7 @@
|
|
|
77
91
|
"eslint-plugin-storybook": "^0.12.0",
|
|
78
92
|
"eslint-plugin-unused-imports": "^3.2.0",
|
|
79
93
|
"jsdom": "^26.0.0",
|
|
94
|
+
"msw": "^2.14.6",
|
|
80
95
|
"plop": "^4.0.0",
|
|
81
96
|
"prettier": "^3.5.3",
|
|
82
97
|
"prop-types": "^15.8.1",
|
|
@@ -100,15 +115,32 @@
|
|
|
100
115
|
},
|
|
101
116
|
"peerDependencies": {
|
|
102
117
|
"@canonical/react-components": "^4.5.0",
|
|
118
|
+
"@tanstack/react-query": "^5.100.11",
|
|
103
119
|
"@tanstack/react-table": "^8.15.3",
|
|
120
|
+
"@testing-library/react": "^16.0.0",
|
|
121
|
+
"@testing-library/user-event": "^14.0.0",
|
|
104
122
|
"@types/react": "^19.1.2",
|
|
105
123
|
"@types/react-dom": "^19.1.3",
|
|
106
124
|
"classnames": "^2.3.2",
|
|
107
|
-
"
|
|
108
|
-
"react
|
|
109
|
-
"react-
|
|
110
|
-
"react-
|
|
111
|
-
"react-router
|
|
112
|
-
"
|
|
125
|
+
"msw": "^2.0.0",
|
|
126
|
+
"react": "^19.1.0",
|
|
127
|
+
"react-dom": "^19.1.0",
|
|
128
|
+
"react-dropzone": "^14.3.8",
|
|
129
|
+
"react-router": ">=6.0.0",
|
|
130
|
+
"vitest": "^3.0.0"
|
|
131
|
+
},
|
|
132
|
+
"peerDependenciesMeta": {
|
|
133
|
+
"@testing-library/react": {
|
|
134
|
+
"optional": true
|
|
135
|
+
},
|
|
136
|
+
"@testing-library/user-event": {
|
|
137
|
+
"optional": true
|
|
138
|
+
},
|
|
139
|
+
"msw": {
|
|
140
|
+
"optional": true
|
|
141
|
+
},
|
|
142
|
+
"vitest": {
|
|
143
|
+
"optional": true
|
|
144
|
+
}
|
|
113
145
|
}
|
|
114
146
|
}
|