mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Use ReactDOM Test Selector API in DevTools e2e tests (#22978)
Builds on top of the existing Playwright tests to plug in the test selector API: https://gist.github.com/bvaughn/d3c8b8842faf2ac2439bb11773a19cec My goals in doing this are to... 1. Experiment with the new API to see what works and what doesn't. 2. Add some test selector attributes (and remove DOM-structure based selectors). 3. Focus the tests on DevTools itself (rather than the test app). I also took this opportunity to add a few new test cases– like named hooks, editable props, component search, and profiling- just to play around more with the Playwright API. Relates to issue #22646
This commit is contained in:
1 parent
ceee524a8f
commit
a4ead704ba
24 files changed
+549
-74
No files matched your search
@@ -23,6 +23,7 @@ type Props = {|
|
||||
searchIndex: number,
|
||||
searchResultsCount: number,
|
||||
searchText: string,
|
||||
testName?: ?string,
|
||||
|};
|
||||
|
||||
export default function SearchInput({
|
||||
@@ -33,6 +34,7 @@ export default function SearchInput({
|
||||
searchIndex,
|
||||
searchResultsCount,
|
||||
searchText,
|
||||
testName,
|
||||
}: Props) {
|
||||
const inputRef = useRef<HTMLInputElement | null>(null);
|
||||
|
||||
@@ -78,9 +80,10 @@ export default function SearchInput({
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className={styles.SearchInput}>
|
||||
<div className={styles.SearchInput} data-testname={testName}>
|
||||
<Icon className={styles.InputIcon} type="search" />
|
||||
<input
|
||||
data-testname={testName ? `${testName}-Input` : undefined}
|
||||
className={styles.Input}
|
||||
onChange={handleChange}
|
||||
onKeyPress={handleKeyPress}
|
||||
@@ -90,12 +93,15 @@ export default function SearchInput({
|
||||
/>
|
||||
{!!searchText && (
|
||||
<React.Fragment>
|
||||
<span className={styles.IndexLabel}>
|
||||
<span
|
||||
className={styles.IndexLabel}
|
||||
data-testname={testName ? `${testName}-ResultsCount` : undefined}>
|
||||
{Math.min(searchIndex + 1, searchResultsCount)} |{' '}
|
||||
{searchResultsCount}
|
||||
</span>
|
||||
<div className={styles.LeftVRule} />
|
||||
<Button
|
||||
data-testname={testName ? `${testName}-PreviousButton` : undefined}
|
||||
className={styles.IconButton}
|
||||
disabled={!searchText}
|
||||
onClick={goToPreviousResult}
|
||||
@@ -108,6 +114,7 @@ export default function SearchInput({
|
||||
<ButtonIcon type="up" />
|
||||
</Button>
|
||||
<Button
|
||||
data-testname={testName ? `${testName}-NextButton` : undefined}
|
||||
className={styles.IconButton}
|
||||
disabled={!searchText}
|
||||
onClick={goToNextResult}
|
||||
@@ -119,6 +126,7 @@ export default function SearchInput({
|
||||
<ButtonIcon type="down" />
|
||||
</Button>
|
||||
<Button
|
||||
data-testname={testName ? `${testName}-ResetButton` : undefined}
|
||||
className={styles.IconButton}
|
||||
disabled={!searchText}
|
||||
onClick={resetSearch}
|
||||
|
||||
Reference in new issue
Block a user