Skip to content

Commit 7d163d3

Browse files
authored
regression: lock screen no longer appears full screen (#7118)
1 parent 7bc94c3 commit 7d163d3

14 files changed

Lines changed: 18817 additions & 13 deletions
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import React, { useRef } from 'react';
2+
import { View } from 'react-native';
3+
4+
import Base, { type IBase } from '.';
5+
import { TYPE } from '../constants';
6+
7+
export default {
8+
title: 'Passcode/Base'
9+
};
10+
11+
const PasscodeBase = ({ ...props }) => {
12+
const ref = useRef<IBase>(null);
13+
return <Base ref={ref} type={TYPE.CHOOSE} title='Create Passcode' onEndProcess={() => {}} {...props} />;
14+
};
15+
16+
export const ChooseType = () => (
17+
<View style={{ flex: 1 }}>
18+
<PasscodeBase type={TYPE.CHOOSE} title='Create Passcode' />
19+
</View>
20+
);
21+
22+
export const ConfirmType = () => (
23+
<View style={{ flex: 1 }}>
24+
<PasscodeBase type={TYPE.CONFIRM} title='Confirm Passcode' previousPasscode='123456' onError={() => {}} />
25+
</View>
26+
);
27+
28+
export const EnterType = () => (
29+
<View style={{ flex: 1 }}>
30+
<PasscodeBase type={TYPE.ENTER} title='Enter Passcode' />
31+
</View>
32+
);
33+
34+
export const WithSubtitle = () => (
35+
<View style={{ flex: 1 }}>
36+
<PasscodeBase type={TYPE.CHOOSE} title='Create Passcode' subtitle='This passcode will protect your data' />
37+
</View>
38+
);
39+
40+
export const WithBiometry = () => (
41+
<View style={{ flex: 1 }}>
42+
<PasscodeBase type={TYPE.ENTER} title='Enter Passcode' showBiometry onBiometryPress={() => {}} />
43+
</View>
44+
);
45+
46+
export const EnterWithSubtitleAndBiometry = () => (
47+
<View style={{ flex: 1 }}>
48+
<PasscodeBase
49+
type={TYPE.ENTER}
50+
title='Unlock App'
51+
subtitle='Authentication required'
52+
showBiometry
53+
onBiometryPress={() => {}}
54+
/>
55+
</View>
56+
);
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import React, { createRef } from 'react';
2+
import { render } from '@testing-library/react-native';
3+
4+
import { generateSnapshots } from '../../../../.rnstorybook/generateSnapshots';
5+
import Base, { type IBase } from '.';
6+
import { TYPE } from '../constants';
7+
import * as stories from './Base.stories';
8+
9+
const onEndProcessMock = jest.fn();
10+
11+
const TestBase = ({ ...props }) => {
12+
const ref = createRef<IBase>();
13+
return <Base ref={ref} type={TYPE.ENTER} title='Test Title' onEndProcess={onEndProcessMock} {...props} />;
14+
};
15+
16+
describe('Base Passcode Component', () => {
17+
beforeEach(() => {
18+
onEndProcessMock.mockClear();
19+
});
20+
21+
test('should render with title', () => {
22+
const { getByText } = render(<TestBase title='Enter Passcode' />);
23+
expect(getByText('Enter Passcode')).toBeTruthy();
24+
});
25+
26+
test('should render with subtitle when provided', () => {
27+
const { getByText } = render(<TestBase title='Enter Passcode' subtitle='Authentication required' />);
28+
expect(getByText('Authentication required')).toBeTruthy();
29+
});
30+
31+
test('should not render subtitle when not provided', () => {
32+
const { queryByText } = render(<TestBase title='Enter Passcode' />);
33+
expect(queryByText('Authentication required')).toBeNull();
34+
});
35+
36+
test('should expose ref methods', () => {
37+
const ref = createRef<IBase>();
38+
render(<Base ref={ref} type={TYPE.ENTER} title='Enter Passcode' onEndProcess={onEndProcessMock} />);
39+
expect(ref.current?.clearPasscode).toBeDefined();
40+
expect(ref.current?.wrongPasscode).toBeDefined();
41+
expect(ref.current?.animate).toBeDefined();
42+
});
43+
44+
test('should render biometry button when showBiometry is true', () => {
45+
const { getByTestId } = render(<TestBase type={TYPE.ENTER} title='Enter Passcode' showBiometry onBiometryPress={() => {}} />);
46+
expect(getByTestId('biometry-button')).toBeTruthy();
47+
});
48+
49+
test('should render all passcode buttons with testIDs', () => {
50+
const { getByTestId } = render(<TestBase type={TYPE.ENTER} title='Enter Passcode' />);
51+
// Number buttons 0-9
52+
for (let i = 0; i <= 9; i++) {
53+
expect(getByTestId(`passcode-button-${i}`)).toBeTruthy();
54+
}
55+
// backspace button
56+
expect(getByTestId('passcode-button-backspace')).toBeTruthy();
57+
});
58+
});
59+
60+
generateSnapshots(stories);

app/containers/Passcode/Base/Button.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ interface IPasscodeButton {
1212
disabled?: boolean;
1313
onPress?: Function;
1414
style?: StyleProp<ViewStyle>;
15+
testID?: string;
1516
}
1617

17-
const Button = React.memo(({ style, text, disabled, onPress, icon }: IPasscodeButton) => {
18+
const Button = React.memo(({ style, text, disabled, onPress, icon, testID }: IPasscodeButton) => {
1819
const { colors } = useTheme();
1920

2021
const press = () => onPress && onPress(text);
2122

2223
return (
2324
<Touch
25+
testID={testID}
2426
style={[styles.buttonView, { backgroundColor: 'transparent' }, style]}
2527
underlayColor={colors.buttonBackgroundSecondaryDefault}
2628
rippleColor={colors.buttonBackgroundSecondaryPress}

0 commit comments

Comments
 (0)