Skip to content

Commit 4bdd49c

Browse files
committed
Gate test selectors on www
These are currently only exposed in www builds
1 parent f696a63 commit 4bdd49c

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

packages/react-dom/src/__tests__/ReactDOMTestSelectors-test.internal.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ describe('ReactDOMTestSelectors', () => {
5656
});
5757

5858
describe('findAllNodes', () => {
59+
// @gate www
5960
it('should support searching from the document root', () => {
6061
function Example() {
6162
return (
@@ -75,6 +76,7 @@ describe('ReactDOMTestSelectors', () => {
7576
expect(matches[0].id).toBe('match');
7677
});
7778

79+
// @gate www
7880
it('should support searching from the container', () => {
7981
function Example() {
8082
return (
@@ -94,6 +96,7 @@ describe('ReactDOMTestSelectors', () => {
9496
expect(matches[0].id).toBe('match');
9597
});
9698

99+
// @gate www
97100
it('should support searching from a previous match if the match had a data-testname', () => {
98101
function Outer() {
99102
return (
@@ -124,6 +127,7 @@ describe('ReactDOMTestSelectors', () => {
124127
expect(matches[0].id).toBe('inner');
125128
});
126129

130+
// @gate www
127131
it('should not support searching from a previous match if the match did not have a data-testname', () => {
128132
function Outer() {
129133
return (
@@ -153,6 +157,7 @@ describe('ReactDOMTestSelectors', () => {
153157
);
154158
});
155159

160+
// @gate www
156161
it('should support an multiple component types in the selector array', () => {
157162
function Outer() {
158163
return (
@@ -206,6 +211,7 @@ describe('ReactDOMTestSelectors', () => {
206211
expect(matches[0].id).toBe('match3');
207212
});
208213

214+
// @gate www
209215
it('should find multiple matches', () => {
210216
function Example1() {
211217
return (
@@ -243,6 +249,7 @@ describe('ReactDOMTestSelectors', () => {
243249
]);
244250
});
245251

252+
// @gate www
246253
it('should ignore nested matches', () => {
247254
function Example() {
248255
return (
@@ -262,6 +269,7 @@ describe('ReactDOMTestSelectors', () => {
262269
expect(matches[0].id).toEqual('match1');
263270
});
264271

272+
// @gate www
265273
it('should enforce the specific order of selectors', () => {
266274
function Outer() {
267275
return (
@@ -286,6 +294,7 @@ describe('ReactDOMTestSelectors', () => {
286294
).toHaveLength(0);
287295
});
288296

297+
// @gate www
289298
it('should not search within hidden subtrees', () => {
290299
const ref1 = React.createRef(null);
291300
const ref2 = React.createRef(null);
@@ -315,6 +324,7 @@ describe('ReactDOMTestSelectors', () => {
315324
expect(matches[0]).toBe(ref2.current);
316325
});
317326

327+
// @gate www
318328
it('should support filtering by display text', () => {
319329
function Example() {
320330
return (
@@ -337,6 +347,7 @@ describe('ReactDOMTestSelectors', () => {
337347
expect(matches[0].id).toBe('match');
338348
});
339349

350+
// @gate www
340351
it('should support filtering by explicit accessibiliy role', () => {
341352
function Example() {
342353
return (
@@ -361,6 +372,7 @@ describe('ReactDOMTestSelectors', () => {
361372
expect(matches[0].id).toBe('match');
362373
});
363374

375+
// @gate www
364376
it('should support filtering by explicit secondary accessibiliy role', () => {
365377
const ref = React.createRef();
366378

@@ -385,6 +397,7 @@ describe('ReactDOMTestSelectors', () => {
385397
expect(matches[0]).toBe(ref.current);
386398
});
387399

400+
// @gate www
388401
it('should support filtering by implicit accessibiliy role', () => {
389402
function Example() {
390403
return (
@@ -407,6 +420,7 @@ describe('ReactDOMTestSelectors', () => {
407420
expect(matches[0].id).toBe('match');
408421
});
409422

423+
// @gate www
410424
it('should support filtering by implicit accessibiliy role with attributes qualifications', () => {
411425
function Example() {
412426
return (
@@ -429,6 +443,7 @@ describe('ReactDOMTestSelectors', () => {
429443
expect(matches[0].id).toBe('match');
430444
});
431445

446+
// @gate www
432447
it('should support searching ahead with the has() selector', () => {
433448
function Example() {
434449
return (
@@ -464,12 +479,14 @@ describe('ReactDOMTestSelectors', () => {
464479
expect(matches[0].id).toBe('match');
465480
});
466481

482+
// @gate www
467483
it('should throw if no container can be found', () => {
468484
expect(() => findAllNodes(document.body, [])).toThrow(
469485
'Could not find React container within specified host subtree.',
470486
);
471487
});
472488

489+
// @gate www
473490
it('should throw if an invalid host root is specified', () => {
474491
const ref = React.createRef();
475492
function Example() {
@@ -485,6 +502,7 @@ describe('ReactDOMTestSelectors', () => {
485502
});
486503

487504
describe('getFindAllNodesFailureDescription', () => {
505+
// @gate www
488506
it('should describe findAllNodes failures caused by the component type selector', () => {
489507
function Outer() {
490508
return <Middle />;
@@ -514,6 +532,7 @@ No matching component was found for:
514532
);
515533
});
516534

535+
// @gate www
517536
it('should return null if findAllNodes was able to find a match', () => {
518537
function Example() {
519538
return (
@@ -549,6 +568,7 @@ No matching component was found for:
549568
};
550569
}
551570

571+
// @gate www
552572
it('should return a single rect for a component that returns a single root host element', () => {
553573
const ref = React.createRef();
554574

@@ -582,6 +602,7 @@ No matching component was found for:
582602
});
583603
});
584604

605+
// @gate www
585606
it('should return a multiple rects for multiple matches', () => {
586607
const outerRef = React.createRef();
587608
const innerRef = React.createRef();
@@ -631,6 +652,7 @@ No matching component was found for:
631652
});
632653
});
633654

655+
// @gate www
634656
it('should return a multiple rects for single match that returns a fragment', () => {
635657
const refA = React.createRef();
636658
const refB = React.createRef();
@@ -680,6 +702,7 @@ No matching component was found for:
680702
});
681703
});
682704

705+
// @gate www
683706
it('should merge overlapping rects', () => {
684707
const refA = React.createRef();
685708
const refB = React.createRef();
@@ -734,6 +757,7 @@ No matching component was found for:
734757
});
735758
});
736759

760+
// @gate www
737761
it('should merge some types of adjacent rects (if they are the same in one dimension)', () => {
738762
const refA = React.createRef();
739763
const refB = React.createRef();
@@ -833,6 +857,7 @@ No matching component was found for:
833857
});
834858
});
835859

860+
// @gate www
836861
it('should not search within hidden subtrees', () => {
837862
const refA = React.createRef();
838863
const refB = React.createRef();
@@ -889,6 +914,7 @@ No matching component was found for:
889914
});
890915

891916
describe('focusWithin', () => {
917+
// @gate www
892918
it('should return false if the specified component path has no matches', () => {
893919
function Example() {
894920
return <Child />;
@@ -909,6 +935,7 @@ No matching component was found for:
909935
expect(didFocus).toBe(false);
910936
});
911937

938+
// @gate www
912939
it('should return false if there are no focusable elements within the matched subtree', () => {
913940
function Example() {
914941
return <Child />;
@@ -926,6 +953,7 @@ No matching component was found for:
926953
expect(didFocus).toBe(false);
927954
});
928955

956+
// @gate www
929957
it('should return false if the only focusable elements are disabled', () => {
930958
function Example() {
931959
return (
@@ -943,6 +971,7 @@ No matching component was found for:
943971
expect(didFocus).toBe(false);
944972
});
945973

974+
// @gate www
946975
it('should return false if the only focusable elements are hidden', () => {
947976
function Example() {
948977
return <button hidden={true}>not clickable</button>;
@@ -956,6 +985,7 @@ No matching component was found for:
956985
expect(didFocus).toBe(false);
957986
});
958987

988+
// @gate www
959989
it('should successfully focus the first focusable element within the tree', () => {
960990
const secondRef = React.createRef(null);
961991

@@ -1010,6 +1040,7 @@ No matching component was found for:
10101040
expect(handleThirdFocus).not.toHaveBeenCalled();
10111041
});
10121042

1043+
// @gate www
10131044
it('should successfully focus the first focusable element even if application logic interferes', () => {
10141045
const ref = React.createRef(null);
10151046

@@ -1039,6 +1070,7 @@ No matching component was found for:
10391070
expect(handleFocus).toHaveBeenCalledTimes(1);
10401071
});
10411072

1073+
// @gate www
10421074
it('should not focus within hidden subtrees', () => {
10431075
const secondRef = React.createRef(null);
10441076

@@ -1162,6 +1194,7 @@ No matching component was found for:
11621194
window.IntersectionObserver = IntersectionObserver;
11631195
});
11641196

1197+
// @gate www
11651198
it('should notify a listener when the underlying instance intersection changes', () => {
11661199
const ref = React.createRef(null);
11671200

@@ -1198,6 +1231,7 @@ No matching component was found for:
11981231
expect(handleVisibilityChange).toHaveBeenCalledWith([{rect, ratio: 0.5}]);
11991232
});
12001233

1234+
// @gate www
12011235
it('should notify a listener of multiple targets when the underlying instance intersection changes', () => {
12021236
const ref1 = React.createRef(null);
12031237
const ref2 = React.createRef(null);
@@ -1274,6 +1308,7 @@ No matching component was found for:
12741308
]);
12751309
});
12761310

1311+
// @gate www
12771312
it('should stop listening when its disconnected', () => {
12781313
const ref = React.createRef(null);
12791314

@@ -1308,7 +1343,7 @@ No matching component was found for:
13081343
});
13091344

13101345
// This test reuires gating because it relies on the __DEV__ only commit hook to work.
1311-
// @gate __DEV__
1346+
// @gate www && __DEV__
13121347
it('should update which targets its listening to after a commit', () => {
13131348
const ref1 = React.createRef(null);
13141349
const ref2 = React.createRef(null);
@@ -1387,6 +1422,7 @@ No matching component was found for:
13871422
]);
13881423
});
13891424

1425+
// @gate www
13901426
it('should not observe components within hidden subtrees', () => {
13911427
const ref1 = React.createRef(null);
13921428
const ref2 = React.createRef(null);

0 commit comments

Comments
 (0)