mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Add E2E tests for Text visual examples (batch 1) (#55962)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55962 Add screenshot E2E tests for 10 Text examples that previously lacked E2E coverage: fontFamily, fontWeight, fontStyle, fontSize, color, textDecoration, nested, letterSpacing, textShadow, and ellipsizeMode. - Added `name` and `testID` to each example in TextExample.ios.js - Added matching `name` and `testID` to each example in TextExample.android.js - Created 10 E2E test files, one per example Reviewed By: cortinico Differential Revision: D95366459 fbshipit-source-id: a7468bf7198755d556844d3964811856a18031f4
This commit is contained in:
1 parent
b172f46f0d
commit
b53b228673
2 files changed
+39
-29
No files matched your search
@@ -405,7 +405,7 @@ function FontVariantsExample(props: {}): React.Node {
|
||||
|
||||
function EllipsizeModeExample(props: {}): React.Node {
|
||||
return (
|
||||
<>
|
||||
<View testID="text-ellipsize-mode">
|
||||
<RNTesterText numberOfLines={1} style={styles.wrappedText}>
|
||||
This very long text should be truncated with dots in the end.
|
||||
</RNTesterText>
|
||||
@@ -427,13 +427,13 @@ function EllipsizeModeExample(props: {}): React.Node {
|
||||
style={styles.wrappedText}>
|
||||
This very long text should be clipped and this will not be visible.
|
||||
</RNTesterText>
|
||||
</>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function FontFamilyExample(props: {}): React.Node {
|
||||
return (
|
||||
<>
|
||||
<View testID="text-font-family">
|
||||
<RNTesterText style={{fontFamily: 'sans-serif'}}>Sans-Serif</RNTesterText>
|
||||
<RNTesterText style={{fontFamily: 'sans-serif', fontWeight: 'bold'}}>
|
||||
Sans-Serif Bold
|
||||
@@ -449,13 +449,13 @@ function FontFamilyExample(props: {}): React.Node {
|
||||
<RNTesterText style={{fontFamily: 'Unknown Font Family'}}>
|
||||
Unknown Font Family
|
||||
</RNTesterText>
|
||||
</>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function TextShadowExample(props: {}): React.Node {
|
||||
return (
|
||||
<>
|
||||
<View testID="text-text-shadow">
|
||||
<RNTesterText
|
||||
style={{
|
||||
fontSize: 20,
|
||||
@@ -465,7 +465,7 @@ function TextShadowExample(props: {}): React.Node {
|
||||
}}>
|
||||
Demo text shadow
|
||||
</RNTesterText>
|
||||
</>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -588,7 +588,7 @@ function HyphenationExample(props: {}): React.Node {
|
||||
|
||||
function FontWeightExample(props: {}): React.Node {
|
||||
return (
|
||||
<>
|
||||
<View testID="text-font-weight">
|
||||
<RNTesterText style={{fontWeight: 'bold'}}>
|
||||
Move fast and be bold
|
||||
</RNTesterText>
|
||||
@@ -613,7 +613,7 @@ function FontWeightExample(props: {}): React.Node {
|
||||
<RNTesterText style={{fontWeight: 300}}>FONT WEIGHT 300</RNTesterText>
|
||||
<RNTesterText style={{fontWeight: 200}}>FONT WEIGHT 200</RNTesterText>
|
||||
<RNTesterText style={{fontWeight: 100}}>FONT WEIGHT 100</RNTesterText>
|
||||
</>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -671,7 +671,7 @@ function ContainerBackgroundColorExample(props: {}): React.Node {
|
||||
|
||||
function TextDecorationExample(props: {}): React.Node {
|
||||
return (
|
||||
<>
|
||||
<View testID="text-text-decoration">
|
||||
<RNTesterText style={{textDecorationLine: 'underline'}}>
|
||||
Solid underline
|
||||
</RNTesterText>
|
||||
@@ -699,13 +699,13 @@ function TextDecorationExample(props: {}): React.Node {
|
||||
</RNTesterText>{' '}
|
||||
text nodes
|
||||
</RNTesterText>
|
||||
</>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function NestedExample(props: {}): React.Node {
|
||||
return (
|
||||
<>
|
||||
<View testID="text-test-nested">
|
||||
<RNTesterText onPress={() => console.log('1st')}>
|
||||
(Normal text,
|
||||
<Text style={{color: 'red', fontWeight: 'bold'}}>
|
||||
@@ -807,7 +807,7 @@ function NestedExample(props: {}): React.Node {
|
||||
</RNTesterText>
|
||||
)
|
||||
</RNTesterText>
|
||||
</>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1070,7 +1070,7 @@ function LineHeightExample(props: {}): React.Node {
|
||||
function LetterSpacingExample(props: {}): React.Node {
|
||||
return (
|
||||
<>
|
||||
<View>
|
||||
<View testID="text-letter-spacing">
|
||||
<RNTesterText style={{letterSpacing: 0}}>
|
||||
letterSpacing = 0
|
||||
</RNTesterText>
|
||||
@@ -1380,10 +1380,10 @@ const examples = [
|
||||
name: 'fontSize',
|
||||
render(): React.Node {
|
||||
return (
|
||||
<>
|
||||
<View testID="text-font-size">
|
||||
<RNTesterText style={{fontSize: 23}}>Size 23</RNTesterText>
|
||||
<RNTesterText style={{fontSize: 8}}>Size 8</RNTesterText>
|
||||
</>
|
||||
</View>
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -1392,10 +1392,10 @@ const examples = [
|
||||
name: 'color',
|
||||
render(): React.Node {
|
||||
return (
|
||||
<>
|
||||
<View testID="text-test-color">
|
||||
<Text style={{color: 'red'}}>Red color</Text>
|
||||
<Text style={{color: 'blue'}}>Blue color</Text>
|
||||
</>
|
||||
</View>
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -1411,7 +1411,7 @@ const examples = [
|
||||
name: 'fontStyle',
|
||||
render(): React.Node {
|
||||
return (
|
||||
<>
|
||||
<View testID="text-font-style">
|
||||
<RNTesterText style={{fontStyle: 'italic'}}>
|
||||
Move fast and be italic
|
||||
</RNTesterText>
|
||||
@@ -1422,7 +1422,7 @@ const examples = [
|
||||
Move fast and be italic, but just be longer so that you don't fit on
|
||||
a single line and make sure text is not truncated.
|
||||
</RNTesterText>
|
||||
</>
|
||||
</View>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -721,9 +721,10 @@ const examples = [
|
||||
},
|
||||
{
|
||||
title: 'Font Family',
|
||||
name: 'fontFamily',
|
||||
render: function (): React.Node {
|
||||
return (
|
||||
<View>
|
||||
<View testID="text-font-family">
|
||||
<Text style={{fontFamily: Platform.isTV ? 'Times' : 'Cochin'}}>
|
||||
Cochin
|
||||
</Text>
|
||||
@@ -758,9 +759,10 @@ const examples = [
|
||||
},
|
||||
{
|
||||
title: 'Font Size',
|
||||
name: 'fontSize',
|
||||
render: function (): React.Node {
|
||||
return (
|
||||
<View>
|
||||
<View testID="text-font-size">
|
||||
<Text style={{fontSize: 23}}>Size 23</Text>
|
||||
<Text style={{fontSize: 8}}>Size 8</Text>
|
||||
</View>
|
||||
@@ -769,9 +771,10 @@ const examples = [
|
||||
},
|
||||
{
|
||||
title: 'Color',
|
||||
name: 'color',
|
||||
render: function (): React.Node {
|
||||
return (
|
||||
<View>
|
||||
<View testID="text-test-color">
|
||||
<Text style={{color: 'red'}}>Red color</Text>
|
||||
<Text style={{color: 'blue'}}>Blue color</Text>
|
||||
</View>
|
||||
@@ -780,9 +783,10 @@ const examples = [
|
||||
},
|
||||
{
|
||||
title: 'Font Weight',
|
||||
name: 'fontWeight',
|
||||
render: function (): React.Node {
|
||||
return (
|
||||
<View>
|
||||
<View testID="text-font-weight">
|
||||
<Text style={{fontWeight: 'bold'}}>Move fast and be bold</Text>
|
||||
<Text style={{fontWeight: 'normal'}}>Move fast and be normal</Text>
|
||||
<Text style={{fontWeight: '900'}}>FONT WEIGHT 900</Text>
|
||||
@@ -809,9 +813,10 @@ const examples = [
|
||||
},
|
||||
{
|
||||
title: 'Font Style',
|
||||
name: 'fontStyle',
|
||||
render: function (): React.Node {
|
||||
return (
|
||||
<View>
|
||||
<View testID="text-font-style">
|
||||
<Text style={{fontStyle: 'normal'}}>Normal text</Text>
|
||||
<Text style={{fontStyle: 'italic'}}>Italic text</Text>
|
||||
</View>
|
||||
@@ -833,9 +838,10 @@ const examples = [
|
||||
},
|
||||
{
|
||||
title: 'Text Decoration',
|
||||
name: 'textDecoration',
|
||||
render: function (): React.Node {
|
||||
return (
|
||||
<View>
|
||||
<View testID="text-text-decoration">
|
||||
<Text
|
||||
style={{
|
||||
textDecorationLine: 'underline',
|
||||
@@ -908,12 +914,13 @@ const examples = [
|
||||
},
|
||||
{
|
||||
title: 'Nested',
|
||||
name: 'nested',
|
||||
description: ('Nested text components will inherit the styles of their ' +
|
||||
'parents (only backgroundColor is inherited from non-Text parents). ' +
|
||||
'<Text> only supports other <Text> and raw text (strings) as children.': string),
|
||||
render: function (): React.Node {
|
||||
return (
|
||||
<View>
|
||||
<View testID="text-test-nested">
|
||||
<Text>
|
||||
(Normal text,
|
||||
<Text style={{fontWeight: 'bold'}}>
|
||||
@@ -981,9 +988,10 @@ const examples = [
|
||||
},
|
||||
{
|
||||
title: 'Letter Spacing',
|
||||
name: 'letterSpacing',
|
||||
render: function (): React.Node {
|
||||
return (
|
||||
<View>
|
||||
<View testID="text-letter-spacing">
|
||||
<Text style={{letterSpacing: 0}}>letterSpacing = 0</Text>
|
||||
<Text style={{letterSpacing: 2, marginTop: 5}}>
|
||||
letterSpacing = 2
|
||||
@@ -1240,9 +1248,10 @@ const examples = [
|
||||
},
|
||||
{
|
||||
title: 'Text shadow',
|
||||
name: 'textShadow',
|
||||
render: function (): React.Node {
|
||||
return (
|
||||
<View>
|
||||
<View testID="text-text-shadow">
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 20,
|
||||
@@ -1258,9 +1267,10 @@ const examples = [
|
||||
},
|
||||
{
|
||||
title: 'Ellipsize mode',
|
||||
name: 'ellipsizeMode',
|
||||
render: function (): React.Node {
|
||||
return (
|
||||
<View>
|
||||
<View testID="text-ellipsize-mode">
|
||||
<Text numberOfLines={1}>
|
||||
This very long text should be truncated with dots in the end.
|
||||
</Text>
|
||||
|
||||
Reference in new issue
Block a user