@terreno/ui 57.19.2 → 57.20.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/.ai/guidelines/core.md +1 -1
- package/CHANGELOG.md +393 -0
- package/dist/Accordion.d.ts.map +1 -1
- package/dist/Accordion.js +3 -3
- package/dist/Accordion.js.map +1 -1
- package/dist/Avatar.d.ts.map +1 -1
- package/dist/Avatar.js +3 -1
- package/dist/Avatar.js.map +1 -1
- package/dist/Box.d.ts.map +1 -1
- package/dist/Box.js +38 -2
- package/dist/Box.js.map +1 -1
- package/dist/Card.js +2 -2
- package/dist/Card.js.map +1 -1
- package/dist/Common.d.ts +120 -7
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/ConsentFormScreen.d.ts +1 -1
- package/dist/ConsentFormScreen.d.ts.map +1 -1
- package/dist/ConsentFormScreen.js +13 -4
- package/dist/ConsentFormScreen.js.map +1 -1
- package/dist/DateTimeField.d.ts.map +1 -1
- package/dist/DateTimeField.js +5 -3
- package/dist/DateTimeField.js.map +1 -1
- package/dist/Field.d.ts.map +1 -1
- package/dist/Field.js +2 -0
- package/dist/Field.js.map +1 -1
- package/dist/FormContainer.d.ts +68 -0
- package/dist/FormContainer.d.ts.map +1 -0
- package/dist/FormContainer.js +79 -0
- package/dist/FormContainer.js.map +1 -0
- package/dist/GPTChat.d.ts.map +1 -1
- package/dist/GPTChat.js +2 -1
- package/dist/GPTChat.js.map +1 -1
- package/dist/Heading.d.ts +1 -1
- package/dist/Heading.d.ts.map +1 -1
- package/dist/Heading.js +5 -2
- package/dist/Heading.js.map +1 -1
- package/dist/Icon.d.ts +4 -0
- package/dist/Icon.d.ts.map +1 -1
- package/dist/Icon.js +43 -2
- package/dist/Icon.js.map +1 -1
- package/dist/LabeledCheckBox.d.ts +22 -0
- package/dist/LabeledCheckBox.d.ts.map +1 -0
- package/dist/LabeledCheckBox.js +30 -0
- package/dist/LabeledCheckBox.js.map +1 -0
- package/dist/ListDetailLayout.d.ts +36 -0
- package/dist/ListDetailLayout.d.ts.map +1 -0
- package/dist/ListDetailLayout.js +153 -0
- package/dist/ListDetailLayout.js.map +1 -0
- package/dist/MarkdownEditor.d.ts.map +1 -1
- package/dist/MarkdownEditor.js +2 -1
- package/dist/MarkdownEditor.js.map +1 -1
- package/dist/MediaQuery.d.ts +1 -1
- package/dist/MediaQuery.d.ts.map +1 -1
- package/dist/MediaQuery.js +1 -1
- package/dist/MediaQuery.js.map +1 -1
- package/dist/OtpField.d.ts +60 -0
- package/dist/OtpField.d.ts.map +1 -0
- package/dist/OtpField.js +154 -0
- package/dist/OtpField.js.map +1 -0
- package/dist/ProvisionalConsentSigner.d.ts +21 -0
- package/dist/ProvisionalConsentSigner.d.ts.map +1 -0
- package/dist/ProvisionalConsentSigner.js +199 -0
- package/dist/ProvisionalConsentSigner.js.map +1 -0
- package/dist/ResponsiveBreakpoint.d.ts +5 -0
- package/dist/ResponsiveBreakpoint.d.ts.map +1 -1
- package/dist/ResponsiveBreakpoint.js +7 -0
- package/dist/ResponsiveBreakpoint.js.map +1 -1
- package/dist/SocialLoginButton.d.ts +10 -0
- package/dist/SocialLoginButton.d.ts.map +1 -1
- package/dist/SocialLoginButton.js +26 -8
- package/dist/SocialLoginButton.js.map +1 -1
- package/dist/SplitPage.d.ts +11 -0
- package/dist/SplitPage.d.ts.map +1 -1
- package/dist/SplitPage.js +11 -5
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.d.ts.map +1 -1
- package/dist/SplitPage.native.js +3 -1
- package/dist/SplitPage.native.js.map +1 -1
- package/dist/SyncStatusBanner.d.ts +7 -1
- package/dist/SyncStatusBanner.d.ts.map +1 -1
- package/dist/SyncStatusBanner.js +20 -4
- package/dist/SyncStatusBanner.js.map +1 -1
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TextField.js +44 -10
- package/dist/TextField.js.map +1 -1
- package/dist/fieldElements/FieldError.d.ts.map +1 -1
- package/dist/fieldElements/FieldError.js +1 -1
- package/dist/fieldElements/FieldError.js.map +1 -1
- package/dist/index.d.ts +19 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/lazyBoundaries/heavyOptionalExports.d.ts +3 -0
- package/dist/lazyBoundaries/heavyOptionalExports.d.ts.map +1 -1
- package/dist/lazyBoundaries/heavyOptionalExports.js +2 -0
- package/dist/lazyBoundaries/heavyOptionalExports.js.map +1 -1
- package/dist/login/LastUsedBadge.d.ts +14 -0
- package/dist/login/LastUsedBadge.d.ts.map +1 -0
- package/dist/login/LastUsedBadge.js +23 -0
- package/dist/login/LastUsedBadge.js.map +1 -0
- package/dist/login/LoginAccountCard.d.ts +38 -0
- package/dist/login/LoginAccountCard.d.ts.map +1 -0
- package/dist/login/LoginAccountCard.js +72 -0
- package/dist/login/LoginAccountCard.js.map +1 -0
- package/dist/login/LoginAccountList.d.ts +33 -0
- package/dist/login/LoginAccountList.d.ts.map +1 -0
- package/dist/login/LoginAccountList.js +30 -0
- package/dist/login/LoginAccountList.js.map +1 -0
- package/dist/login/LoginScreen.d.ts +4 -4
- package/dist/login/LoginScreen.d.ts.map +1 -1
- package/dist/login/LoginScreen.js +294 -13
- package/dist/login/LoginScreen.js.map +1 -1
- package/dist/login/OutlinePill.d.ts +28 -0
- package/dist/login/OutlinePill.d.ts.map +1 -0
- package/dist/login/OutlinePill.js +48 -0
- package/dist/login/OutlinePill.js.map +1 -0
- package/dist/login/TwoFactorChallengeScreen.d.ts +26 -0
- package/dist/login/TwoFactorChallengeScreen.d.ts.map +1 -0
- package/dist/login/TwoFactorChallengeScreen.js +139 -0
- package/dist/login/TwoFactorChallengeScreen.js.map +1 -0
- package/dist/login/loginMethods.d.ts +27 -0
- package/dist/login/loginMethods.d.ts.map +1 -0
- package/dist/login/loginMethods.js +37 -0
- package/dist/login/loginMethods.js.map +1 -0
- package/dist/login/loginTypes.d.ts +202 -5
- package/dist/login/loginTypes.d.ts.map +1 -1
- package/dist/pdfHtmlTemplate.d.ts +17 -0
- package/dist/pdfHtmlTemplate.d.ts.map +1 -1
- package/dist/pdfHtmlTemplate.js +78 -0
- package/dist/pdfHtmlTemplate.js.map +1 -1
- package/dist/security/AccountSecurityScreen.d.ts +10 -0
- package/dist/security/AccountSecurityScreen.d.ts.map +1 -0
- package/dist/security/AccountSecurityScreen.js +50 -0
- package/dist/security/AccountSecurityScreen.js.map +1 -0
- package/dist/security/LinkedAccountsCard.d.ts +32 -0
- package/dist/security/LinkedAccountsCard.d.ts.map +1 -0
- package/dist/security/LinkedAccountsCard.js +145 -0
- package/dist/security/LinkedAccountsCard.js.map +1 -0
- package/dist/security/PasskeysCard.d.ts +39 -0
- package/dist/security/PasskeysCard.d.ts.map +1 -0
- package/dist/security/PasskeysCard.js +168 -0
- package/dist/security/PasskeysCard.js.map +1 -0
- package/dist/security/PasswordCard.d.ts +32 -0
- package/dist/security/PasswordCard.d.ts.map +1 -0
- package/dist/security/PasswordCard.js +198 -0
- package/dist/security/PasswordCard.js.map +1 -0
- package/dist/security/SessionsCard.d.ts +39 -0
- package/dist/security/SessionsCard.d.ts.map +1 -0
- package/dist/security/SessionsCard.js +168 -0
- package/dist/security/SessionsCard.js.map +1 -0
- package/dist/security/TwoFactorSettingsCard.d.ts +55 -0
- package/dist/security/TwoFactorSettingsCard.d.ts.map +1 -0
- package/dist/security/TwoFactorSettingsCard.js +458 -0
- package/dist/security/TwoFactorSettingsCard.js.map +1 -0
- package/dist/security/securityMethods.d.ts +40 -0
- package/dist/security/securityMethods.d.ts.map +1 -0
- package/dist/security/securityMethods.js +66 -0
- package/dist/security/securityMethods.js.map +1 -0
- package/dist/security/securityTypes.d.ts +467 -0
- package/dist/security/securityTypes.d.ts.map +1 -0
- package/dist/security/securityTypes.js +2 -0
- package/dist/security/securityTypes.js.map +1 -0
- package/dist/security/userAgent.d.ts +26 -0
- package/dist/security/userAgent.d.ts.map +1 -0
- package/dist/security/userAgent.js +80 -0
- package/dist/security/userAgent.js.map +1 -0
- package/dist/signUp/OAuthButtons.d.ts +28 -5
- package/dist/signUp/OAuthButtons.d.ts.map +1 -1
- package/dist/signUp/OAuthButtons.js +44 -5
- package/dist/signUp/OAuthButtons.js.map +1 -1
- package/dist/signUp/SignUpScreen.d.ts.map +1 -1
- package/dist/signUp/SignUpScreen.js +50 -5
- package/dist/signUp/SignUpScreen.js.map +1 -1
- package/dist/signUp/signUpTypes.d.ts +21 -1
- package/dist/signUp/signUpTypes.d.ts.map +1 -1
- package/dist/useConsentForms.d.ts +9 -0
- package/dist/useConsentForms.d.ts.map +1 -1
- package/dist/useConsentForms.js +18 -0
- package/dist/useConsentForms.js.map +1 -1
- package/dist/useProvisionalConsent.d.ts +124 -0
- package/dist/useProvisionalConsent.d.ts.map +1 -0
- package/dist/useProvisionalConsent.js +79 -0
- package/dist/useProvisionalConsent.js.map +1 -0
- package/package.json +3 -2
- package/src/Accordion.test.tsx +5 -0
- package/src/Accordion.tsx +3 -8
- package/src/AreaChart.test.tsx +15 -0
- package/src/Avatar.test.tsx +8 -0
- package/src/Avatar.tsx +2 -0
- package/src/BarChart.test.tsx +15 -0
- package/src/Box.test.tsx +61 -1
- package/src/Box.tsx +44 -2
- package/src/Card.tsx +2 -2
- package/src/Common.ts +134 -7
- package/src/ConsentFormScreen.test.tsx +84 -0
- package/src/ConsentFormScreen.tsx +28 -4
- package/src/DateTimeField.tsx +5 -3
- package/src/DonutChart.test.tsx +15 -0
- package/src/Field.tsx +2 -0
- package/src/FilePickerButton.test.tsx +35 -0
- package/src/FormContainer.test.tsx +242 -0
- package/src/FormContainer.tsx +177 -0
- package/src/GPTChat.test.tsx +16 -0
- package/src/GPTChat.tsx +8 -2
- package/src/Heading.test.tsx +14 -0
- package/src/Heading.tsx +6 -1
- package/src/Icon.test.tsx +52 -1
- package/src/Icon.tsx +92 -3
- package/src/IconButton.test.tsx +85 -0
- package/src/LabeledCheckBox.test.tsx +45 -0
- package/src/LabeledCheckBox.tsx +89 -0
- package/src/ListDetailLayout.tsx +247 -0
- package/src/MarkdownEditor.tsx +2 -1
- package/src/MediaQuery.ts +1 -0
- package/src/OtpField.test.tsx +280 -0
- package/src/OtpField.tsx +307 -0
- package/src/ProvisionalConsentSigner.test.tsx +625 -0
- package/src/ProvisionalConsentSigner.tsx +423 -0
- package/src/ResponsiveBreakpoint.test.tsx +7 -0
- package/src/ResponsiveBreakpoint.tsx +14 -0
- package/src/RootImportRegression.test.tsx +3 -0
- package/src/SocialLoginButton.test.tsx +14 -0
- package/src/SocialLoginButton.tsx +51 -7
- package/src/SplitPage.native.tsx +3 -1
- package/src/SplitPage.tsx +11 -5
- package/src/SyncStatusBanner.test.tsx +61 -4
- package/src/SyncStatusBanner.tsx +29 -3
- package/src/TextField.test.tsx +150 -0
- package/src/TextField.tsx +66 -8
- package/src/__snapshots__/AddressField.test.tsx.snap +12 -0
- package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +15 -0
- package/src/__snapshots__/Avatar.test.tsx.snap +1 -0
- package/src/__snapshots__/CustomSelectField.test.tsx.snap +3 -0
- package/src/__snapshots__/EmailField.test.tsx.snap +6 -0
- package/src/__snapshots__/Field.test.tsx.snap +37 -0
- package/src/__snapshots__/HeightField.test.tsx.snap +2 -0
- package/src/__snapshots__/MobileAddressAutoComplete.test.tsx.snap +3 -0
- package/src/__snapshots__/NumberField.test.tsx.snap +3 -0
- package/src/__snapshots__/PhoneNumberField.test.tsx.snap +12 -0
- package/src/__snapshots__/Slider.test.tsx.snap +1 -0
- package/src/__snapshots__/SocialLoginButton.test.tsx.snap +43 -22
- package/src/__snapshots__/TapToEdit.test.tsx.snap +3 -0
- package/src/__snapshots__/TextArea.test.tsx.snap +17 -1
- package/src/__snapshots__/TextField.test.tsx.snap +19 -2
- package/src/__snapshots__/TypedSignatureField.test.tsx.snap +3 -0
- package/src/__snapshots__/UnifiedAddressAutoComplete.test.tsx.snap +18 -0
- package/src/__snapshots__/WebAddressAutocomplete.test.tsx.snap +12 -0
- package/src/bunSetup.ts +13 -1
- package/src/fieldElements/FieldError.tsx +1 -0
- package/src/fieldElements/__snapshots__/FieldError.test.tsx.snap +2 -0
- package/src/index.tsx +42 -1
- package/src/isolated/ListDetailLayout.isolated.tsx +634 -0
- package/src/lazyBoundaries/heavyOptionalExports.tsx +7 -0
- package/src/login/LastUsedBadge.tsx +40 -0
- package/src/login/LoginAccountCard.tsx +205 -0
- package/src/login/LoginAccountList.tsx +115 -0
- package/src/login/LoginScreen.test.tsx +837 -1
- package/src/login/LoginScreen.tsx +674 -91
- package/src/login/OutlinePill.tsx +110 -0
- package/src/login/TwoFactorChallengeScreen.test.tsx +376 -0
- package/src/login/TwoFactorChallengeScreen.tsx +307 -0
- package/src/login/__snapshots__/LoginScreen.test.tsx.snap +1454 -334
- package/src/login/loginMethods.test.ts +53 -0
- package/src/login/loginMethods.ts +60 -0
- package/src/login/loginTypes.ts +208 -5
- package/src/pdfHtmlTemplate.test.ts +243 -4
- package/src/pdfHtmlTemplate.ts +93 -0
- package/src/security/AccountSecurityScreen.test.tsx +262 -0
- package/src/security/AccountSecurityScreen.tsx +156 -0
- package/src/security/LinkedAccountsCard.test.tsx +371 -0
- package/src/security/LinkedAccountsCard.tsx +297 -0
- package/src/security/PasskeysCard.test.tsx +378 -0
- package/src/security/PasskeysCard.tsx +371 -0
- package/src/security/PasswordCard.test.tsx +445 -0
- package/src/security/PasswordCard.tsx +342 -0
- package/src/security/SessionsCard.test.tsx +349 -0
- package/src/security/SessionsCard.tsx +362 -0
- package/src/security/TwoFactorSettingsCard.test.tsx +700 -0
- package/src/security/TwoFactorSettingsCard.tsx +872 -0
- package/src/security/securityMethods.test.ts +101 -0
- package/src/security/securityMethods.ts +104 -0
- package/src/security/securityTypes.ts +480 -0
- package/src/security/userAgent.test.ts +119 -0
- package/src/security/userAgent.ts +102 -0
- package/src/signUp/OAuthButtons.test.tsx +27 -0
- package/src/signUp/OAuthButtons.tsx +153 -19
- package/src/signUp/SignUpScreen.test.tsx +170 -1
- package/src/signUp/SignUpScreen.tsx +87 -25
- package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +22 -11
- package/src/signUp/signUpTypes.ts +23 -1
- package/src/useConsentForms.test.ts +37 -1
- package/src/useConsentForms.ts +25 -0
- package/src/useProvisionalConsent.test.ts +256 -0
- package/src/useProvisionalConsent.ts +218 -0
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
import {afterAll, afterEach, beforeEach, describe, expect, it, type Mock, mock} from "bun:test";
|
|
2
|
+
import {act, fireEvent} from "@testing-library/react-native";
|
|
3
|
+
import * as expoRouterModule from "expo-router";
|
|
4
|
+
import {useEffect} from "react";
|
|
5
|
+
import {Text, useWindowDimensions} from "react-native";
|
|
6
|
+
|
|
7
|
+
import type {ListDetailState} from "../Common";
|
|
8
|
+
import {renderWithTheme} from "../test-utils";
|
|
9
|
+
|
|
10
|
+
// This file runs in its own process (src/isolated), so it can install route and router doubles
|
|
11
|
+
// for the hooks this layout reads without affecting other suites.
|
|
12
|
+
const originalExpoRouter = {...expoRouterModule};
|
|
13
|
+
const mockedPathname = mock((): string => "/");
|
|
14
|
+
const mockedSegments = mock((): string[] => []);
|
|
15
|
+
const mockedSearchParams = mock((): Record<string, string | string[] | undefined> => ({}));
|
|
16
|
+
const mockedRouter = {
|
|
17
|
+
dismissTo: mock((_href: string): void => {}),
|
|
18
|
+
push: mock((_href: string): void => {}),
|
|
19
|
+
replace: mock((_href: string): void => {}),
|
|
20
|
+
};
|
|
21
|
+
mock.module("expo-router", () => ({
|
|
22
|
+
...originalExpoRouter,
|
|
23
|
+
router: {...originalExpoRouter.router, ...mockedRouter},
|
|
24
|
+
useGlobalSearchParams: mockedSearchParams,
|
|
25
|
+
usePathname: mockedPathname,
|
|
26
|
+
useSegments: mockedSegments,
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
import {ListDetailIndex, ListDetailLayout, useListDetail} from "../ListDetailLayout";
|
|
30
|
+
|
|
31
|
+
const mockedWindowDimensions = useWindowDimensions as unknown as Mock<typeof useWindowDimensions>;
|
|
32
|
+
|
|
33
|
+
// Matches the bunSetup.ts default so other test files see an untouched mock.
|
|
34
|
+
const DEFAULT_WINDOW = {fontScale: 1, height: 812, scale: 2, width: 375};
|
|
35
|
+
|
|
36
|
+
const setWindowWidth = (width: number): void => {
|
|
37
|
+
mockedWindowDimensions.mockImplementation(() => ({...DEFAULT_WINDOW, width}));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
setWindowWidth(DEFAULT_WINDOW.width);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
afterAll(() => {
|
|
45
|
+
mockedWindowDimensions.mockImplementation(() => DEFAULT_WINDOW);
|
|
46
|
+
mock.module("expo-router", () => originalExpoRouter);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const fireLayout = (element: Parameters<typeof fireEvent>[0], width: number): void => {
|
|
50
|
+
act(() => {
|
|
51
|
+
fireEvent(element, "layout", {nativeEvent: {layout: {height: 800, width, x: 0, y: 0}}});
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
let latestState: ListDetailState | undefined;
|
|
56
|
+
|
|
57
|
+
const SplitProbe = (): React.ReactElement => {
|
|
58
|
+
const state = useListDetail();
|
|
59
|
+
latestState = state;
|
|
60
|
+
return <Text testID="split-probe">{state.isSplit ? "split" : "stacked"}</Text>;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const currentState = (): ListDetailState => {
|
|
64
|
+
if (!latestState) {
|
|
65
|
+
throw new Error("SplitProbe has not rendered");
|
|
66
|
+
}
|
|
67
|
+
return latestState;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
let stackChildMounts = 0;
|
|
71
|
+
|
|
72
|
+
// Rendered as a Stack child; a remounted Stack remounts it too.
|
|
73
|
+
const StackChild = (): React.ReactElement => {
|
|
74
|
+
// Count mounts so the test can prove the Stack never remounts.
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
stackChildMounts += 1;
|
|
77
|
+
}, []);
|
|
78
|
+
return <Text testID="stack-child">screen</Text>;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const renderLayout = (props: Partial<Parameters<typeof ListDetailLayout>[0]> = {}) => {
|
|
82
|
+
return renderWithTheme(
|
|
83
|
+
<ListDetailLayout
|
|
84
|
+
detailHref={(id) => `/mail/${id}`}
|
|
85
|
+
emptyDetail={<Text testID="mail-empty">Select a message</Text>}
|
|
86
|
+
indexHref="/mail"
|
|
87
|
+
list={<Text testID="mail-list">Inbox</Text>}
|
|
88
|
+
{...props}
|
|
89
|
+
>
|
|
90
|
+
<StackChild />
|
|
91
|
+
<SplitProbe />
|
|
92
|
+
<ListDetailIndex />
|
|
93
|
+
</ListDetailLayout>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
describe("ListDetailLayout", () => {
|
|
98
|
+
beforeEach(() => {
|
|
99
|
+
stackChildMounts = 0;
|
|
100
|
+
setWindowWidth(375);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("shows the list pane beside the Stack on a wide window", () => {
|
|
104
|
+
setWindowWidth(1024);
|
|
105
|
+
const {getByTestId} = renderLayout();
|
|
106
|
+
|
|
107
|
+
const listPane = getByTestId("list-detail-list-pane");
|
|
108
|
+
expect(listPane.props.style).toMatchObject({width: 360});
|
|
109
|
+
expect(getByTestId("split-probe").props.children).toBe("split");
|
|
110
|
+
// The Stack lives inside the detail pane, not the list pane.
|
|
111
|
+
const isStack = (node: {type: unknown}): boolean => node.type === "Stack";
|
|
112
|
+
expect(getByTestId("list-detail-detail-pane").findAll(isStack)).toHaveLength(1);
|
|
113
|
+
expect(listPane.findAll(isStack)).toHaveLength(0);
|
|
114
|
+
// The list pane comes before the detail pane.
|
|
115
|
+
const paneIds = getByTestId("list-detail-layout")
|
|
116
|
+
.findAll(
|
|
117
|
+
(node) => typeof node.props.testID === "string" && node.props.testID.endsWith("-pane")
|
|
118
|
+
)
|
|
119
|
+
.map((node) => node.props.testID);
|
|
120
|
+
expect(paneIds.indexOf("list-detail-list-pane")).toBeLessThan(
|
|
121
|
+
paneIds.indexOf("list-detail-detail-pane")
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("renders only the Stack on a phone-width window", () => {
|
|
126
|
+
const {getByTestId, queryByTestId} = renderLayout();
|
|
127
|
+
|
|
128
|
+
expect(queryByTestId("list-detail-list-pane")).toBeNull();
|
|
129
|
+
expect(
|
|
130
|
+
getByTestId("list-detail-detail-pane").findAll((node) => node.type === "Stack")
|
|
131
|
+
).toHaveLength(1);
|
|
132
|
+
expect(getByTestId("split-probe").props.children).toBe("stacked");
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("uses the measured layout width over the window width", () => {
|
|
136
|
+
setWindowWidth(1024);
|
|
137
|
+
const {getByTestId, queryByTestId} = renderLayout();
|
|
138
|
+
|
|
139
|
+
fireLayout(getByTestId("list-detail-layout"), 600);
|
|
140
|
+
|
|
141
|
+
expect(queryByTestId("list-detail-list-pane")).toBeNull();
|
|
142
|
+
expect(getByTestId("split-probe").props.children).toBe("stacked");
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("ignores zero-width layout events", () => {
|
|
146
|
+
setWindowWidth(1024);
|
|
147
|
+
const {getByTestId} = renderLayout();
|
|
148
|
+
|
|
149
|
+
fireLayout(getByTestId("list-detail-layout"), 0);
|
|
150
|
+
|
|
151
|
+
expect(getByTestId("list-detail-list-pane")).toBeTruthy();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("splits at exactly the default 768 px", () => {
|
|
155
|
+
const {getByTestId} = renderLayout();
|
|
156
|
+
|
|
157
|
+
fireLayout(getByTestId("list-detail-layout"), 768);
|
|
158
|
+
|
|
159
|
+
expect(getByTestId("list-detail-list-pane")).toBeTruthy();
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("stays stacked at 767 px", () => {
|
|
163
|
+
const {getByTestId, queryByTestId} = renderLayout();
|
|
164
|
+
|
|
165
|
+
fireLayout(getByTestId("list-detail-layout"), 767);
|
|
166
|
+
|
|
167
|
+
expect(queryByTestId("list-detail-list-pane")).toBeNull();
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("respects a custom splitAtWidth and listWidth", () => {
|
|
171
|
+
setWindowWidth(1024);
|
|
172
|
+
const {getByTestId, queryByTestId} = renderLayout({listWidth: 280, splitAtWidth: 1200});
|
|
173
|
+
|
|
174
|
+
expect(queryByTestId("list-detail-list-pane")).toBeNull();
|
|
175
|
+
|
|
176
|
+
fireLayout(getByTestId("list-detail-layout"), 1300);
|
|
177
|
+
|
|
178
|
+
expect(getByTestId("list-detail-list-pane").props.style).toMatchObject({width: 280});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("never remounts the Stack when crossing the breakpoint", () => {
|
|
182
|
+
setWindowWidth(1024);
|
|
183
|
+
const {getByTestId, queryByTestId} = renderLayout();
|
|
184
|
+
const root = getByTestId("list-detail-layout");
|
|
185
|
+
|
|
186
|
+
fireLayout(root, 375);
|
|
187
|
+
expect(queryByTestId("list-detail-list-pane")).toBeNull();
|
|
188
|
+
fireLayout(root, 1024);
|
|
189
|
+
expect(getByTestId("list-detail-list-pane")).toBeTruthy();
|
|
190
|
+
|
|
191
|
+
expect(stackChildMounts).toBe(1);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("passes screenOptions and children through to the Stack", () => {
|
|
195
|
+
const screenOptions = {headerShown: false};
|
|
196
|
+
const {getByTestId, UNSAFE_getByType} = renderLayout({screenOptions});
|
|
197
|
+
|
|
198
|
+
expect(
|
|
199
|
+
UNSAFE_getByType("Stack" as unknown as React.ComponentType).props.screenOptions
|
|
200
|
+
).toMatchObject({headerShown: false});
|
|
201
|
+
expect(getByTestId("stack-child")).toBeTruthy();
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it("draws the list pane divider from the theme", () => {
|
|
205
|
+
setWindowWidth(1024);
|
|
206
|
+
const {getByTestId} = renderLayout();
|
|
207
|
+
|
|
208
|
+
const style = getByTestId("list-detail-list-pane").props.style;
|
|
209
|
+
expect(style.borderRightWidth).toBe(1);
|
|
210
|
+
// The default theme's border.default is the neutral300 primitive.
|
|
211
|
+
expect(style.borderRightColor).toBe("#CDCDCD");
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
describe("ListDetailIndex", () => {
|
|
216
|
+
beforeEach(() => {
|
|
217
|
+
setWindowWidth(375);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("renders the list when stacked", () => {
|
|
221
|
+
const {getByTestId, queryByTestId} = renderLayout();
|
|
222
|
+
|
|
223
|
+
expect(getByTestId("mail-list")).toBeTruthy();
|
|
224
|
+
expect(queryByTestId("list-detail-empty")).toBeNull();
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it("renders the empty detail when split", () => {
|
|
228
|
+
setWindowWidth(1024);
|
|
229
|
+
const {getByTestId, getAllByTestId} = renderLayout();
|
|
230
|
+
|
|
231
|
+
expect(getByTestId("list-detail-empty")).toBeTruthy();
|
|
232
|
+
expect(getByTestId("mail-empty")).toBeTruthy();
|
|
233
|
+
// The list renders once, in the list pane, not again in the index route.
|
|
234
|
+
expect(getAllByTestId("mail-list")).toHaveLength(1);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it("renders an empty pane when split without emptyDetail", () => {
|
|
238
|
+
setWindowWidth(1024);
|
|
239
|
+
const {getByTestId} = renderLayout({emptyDetail: undefined});
|
|
240
|
+
|
|
241
|
+
expect(getByTestId("list-detail-empty").props.children).toBeFalsy();
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
describe("useListDetail", () => {
|
|
246
|
+
it("throws outside a ListDetailLayout", () => {
|
|
247
|
+
const originalError = console.error;
|
|
248
|
+
console.error = (): void => {};
|
|
249
|
+
try {
|
|
250
|
+
expect(() => renderWithTheme(<SplitProbe />)).toThrow(
|
|
251
|
+
"useListDetail must be used inside a ListDetailLayout"
|
|
252
|
+
);
|
|
253
|
+
} finally {
|
|
254
|
+
console.error = originalError;
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// Puts the router on a route: a pathname, its segments, and its params.
|
|
260
|
+
const setRoute = (
|
|
261
|
+
pathname: string,
|
|
262
|
+
segments: string[],
|
|
263
|
+
params: Record<string, string | string[] | undefined> = {}
|
|
264
|
+
): void => {
|
|
265
|
+
mockedPathname.mockImplementation(() => pathname);
|
|
266
|
+
mockedSegments.mockImplementation(() => segments);
|
|
267
|
+
mockedSearchParams.mockImplementation(() => params);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
describe("useListDetail selection", () => {
|
|
271
|
+
beforeEach(() => {
|
|
272
|
+
latestState = undefined;
|
|
273
|
+
setWindowWidth(375);
|
|
274
|
+
setRoute("/mail", ["mail"]);
|
|
275
|
+
mockedRouter.dismissTo.mockClear();
|
|
276
|
+
mockedRouter.push.mockClear();
|
|
277
|
+
mockedRouter.replace.mockClear();
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
afterAll(() => {
|
|
281
|
+
// Restore the bunSetup.ts defaults for later test files.
|
|
282
|
+
setRoute("/", []);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it("reads the selected id from the open detail route", () => {
|
|
286
|
+
setRoute("/mail/3", ["mail", "[id]"], {id: "3"});
|
|
287
|
+
renderLayout();
|
|
288
|
+
|
|
289
|
+
expect(currentState().selectedId).toBe("3");
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it("has no selection on the index route even when an id param exists", () => {
|
|
293
|
+
setRoute("/mail", ["mail"], {id: "3"});
|
|
294
|
+
renderLayout();
|
|
295
|
+
|
|
296
|
+
expect(currentState().selectedId).toBeUndefined();
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it("has no selection on a static sibling route at the detail's depth", () => {
|
|
300
|
+
setRoute("/mail/compose", ["mail", "compose"], {id: "3"});
|
|
301
|
+
renderLayout();
|
|
302
|
+
|
|
303
|
+
expect(currentState().selectedId).toBeUndefined();
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it("has no selection on a static sibling whose name matches its id param", () => {
|
|
307
|
+
setRoute("/mail/compose", ["mail", "compose"], {id: "compose"});
|
|
308
|
+
renderLayout();
|
|
309
|
+
|
|
310
|
+
expect(currentState().selectedId).toBeUndefined();
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it("has no selection when the id param is empty", () => {
|
|
314
|
+
setRoute("/mail/", ["mail", "[id]"], {id: ""});
|
|
315
|
+
renderLayout();
|
|
316
|
+
|
|
317
|
+
expect(currentState().selectedId).toBeUndefined();
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
it("ignores an id from a parent dynamic segment", () => {
|
|
321
|
+
setRoute("/orgs/9/mail", ["orgs", "[id]", "mail"], {id: "9"});
|
|
322
|
+
renderLayout({indexHref: "/orgs/9/mail"});
|
|
323
|
+
|
|
324
|
+
expect(currentState().selectedId).toBeUndefined();
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it("ignores a detail route outside the group", () => {
|
|
328
|
+
setRoute("/news/3", ["news", "[id]"], {id: "3"});
|
|
329
|
+
renderLayout();
|
|
330
|
+
|
|
331
|
+
expect(currentState().selectedId).toBeUndefined();
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it("reads the selection inside a route group", () => {
|
|
335
|
+
setRoute("/mail/3", ["(tabs)", "mail", "[id]"], {id: "3"});
|
|
336
|
+
renderLayout();
|
|
337
|
+
|
|
338
|
+
expect(currentState().selectedId).toBe("3");
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it("keeps an id that contains a slash", () => {
|
|
342
|
+
setRoute("/mail/a/b", ["mail", "[id]"], {id: "a/b"});
|
|
343
|
+
renderLayout();
|
|
344
|
+
|
|
345
|
+
expect(currentState().selectedId).toBe("a/b");
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
it("matches an id that the pathname encodes", () => {
|
|
349
|
+
setRoute("/mail/a%20b", ["mail", "[id]"], {id: "a b"});
|
|
350
|
+
renderLayout();
|
|
351
|
+
|
|
352
|
+
expect(currentState().selectedId).toBe("a b");
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
it("ignores routes deeper than one segment below the index", () => {
|
|
356
|
+
setRoute("/mail/3/attachments", ["mail", "[id]"], {id: "3"});
|
|
357
|
+
renderLayout();
|
|
358
|
+
|
|
359
|
+
expect(currentState().selectedId).toBeUndefined();
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it("uses a custom detailRoute and paramName", () => {
|
|
363
|
+
setRoute("/mail/7", ["mail", "[messageId]"], {id: "1", messageId: "7"});
|
|
364
|
+
renderLayout({detailRoute: "[messageId]", paramName: "messageId"});
|
|
365
|
+
|
|
366
|
+
expect(currentState().selectedId).toBe("7");
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it("takes the first value of an array param", () => {
|
|
370
|
+
setRoute("/mail/5", ["mail", "[id]"], {id: ["5", "6"]});
|
|
371
|
+
renderLayout();
|
|
372
|
+
|
|
373
|
+
expect(currentState().selectedId).toBe("5");
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it("tolerates a trailing slash on indexHref", () => {
|
|
377
|
+
setRoute("/mail/3", ["mail", "[id]"], {id: "3"});
|
|
378
|
+
renderLayout({indexHref: "/mail/"});
|
|
379
|
+
|
|
380
|
+
expect(currentState().selectedId).toBe("3");
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
it("pushes the detail route when stacked", () => {
|
|
384
|
+
renderLayout();
|
|
385
|
+
|
|
386
|
+
act(() => {
|
|
387
|
+
currentState().select("4");
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
expect(mockedRouter.push).toHaveBeenCalledTimes(1);
|
|
391
|
+
expect(mockedRouter.push).toHaveBeenCalledWith("/mail/4");
|
|
392
|
+
expect(mockedRouter.replace).not.toHaveBeenCalled();
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
it("pushes the next detail when stacked with an item open", () => {
|
|
396
|
+
setRoute("/mail/3", ["mail", "[id]"], {id: "3"});
|
|
397
|
+
renderLayout();
|
|
398
|
+
|
|
399
|
+
act(() => {
|
|
400
|
+
currentState().select("4");
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
expect(mockedRouter.push).toHaveBeenCalledTimes(1);
|
|
404
|
+
expect(mockedRouter.push).toHaveBeenCalledWith("/mail/4");
|
|
405
|
+
expect(mockedRouter.replace).not.toHaveBeenCalled();
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
it("pushes the detail route when split with nothing open", () => {
|
|
409
|
+
setWindowWidth(1024);
|
|
410
|
+
renderLayout();
|
|
411
|
+
|
|
412
|
+
act(() => {
|
|
413
|
+
currentState().select("4");
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
expect(mockedRouter.push).toHaveBeenCalledWith("/mail/4");
|
|
417
|
+
expect(mockedRouter.replace).not.toHaveBeenCalled();
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it("replaces the open detail when split, keeping one detail on the stack", () => {
|
|
421
|
+
setWindowWidth(1024);
|
|
422
|
+
setRoute("/mail/3", ["mail", "[id]"], {id: "3"});
|
|
423
|
+
renderLayout();
|
|
424
|
+
|
|
425
|
+
act(() => {
|
|
426
|
+
currentState().select("4");
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
expect(mockedRouter.replace).toHaveBeenCalledTimes(1);
|
|
430
|
+
expect(mockedRouter.replace).toHaveBeenCalledWith("/mail/4");
|
|
431
|
+
expect(mockedRouter.push).not.toHaveBeenCalled();
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
it("does nothing when split and the open item is selected again", () => {
|
|
435
|
+
setWindowWidth(1024);
|
|
436
|
+
setRoute("/mail/3", ["mail", "[id]"], {id: "3"});
|
|
437
|
+
renderLayout();
|
|
438
|
+
|
|
439
|
+
act(() => {
|
|
440
|
+
currentState().select("3");
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
expect(mockedRouter.replace).not.toHaveBeenCalled();
|
|
444
|
+
expect(mockedRouter.push).not.toHaveBeenCalled();
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
it("dismisses to the index to clear the open item", () => {
|
|
448
|
+
setRoute("/mail/3", ["mail", "[id]"], {id: "3"});
|
|
449
|
+
renderLayout();
|
|
450
|
+
|
|
451
|
+
act(() => {
|
|
452
|
+
currentState().clear();
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
expect(mockedRouter.dismissTo).toHaveBeenCalledTimes(1);
|
|
456
|
+
expect(mockedRouter.dismissTo).toHaveBeenCalledWith("/mail");
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
it("does nothing on clear when no item is open", () => {
|
|
460
|
+
renderLayout();
|
|
461
|
+
|
|
462
|
+
act(() => {
|
|
463
|
+
currentState().clear();
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
expect(mockedRouter.dismissTo).not.toHaveBeenCalled();
|
|
467
|
+
});
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
describe("ListDetailLayout split screen options", () => {
|
|
471
|
+
type ScreenOptionsFn = (props: unknown) => Record<string, unknown>;
|
|
472
|
+
|
|
473
|
+
const stackOptions = (rendered: ReturnType<typeof renderLayout>): unknown => {
|
|
474
|
+
return rendered.UNSAFE_getByType("Stack" as unknown as React.ComponentType).props.screenOptions;
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
// Screen options for a screen whose parent navigator can (or cannot) go back.
|
|
478
|
+
const resolveSplitOptions = (
|
|
479
|
+
rendered: ReturnType<typeof renderLayout>,
|
|
480
|
+
parent: {canGoBack: () => boolean; goBack: () => void} | undefined
|
|
481
|
+
): Record<string, unknown> => {
|
|
482
|
+
const options = stackOptions(rendered) as ScreenOptionsFn;
|
|
483
|
+
return options({navigation: {getParent: () => parent}, route: {key: "detail", name: "[id]"}});
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
beforeEach(() => {
|
|
487
|
+
setWindowWidth(375);
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
it("turns off the push animation and the back-to-list button when split", () => {
|
|
491
|
+
setWindowWidth(1024);
|
|
492
|
+
const options = resolveSplitOptions(renderLayout(), undefined);
|
|
493
|
+
|
|
494
|
+
expect(options.animation).toBe("none");
|
|
495
|
+
expect(options.headerBackVisible).toBe(false);
|
|
496
|
+
// With no parent history, headerLeft draws nothing (the web header would otherwise draw back).
|
|
497
|
+
expect((options.headerLeft as () => unknown)()).toBeNull();
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
it("offers a back button that leaves the group when the parent can go back", () => {
|
|
501
|
+
setWindowWidth(1024);
|
|
502
|
+
const goBack = mock((): void => {});
|
|
503
|
+
const options = resolveSplitOptions(renderLayout(), {canGoBack: () => true, goBack});
|
|
504
|
+
// bunSetup.ts mocks IconButton to render nothing, so check the element it is given.
|
|
505
|
+
const button = (
|
|
506
|
+
options.headerLeft as () => React.ReactElement<{
|
|
507
|
+
accessibilityLabel: string;
|
|
508
|
+
onClick: () => void;
|
|
509
|
+
testID: string;
|
|
510
|
+
}>
|
|
511
|
+
)();
|
|
512
|
+
expect(button.props.testID).toBe("list-detail-leave");
|
|
513
|
+
expect(button.props.accessibilityLabel).toBe("Back");
|
|
514
|
+
|
|
515
|
+
button.props.onClick();
|
|
516
|
+
|
|
517
|
+
expect(goBack).toHaveBeenCalledTimes(1);
|
|
518
|
+
expect(mockedRouter.dismissTo).not.toHaveBeenCalled();
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
it("leaves screen options untouched when stacked", () => {
|
|
522
|
+
expect(stackOptions(renderLayout())).toBeUndefined();
|
|
523
|
+
expect(stackOptions(renderLayout({screenOptions: {title: "Inbox"}}))).toEqual({
|
|
524
|
+
title: "Inbox",
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
it("lets the caller's screen options win when split", () => {
|
|
529
|
+
setWindowWidth(1024);
|
|
530
|
+
const rendered = renderLayout({screenOptions: {animation: "fade", title: "Inbox"}});
|
|
531
|
+
|
|
532
|
+
expect(resolveSplitOptions(rendered, undefined)).toMatchObject({
|
|
533
|
+
animation: "fade",
|
|
534
|
+
headerBackVisible: false,
|
|
535
|
+
title: "Inbox",
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
it("merges into function screen options when split", () => {
|
|
540
|
+
setWindowWidth(1024);
|
|
541
|
+
const rendered = renderLayout({screenOptions: () => ({animation: "fade", title: "Inbox"})});
|
|
542
|
+
|
|
543
|
+
expect(resolveSplitOptions(rendered, undefined)).toMatchObject({
|
|
544
|
+
animation: "fade",
|
|
545
|
+
headerBackVisible: false,
|
|
546
|
+
title: "Inbox",
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
it("keeps the caller's headerLeft when split", () => {
|
|
551
|
+
setWindowWidth(1024);
|
|
552
|
+
const headerLeft = (): string => "menu";
|
|
553
|
+
const rendered = renderLayout({screenOptions: {headerLeft}});
|
|
554
|
+
|
|
555
|
+
expect(resolveSplitOptions(rendered, undefined).headerLeft).toBe(headerLeft);
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
describe("ListDetailLayout across the breakpoint", () => {
|
|
560
|
+
beforeEach(() => {
|
|
561
|
+
latestState = undefined;
|
|
562
|
+
stackChildMounts = 0;
|
|
563
|
+
setWindowWidth(1024);
|
|
564
|
+
setRoute("/mail/3", ["mail", "[id]"], {id: "3"});
|
|
565
|
+
mockedRouter.dismissTo.mockClear();
|
|
566
|
+
mockedRouter.push.mockClear();
|
|
567
|
+
mockedRouter.replace.mockClear();
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
afterAll(() => {
|
|
571
|
+
setRoute("/", []);
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
it("keeps the open item through a resize to phone width and back", () => {
|
|
575
|
+
const {getByTestId, queryByTestId} = renderLayout();
|
|
576
|
+
const root = getByTestId("list-detail-layout");
|
|
577
|
+
expect(currentState().selectedId).toBe("3");
|
|
578
|
+
expect(currentState().isSplit).toBe(true);
|
|
579
|
+
|
|
580
|
+
fireLayout(root, 375);
|
|
581
|
+
expect(currentState().selectedId).toBe("3");
|
|
582
|
+
expect(currentState().isSplit).toBe(false);
|
|
583
|
+
expect(queryByTestId("list-detail-list-pane")).toBeNull();
|
|
584
|
+
|
|
585
|
+
fireLayout(root, 1024);
|
|
586
|
+
expect(currentState().selectedId).toBe("3");
|
|
587
|
+
expect(currentState().isSplit).toBe(true);
|
|
588
|
+
expect(getByTestId("list-detail-list-pane")).toBeTruthy();
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
it("keeps the detail route mounted at phone width with no list pane", () => {
|
|
592
|
+
const {getByTestId, queryByTestId} = renderLayout();
|
|
593
|
+
|
|
594
|
+
fireLayout(getByTestId("list-detail-layout"), 375);
|
|
595
|
+
|
|
596
|
+
expect(queryByTestId("list-detail-list-pane")).toBeNull();
|
|
597
|
+
expect(stackChildMounts).toBe(1);
|
|
598
|
+
// The index screen under the detail now holds the list, so swipe-back reveals it.
|
|
599
|
+
expect(getByTestId("mail-list")).toBeTruthy();
|
|
600
|
+
expect(queryByTestId("list-detail-empty")).toBeNull();
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
it("makes no router call while resizing", () => {
|
|
604
|
+
const {getByTestId} = renderLayout();
|
|
605
|
+
const root = getByTestId("list-detail-layout");
|
|
606
|
+
|
|
607
|
+
fireLayout(root, 375);
|
|
608
|
+
fireLayout(root, 1024);
|
|
609
|
+
fireLayout(root, 600);
|
|
610
|
+
|
|
611
|
+
expect(mockedRouter.push).not.toHaveBeenCalled();
|
|
612
|
+
expect(mockedRouter.replace).not.toHaveBeenCalled();
|
|
613
|
+
expect(mockedRouter.dismissTo).not.toHaveBeenCalled();
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
it("follows a window resize before the first layout event", () => {
|
|
617
|
+
const {queryByTestId, rerender} = renderLayout();
|
|
618
|
+
expect(queryByTestId("list-detail-list-pane")).toBeTruthy();
|
|
619
|
+
|
|
620
|
+
setWindowWidth(375);
|
|
621
|
+
rerender(
|
|
622
|
+
<ListDetailLayout
|
|
623
|
+
detailHref={(id) => `/mail/${id}`}
|
|
624
|
+
indexHref="/mail"
|
|
625
|
+
list={<Text testID="mail-list">Inbox</Text>}
|
|
626
|
+
>
|
|
627
|
+
<SplitProbe />
|
|
628
|
+
</ListDetailLayout>
|
|
629
|
+
);
|
|
630
|
+
|
|
631
|
+
expect(queryByTestId("list-detail-list-pane")).toBeNull();
|
|
632
|
+
expect(currentState().selectedId).toBe("3");
|
|
633
|
+
});
|
|
634
|
+
});
|
|
@@ -18,6 +18,7 @@ import type {GPTMemoryModal as GPTMemoryModalComponent} from "../GPTMemoryModal"
|
|
|
18
18
|
import type {LineChart as LineChartComponent} from "../LineChart";
|
|
19
19
|
import type {MarkdownEditor as MarkdownEditorComponent} from "../MarkdownEditor";
|
|
20
20
|
import type {MarkdownEditorField as MarkdownEditorFieldComponent} from "../MarkdownEditorField";
|
|
21
|
+
import type {ProvisionalConsentSigner as ProvisionalConsentSignerComponent} from "../ProvisionalConsentSigner";
|
|
21
22
|
import type {Scorecard as ScorecardComponent} from "../Scorecard";
|
|
22
23
|
import type {SparklineChart as SparklineChartComponent} from "../SparklineChart";
|
|
23
24
|
import type {UpgradeRequiredScreen as UpgradeRequiredScreenComponent} from "../UpgradeRequiredScreen";
|
|
@@ -43,6 +44,7 @@ export const heavyOptionalModuleFactories = {
|
|
|
43
44
|
LineChart: () => import("../LineChart"),
|
|
44
45
|
MarkdownEditor: () => import("../MarkdownEditor"),
|
|
45
46
|
MarkdownEditorField: () => import("../MarkdownEditorField"),
|
|
47
|
+
ProvisionalConsentSigner: () => import("../ProvisionalConsentSigner"),
|
|
46
48
|
Scorecard: () => import("../Scorecard"),
|
|
47
49
|
SparklineChart: () => import("../SparklineChart"),
|
|
48
50
|
UpgradeRequiredScreen: () => import("../UpgradeRequiredScreen"),
|
|
@@ -114,6 +116,11 @@ export const ConsentNavigator = createLazyNamedExport(
|
|
|
114
116
|
"ConsentNavigator"
|
|
115
117
|
) as unknown as typeof ConsentNavigatorComponent;
|
|
116
118
|
|
|
119
|
+
export const ProvisionalConsentSigner = createLazyNamedExport(
|
|
120
|
+
heavyOptionalModuleFactories.ProvisionalConsentSigner,
|
|
121
|
+
"ProvisionalConsentSigner"
|
|
122
|
+
) as unknown as typeof ProvisionalConsentSignerComponent;
|
|
123
|
+
|
|
117
124
|
export const DonutChart = createLazyNamedExport(
|
|
118
125
|
heavyOptionalModuleFactories.DonutChart,
|
|
119
126
|
"DonutChart"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type {FC} from "react";
|
|
2
|
+
import {View} from "react-native";
|
|
3
|
+
|
|
4
|
+
import {Text} from "../Text";
|
|
5
|
+
import {useTheme} from "../Theme";
|
|
6
|
+
|
|
7
|
+
interface LastUsedPillProps {
|
|
8
|
+
/** Pill text, such as "Last used". */
|
|
9
|
+
label: string;
|
|
10
|
+
/** Test ID for the pill. */
|
|
11
|
+
testID: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Marks the sign-in method this device used last. Sits inline after an account name, on an email
|
|
16
|
+
* label, or at the right edge of a method button.
|
|
17
|
+
*/
|
|
18
|
+
export const LastUsedPill: FC<LastUsedPillProps> = ({label, testID}) => {
|
|
19
|
+
const {theme} = useTheme();
|
|
20
|
+
if (!theme) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return (
|
|
24
|
+
<View
|
|
25
|
+
style={{
|
|
26
|
+
backgroundColor: theme.surface.secondaryExtraLight,
|
|
27
|
+
borderColor: theme.surface.secondaryLight,
|
|
28
|
+
borderRadius: theme.radius.rounded,
|
|
29
|
+
borderWidth: 1,
|
|
30
|
+
paddingHorizontal: 8,
|
|
31
|
+
paddingVertical: 2,
|
|
32
|
+
}}
|
|
33
|
+
testID={testID}
|
|
34
|
+
>
|
|
35
|
+
<Text bold color="secondaryDark" size="sm">
|
|
36
|
+
{label}
|
|
37
|
+
</Text>
|
|
38
|
+
</View>
|
|
39
|
+
);
|
|
40
|
+
};
|