Skip to content

Commit 960ee44

Browse files
authored
chore(browser-repl): add data-testid to lines in shell (#1454)
1 parent a1ed0f8 commit 960ee44

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

packages/browser-repl/src/components/shell-input.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ export class ShellInput extends Component<ShellInputProps, ShellInputState> {
152152
);
153153

154154
return (
155-
<LineWithIcon className={shellInput} icon={prompt}>
155+
<LineWithIcon
156+
className={shellInput}
157+
icon={prompt}
158+
data-testid="shell-input"
159+
>
156160
{editor}
157161
</LineWithIcon>
158162
);

packages/browser-repl/src/components/shell-output-line.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export class ShellOutputLine extends Component<ShellOutputLineProps> {
166166
format === 'error' && shellOutputLineError
167167
)}
168168
icon={icon}
169+
data-testid="shell-output"
169170
>
170171
{this.renderValue()}
171172
</LineWithIcon>

packages/browser-repl/src/components/utils/expandable.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ export class Expandable extends Component<ExpandableProps, ExpandableState> {
4747
onClick={this.toggle}
4848
/>);
4949

50-
return (<LineWithIcon icon={icon}>
51-
{typeof this.props.children === 'function'
52-
? this.props.children(this.state.expanded, this.toggle)
53-
: this.props.children}
54-
55-
</LineWithIcon>);
50+
return (
51+
<LineWithIcon icon={icon} data-testid="shell-output">
52+
{typeof this.props.children === 'function'
53+
? this.props.children(this.state.expanded, this.toggle)
54+
: this.props.children}
55+
</LineWithIcon>
56+
);
5657
}
5758
}

packages/browser-repl/src/components/utils/line-with-icon.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,26 @@ const lineWithIconContent = css({
2222
interface LineWithIconProps {
2323
icon: JSX.Element;
2424
className?: string;
25+
['data-testid']?: string;
2526
}
2627

2728
export class LineWithIcon extends Component<LineWithIconProps> {
2829
static propTypes = {
2930
icon: PropTypes.object.isRequired,
30-
className: PropTypes.string
31+
className: PropTypes.string,
32+
['data-testid']: PropTypes.string
3133
};
3234

3335
render(): JSX.Element {
34-
return (<div className={cx(this.props.className, lineWithIcon)}>
35-
<span className={lineWithIconIcon}>
36-
{this.props.icon}
37-
</span>
38-
<div className={lineWithIconContent}>
39-
{this.props.children}
36+
return (
37+
<div
38+
className={cx(this.props.className, lineWithIcon)}
39+
data-testid={this.props['data-testid']}
40+
>
41+
<span className={lineWithIconIcon}>{this.props.icon}</span>
42+
<div className={lineWithIconContent}>{this.props.children}</div>
4043
</div>
41-
</div>);
44+
);
4245
}
4346
}
4447

0 commit comments

Comments
 (0)