Skip to content

Commit d5a271d

Browse files
NickGerlemanmeta-codesync[bot]
authored andcommitted
Add E2E tests for Text visual examples (batch 2) (#55963)
Summary: Pull Request resolved: #55963 Add screenshot E2E tests for 9 Text examples that previously lacked E2E coverage: wrap, substringEmoji, transparentBackgroundColor, padding, spaces, backgroundColorAttr, fontVariants, textTransform, and lineHeightIOS. - Added `name` and `testID` to each example in TextExample.ios.js - Added matching `name` and `testID` to Android examples (wrap, padding, spaces, backgroundColorAttr, fontVariants) in TextExample.android.js - 4 tests are iOS-only (substringEmoji, transparentBackgroundColor, textTransform, lineHeightIOS) as these examples don't exist on Android - 5 tests are cross-platform (excludedPlatforms: ['mac']) - lineBreakStrategy test was removed due to persistent infra failure preventing screenshot capture; name and testID were still added to the source Reviewed By: cortinico Differential Revision: D95370389 fbshipit-source-id: 2506619ee2803c44e4f8409f2401819a0ff0c719
1 parent b53b228 commit d5a271d

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

packages/rn-tester/js/examples/Text/TextExample.android.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ function IncludeFontPaddingExample(props: {}): React.Node {
361361

362362
function FontVariantsExample(props: {}): React.Node {
363363
return (
364-
<>
364+
<View testID="text-font-variants">
365365
<RNTesterText style={{fontVariant: ['small-caps']}}>
366366
Small Caps{'\n'}
367367
</RNTesterText>
@@ -399,7 +399,7 @@ function FontVariantsExample(props: {}): React.Node {
399399
}}>
400400
Stylistic & and $
401401
</RNTesterText>
402-
</>
402+
</View>
403403
);
404404
}
405405

@@ -619,7 +619,7 @@ function FontWeightExample(props: {}): React.Node {
619619

620620
function BackgroundColorExample(props: {}): React.Node {
621621
return (
622-
<>
622+
<View testID="text-bg-color-attr">
623623
<RNTesterText style={{backgroundColor: '#ffaaaa'}}>
624624
Red background,
625625
<RNTesterText style={{backgroundColor: '#aaaaff'}}>
@@ -644,7 +644,7 @@ function BackgroundColorExample(props: {}): React.Node {
644644
</RNTesterText>
645645
</RNTesterText>
646646
</RNTesterText>
647-
</>
647+
</View>
648648
);
649649
}
650650

@@ -1322,7 +1322,7 @@ const examples = [
13221322
name: 'wrap',
13231323
render(): React.Node {
13241324
return (
1325-
<RNTesterText style={styles.wrappedText}>
1325+
<RNTesterText testID="text-wrap" style={styles.wrappedText}>
13261326
The text should wrap if it goes on multiple lines. See, this is going
13271327
to the next line.
13281328
</RNTesterText>
@@ -1341,7 +1341,7 @@ const examples = [
13411341
name: 'padding',
13421342
render(): React.Node {
13431343
return (
1344-
<RNTesterText style={{padding: 10}}>
1344+
<RNTesterText testID="text-padding" style={{padding: 10}}>
13451345
This text is indented by 10px padding on all sides.
13461346
</RNTesterText>
13471347
);
@@ -1470,7 +1470,7 @@ const examples = [
14701470
name: 'spaces',
14711471
render(): React.Node {
14721472
return (
1473-
<RNTesterText>
1473+
<RNTesterText testID="text-spaces">
14741474
A {'generated'} {'string'} and some &nbsp;&nbsp;&nbsp; spaces
14751475
</RNTesterText>
14761476
);
@@ -1497,7 +1497,7 @@ const examples = [
14971497
},
14981498
{
14991499
title: 'backgroundColor attribute',
1500-
name: 'backgroundColorAttribute',
1500+
name: 'backgroundColorAttr',
15011501
render(): React.Node {
15021502
return <BackgroundColorExample />;
15031503
},

packages/rn-tester/js/examples/Text/TextExample.ios.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,10 @@ const examples = [
601601
},
602602
{
603603
title: 'Wrap',
604+
name: 'wrap',
604605
render: function (): React.Node {
605606
return (
606-
<Text>
607+
<Text testID="text-wrap">
607608
The text should wrap if it goes on multiple lines. See, this is going
608609
to the next line.
609610
</Text>
@@ -612,15 +613,21 @@ const examples = [
612613
},
613614
{
614615
title: "Substring Emoji (should only see 'test')",
616+
name: 'substringEmoji',
615617
render: function (): React.Node {
616-
return <Text>{'test🙃'.substring(0, 5)}</Text>;
618+
return (
619+
<Text testID="text-substring-emoji">{'test🙃'.substring(0, 5)}</Text>
620+
);
617621
},
618622
},
619623
{
620624
title: 'Transparent Background Color',
625+
name: 'transparentBackgroundColor',
621626
render: function (): React.Node {
622627
return (
623-
<Text style={{backgroundColor: '#00000020', padding: 10}}>
628+
<Text
629+
testID="text-transparent-bg"
630+
style={{backgroundColor: '#00000020', padding: 10}}>
624631
Text in a gray box!
625632
<Text style={{backgroundColor: 'red'}}>
626633
Another text in a (inline) red box (which is inside the gray box).
@@ -711,9 +718,10 @@ const examples = [
711718
},
712719
{
713720
title: 'Padding',
721+
name: 'padding',
714722
render: function (): React.Node {
715723
return (
716-
<Text style={{padding: 10}}>
724+
<Text testID="text-padding" style={{padding: 10}}>
717725
This text is indented by 10px padding on all sides.
718726
</Text>
719727
);
@@ -1033,19 +1041,21 @@ const examples = [
10331041
},
10341042
{
10351043
title: 'Spaces',
1044+
name: 'spaces',
10361045
render: function (): React.Node {
10371046
return (
1038-
<Text>
1047+
<Text testID="text-spaces">
10391048
A {'generated'} {'string'} and some &nbsp;&nbsp;&nbsp; spaces
10401049
</Text>
10411050
);
10421051
},
10431052
},
10441053
{
10451054
title: 'Line Height',
1055+
name: 'lineHeightIOS',
10461056
render: function (): React.Node {
10471057
return (
1048-
<Text>
1058+
<Text testID="text-line-height-ios">
10491059
<Text style={{lineHeight: 35}}>
10501060
A lot of space between the lines of this long passage that should
10511061
wrap once.
@@ -1061,10 +1071,11 @@ const examples = [
10611071
},
10621072
{
10631073
title: 'backgroundColor attribute',
1074+
name: 'backgroundColorAttr',
10641075
description: 'backgroundColor is inherited from all types of views.',
10651076
render: function (): React.Node {
10661077
return (
1067-
<Text style={{backgroundColor: 'yellow'}}>
1078+
<Text testID="text-bg-color-attr" style={{backgroundColor: 'yellow'}}>
10681079
Yellow container background,
10691080
<Text style={{backgroundColor: '#ffaaaa'}}>
10701081
{' '}
@@ -1289,9 +1300,10 @@ const examples = [
12891300
},
12901301
{
12911302
title: 'Font variants',
1303+
name: 'fontVariants',
12921304
render: function (): React.Node {
12931305
return (
1294-
<View>
1306+
<View testID="text-font-variants">
12951307
<Text style={{fontVariant: ['small-caps']}}>Small Caps{'\n'}</Text>
12961308
<Text
12971309
style={{
@@ -1370,9 +1382,10 @@ const examples = [
13701382
},
13711383
{
13721384
title: 'Transform',
1385+
name: 'textTransform',
13731386
render: function (): React.Node {
13741387
return (
1375-
<View>
1388+
<View testID="text-transform">
13761389
<Text style={{textTransform: 'uppercase'}}>
13771390
This text should be uppercased.
13781391
</Text>
@@ -1429,6 +1442,7 @@ const examples = [
14291442
},
14301443
{
14311444
title: 'Line Break Strategy',
1445+
name: 'lineBreakStrategy',
14321446
render: function (): React.Node {
14331447
const lineBreakStrategy = [
14341448
'none',
@@ -1444,7 +1458,7 @@ const examples = [
14441458
};
14451459

14461460
return (
1447-
<View>
1461+
<View testID="text-line-break-strategy">
14481462
{lineBreakStrategy.map(strategy => {
14491463
return (
14501464
<View key={strategy} style={{marginBottom: 12}}>

0 commit comments

Comments
 (0)