@terreno/ui 0.31.0 → 56.0.0-beta.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/LICENSE +203 -21
- package/dist/ActionSheet.d.ts +1 -1
- package/dist/Avatar.js +1 -4
- package/dist/Avatar.js.map +1 -1
- package/dist/Box.js +45 -9
- package/dist/Box.js.map +1 -1
- package/dist/Common.d.ts +21 -39
- package/dist/Common.js.map +1 -1
- package/dist/ConflictSheet.d.ts +53 -0
- package/dist/ConflictSheet.js +132 -0
- package/dist/ConflictSheet.js.map +1 -0
- package/dist/DateTimeActionSheet.d.ts +2 -1
- package/dist/DecimalRangeActionSheet.d.ts +1 -1
- package/dist/EmojiSelector.d.ts +1 -1
- package/dist/ErrorPage.d.ts +1 -1
- package/dist/HeightActionSheet.d.ts +1 -1
- package/dist/Hyperlink.d.ts +2 -1
- package/dist/Hyperlink.js +2 -1
- package/dist/Hyperlink.js.map +1 -1
- package/dist/Image.d.ts +1 -1
- package/dist/ImageBackground.d.ts +1 -1
- package/dist/MobileAddressAutoComplete.d.ts +1 -1
- package/dist/NumberPickerActionSheet.d.ts +1 -1
- package/dist/Page.d.ts +3 -3
- package/dist/PickerSelect.d.ts +1 -1
- package/dist/SidebarNavigation.js +1 -1
- package/dist/SidebarNavigation.js.map +1 -1
- package/dist/SidebarNavigation.native.js +1 -1
- package/dist/SidebarNavigation.native.js.map +1 -1
- package/dist/SplitPage.d.ts +1 -1
- package/dist/SplitPage.js +1 -4
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.d.ts +1 -1
- package/dist/SyncStatusBanner.d.ts +46 -0
- package/dist/SyncStatusBanner.js +29 -0
- package/dist/SyncStatusBanner.js.map +1 -0
- package/dist/Theme.d.ts +1 -1
- package/dist/Theme.js +0 -1
- package/dist/Theme.js.map +1 -1
- package/dist/Toast.d.ts +9 -1
- package/dist/Toast.js +20 -7
- package/dist/Toast.js.map +1 -1
- package/dist/ToastNotifications.js +23 -1
- package/dist/ToastNotifications.js.map +1 -1
- package/dist/UnifiedAddressAutoComplete.d.ts +1 -1
- package/dist/Unifier.js +1 -1
- package/dist/Unifier.js.map +1 -1
- package/dist/conflictFieldDiff.d.ts +14 -0
- package/dist/conflictFieldDiff.js +62 -0
- package/dist/conflictFieldDiff.js.map +1 -0
- package/dist/icons/OfflineIcon.d.ts +1 -1
- package/dist/icons/OnlineIcon.d.ts +1 -1
- package/dist/icons/OutOfficeIcon.d.ts +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/pdfHtmlTemplate.d.ts +30 -0
- package/dist/pdfHtmlTemplate.js +170 -0
- package/dist/pdfHtmlTemplate.js.map +1 -0
- package/dist/table/TableTitle.js +1 -3
- package/dist/table/TableTitle.js.map +1 -1
- package/dist/useAppLaunchOrForeground.d.ts +9 -0
- package/dist/useAppLaunchOrForeground.js +27 -0
- package/dist/useAppLaunchOrForeground.js.map +1 -0
- package/package.json +45 -39
- package/src/ActionSheet.test.tsx +37 -80
- package/src/Box.test.tsx +39 -9
- package/src/Box.tsx +46 -7
- package/src/Common.ts +21 -50
- package/src/ConflictSheet.test.tsx +461 -0
- package/src/ConflictSheet.tsx +399 -0
- package/src/ConsentNavigator.test.tsx +8 -6
- package/src/DateTimeField.test.tsx +0 -36
- package/src/Hyperlink.tsx +1 -1
- package/src/PickerSelect.test.tsx +12 -23
- package/src/SidebarNavigation.native.tsx +1 -1
- package/src/SidebarNavigation.tsx +1 -1
- package/src/SyncStatusBanner.test.tsx +204 -0
- package/src/SyncStatusBanner.tsx +148 -0
- package/src/TerrenoProvider.test.tsx +3 -4
- package/src/Theme.tsx +0 -1
- package/src/Toast.test.tsx +60 -0
- package/src/Toast.tsx +46 -1
- package/src/ToastNotifications.test.tsx +82 -0
- package/src/ToastNotifications.tsx +25 -1
- package/src/Unifier.ts +1 -1
- package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +0 -3
- package/src/__snapshots__/Body.test.tsx.snap +0 -16
- package/src/__snapshots__/Box.test.tsx.snap +4 -13
- package/src/__snapshots__/Card.test.tsx.snap +0 -1
- package/src/__snapshots__/Page.test.tsx.snap +0 -84
- package/src/__snapshots__/SplitPage.test.tsx.snap +24 -120
- package/src/__snapshots__/TapToEdit.test.tsx.snap +5 -16
- package/src/__snapshots__/Toast.test.tsx.snap +4 -2
- package/src/bunSetup.ts +21 -6
- package/src/conflictFieldDiff.test.ts +26 -0
- package/src/conflictFieldDiff.ts +78 -0
- package/src/index.tsx +5 -3
- package/src/login/__snapshots__/LoginScreen.test.tsx.snap +0 -9
- package/src/pdfHtmlTemplate.ts +219 -0
- package/src/signUp/__snapshots__/OAuthButtons.test.tsx.snap +0 -1
- package/src/signUp/__snapshots__/PasswordRequirements.test.tsx.snap +2 -16
- package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +1 -17
- package/src/signUp/__snapshots__/Swiper.test.tsx.snap +0 -1
- package/src/table/__snapshots__/Table.test.tsx.snap +22 -87
- package/src/table/__snapshots__/TableHeader.test.tsx.snap +10 -50
- package/src/table/__snapshots__/TableHeaderCell.test.tsx.snap +10 -84
- package/src/table/__snapshots__/TableRow.test.tsx.snap +12 -77
- package/src/useAppLaunchOrForeground.test.tsx +54 -0
- package/src/useAppLaunchOrForeground.ts +30 -0
- package/dist/ConsentHistory.d.ts +0 -9
- package/dist/ConsentHistory.js +0 -70
- package/dist/ConsentHistory.js.map +0 -1
- package/dist/EditableCard.d.ts +0 -3
- package/dist/EditableCard.js +0 -23
- package/dist/EditableCard.js.map +0 -1
- package/dist/generateConsentHistoryPdf.d.ts +0 -2
- package/dist/generateConsentHistoryPdf.js +0 -185
- package/dist/generateConsentHistoryPdf.js.map +0 -1
- package/dist/useConsentHistory.d.ts +0 -63
- package/dist/useConsentHistory.js +0 -40
- package/dist/useConsentHistory.js.map +0 -1
- package/src/ConsentHistory.test.tsx +0 -224
- package/src/ConsentHistory.tsx +0 -249
- package/src/DraggableList.test.tsx +0 -377
- package/src/EditableCard.test.tsx +0 -69
- package/src/EditableCard.tsx +0 -73
- package/src/SidebarNavigation.test.tsx +0 -339
- package/src/__snapshots__/EditableCard.test.tsx.snap +0 -242
- package/src/generateConsentHistoryPdf.test.ts +0 -253
- package/src/generateConsentHistoryPdf.ts +0 -211
- package/src/useConsentHistory.test.ts +0 -106
- package/src/useConsentHistory.ts +0 -94
package/src/EditableCard.tsx
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type React from "react";
|
|
2
|
-
|
|
3
|
-
import {Badge} from "./Badge";
|
|
4
|
-
import {Box} from "./Box";
|
|
5
|
-
import {Card} from "./Card";
|
|
6
|
-
import type {EditableCardProps} from "./Common";
|
|
7
|
-
import {Icon} from "./Icon";
|
|
8
|
-
import {IconButton} from "./IconButton";
|
|
9
|
-
import {Text} from "./Text";
|
|
10
|
-
|
|
11
|
-
export const EditableCard = ({
|
|
12
|
-
children,
|
|
13
|
-
attention = false,
|
|
14
|
-
badge,
|
|
15
|
-
color,
|
|
16
|
-
description,
|
|
17
|
-
editAccessibilityLabel = "Edit",
|
|
18
|
-
helperText,
|
|
19
|
-
iconName,
|
|
20
|
-
onEdit,
|
|
21
|
-
padding = 3,
|
|
22
|
-
title,
|
|
23
|
-
...rest
|
|
24
|
-
}: EditableCardProps): React.ReactElement => {
|
|
25
|
-
return (
|
|
26
|
-
<Card
|
|
27
|
-
borderLeft="default"
|
|
28
|
-
borderRight="default"
|
|
29
|
-
color={color ?? (attention ? "secondaryExtraLight" : "base")}
|
|
30
|
-
direction="row"
|
|
31
|
-
gap={2}
|
|
32
|
-
padding={padding}
|
|
33
|
-
rounding="md"
|
|
34
|
-
width="100%"
|
|
35
|
-
{...rest}
|
|
36
|
-
>
|
|
37
|
-
{Boolean(iconName) && (
|
|
38
|
-
<Box paddingY={1}>
|
|
39
|
-
<Icon iconName={iconName!} size="md" />
|
|
40
|
-
</Box>
|
|
41
|
-
)}
|
|
42
|
-
<Box direction="column" flex="grow" gap={1} minWidth={0}>
|
|
43
|
-
{(Boolean(title) || Boolean(badge)) && (
|
|
44
|
-
<Box alignItems="center" direction="row" gap={2}>
|
|
45
|
-
{Boolean(title) && (
|
|
46
|
-
<Box flex="shrink" minWidth={0}>
|
|
47
|
-
<Text bold size="md" truncate>
|
|
48
|
-
{title}
|
|
49
|
-
</Text>
|
|
50
|
-
</Box>
|
|
51
|
-
)}
|
|
52
|
-
{Boolean(badge) && <Badge {...badge!} />}
|
|
53
|
-
</Box>
|
|
54
|
-
)}
|
|
55
|
-
{Boolean(description) && <Text size="md">{description}</Text>}
|
|
56
|
-
{Boolean(helperText) && (
|
|
57
|
-
<Text color="secondaryLight" size="sm">
|
|
58
|
-
{helperText}
|
|
59
|
-
</Text>
|
|
60
|
-
)}
|
|
61
|
-
{children}
|
|
62
|
-
</Box>
|
|
63
|
-
{Boolean(onEdit) && (
|
|
64
|
-
<IconButton
|
|
65
|
-
accessibilityLabel={editAccessibilityLabel}
|
|
66
|
-
iconName="pencil"
|
|
67
|
-
onClick={onEdit!}
|
|
68
|
-
variant="ghost"
|
|
69
|
-
/>
|
|
70
|
-
)}
|
|
71
|
-
</Card>
|
|
72
|
-
);
|
|
73
|
-
};
|
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
import {afterAll, beforeEach, describe, expect, it, mock} from "bun:test";
|
|
2
|
-
import {fireEvent} from "@testing-library/react-native";
|
|
3
|
-
import React, {type ReactNode} from "react";
|
|
4
|
-
import {View} from "react-native";
|
|
5
|
-
|
|
6
|
-
import type {SidebarNavigationItem} from "./Common";
|
|
7
|
-
import {renderWithTheme} from "./test-utils";
|
|
8
|
-
|
|
9
|
-
interface MockChildrenProps {
|
|
10
|
-
children?: ReactNode;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface NavigatorContext {
|
|
14
|
-
state: {index: number; routes: {key: string; name: string}[]};
|
|
15
|
-
navigation: {navigate: (route: string) => void};
|
|
16
|
-
descriptors: Record<string, {options: Record<string, unknown>}>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const navigate = mock((_route: string) => {});
|
|
20
|
-
|
|
21
|
-
let navigatorContext: NavigatorContext = {
|
|
22
|
-
descriptors: {},
|
|
23
|
-
navigation: {navigate},
|
|
24
|
-
state: {index: 0, routes: [{key: "home-key", name: "index"}]},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// bunSetup.ts mocks expo-router without Navigator.useContext, which
|
|
28
|
-
// SidebarNavigatorContent depends on. Restored in afterAll to avoid leaking
|
|
29
|
-
// into other test files.
|
|
30
|
-
mock.module("expo-router", () => ({
|
|
31
|
-
Link: ({children, ...props}: MockChildrenProps) => React.createElement("Link", props, children),
|
|
32
|
-
Navigator: Object.assign(
|
|
33
|
-
({children, ...props}: MockChildrenProps) => React.createElement("Navigator", props, children),
|
|
34
|
-
{useContext: () => navigatorContext}
|
|
35
|
-
),
|
|
36
|
-
router: {
|
|
37
|
-
back: mock(() => {}),
|
|
38
|
-
canGoBack: mock(() => true),
|
|
39
|
-
navigate: mock(() => {}),
|
|
40
|
-
push: mock(() => {}),
|
|
41
|
-
replace: mock(() => {}),
|
|
42
|
-
},
|
|
43
|
-
Slot: ({children, ...props}: MockChildrenProps) => React.createElement("Slot", props, children),
|
|
44
|
-
Stack: ({children, ...props}: MockChildrenProps) => React.createElement("Stack", props, children),
|
|
45
|
-
Tabs: ({children, ...props}: MockChildrenProps) => React.createElement("Tabs", props, children),
|
|
46
|
-
useLocalSearchParams: mock(() => ({})),
|
|
47
|
-
useRouter: mock(() => ({
|
|
48
|
-
back: mock(() => {}),
|
|
49
|
-
canGoBack: mock(() => true),
|
|
50
|
-
navigate: mock(() => {}),
|
|
51
|
-
push: mock(() => {}),
|
|
52
|
-
replace: mock(() => {}),
|
|
53
|
-
})),
|
|
54
|
-
useSegments: mock(() => []),
|
|
55
|
-
}));
|
|
56
|
-
|
|
57
|
-
import {SidebarNavigation, SidebarNavigationPanel} from "./SidebarNavigation";
|
|
58
|
-
|
|
59
|
-
afterAll(() => {
|
|
60
|
-
mock.module("expo-router", () => ({
|
|
61
|
-
Link: ({children, ...props}: MockChildrenProps) => React.createElement("Link", props, children),
|
|
62
|
-
Navigator: ({children, ...props}: MockChildrenProps) =>
|
|
63
|
-
React.createElement("Navigator", props, children),
|
|
64
|
-
router: {
|
|
65
|
-
back: mock(() => {}),
|
|
66
|
-
canGoBack: mock(() => true),
|
|
67
|
-
navigate: mock(() => {}),
|
|
68
|
-
push: mock(() => {}),
|
|
69
|
-
replace: mock(() => {}),
|
|
70
|
-
},
|
|
71
|
-
Slot: ({children, ...props}: MockChildrenProps) => React.createElement("Slot", props, children),
|
|
72
|
-
Stack: ({children, ...props}: MockChildrenProps) =>
|
|
73
|
-
React.createElement("Stack", props, children),
|
|
74
|
-
Tabs: ({children, ...props}: MockChildrenProps) => React.createElement("Tabs", props, children),
|
|
75
|
-
useLocalSearchParams: mock(() => ({})),
|
|
76
|
-
useRouter: mock(() => ({
|
|
77
|
-
back: mock(() => {}),
|
|
78
|
-
canGoBack: mock(() => true),
|
|
79
|
-
navigate: mock(() => {}),
|
|
80
|
-
push: mock(() => {}),
|
|
81
|
-
replace: mock(() => {}),
|
|
82
|
-
})),
|
|
83
|
-
useSegments: mock(() => []),
|
|
84
|
-
}));
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const topItems: SidebarNavigationItem[] = [
|
|
88
|
-
{iconName: "house", label: "Home", route: "index"},
|
|
89
|
-
{badge: 5, iconName: "bell", label: "Alerts", route: "alerts"},
|
|
90
|
-
{badge: true, badgeStatus: "info", iconName: "envelope", label: "Inbox", route: "inbox"},
|
|
91
|
-
];
|
|
92
|
-
|
|
93
|
-
const bottomItems: SidebarNavigationItem[] = [
|
|
94
|
-
{iconName: "gear", label: "Settings", route: "settings"},
|
|
95
|
-
];
|
|
96
|
-
|
|
97
|
-
describe("SidebarNavigationPanel", () => {
|
|
98
|
-
it("renders every top and bottom item", () => {
|
|
99
|
-
const onNavigate = mock((_route: string) => {});
|
|
100
|
-
const {getByLabelText} = renderWithTheme(
|
|
101
|
-
<SidebarNavigationPanel
|
|
102
|
-
activeRoute="index"
|
|
103
|
-
bottomItems={bottomItems}
|
|
104
|
-
onNavigate={onNavigate}
|
|
105
|
-
topItems={topItems}
|
|
106
|
-
/>
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
for (const item of [...topItems, ...bottomItems]) {
|
|
110
|
-
expect(getByLabelText(item.label)).toBeTruthy();
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("renders children next to the rail", () => {
|
|
115
|
-
const {getByTestId} = renderWithTheme(
|
|
116
|
-
<SidebarNavigationPanel
|
|
117
|
-
activeRoute="index"
|
|
118
|
-
bottomItems={bottomItems}
|
|
119
|
-
onNavigate={mock((_route: string) => {})}
|
|
120
|
-
topItems={topItems}
|
|
121
|
-
>
|
|
122
|
-
<View testID="panel-child" />
|
|
123
|
-
</SidebarNavigationPanel>
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
expect(getByTestId("panel-child")).toBeTruthy();
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it("calls onNavigate with the pressed item route", () => {
|
|
130
|
-
const onNavigate = mock((_route: string) => {});
|
|
131
|
-
const {getByLabelText} = renderWithTheme(
|
|
132
|
-
<SidebarNavigationPanel
|
|
133
|
-
activeRoute="index"
|
|
134
|
-
bottomItems={bottomItems}
|
|
135
|
-
onNavigate={onNavigate}
|
|
136
|
-
topItems={topItems}
|
|
137
|
-
/>
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
fireEvent.press(getByLabelText("Settings"));
|
|
141
|
-
expect(onNavigate).toHaveBeenCalledWith("settings");
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it("hides labels while collapsed and shows them once hovered", () => {
|
|
145
|
-
const {UNSAFE_getAllByType, queryByText, getByText} = renderWithTheme(
|
|
146
|
-
<SidebarNavigationPanel
|
|
147
|
-
activeRoute="index"
|
|
148
|
-
bottomItems={bottomItems}
|
|
149
|
-
onNavigate={mock((_route: string) => {})}
|
|
150
|
-
topItems={topItems}
|
|
151
|
-
/>
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
expect(queryByText("Home")).toBeNull();
|
|
155
|
-
|
|
156
|
-
const rail = UNSAFE_getAllByType(View).find(
|
|
157
|
-
(node) => node.props.onMouseEnter !== undefined && node.props.onMouseLeave !== undefined
|
|
158
|
-
);
|
|
159
|
-
if (!rail) {
|
|
160
|
-
throw new Error("expected the sidebar rail to expose hover handlers");
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
fireEvent(rail, "mouseEnter");
|
|
164
|
-
expect(getByText("Home")).toBeTruthy();
|
|
165
|
-
expect(getByText("Settings")).toBeTruthy();
|
|
166
|
-
|
|
167
|
-
fireEvent(rail, "mouseLeave");
|
|
168
|
-
expect(queryByText("Home")).toBeNull();
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("bolds the active label and leaves inactive labels unbolded", () => {
|
|
172
|
-
const {UNSAFE_getAllByType, getByText} = renderWithTheme(
|
|
173
|
-
<SidebarNavigationPanel
|
|
174
|
-
activeRoute="alerts"
|
|
175
|
-
bottomItems={bottomItems}
|
|
176
|
-
onNavigate={mock((_route: string) => {})}
|
|
177
|
-
topItems={topItems}
|
|
178
|
-
/>
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
const rail = UNSAFE_getAllByType(View).find((node) => node.props.onMouseEnter !== undefined);
|
|
182
|
-
if (!rail) {
|
|
183
|
-
throw new Error("expected the sidebar rail to expose hover handlers");
|
|
184
|
-
}
|
|
185
|
-
fireEvent(rail, "mouseEnter");
|
|
186
|
-
|
|
187
|
-
const fontFamilyOf = (label: string): unknown =>
|
|
188
|
-
Object.assign(
|
|
189
|
-
{},
|
|
190
|
-
...(Array.isArray(getByText(label).props.style)
|
|
191
|
-
? getByText(label).props.style.flat(Number.POSITIVE_INFINITY)
|
|
192
|
-
: [getByText(label).props.style])
|
|
193
|
-
).fontFamily;
|
|
194
|
-
|
|
195
|
-
expect(fontFamilyOf("Alerts")).not.toBe(fontFamilyOf("Home"));
|
|
196
|
-
expect(String(fontFamilyOf("Alerts"))).toContain("bold");
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it("applies hover styling to individual items", () => {
|
|
200
|
-
const {getByLabelText} = renderWithTheme(
|
|
201
|
-
<SidebarNavigationPanel
|
|
202
|
-
activeRoute="index"
|
|
203
|
-
bottomItems={bottomItems}
|
|
204
|
-
onNavigate={mock((_route: string) => {})}
|
|
205
|
-
topItems={topItems}
|
|
206
|
-
/>
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
const item = getByLabelText("Alerts");
|
|
210
|
-
const flatten = (style: unknown): Record<string, unknown> =>
|
|
211
|
-
Object.assign({}, ...(Array.isArray(style) ? style : [style]));
|
|
212
|
-
|
|
213
|
-
const initialBackground = flatten(item.props.style).backgroundColor;
|
|
214
|
-
fireEvent(item, "hoverIn");
|
|
215
|
-
expect(flatten(getByLabelText("Alerts").props.style).backgroundColor).not.toBe(
|
|
216
|
-
initialBackground
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
fireEvent(item, "hoverOut");
|
|
220
|
-
expect(flatten(getByLabelText("Alerts").props.style).backgroundColor).toBe(initialBackground);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
it("applies custom panel and item styles", () => {
|
|
224
|
-
const {getByLabelText, UNSAFE_getAllByType} = renderWithTheme(
|
|
225
|
-
<SidebarNavigationPanel
|
|
226
|
-
activeRoute="index"
|
|
227
|
-
bottomItems={bottomItems}
|
|
228
|
-
itemStyle={{opacity: 0.5}}
|
|
229
|
-
onNavigate={mock((_route: string) => {})}
|
|
230
|
-
panelStyle={{borderRightWidth: 4}}
|
|
231
|
-
topItems={topItems}
|
|
232
|
-
/>
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
const rail = UNSAFE_getAllByType(View).find((node) => node.props.onMouseEnter !== undefined);
|
|
236
|
-
expect(rail?.props.style).toContainEqual({borderRightWidth: 4});
|
|
237
|
-
expect(getByLabelText("Home").props.style).toContainEqual({opacity: 0.5});
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
describe("SidebarNavigation", () => {
|
|
242
|
-
beforeEach(() => {
|
|
243
|
-
navigate.mockClear();
|
|
244
|
-
navigatorContext = {
|
|
245
|
-
descriptors: {},
|
|
246
|
-
navigation: {navigate},
|
|
247
|
-
state: {index: 0, routes: [{key: "home-key", name: "index"}]},
|
|
248
|
-
};
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
it("exposes Screen for per-screen options", () => {
|
|
252
|
-
expect(SidebarNavigation.Screen).toBeDefined();
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
it("renders the sidebar for the active navigator route", () => {
|
|
256
|
-
const {getByLabelText} = renderWithTheme(
|
|
257
|
-
<SidebarNavigation bottomItems={bottomItems} topItems={topItems} />
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
expect(getByLabelText("Home")).toBeTruthy();
|
|
261
|
-
expect(getByLabelText("Settings")).toBeTruthy();
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it("navigates through the navigator and forwards the route to onNavigate", () => {
|
|
265
|
-
const onNavigate = mock((_route: string) => {});
|
|
266
|
-
const {getByLabelText} = renderWithTheme(
|
|
267
|
-
<SidebarNavigation bottomItems={bottomItems} onNavigate={onNavigate} topItems={topItems} />
|
|
268
|
-
);
|
|
269
|
-
|
|
270
|
-
fireEvent.press(getByLabelText("Alerts"));
|
|
271
|
-
expect(navigate).toHaveBeenCalledWith("alerts");
|
|
272
|
-
expect(onNavigate).toHaveBeenCalledWith("alerts");
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it("navigates without an onNavigate callback", () => {
|
|
276
|
-
const {getByLabelText} = renderWithTheme(
|
|
277
|
-
<SidebarNavigation bottomItems={bottomItems} topItems={topItems} />
|
|
278
|
-
);
|
|
279
|
-
|
|
280
|
-
fireEvent.press(getByLabelText("Inbox"));
|
|
281
|
-
expect(navigate).toHaveBeenCalledWith("inbox");
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
it("renders the header with the screen title and header slots", () => {
|
|
285
|
-
navigatorContext = {
|
|
286
|
-
descriptors: {
|
|
287
|
-
"home-key": {
|
|
288
|
-
options: {
|
|
289
|
-
headerLeft: () => <View testID="header-left" />,
|
|
290
|
-
headerRight: () => <View testID="header-right" />,
|
|
291
|
-
title: "Dashboard",
|
|
292
|
-
},
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
navigation: {navigate},
|
|
296
|
-
state: {index: 0, routes: [{key: "home-key", name: "index"}]},
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
const {getByTestId, getByText} = renderWithTheme(
|
|
300
|
-
<SidebarNavigation bottomItems={bottomItems} topItems={topItems} />
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
expect(getByText("Dashboard")).toBeTruthy();
|
|
304
|
-
expect(getByTestId("header-left")).toBeTruthy();
|
|
305
|
-
expect(getByTestId("header-right")).toBeTruthy();
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it("omits the header when the active screen has no title or header slots", () => {
|
|
309
|
-
const {queryByText} = renderWithTheme(
|
|
310
|
-
<SidebarNavigation bottomItems={bottomItems} topItems={topItems} />
|
|
311
|
-
);
|
|
312
|
-
|
|
313
|
-
expect(queryByText("Dashboard")).toBeNull();
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
it("renders Screen children passed to the navigator", () => {
|
|
317
|
-
const {getByTestId} = renderWithTheme(
|
|
318
|
-
<SidebarNavigation bottomItems={bottomItems} topItems={topItems}>
|
|
319
|
-
<View testID="screen-child" />
|
|
320
|
-
</SidebarNavigation>
|
|
321
|
-
);
|
|
322
|
-
|
|
323
|
-
expect(getByTestId("screen-child")).toBeTruthy();
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
it("handles an empty navigator route list", () => {
|
|
327
|
-
navigatorContext = {
|
|
328
|
-
descriptors: {},
|
|
329
|
-
navigation: {navigate},
|
|
330
|
-
state: {index: 0, routes: []},
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
const {getByLabelText} = renderWithTheme(
|
|
334
|
-
<SidebarNavigation bottomItems={bottomItems} topItems={topItems} />
|
|
335
|
-
);
|
|
336
|
-
|
|
337
|
-
expect(getByLabelText("Home")).toBeTruthy();
|
|
338
|
-
});
|
|
339
|
-
});
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
|
|
2
|
-
|
|
3
|
-
exports[`EditableCard renders correctly with all props 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"$$typeof": Symbol(react.test.json),
|
|
6
|
-
"children": [
|
|
7
|
-
{
|
|
8
|
-
"$$typeof": Symbol(react.test.json),
|
|
9
|
-
"children": null,
|
|
10
|
-
"props": {
|
|
11
|
-
"onPointerEnter": [Function: AsyncFunction],
|
|
12
|
-
"onPointerLeave": [Function: AsyncFunction],
|
|
13
|
-
"style": {
|
|
14
|
-
"paddingBottom": 4,
|
|
15
|
-
"paddingTop": 4,
|
|
16
|
-
},
|
|
17
|
-
"testID": undefined,
|
|
18
|
-
},
|
|
19
|
-
"type": "View",
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"$$typeof": Symbol(react.test.json),
|
|
23
|
-
"children": [
|
|
24
|
-
{
|
|
25
|
-
"$$typeof": Symbol(react.test.json),
|
|
26
|
-
"children": [
|
|
27
|
-
{
|
|
28
|
-
"$$typeof": Symbol(react.test.json),
|
|
29
|
-
"children": [
|
|
30
|
-
{
|
|
31
|
-
"$$typeof": Symbol(react.test.json),
|
|
32
|
-
"children": [
|
|
33
|
-
{
|
|
34
|
-
"$$typeof": Symbol(react.test.json),
|
|
35
|
-
"children": [
|
|
36
|
-
"Home Address",
|
|
37
|
-
],
|
|
38
|
-
"props": {
|
|
39
|
-
"numberOfLines": 1,
|
|
40
|
-
"selectable": undefined,
|
|
41
|
-
"style": {
|
|
42
|
-
"color": "#1C1C1C",
|
|
43
|
-
"fontFamily": "text-bold",
|
|
44
|
-
"fontSize": 14,
|
|
45
|
-
"textAlign": "left",
|
|
46
|
-
},
|
|
47
|
-
"testID": undefined,
|
|
48
|
-
},
|
|
49
|
-
"type": "Text",
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
"props": {},
|
|
53
|
-
"type": "View",
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
"props": {
|
|
57
|
-
"onPointerEnter": [Function: AsyncFunction],
|
|
58
|
-
"onPointerLeave": [Function: AsyncFunction],
|
|
59
|
-
"style": {
|
|
60
|
-
"display": "flex",
|
|
61
|
-
"flexShrink": 1,
|
|
62
|
-
"minWidth": 0,
|
|
63
|
-
},
|
|
64
|
-
"testID": undefined,
|
|
65
|
-
},
|
|
66
|
-
"type": "View",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
"$$typeof": Symbol(react.test.json),
|
|
70
|
-
"children": [
|
|
71
|
-
{
|
|
72
|
-
"$$typeof": Symbol(react.test.json),
|
|
73
|
-
"children": [
|
|
74
|
-
{
|
|
75
|
-
"$$typeof": Symbol(react.test.json),
|
|
76
|
-
"children": null,
|
|
77
|
-
"props": {
|
|
78
|
-
"style": {
|
|
79
|
-
"marginRight": 8,
|
|
80
|
-
},
|
|
81
|
-
"testID": "icon",
|
|
82
|
-
},
|
|
83
|
-
"type": "View",
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
"$$typeof": Symbol(react.test.json),
|
|
87
|
-
"children": [
|
|
88
|
-
"Verified",
|
|
89
|
-
],
|
|
90
|
-
"props": {
|
|
91
|
-
"style": {
|
|
92
|
-
"color": "#1A7F36",
|
|
93
|
-
"fontFamily": "text",
|
|
94
|
-
"fontSize": 10,
|
|
95
|
-
"fontWeight": "700",
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
"type": "Text",
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
"props": {
|
|
102
|
-
"style": [
|
|
103
|
-
{
|
|
104
|
-
"alignItems": "center",
|
|
105
|
-
"backgroundColor": "#DCF2E2",
|
|
106
|
-
"borderRadius": 4,
|
|
107
|
-
"flexDirection": "row",
|
|
108
|
-
"height": 20,
|
|
109
|
-
"justifyContent": "center",
|
|
110
|
-
"paddingHorizontal": 8,
|
|
111
|
-
"paddingVertical": 0,
|
|
112
|
-
"width": "auto",
|
|
113
|
-
},
|
|
114
|
-
false,
|
|
115
|
-
{
|
|
116
|
-
"borderColor": "#7FD898",
|
|
117
|
-
"borderWidth": 1,
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
"testID": undefined,
|
|
121
|
-
},
|
|
122
|
-
"type": "View",
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
"props": {
|
|
126
|
-
"style": {
|
|
127
|
-
"alignItems": "flex-start",
|
|
128
|
-
},
|
|
129
|
-
"testID": undefined,
|
|
130
|
-
},
|
|
131
|
-
"type": "View",
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
"props": {
|
|
135
|
-
"onPointerEnter": [Function: AsyncFunction],
|
|
136
|
-
"onPointerLeave": [Function: AsyncFunction],
|
|
137
|
-
"style": {
|
|
138
|
-
"alignItems": "center",
|
|
139
|
-
"display": "flex",
|
|
140
|
-
"flexDirection": "row",
|
|
141
|
-
"gap": 8,
|
|
142
|
-
},
|
|
143
|
-
"testID": undefined,
|
|
144
|
-
},
|
|
145
|
-
"type": "View",
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
"$$typeof": Symbol(react.test.json),
|
|
149
|
-
"children": [
|
|
150
|
-
{
|
|
151
|
-
"$$typeof": Symbol(react.test.json),
|
|
152
|
-
"children": [
|
|
153
|
-
"123 Main Street",
|
|
154
|
-
],
|
|
155
|
-
"props": {
|
|
156
|
-
"numberOfLines": 0,
|
|
157
|
-
"selectable": undefined,
|
|
158
|
-
"style": {
|
|
159
|
-
"color": "#1C1C1C",
|
|
160
|
-
"fontFamily": "text-regular",
|
|
161
|
-
"fontSize": 14,
|
|
162
|
-
"textAlign": "left",
|
|
163
|
-
},
|
|
164
|
-
"testID": undefined,
|
|
165
|
-
},
|
|
166
|
-
"type": "Text",
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
"props": {},
|
|
170
|
-
"type": "View",
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
"$$typeof": Symbol(react.test.json),
|
|
174
|
-
"children": [
|
|
175
|
-
{
|
|
176
|
-
"$$typeof": Symbol(react.test.json),
|
|
177
|
-
"children": [
|
|
178
|
-
"Last updated 2 days ago",
|
|
179
|
-
],
|
|
180
|
-
"props": {
|
|
181
|
-
"numberOfLines": 0,
|
|
182
|
-
"selectable": undefined,
|
|
183
|
-
"style": {
|
|
184
|
-
"color": "#686868",
|
|
185
|
-
"fontFamily": "text-regular",
|
|
186
|
-
"fontSize": 10,
|
|
187
|
-
"textAlign": "left",
|
|
188
|
-
},
|
|
189
|
-
"testID": undefined,
|
|
190
|
-
},
|
|
191
|
-
"type": "Text",
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
"props": {},
|
|
195
|
-
"type": "View",
|
|
196
|
-
},
|
|
197
|
-
],
|
|
198
|
-
"props": {
|
|
199
|
-
"onPointerEnter": [Function: AsyncFunction],
|
|
200
|
-
"onPointerLeave": [Function: AsyncFunction],
|
|
201
|
-
"style": {
|
|
202
|
-
"display": "flex",
|
|
203
|
-
"flexDirection": "column",
|
|
204
|
-
"flexGrow": 1,
|
|
205
|
-
"flexShrink": 1,
|
|
206
|
-
"gap": 4,
|
|
207
|
-
"minWidth": 0,
|
|
208
|
-
},
|
|
209
|
-
"testID": undefined,
|
|
210
|
-
},
|
|
211
|
-
"type": "View",
|
|
212
|
-
},
|
|
213
|
-
],
|
|
214
|
-
"props": {
|
|
215
|
-
"onPointerEnter": [Function: AsyncFunction],
|
|
216
|
-
"onPointerLeave": [Function: AsyncFunction],
|
|
217
|
-
"style": {
|
|
218
|
-
"backgroundColor": "#FFFFFF",
|
|
219
|
-
"borderBottomColor": "#CDCDCD",
|
|
220
|
-
"borderBottomWidth": 1,
|
|
221
|
-
"borderLeftColor": "#CDCDCD",
|
|
222
|
-
"borderLeftWidth": 1,
|
|
223
|
-
"borderRadius": 4,
|
|
224
|
-
"borderRightColor": "#CDCDCD",
|
|
225
|
-
"borderRightWidth": 1,
|
|
226
|
-
"borderTopColor": "#CDCDCD",
|
|
227
|
-
"borderTopWidth": 1,
|
|
228
|
-
"display": "flex",
|
|
229
|
-
"flex": undefined,
|
|
230
|
-
"flexDirection": "row",
|
|
231
|
-
"gap": 8,
|
|
232
|
-
"maxWidth": "100%",
|
|
233
|
-
"minWidth": 0,
|
|
234
|
-
"overflow": "hidden",
|
|
235
|
-
"padding": 12,
|
|
236
|
-
"width": "100%",
|
|
237
|
-
},
|
|
238
|
-
"testID": undefined,
|
|
239
|
-
},
|
|
240
|
-
"type": "View",
|
|
241
|
-
}
|
|
242
|
-
`;
|