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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
import type { ChangeEventHandler } from 'react';
import React, { version as ReactVersion, useEffect, useRef, useState } from 'react';
import { AlertFilled } from '@ant-design/icons';
import type { ColProps } from 'antd/es/grid';
import classNames from 'classnames';
import scrollIntoView from 'scroll-into-view-if-needed';

import type { FormInstance } from '..';
import Form from '..';
import { resetWarned } from '../../_util/warning';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { act, fireEvent, pureRender, render, screen, waitFakeTimer } from '../../../tests/utils';
import Button from '../../button';
import Cascader from '../../cascader';
import Checkbox from '../../checkbox';
import ColorPicker from '../../color-picker';
import ConfigProvider from '../../config-provider';
import DatePicker from '../../date-picker';
import Drawer from '../../drawer';
import Input from '../../input';
import InputNumber from '../../input-number';
import zhCN from '../../locale/zh_CN';
import Modal from '../../modal';
import Radio from '../../radio';
import Select from '../../select';
import Slider from '../../slider';
import Switch from '../../switch';
import TreeSelect from '../../tree-select';
import Upload from '../../upload';
import type { NamePath } from '../interface';
import * as Util from '../util';

const { RangePicker } = DatePicker;
const { TextArea } = Input;

jest.mock('scroll-into-view-if-needed');

describe('Form', () => {
  mountTest(Form);
  mountTest(Form.Item);

  rtlTest(Form);
  rtlTest(Form.Item);

  (scrollIntoView as any).mockImplementation(() => {});
  const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
  const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});

  const changeValue = async (
    input: HTMLElement | null | number,
    value: string,
    advTimer = 1000,
  ) => {
    let element: HTMLElement;

    if (typeof input === 'number') {
      element = document.querySelectorAll('input')[input];
    }

    expect(element!).toBeTruthy();

    fireEvent.change(element!, {
      target: {
        value,
      },
    });

    if (advTimer) {
      await waitFakeTimer(advTimer / 20, 20);
    }
  };

  beforeEach(() => {
    document.body.innerHTML = '';
    jest.useFakeTimers();
    (scrollIntoView as any).mockReset();
  });

  afterEach(() => {
    errorSpy.mockReset();
  });

  afterAll(() => {
    jest.clearAllTimers();
    jest.useRealTimers();
    errorSpy.mockRestore();
    warnSpy.mockRestore();
    (scrollIntoView as any).mockRestore();
  });

  describe('noStyle Form.Item', () => {
    it('should show error when form field is required but empty', async () => {
      const onChange = jest.fn();

      const { container } = render(
        <Form>
          <Form.Item>
            <Form.Item name="test" label="test" initialValue="bamboo" rules={[{ required: true }]}>
              <Input onChange={onChange} />
            </Form.Item>
          </Form.Item>
        </Form>,
      );

      // user type something and clear
      await changeValue(0, 'test');
      await changeValue(0, '');
      // should show error with correct message and show correct styles
      expect(container.querySelector('.ant-form-item-explain')).not.toHaveAttribute('role');
      expect(container.querySelector('.ant-form-item-explain-error')).toHaveTextContent(
        "'test' is required",
      );
      expect(container.querySelector('.ant-input-status-error')).toBeTruthy();
      expect(container.querySelector('.ant-form-item-has-error')).toBeTruthy();

      expect(onChange).toHaveBeenCalled();
    });

    it('should clean up', async () => {
      const Demo: React.FC = () => {
        const [form] = Form.useForm();

        const onChange = async () => {
          // Wait a while and then some logic to validate
          await waitFakeTimer();

          try {
            await act(async () => {
              await form.validateFields();
            });
          } catch {
            // do nothing
          }
        };

        return (
          <Form form={form} initialValues={{ aaa: '2' }}>
            <Form.Item name="aaa">
              <Input onChange={onChange} />
            </Form.Item>
            <Form.Item shouldUpdate noStyle>
              {() => {
                const aaa = form.getFieldValue('aaa');

                if (aaa === '1') {
                  return (
                    <Form.Item name="bbb" rules={[{ required: true, message: 'aaa' }]}>
                      <Input />
                    </Form.Item>
                  );
                }

                return (
                  <Form.Item>
                    <Form.Item name="ccc" rules={[{ required: true, message: 'ccc' }]} noStyle>
                      <Input />
                    </Form.Item>
                  </Form.Item>
                );
              }}
            </Form.Item>
          </Form>
        );
      };

      const { container } = render(<Demo />);

      await changeValue(0, '1');
      await waitFakeTimer(2000, 2000);
      expect(container.querySelector('.ant-form-item-explain-error')).toHaveTextContent('aaa');

      await changeValue(0, '2');
      await waitFakeTimer(2000, 2000);
      expect(container.querySelector('.ant-form-item-explain-error')).toHaveTextContent('ccc');

      await changeValue(0, '1');
      await waitFakeTimer(2000, 2000);
      expect(container.querySelector('.ant-form-item-explain-error')).toHaveTextContent('aaa');
    });

    // https://github.com/ant-design/ant-design/issues/41620
    it('should not throw error when `help=false` and `noStyle=true`', async () => {
      const App: React.FC<{ help?: React.ReactNode }> = (props) => {
        const { help = false } = props || {};
        return (
          <Form>
            <Form.Item name="list" label="List" rules={[{ required: true }]}>
              <Form.Item name={['list', 0]} noStyle help={help} rules={[{ required: true }]}>
                <Input />
              </Form.Item>
              <Form.Item name={['list', 1]} noStyle help={help} rules={[{ required: true }]}>
                <Input />
              </Form.Item>
            </Form.Item>
            <Form.Item>
              <button type="submit">submit</button>
            </Form.Item>
          </Form>
        );
      };

      const { container, getByRole, rerender } = render(<App />);

      // click submit to trigger validate
      fireEvent.click(getByRole('button'));

      await waitFakeTimer();
      expect(container.querySelectorAll('.ant-form-item-explain-error')).toHaveLength(1);

      // When noStyle=true but help is not false, help will be displayed
      rerender(<App help="help" />);
      await waitFakeTimer();
      fireEvent.click(getByRole('button'));
      await waitFakeTimer();
      expect(container.querySelectorAll('.ant-form-item-explain-error')).toHaveLength(3);
    });
  });

  it('render functions require either `shouldUpdate` or `dependencies`', () => {
    render(
      <Form>
        <Form.Item>{() => null}</Form.Item>
      </Form>,
    );
    expect(errorSpy).toHaveBeenCalledWith(
      'Warning: [antd: Form.Item] A `Form.Item` with a render function must have either `shouldUpdate` or `dependencies`.',
    );
  });

  it("`shouldUpdate` shouldn't work with `dependencies`", () => {
    render(
      <Form>
        <Form.Item shouldUpdate dependencies={[]}>
          {() => null}
        </Form.Item>
      </Form>,
    );
    expect(errorSpy).toHaveBeenCalledWith(
      "Warning: [antd: Form.Item] `shouldUpdate` and `dependencies` shouldn't be used together. See https://u.ant.design/form-deps.",
    );
  });

  it('`name` should not work with render props', () => {
    render(
      <Form>
        <Form.Item name="test" shouldUpdate>
          {() => null}
        </Form.Item>
      </Form>,
    );
    expect(errorSpy).toHaveBeenCalledWith(
      'Warning: [antd: Form.Item] A `Form.Item` with a render function cannot be a field, and thus cannot have a `name` prop.',
    );
  });

  it('multiple children with a name prop', () => {
    render(
      <Form>
        <Form.Item name="test">
          <div>one</div>
          <div>two</div>
        </Form.Item>
      </Form>,
    );
    expect(errorSpy).toHaveBeenCalledWith(
      'Warning: [antd: Form.Item] A `Form.Item` with a `name` prop must have a single child element. For information on how to render more complex form items, see https://u.ant.design/complex-form-item.',
    );
  });

  it('input element should have the prop aria-describedby pointing to the help id when there is a help message', () => {
    const { container } = pureRender(
      <Form>
        <Form.Item name="test" help="This is a help">
          <input />
        </Form.Item>
      </Form>,
    );
    expect(container.querySelector('input')?.getAttribute('aria-describedby')).toBe('test_help');
    expect(container.querySelector('.ant-form-item-explain')?.id).toBe('test_help');
  });

  it('input element should not have the prop aria-describedby pointing to the help id when there is a help message and name is not defined', () => {
    const { container } = render(
      <Form>
        <Form.Item help="This is a help">
          <input />
        </Form.Item>
      </Form>,
    );
    expect(container.querySelector('input')?.getAttribute('aria-describedby')).toBeFalsy();
    expect(container.querySelector('.ant-form-item-explain')?.id).toBeFalsy();
  });

  it('input element should have the prop aria-describedby concatenated with the form name pointing to the help id when there is a help message', () => {
    const { container } = render(
      <Form name="form">
        <Form.Item name="test" help="This is a help">
          <input />
        </Form.Item>
      </Form>,
    );
    expect(container.querySelector('input')?.getAttribute('aria-describedby')).toBe(
      'form_test_help',
    );
    expect(container.querySelector('.ant-form-item-explain')?.id).toBe('form_test_help');
  });

  it('input element should have the prop aria-describedby pointing to the help id when there are errors', async () => {
    const { container } = pureRender(
      <Form>
        <Form.Item name="test" rules={[{ len: 3 }, { type: 'number' }]}>
          <input />
        </Form.Item>
      </Form>,
    );

    await changeValue(0, 'Invalid number');

    expect(container.querySelector('input')?.getAttribute('aria-describedby')).toBe('test_help');
    expect(container.querySelector('.ant-form-item-explain')?.id).toBe('test_help');
  });

  it('input element should have the prop aria-invalid when there are errors', async () => {
    const { container } = render(
      <Form>
        <Form.Item name="test" rules={[{ len: 3 }, { type: 'number' }]}>
          <input />
        </Form.Item>
      </Form>,
    );

    await changeValue(0, 'Invalid number');
    expect(container.querySelector('input')?.getAttribute('aria-invalid')).toBe('true');
  });

  it('input element should have the prop aria-required when the prop `required` is true', () => {
    const { container } = render(
      <Form>
        <Form.Item name="test" required>
          <input />
        </Form.Item>
      </Form>,
    );
    expect(container.querySelector('input')?.getAttribute('aria-required')).toBe('true');
  });

  it('input element should have the prop aria-required when there is a rule with required', () => {
    const { container } = render(
      <Form>
        <Form.Item name="test" rules={[{ required: true }]}>
          <input />
        </Form.Item>
      </Form>,
    );
    expect(container.querySelector('input')?.getAttribute('aria-required')).toBe('true');
  });

  it('input element should have the prop aria-describedby pointing to the extra id when there is a extra message', () => {
    const { container } = render(
      <Form>
        <Form.Item name="test" extra="This is a extra message">
          <input />
        </Form.Item>
      </Form>,
    );
    expect(container.querySelector('input')?.getAttribute('aria-describedby')).toBe('test_extra');
    expect(container.querySelector('.ant-form-item-extra')?.id).toBe('test_extra');
  });

  it('input element should not have the prop aria-describedby pointing to the extra id when there is a extra message and name is not defined', () => {
    const { container } = render(
      <Form>
        <Form.Item extra="This is a extra message">
          <input />
        </Form.Item>
      </Form>,
    );
    expect(container.querySelector('input')?.getAttribute('aria-describedby')).toBeFalsy();
    expect(container.querySelector('.ant-form-item-extra')?.id).toBeFalsy();
  });

  it('input element should have the prop aria-describedby pointing to the help and extra id when there is a help and extra message', () => {
    const { container } = render(
      <Form>
        <Form.Item name="test" help="This is a help" extra="This is a extra message">
          <input />
        </Form.Item>
      </Form>,
    );
    expect(container.querySelector('input')?.getAttribute('aria-describedby')).toBe(
      'test_help test_extra',
    );
  });

  describe('scrollToField', () => {
    const test = (name: string, genForm: () => any) => {
      it(name, () => {
        let callGetForm: any;

        const Demo: React.FC = () => {
          const { props, getForm } = genForm();
          callGetForm = getForm;

          return (
            <Form name="scroll" {...props}>
              <Form.Item name="test">
                <Input />
              </Form.Item>
            </Form>
          );
        };

        render(<Demo />);

        expect(scrollIntoView).not.toHaveBeenCalled();
        const form = callGetForm();
        form.scrollToField('test', {
          block: 'start',
        });

        const inputNode = document.getElementById('scroll_test');
        expect(scrollIntoView).toHaveBeenCalledWith(inputNode, {
          block: 'start',
          scrollMode: 'if-needed',
        });
      });
    };

    // hooks
    test('useForm', () => {
      const [form] = Form.useForm();
      return {
        props: { form },
        getForm: () => form,
      };
    });

    // ref
    test('ref', () => {
      let form: any;
      return {
        props: {
          ref: (instance: any) => {
            form = instance;
          },
        },
        getForm: () => form,
      };
    });

    it('should work with id', () => {
      const MyComponent = ({ id }: { id?: string }) => <input type="text" id={id} />;

      let formInstance: any;
      const Demo = () => {
        const [form] = Form.useForm();
        formInstance = form;
        return (
          <Form>
            <Form.Item name="test">
              <MyComponent />
            </Form.Item>
          </Form>
        );
      };

      const { getByRole } = render(<Demo />);
      const input = getByRole('textbox');

      expect(input.id).toBe('test');
      formInstance.scrollToField('test');
      expect(scrollIntoView).toHaveBeenCalledWith(input, expect.any(Object));
    });
  });

  describe('scrollToField with focus', () => {
    it('focusField should work', () => {
      let formInstance: any;
      const Demo = () => {
        const [form] = Form.useForm();
        formInstance = form;
        return (
          <Form>
            <Form.Item name="test">
              <input type="text" />
            </Form.Item>
          </Form>
        );
      };

      const { getByRole } = render(<Demo />);
      const input = getByRole('textbox');

      formInstance.focusField('test');
      expect(input).toHaveFocus();
    });

    // https://github.com/ant-design/ant-design/pull/52712#issuecomment-2646831569
    it('focusField should work with Select', () => {
      let formInstance: any;

      const Demo = () => {
        const [form] = Form.useForm();
        formInstance = form;
        return (
          <Form form={form}>
            <Form.Item name="test">
              <Select
                options={[
                  { label: 'afc163', value: 'A' },
                  { label: 'Wxh16144', value: 'B' },
                ]}
              />
            </Form.Item>
          </Form>
        );
      };

      const { getByRole } = render(<Demo />);
      const select = getByRole('combobox');

      formInstance.focusField('test');
      expect(select).toHaveFocus();
    });
  });

  describe('scrollToFirstError', () => {
    it('should work with scrollToFirstError', async () => {
      const onFinishFailed = jest.fn();

      const { container } = render(
        <Form scrollToFirstError={{ block: 'center' }} onFinishFailed={onFinishFailed}>
          <Form.Item name="test" rules={[{ required: true }]}>
            <input />
          </Form.Item>
          <Form.Item>
            <Button htmlType="submit">Submit</Button>
          </Form.Item>
        </Form>,
      );

      expect(scrollIntoView).not.toHaveBeenCalled();
      fireEvent.submit(container.querySelector('form')!);
      await waitFakeTimer();

      const inputNode = document.getElementById('test');
      expect(scrollIntoView).toHaveBeenCalledWith(inputNode, {
        block: 'center',
        scrollMode: 'if-needed',
      });
      expect(onFinishFailed).toHaveBeenCalled();
    });

    it('should work with scrollToFirstError with ref', async () => {
      const ForwardRefInput = React.forwardRef<HTMLInputElement, any>(({ id, ...props }, ref) => (
        <input {...props} ref={ref} />
      ));

      const NativeInput = React.forwardRef<any, any>(({ id, ...props }, ref) => {
        const internalRef = React.useRef<HTMLInputElement>(null);
        React.useImperativeHandle(ref, () => ({
          nativeElement: internalRef.current,
        }));
        return <input {...props} ref={internalRef} />;
      });

      const NormalInput = (props: any) => <input {...props} />;

      const { getByRole, getAllByRole } = render(
        <Form scrollToFirstError>
          <Form.Item name="foo" rules={[{ required: true }]}>
            <ForwardRefInput />
          </Form.Item>
          <Form.Item name="bar" rules={[{ required: true }]}>
            <NativeInput />
          </Form.Item>
          <Form.Item name="baz" rules={[{ required: true }]}>
            <NormalInput />
          </Form.Item>
          <Form.Item>
            <Button htmlType="submit">Submit</Button>
          </Form.Item>
        </Form>,
      );

      // click submit to trigger validate
      const allInputs = getAllByRole('textbox');
      const button = getByRole('button');
      expect(allInputs).toHaveLength(3);

      fireEvent.click(button);
      await waitFakeTimer();

      expect(scrollIntoView).toHaveBeenNthCalledWith(1, allInputs[0], expect.any(Object));

      // change the value of the first input
      fireEvent.change(allInputs[0], { target: { value: '123' } });
      fireEvent.click(button);
      await waitFakeTimer();

      expect(scrollIntoView).toHaveBeenNthCalledWith(2, allInputs[1], expect.any(Object));

      // change the value of the second input
      fireEvent.change(allInputs[1], { target: { value: 'abc' } });
      fireEvent.click(button);
      await waitFakeTimer();

      expect(scrollIntoView).toHaveBeenNthCalledWith(3, allInputs[2], expect.any(Object));

      expect(scrollIntoView).toHaveBeenCalledTimes(3);
    });

    it('should scrollToFirstError work with focus', async () => {
      const onFinishFailed = jest.fn();

      const { container } = render(
        <Form scrollToFirstError={{ block: 'center', focus: true }} onFinishFailed={onFinishFailed}>
          <Form.Item name="test" rules={[{ required: true }]}>
            <input />
          </Form.Item>
          <Form.Item>
            <Button htmlType="submit">Submit</Button>
          </Form.Item>
        </Form>,
      );

      expect(scrollIntoView).not.toHaveBeenCalled();

      fireEvent.submit(container.querySelector('form')!);
      await waitFakeTimer();

      const inputNode = document.getElementById('test');
      expect(scrollIntoView).toHaveBeenCalledWith(inputNode, {
        block: 'center',
        scrollMode: 'if-needed',
      });

      expect(inputNode).toHaveFocus();
    });

    // https://github.com/ant-design/ant-design/issues/28869
    it('should work with Upload', async () => {
      const uploadRef = React.createRef<any>();

      const { getByRole } = render(
        <Form scrollToFirstError>
          <Form.Item
            name="demo-form_dragger"
            valuePropName="fileList"
            getValueFromEvent={(e) => (Array.isArray(e) ? e : e?.fileList)}
            rules={[{ required: true }]}
          >
            <Upload name="files" action="/upload.do" ref={uploadRef} />
          </Form.Item>
          <Form.Item>
            <Button htmlType="submit">Submit</Button>
          </Form.Item>
        </Form>,
      );
      fireEvent.click(getByRole('button'));
      await waitFakeTimer();

      expect(scrollIntoView).toHaveBeenCalled();
      expect((scrollIntoView as any).mock.calls[0][0]).toBe(uploadRef.current.nativeElement);
    });

    // https://github.com/ant-design/ant-design/issues/48981
    it('should not throw error when use InputNumber', async () => {
      const inputNumberRef = React.createRef<any>();

      const { getByText } = render(
        <Form scrollToFirstError>
          <Form.Item name="demo-form_input-number" rules={[{ required: true }]}>
            <InputNumber ref={inputNumberRef} />
          </Form.Item>
          <Form.Item>
            <Button htmlType="submit">Submit</Button>
          </Form.Item>
        </Form>,
      );
      fireEvent.click(getByText('Submit'));
      await waitFakeTimer();
      expect(scrollIntoView).toHaveBeenCalled();
      expect((scrollIntoView as any).mock.calls[0][0]).toBe(inputNumberRef.current?.nativeElement);
    });
  });

  it('Form.Item should support data-*、aria-* and custom attribute', () => {
    const { container } = render(
      <Form>
        {/* @ts-ignore */}
        <Form.Item data-text="123" aria-hidden="true" cccc="bbbb">
          text
        </Form.Item>
      </Form>,
    );
    expect(container.firstChild).toMatchSnapshot();
  });

  it('warning when use `name` but children is not validate element', () => {
    render(
      <Form>
        <Form.Item name="warning">text</Form.Item>
      </Form>,
    );
    expect(errorSpy).toHaveBeenCalledWith(
      'Warning: [antd: Form.Item] `name` is only used for validate React element. If you are using Form.Item as layout display, please remove `name` instead.',
    );
  });

  it('No warning when use noStyle and children is empty', () => {
    render(
      <Form>
        <Form.Item name="noWarning" noStyle />
      </Form>,
    );
    expect(errorSpy).not.toHaveBeenCalled();
  });

  it('dynamic change required', async () => {
    const { container } = render(
      <Form>
        <Form.Item label="light" name="light" valuePropName="checked">
          <input type="checkbox" />
        </Form.Item>
        <Form.Item
          label="bamboo"
          name="bamboo"
          dependencies={['light']}
          rules={[({ getFieldValue }) => ({ required: getFieldValue('light') })]}
        >
          <input />
        </Form.Item>
      </Form>,
    );

    // should not show alert by default
    expect(container.querySelector('.ant-form-item-explain')).toBeFalsy();

    // click to change the light field value to true
    fireEvent.click(container.querySelector('input')!);
    await waitFakeTimer();

    // user input something and clear
    await changeValue(1, '1');
    await changeValue(1, '');

    // should show alert says that the field is required
    expect(container.querySelector('.ant-form-item-explain-error')).toHaveTextContent(
      "'bamboo' is required",
    );
  });

  describe('should show related className when customize help', () => {
    it('normal', async () => {
      const { container } = render(
        <Form>
          <Form.Item help="good">
            <input />
          </Form.Item>
        </Form>,
      );

      await waitFakeTimer();

      expect(container.querySelector('.ant-form-item-explain')).toHaveTextContent('good');
      expect(container.querySelector('.ant-form-item-with-help')).toBeTruthy();
    });

    it('empty string', async () => {
      const { container } = render(
        <Form>
          <Form.Item help="">
            <input />
          </Form.Item>
        </Form>,
      );

      await waitFakeTimer();

      expect(container.querySelector('.ant-form-item-explain')).toHaveTextContent('');
      expect(container.querySelector('.ant-form-item-with-help')).toBeTruthy();
    });
  });

  it('warning when use v3 function', () => {
    Form.create();
    expect(errorSpy).toHaveBeenCalledWith(
      'Warning: [antd: Form] antd v4 removed `Form.create`. Please remove or use `@ant-design/compatible` instead.',
    );
  });

  // https://github.com/ant-design/ant-design/issues/20706
  it('Error change should work', async () => {
    const { container } = render(
      <Form>
        <Form.Item
          name="name"
          label="test"
          rules={[
            { required: true },
            {
              validator: (_, value) => {
                if (value === 'p') {
                  return Promise.reject(new Error('not a p'));
                }
                return Promise.resolve();
              },
            },
          ]}
        >
          <Input />
        </Form.Item>
      </Form>,
    );

    for (let i = 0; i < 3; i += 1) {
      await changeValue(0, 'bamboo');
      await changeValue(0, '');
      expect(container.querySelector('.ant-form-item-explain')?.textContent).toEqual(
        "'name' is required",
      );

      await changeValue(0, 'p');
      expect(container.querySelector('.ant-form-item-explain')?.textContent).toEqual('not a p');
    }
  });

  // https://github.com/ant-design/ant-design/issues/20813
  it('should update help directly when provided', async () => {
    const App: React.FC = () => {
      const [message, updateMessage] = React.useState('');
      return (
        <Form>
          <Form.Item label="hello" help={message}>
            <Input />
          </Form.Item>
          <Button onClick={() => updateMessage('bamboo')} />
        </Form>
      );
    };

    const { container } = render(<App />);

    // should show initial text
    await waitFakeTimer();
    expect(container.querySelector('.ant-form-item-explain')).toHaveTextContent('');

    fireEvent.click(container.querySelector('button')!);

    // should show bamboo alert without opacity and hide first alert with opacity: 0
    await waitFakeTimer();
    expect(container.querySelector('.ant-form-item-explain')).toHaveTextContent('bamboo');
  });

  it('warning when use `dependencies` but `name` is empty & children is not a render props', () => {
    render(
      <Form>
        <Form.Item dependencies={[]}>text</Form.Item>
      </Form>,
    );
    expect(errorSpy).toHaveBeenCalledWith(
      'Warning: [antd: Form.Item] Must set `name` or use a render function when `dependencies` is set.',
    );
  });

  // https://github.com/ant-design/ant-design/issues/20948
  it('not repeat render when Form.Item is not a real Field', async () => {
    const shouldNotRender = jest.fn();
    const StaticInput: React.FC<React.InputHTMLAttributes<HTMLInputElement>> = ({
      id,
      value = '',
    }) => {
      shouldNotRender();
      return <input id={id} value={value} />;
    };

    const shouldRender = jest.fn();
    const DynamicInput: React.FC<React.InputHTMLAttributes<HTMLInputElement>> = ({
      value = '',
      id,
    }) => {
      shouldRender(value);
      return <input id={id} value={value} />;
    };

    const Demo = () => {
      const [form] = Form.useForm();

      return (
        <Form form={form}>
          <Form.Item>
            <StaticInput />
          </Form.Item>
          <Form.Item name="light">
            <DynamicInput id="changed" />
          </Form.Item>
          <Button id="fill-btn" onClick={() => form.setFieldValue('light', 'bamboo')}>
            fill
          </Button>
        </Form>
      );
    };

    const { container } = pureRender(<Demo />);

    await waitFakeTimer();

    expect(container.querySelector<HTMLInputElement>('#changed')!.value).toEqual('');
    expect(shouldNotRender).toHaveBeenCalledTimes(1);
    expect(shouldRender).toHaveBeenCalledTimes(1);

    fireEvent.click(container.querySelector('#fill-btn')!);
    await waitFakeTimer();

    expect(shouldNotRender).toHaveBeenCalledTimes(1);
    expect(shouldRender).toHaveBeenLastCalledWith('bamboo');
    expect(shouldRender).toHaveBeenCalledTimes(2);
  });

  it('empty help should also render', () => {
    const { container } = render(
      <Form.Item help="">
        <input />
      </Form.Item>,
    );
    expect(container.querySelectorAll('.ant-form-item-explain').length).toBeTruthy();
  });

  it('Form.Item with `help` should display error style when validate failed', async () => {
    const { container } = render(
      <Form>
        <Form.Item
          name="test"
          label="test"
          help="help"
          initialValue="bamboo"
          rules={[{ required: true, message: 'message' }]}
        >
          <Input />
        </Form.Item>
      </Form>,
    );

    await changeValue(0, '');
    expect(container.querySelector('.ant-form-item')).toHaveClass('ant-form-item-has-error');
    expect(container.querySelector('.ant-form-item-explain')!.textContent).toEqual('help');
  });

  it('clear validation message when', async () => {
    const { container } = render(
      <Form>
        <Form.Item name="test" label="test" rules={[{ required: true, message: 'message' }]}>
          <Input />
        </Form.Item>
      </Form>,
    );

    await changeValue(0, '1');
    expect(container.querySelectorAll('.ant-form-item-explain').length).toBeFalsy();

    await changeValue(0, '');
    expect(container.querySelectorAll('.ant-form-item-explain').length).toBeTruthy();

    await changeValue(0, '123');
    expect(container.querySelectorAll('.ant-form-item-explain').length).toBeFalsy();
  });

  // https://github.com/ant-design/ant-design/issues/21167
  it('`require` without `name`', () => {
    const { container } = render(
      <Form.Item label="test" name="test" required>
        <input />
      </Form.Item>,
    );

    // expect(screen.getByTitle('test')).toHaveClass('ant-form-item-required');
    expect(container.querySelector('.ant-form-item-required')).toBeTruthy();
  });

  it('0 is a validate Field', () => {
    render(
      <Form.Item name={0} label="0">
        <input />
      </Form.Item>,
    );

    // if getByLabelText can get element, then it is a validate field with form control and label
    expect(screen.getByLabelText('0')).toBeInTheDocument();
  });

  it('`null` triggers warning and is treated as `undefined`', () => {
    render(
      <Form.Item name={null as unknown as NamePath} label="test">
        <input />
      </Form.Item>,
    );

    // if getByLabelText can get element, then it is a validate field with form control and label
    expect(screen.queryByLabelText('test')).not.toBeInTheDocument();
    expect(errorSpy).toHaveBeenCalledWith(
      'Warning: [antd: Form.Item] `null` is passed as `name` property',
    );
  });

  // https://github.com/ant-design/ant-design/issues/21415
  it('should not throw error when Component.props.onChange is null', async () => {
    const CustomComponent: React.FC = () => (
      <input onChange={null as unknown as ChangeEventHandler<HTMLInputElement>} />
    );
    render(
      <Form>
        <Form.Item name="custom">
          <CustomComponent />
        </Form.Item>
      </Form>,
    );

    await changeValue(0, 'aaa');
  });

  it('change `help` should not warning', async () => {
    const Demo: React.FC = () => {
      const [error, setError] = React.useState(false);
      return (
        <Form>
          <Form.Item
            help={error ? 'This is an error msg' : undefined}
            validateStatus={error ? 'error' : ''}
            label="Username"
            name="username"
          >
            <input />
          </Form.Item>

          <Form.Item>
            <button type="button" onClick={() => setError(!error)}>
              Trigger
            </button>
          </Form.Item>
        </Form>
      );
    };

    const { container } = render(<Demo />);
    fireEvent.click(container.querySelector('button')!);

    expect(errorSpy).not.toHaveBeenCalled();
  });

  it('`label` support template', async () => {
    const { container } = render(
      // eslint-disable-next-line no-template-curly-in-string
      <Form validateMessages={{ required: '${label} is good!' }}>
        <Form.Item name="test" label="Bamboo" rules={[{ required: true }]}>
          <input />
        </Form.Item>
      </Form>,
    );

    fireEvent.submit(container.querySelector('form')!);
    await waitFakeTimer();

    expect(container.querySelector('.ant-form-item-explain-error')).toHaveTextContent(
      'Bamboo is good!',
    );
  });

  // https://github.com/ant-design/ant-design/issues/33691
  it('should keep upper locale in nested ConfigProvider', async () => {
    const { container } = render(
      <ConfigProvider locale={zhCN}>
        <ConfigProvider>
          <Form>
            <Form.Item name="test" label="Bamboo" rules={[{ required: true }]}>
              <input />
            </Form.Item>
          </Form>
        </ConfigProvider>
      </ConfigProvider>,
    );

    fireEvent.submit(container.querySelector('form')!);
    await waitFakeTimer();

    expect(container.querySelector('.ant-form-item-explain-error')).toHaveTextContent(
      '请输入Bamboo',
    );
  });

  it('`name` support template when label is not provided', async () => {
    const { container } = render(
      // eslint-disable-next-line no-template-curly-in-string
      <Form validateMessages={{ required: '${label} is good!' }}>
        <Form.Item name="Bamboo" rules={[{ required: true }]}>
          <input />
        </Form.Item>
      </Form>,
    );

    fireEvent.submit(container.querySelector('form')!);
    await waitFakeTimer();

    expect(container.querySelector('.ant-form-item-explain-error')).toHaveTextContent(
      'Bamboo is good!',
    );
  });

  it('`messageVariables` support validate', async () => {
    const { container } = render(
      // eslint-disable-next-line no-template-curly-in-string
      <Form validateMessages={{ required: '${label} is good!' }}>
        <Form.Item name="test" messageVariables={{ label: 'Bamboo' }} rules={[{ required: true }]}>
          <input />
        </Form.Item>
      </Form>,
    );

    fireEvent.submit(container.querySelector('form')!);
    await waitFakeTimer();

    expect(container.querySelector('.ant-form-item-explain-error')).toHaveTextContent(
      'Bamboo is good!',
    );
  });

  it('validation message should have correct error', async () => {
    // https://github.com/ant-design/ant-design/issues/25711
    const { container } = render(
      <Form validateMessages={{ required: 'name is good!' }}>
        <Form.Item name="test" rules={[{ required: true }]}>
          <input />
        </Form.Item>
        <Form.Item>
          <Button htmlType="submit">Submit</Button>
        </Form.Item>
      </Form>,
    );

    fireEvent.submit(container.querySelector('form')!);
    await waitFakeTimer();

    expect(container.querySelector('.ant-form-item-explain')).not.toHaveAttribute('role');
    expect(container.querySelector('.ant-form-item-explain-error')).toHaveTextContent(
      'name is good!',
    );
  });

  it('return same form instance', async () => {
    const instances = new Set();

    const App: React.FC = () => {
      const [form] = Form.useForm();
      instances.add(form);
      const [, forceUpdate] = React.useState({});
      return (
        <button
          type="button"
          onClick={() => {
            forceUpdate({});
          }}
        >
          Refresh
        </button>
      );
    };

    const { container } = pureRender(<App />);

    for (let i = 0; i < 5; i += 1) {
      fireEvent.click(container.querySelector('button')!);

      await waitFakeTimer();
    }

    expect(instances.size).toBe(1);
  });

  it('should avoid re-render', async () => {
    let renderTimes = 0;

    const MyInput: React.FC<{ value?: string }> = ({ value = '', ...props }) => {
      renderTimes += 1;
      return <input value={value} {...props} />;
    };

    const Demo: React.FC = () => (
      <Form>
        <Form.Item name="username" label="username" rules={[{ required: true }]}>
          <MyInput />
        </Form.Item>
      </Form>
    );
    const { container } = pureRender(<Demo />);
    renderTimes = 0;

    await changeValue(0, 'a');

    expect(renderTimes).toEqual(1);
    expect(container.querySelector('input')).toHaveValue('a');
  });

  it('should warning with `defaultValue`', () => {
    render(
      <Form>
        <Form.Item name="light">
          <input defaultValue="should warning" />
        </Form.Item>
      </Form>,
    );

    expect(errorSpy).toHaveBeenCalledWith(
      'Warning: [antd: Form.Item] `defaultValue` will not work on controlled Field. You should use `initialValues` of Form instead.',
    );
  });

  it('should remove Field and also reset error', async () => {
    const Demo: React.FC<{ showA?: boolean }> = ({ showA }) => (
      <Form>
        {showA ? (
          <Form.Item name="a" help="error">
            <input />
          </Form.Item>
        ) : (
          <Form.Item name="b">
            <input />
          </Form.Item>
        )}
      </Form>
    );

    const { container, rerender } = render(<Demo showA />);

    await waitFakeTimer();
    expect(container.querySelector('.ant-form-item-explain')).toBeTruthy();

    rerender(<Demo showA={false} />);

    await waitFakeTimer();
    expect(container.querySelector('.ant-form-item-explain')).toBeFalsy();
  });

  it('no warning of initialValue & getValueProps & preserve', () => {
    render(
      <Form>
        <Form.Item initialValue="bamboo" getValueProps={() => ({})} preserve={false}>
          <Input />
        </Form.Item>
      </Form>,
    );
    expect(errorSpy).not.toHaveBeenCalled();
  });

  it('should customize id when pass with id', () => {
    const { container } = render(
      <Form>
        <Form.Item name="light">
          <Input id="bamboo" />
        </Form.Item>
      </Form>,
    );

    expect(container.querySelector('input')!.id).toEqual('bamboo');
  });

  it('should trigger validate when onBlur when pass validateTrigger onBlur', async () => {
    const { container } = render(
      <Form validateTrigger="onBlur">
        <Form.Item name="light" label="light" rules={[{ len: 3 }]}>
          <Input />
        </Form.Item>
      </Form>,
    );

    // type a invalidate value, not trigger validation
    await changeValue(0, '7777');
    expect(container.querySelector('.ant-form-item-explain')).toBeFalsy();

    // tab(onBlur) the input field, trigger and see the alert
    fireEvent.blur(container.querySelector('input')!);
    await waitFakeTimer();

    expect(container.querySelector('.ant-form-item-explain')).toBeTruthy();
  });

  describe('Form item hidden', () => {
    it('should work', () => {
      const { container } = render(
        <Form>
          <Form.Item name="light" hidden>
            <Input />
          </Form.Item>
        </Form>,
      );
      expect(container.firstChild).toMatchSnapshot();
    });

    it('noStyle should not work when hidden', () => {
      const { container } = render(
        <Form>
          <Form.Item name="light" hidden noStyle>
            <Input />
          </Form.Item>
        </Form>,
      );
      expect(container.firstChild).toMatchSnapshot();
    });
  });

  describe('legacy hideRequiredMark', () => {
    it('should work', () => {
      const { container } = render(
        <Form hideRequiredMark role="form">
          <Form.Item name="light" label="light" required>
            <Input />
          </Form.Item>
        </Form>,
      );

      expect(container.querySelector('form')!).toHaveClass('ant-form-hide-required-mark');
    });

    it('priority should be higher than CP', () => {
      const { container, rerender } = render(
        <ConfigProvider form={{ requiredMark: true }}>
          <Form hideRequiredMark role="form">
            <Form.Item name="light" label="light" required>
              <Input />
            </Form.Item>
          </Form>
        </ConfigProvider>,
      );

      expect(container.querySelector('form')!).toHaveClass('ant-form-hide-required-mark');

      rerender(
        <ConfigProvider form={{ requiredMark: undefined }}>
          <Form hideRequiredMark role="form">
            <Form.Item name="light" label="light" required>
              <Input />
            </Form.Item>
          </Form>
        </ConfigProvider>,
      );

      expect(container.querySelector('form')!).toHaveClass('ant-form-hide-required-mark');
    });
  });

  it('form should support disabled', () => {
    const App: React.FC = () => (
      <Form labelCol={{ span: 4 }} wrapperCol={{ span: 14 }} layout="horizontal" disabled>
        <Form.Item label="Form disabled" name="disabled" valuePropName="checked">
          <Checkbox>disabled</Checkbox>
        </Form.Item>
        <Form.Item label="Radio">
          <Radio.Group>
            <Radio value="apple">Apple</Radio>
            <Radio value="pear">Pear</Radio>
          </Radio.Group>
        </Form.Item>
        <Form.Item label="Input">
          <Input />
        </Form.Item>
        <Form.Item label="Select">
          <Select>
            <Select.Option value="demo">Demo</Select.Option>
          </Select>
        </Form.Item>
        <Form.Item label="TreeSelect">
          <TreeSelect
            treeData={[
              {
                title: 'Light',
                value: 'light',
                children: [{ title: 'Bamboo', value: 'bamboo' }],
              },
            ]}
          />
        </Form.Item>
        <Form.Item label="Cascader">
          <Cascader
            options={[
              {
                value: 'zhejiang',
                label: 'Zhejiang',
                children: [{ value: 'hangzhou', label: 'Hangzhou' }],
              },
            ]}
          />
        </Form.Item>
        <Form.Item label="DatePicker">
          <DatePicker />
        </Form.Item>
        <Form.Item label="RangePicker">
          <RangePicker />
        </Form.Item>
        <Form.Item label="InputNumber">
          <InputNumber />
        </Form.Item>
        <Form.Item label="TextArea">
          <TextArea rows={4} />
        </Form.Item>
        <Form.Item label="Switch" valuePropName="checked">
          <Switch />
        </Form.Item>
        <Form.Item label="Upload" valuePropName="fileList">
          <Upload />
        </Form.Item>
        <Form.Item label="Button">
          <Button>Button</Button>
        </Form.Item>
        <Form.Item label="Slider">
          <Slider />
        </Form.Item>
        <Form.Item label="ColorPicker">
          <ColorPicker />
        </Form.Item>
      </Form>
    );
    const { container } = render(<App />);
    expect(container.firstChild).toMatchSnapshot();
  });

  it('form.item should support layout', () => {
    const App: React.FC = () => (
      <Form labelCol={{ span: 4 }} wrapperCol={{ span: 14 }} layout="horizontal">
        <Form.Item label="name" name="name">
          <Input />
        </Form.Item>
        <Form.Item label="horizontal" name="horizontal" layout="horizontal">
          <Input />
        </Form.Item>
        <Form.Item label="vertical" name="vertical" layout="vertical">
          <Input />
        </Form.Item>
      </Form>
    );
    const { container } = render(<App />);
    expect(container.firstChild).toMatchSnapshot();
  });

  it('form.item should support label = null', () => {
    // base size
    const App: React.FC = () => (
      <Form labelCol={{ span: 4 }} wrapperCol={{ span: 14 }}>
        <Form.Item label="name" name="name">
          <Input />
        </Form.Item>
        <Form.Item label={null}>
          <Button>Submit</Button>
        </Form.Item>
      </Form>
    );
    const { container } = render(<App />);

    const items = container.querySelectorAll('.ant-form-item');
    const oneItems = items[0].querySelector('.ant-row')?.querySelectorAll('.ant-col');
    expect(oneItems?.[0]).toHaveClass('ant-col-4');
    expect(oneItems?.[0].className.includes('offset')).toBeFalsy();
    expect(oneItems?.[1]).toHaveClass('ant-col-14');
    expect(oneItems?.[1].className.includes('offset')).toBeFalsy();
    const twoItem = items[1].querySelector('.ant-row')?.querySelector('.ant-col');
    expect(twoItem).toHaveClass('ant-col-14 ant-col-offset-4');

    // more size
    const list = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'] as const;
    list.forEach((size) => {
      const { container } = render(
        <Form labelCol={{ [size]: { span: 4 } }} wrapperCol={{ span: 14 }}>
          <Form.Item label="name" name="name">
            <Input />
          </Form.Item>
          <Form.Item label={null}>
            <Button>Submit</Button>
          </Form.Item>
        </Form>,
      );

      const items = container.querySelectorAll('.ant-form-item');
      const oneItems = items[0].querySelector('.ant-row')?.querySelectorAll('.ant-col');
      expect(oneItems?.[0]).toHaveClass(`ant-col-${size}-4`);
      expect(oneItems?.[0].className.includes('offset')).toBeFalsy();
      expect(oneItems?.[1]).toHaveClass('ant-col-14');
      expect(oneItems?.[1].className.includes('offset')).toBeFalsy();
      const twoItem = items[1].querySelector('.ant-row')?.querySelector('.ant-col');
      expect(twoItem).toHaveClass(`ant-col-14 ant-col-${size}-offset-4`);
    });
  });

  it('form.item should support label = null and labelCol.span = 24', () => {
    // base size
    const App: React.FC = () => (
      <Form labelCol={{ span: 24 }} wrapperCol={{ span: 24 }}>
        <Form.Item label="name" name="name">
          <Input />
        </Form.Item>
        <Form.Item label={null}>
          <Button>Submit</Button>
        </Form.Item>
      </Form>
    );
    const { container } = render(<App />);

    const items = container.querySelectorAll('.ant-form-item');
    const oneItems = items[0].querySelector('.ant-row')?.querySelectorAll('.ant-col');
    expect(oneItems?.[0]).toHaveClass('ant-col-24');
    expect(oneItems?.[0].className.includes('offset')).toBeFalsy();
    expect(oneItems?.[1]).toHaveClass('ant-col-24');
    expect(oneItems?.[1].className.includes('offset')).toBeFalsy();
    const twoItem = items[1].querySelector('.ant-row')?.querySelector('.ant-col');
    expect(twoItem).toHaveClass('ant-col-24');
    expect(twoItem?.className.includes('offset')).toBeFalsy();

    // more size
    const list = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'] as const;
    list.forEach((size) => {
      const { container } = render(
        <Form labelCol={{ [size]: { span: 24 } }} wrapperCol={{ span: 24 }}>
          <Form.Item label="name" name="name">
            <Input />
          </Form.Item>
          <Form.Item label={null}>
            <Button>Submit</Button>
          </Form.Item>
        </Form>,
      );

      const items = container.querySelectorAll('.ant-form-item');
      const oneItems = items[0].querySelector('.ant-row')?.querySelectorAll('.ant-col');
      expect(oneItems?.[0]).toHaveClass(`ant-col-${size}-24`);
      expect(oneItems?.[0].className.includes('offset')).toBeFalsy();
      expect(oneItems?.[1]).toHaveClass('ant-col-24');
      expect(oneItems?.[1].className.includes('offset')).toBeFalsy();
      const twoItem = items[1].querySelector('.ant-row')?.querySelector('.ant-col');
      expect(twoItem).toHaveClass(`ant-col-24`);
      expect(twoItem?.className.includes('offset')).toBeFalsy();
    });
  });

  it('_internalItemRender api test', () => {
    const { container } = render(
      <Form>
        <Form.Item
          name="light"
          // @ts-ignore
          _internalItemRender={{
            mark: 'pro_table_render',
            render: (_: any, doms: any) => (
              <div>
                <div className="bamboo">warning title</div>
                {doms.input}
                {doms.errorList}
                {doms.extra}
              </div>
            ),
          }}
        >
          <input defaultValue="should warning" />
        </Form.Item>
      </Form>,
    );

    expect(container.querySelector('.bamboo')!).toHaveTextContent(/warning title/i);
  });

  it('Form Item element id will auto add form_item prefix if form name is empty and item name is in the black list', async () => {
    const mockFn = jest.spyOn(Util, 'getFieldId');
    const itemName = 'parentNode';
    // mock getFieldId old logic
    // if form name is empty and item name is parentNode
    // will get parentNode
    mockFn.mockImplementation(() => itemName);
    const { Option } = Select;
    const Demo: React.FC = () => {
      const [open, setOpen] = useState(false);
      return (
        <>
          <Form>
            <Form.Item name={itemName} label={itemName}>
              <Select
                className="form_item_parentNode"
                defaultValue="lucy"
                open={open}
                style={{ width: 120 }}
              >
                <Option value="jack">Jack</Option>
                <Option value="lucy">Lucy</Option>
                <Option value="Yiminghe">yiminghe</Option>
              </Select>
            </Form.Item>
          </Form>
          <button
            type="button"
            onClick={() => {
              setOpen(true);
            }}
          >
            {open ? 'show' : 'hidden'}
          </button>
        </>
      );
    };

    const { container, rerender } = render(<Demo />);
    expect(mockFn).toHaveBeenCalled();
    expect((Util.getFieldId as () => string)()).toBe(itemName);

    // make sure input id is parentNode
    expect(screen.getByLabelText(itemName)).toHaveAccessibleName(itemName);

    fireEvent.click(container.querySelector('button')!);
    await waitFakeTimer();

    expect(container.querySelector('button')!).toHaveTextContent('show');

    mockFn.mockRestore();

    rerender(<Demo />);
    expect(screen.getByLabelText(itemName)).toBeInTheDocument();
  });

  describe('tooltip', () => {
    it('ReactNode', async () => {
      const { container } = render(
        <Form>
          <Form.Item label="light" tooltip={<span>Bamboo</span>}>
            <Input />
          </Form.Item>
        </Form>,
      );

      fireEvent.mouseEnter(container.querySelector('.anticon-question-circle')!);
      await waitFakeTimer();

      expect(container.querySelector('.ant-tooltip-inner')).toHaveTextContent('Bamboo');
    });

    it('config tooltip should show when hover on icon', async () => {
      const { container } = render(
        <Form>
          <Form.Item label="light" tooltip={{ title: 'Bamboo' }}>
            <Input />
          </Form.Item>
        </Form>,
      );

      fireEvent.mouseEnter(container.querySelector('.anticon-question-circle')!);
      fireEvent.click(container.querySelector('.anticon-question-circle')!);
      await waitFakeTimer();

      expect(container.querySelector('.ant-tooltip-inner')).toHaveTextContent('Bamboo');
    });
  });

  it('warningOnly validate', async () => {
    const { container } = render(
      <Form>
        <Form.Item>
          <Form.Item
            name="test"
            label="test"
            initialValue="bamboo"
            rules={[{ required: true, warningOnly: true }]}
          >
            <Input />
          </Form.Item>
        </Form.Item>
      </Form>,
    );

    await changeValue(0, 'test');
    await changeValue(0, '');

    expect(container.querySelector('.ant-form-item-with-help')).toBeTruthy();
    expect(container.querySelector('.ant-form-item-has-warning')).toBeTruthy();
  });

  it('not warning when remove on validate', async () => {
    let rejectFn: (reason?: any) => void = jest.fn();

    const { unmount } = render(
      <Form>
        <Form.Item>
          <Form.Item
            noStyle
            name="test"
            initialValue="bamboo"
            rules={[
              {
                validator: () =>
                  new Promise((_, reject) => {
                    rejectFn = reject;
                  }),
              },
            ]}
          >
            <Input />
          </Form.Item>
        </Form.Item>
      </Form>,
    );

    await changeValue(0, '');

    unmount();

    // Delay validate failed
    rejectFn(new Error('delay failed'));

    expect(errorSpy).not.toHaveBeenCalled();
  });

  describe('form colon', () => {
    it('default colon', () => {
      render(
        <Form>
          <Form.Item label="姓名" name="姓名">
            <input />
          </Form.Item>
        </Form>,
      );

      expect(screen.getByText('姓名')).not.toHaveClass('ant-form-item-no-colon');
    });

    it('set Form.Item colon false', () => {
      render(
        <Form colon>
          <Form.Item colon={false} label="姓名" name="姓名">
            <Input />
          </Form.Item>
        </Form>,
      );

      expect(screen.getByText('姓名')).toHaveClass('ant-form-item-no-colon');
    });

    it('set Form colon false', () => {
      render(
        <Form colon={false}>
          <Form.Item label="姓名" name="姓名">
            <Input />
          </Form.Item>
        </Form>,
      );

      expect(screen.getByText('姓名')).toHaveClass('ant-form-item-no-colon');
    });
  });

  it('useFormInstance', () => {
    let formInstance: any;
    let subFormInstance: any;

    const Sub = () => {
      const formSub = Form.useFormInstance();
      subFormInstance = formSub;

      return null;
    };

    const Demo: React.FC = () => {
      const [form] = Form.useForm();
      formInstance = form;

      return (
        <Form form={form}>
          <Sub />
        </Form>
      );
    };

    render(<Demo />);
    expect(subFormInstance).toBe(formInstance);
  });

  describe('noStyle with status', () => {
    it('noStyle should not affect status', async () => {
      const Demo: React.FC = () => (
        <Form>
          {/* should change status */}
          <Form.Item validateStatus="error" noStyle>
            <Select className="custom-select" />
          </Form.Item>

          {/* should follow parent status */}
          <Form.Item validateStatus="error" hasFeedback>
            <Form.Item noStyle>
              <Select className="custom-select-b" />
            </Form.Item>
          </Form.Item>

          {/* should follow child status */}
          <Form.Item validateStatus="error" hasFeedback>
            <Form.Item noStyle validateStatus="warning" hasFeedback={false}>
              <Select className="custom-select-c" />
            </Form.Item>
          </Form.Item>

          {/* should follow child status */}
          <Form.Item noStyle>
            <Form.Item validateStatus="warning">
              <Select className="custom-select-d" />
            </Form.Item>
          </Form.Item>

          {/* should follow child status */}
          <Form.Item validateStatus="error">
            <Form.Item noStyle validateStatus="">
              <Select className="custom-select-e" />
            </Form.Item>
          </Form.Item>
        </Form>
      );
      const { container } = render(<Demo />);

      await waitFakeTimer();

      expect(container.querySelector('.custom-select')).toHaveClass('ant-select-status-error');
      expect(container.querySelector('.custom-select')).not.toHaveClass('ant-select-in-form-item');

      expect(container.querySelector('.custom-select-b')).toHaveClass('ant-select-status-error');
      expect(container.querySelector('.custom-select-b')).toHaveClass('ant-select-in-form-item');
      expect(
        container
          .querySelector('.custom-select-b')
          ?.querySelector('.ant-form-item-feedback-icon-error'),
      ).toBeTruthy();

      expect(container.querySelector('.custom-select-c')).toHaveClass('ant-select-status-warning');
      expect(container.querySelector('.custom-select-c')).toHaveClass('ant-select-in-form-item');
      expect(
        container
          .querySelector('.custom-select-c')
          ?.querySelector('.ant-form-item-feedback-icon-warning'),
      ).toBeFalsy();

      expect(container.querySelector('.custom-select-d')).toHaveClass('ant-select-status-warning');
      expect(container.querySelector('.custom-select-d')).toHaveClass('ant-select-in-form-item');

      expect(container.querySelector('.custom-select-e')).not.toHaveClass(
        'ant-select-status-error',
      );
      expect(container.querySelector('.custom-select-e')).toHaveClass('ant-select-in-form-item');
    });

    it('parent pass status', async () => {
      const { container } = render(
        <Form>
          <Form.Item label="name">
            <Form.Item name="first" noStyle rules={[{ required: true }]}>
              <Input />
            </Form.Item>
            <Form.Item name="last" noStyle>
              <Input />
            </Form.Item>
          </Form.Item>
        </Form>,
      );

      // Input and set back to empty
      await changeValue(0, 'Once');
      await changeValue(0, '');

      expect(container.querySelector('.ant-form-item-explain-error')?.textContent).toEqual(
        "'first' is required",
      );

      expect(container.querySelectorAll('input')[0]).toHaveClass('ant-input-status-error');
      expect(container.querySelectorAll('input')[1]).not.toHaveClass('ant-input-status-error');
    });
  });

  it('should not affect Popup children style', () => {
    const Demo: React.FC = () => (
      <Form>
        <Form.Item labelCol={4 as ColProps} validateStatus="error">
          <Modal open>
            <Select className="modal-select" />
          </Modal>
        </Form.Item>
        <Form.Item validateStatus="error">
          <Drawer open>
            <Select className="drawer-select" />
          </Drawer>
        </Form.Item>
      </Form>
    );
    const { container } = render(<Demo />, { container: document.body });
    expect(container.querySelector('.modal-select')?.className).not.toContain('in-form-item');
    expect(container.querySelector('.modal-select')?.className).not.toContain('status-error');
    expect(container.querySelector('.drawer-select')?.className).not.toContain('in-form-item');
    expect(container.querySelector('.drawer-select')?.className).not.toContain('status-error');
  });

  it('should be set up correctly marginBottom', () => {
    render(
      <Modal open>
        <Form>
          <Form.Item help="This is a help message">
            <Input />
          </Form.Item>
        </Form>
      </Modal>,
    );

    expect(document.querySelector('.ant-form-item-margin-offset')).toBeTruthy();
  });

  it('Form.Item.useStatus should work', async () => {
    const {
      Item: { useStatus },
    } = Form;

    const CustomInput: React.FC<{ className?: string; value?: React.ReactNode }> = ({
      className,
      value,
    }) => {
      const { status } = useStatus();
      return <div className={classNames(className, `custom-input-status-${status}`)}>{value}</div>;
    };

    const Demo: React.FC = () => {
      const [form] = Form.useForm();

      return (
        <Form form={form} name="my-form">
          <Form.Item name="required" rules={[{ required: true }]}>
            <CustomInput className="custom-input-required" value="" />
          </Form.Item>
          <Form.Item name="warning" validateStatus="warning">
            <CustomInput className="custom-input-warning" />
          </Form.Item>
          <Form.Item name="normal">
            <CustomInput className="custom-input" />
          </Form.Item>
          <CustomInput className="custom-input-wrong" />
          <Button onClick={() => form.submit()} className="submit-button">
            Submit
          </Button>
        </Form>
      );
    };

    const { container } = render(<Demo />);

    expect(container.querySelector('.custom-input-required')?.className).toContain(
      'custom-input-status-',
    );
    expect(container.querySelector('.custom-input-warning')?.classList).toContain(
      'custom-input-status-warning',
    );
    expect(container.querySelector('.custom-input')?.className).toContain('custom-input-status-');
    expect(container.querySelector('.custom-input-wrong')?.classList).toContain(
      'custom-input-status-undefined',
    );
    expect(errorSpy).toHaveBeenCalledWith(
      expect.stringContaining('Form.Item.useStatus should be used under Form.Item component.'),
    );

    fireEvent.click(container.querySelector('.submit-button')!);
    await waitFakeTimer();

    expect(container.querySelector('.custom-input-required')?.classList).toContain(
      'custom-input-status-error',
    );
  });

  it('Form.Item.useStatus should supports get error messages and warning messages', async () => {
    const {
      Item: { useStatus },
    } = Form;

    const ErrorItem: React.FC = () => {
      const { errors } = useStatus();
      return <div className="test-error">{errors[0]}</div>;
    };

    const WarningItem: React.FC = () => {
      const { warnings } = useStatus();
      return <div className="test-warning">{warnings[0]}</div>;
    };

    const Demo: React.FC = () => {
      const [form] = Form.useForm();

      return (
        <Form form={form} name="test-form">
          <Form.Item name="error" rules={[{ required: true, message: 'This is a error message.' }]}>
            <ErrorItem />
          </Form.Item>
          <Form.Item
            name="warning"
            rules={[{ required: true, message: 'This is a warning message.', warningOnly: true }]}
          >
            <WarningItem />
          </Form.Item>
          <Button onClick={() => form.submit()} className="submit-button">
            Submit
          </Button>
        </Form>
      );
    };

    const { container } = render(<Demo />);

    fireEvent.click(container.querySelector('.submit-button')!);
    await waitFakeTimer();

    expect(container.querySelector('.test-error')).toHaveTextContent('This is a error message.');
    expect(container.querySelector('.test-warning')).toHaveTextContent(
      'This is a warning message.',
    );
  });

  it('item customize margin', async () => {
    const computeSpy = jest
      .spyOn(window, 'getComputedStyle')
      .mockImplementation(() => ({ marginBottom: 24 }) as unknown as CSSStyleDeclaration);

    const { container } = render(
      <Form>
        <Form.Item name="required" initialValue="bamboo" rules={[{ required: true }]}>
          <Input />
        </Form.Item>
      </Form>,
    );

    await changeValue(0, '');

    computeSpy.mockRestore();

    expect(container.querySelector('.ant-form-item-margin-offset')).toHaveStyle({
      marginBottom: -24,
    });
  });

  it('form child components should be given priority to own disabled props when it in a disabled form', () => {
    const props = {
      name: 'file',
      action: 'https://660d2bd96ddfa2943b33731c.mockapi.io/api/upload',
      headers: {
        authorization: 'authorization-text',
      },
      capture: true,
    };
    const renderComps = (disabled?: boolean) => [
      <Button key="Button" disabled={disabled} type="primary" htmlType="submit">
        test
      </Button>,
      <Cascader key="Cascader" disabled={disabled} options={[]} />,
      <Checkbox key="Checkbox" disabled={disabled} />,
      <Checkbox.Group
        key="CheckboxGroup"
        disabled={disabled}
        options={[
          { label: 'male', value: 0 },
          { label: 'female', value: 1 },
        ]}
      />,
      <ColorPicker key="ColorPicker" disabled={disabled} />,
      <InputNumber key="InputNumber" disabled={disabled} />,
      <Input key="Input" disabled={disabled} />,
      <Select key="Select" disabled={disabled} />,
      <Switch key="Switch" disabled={disabled} />,
      <TreeSelect key="TreeSelect" disabled={disabled} />,
      <Upload key="Upload" {...props} disabled={disabled}>
        <Button disabled={disabled}>Click to Upload</Button>
      </Upload>,
      <DatePicker key="DatePicker" disabled={disabled} />,
      <DatePicker.RangePicker key="DatePicker.RangePicker" disabled={disabled} />,
      <DatePicker.MonthPicker key="DatePicker.MonthPicker" disabled={disabled} />,
      <DatePicker.QuarterPicker key="DatePicker.QuarterPicker" disabled={disabled} />,
      <DatePicker.WeekPicker key="DatePicker.WeekPicker" disabled={disabled} />,
      <DatePicker.YearPicker key="DatePicker.YearPicker" disabled={disabled} />,
      <DatePicker.TimePicker key="DatePicker.TimePicker" disabled={disabled} />,
    ];
    const App: React.FC = () => <Form disabled>{renderComps(false)}</Form>;

    const wrapper = render(<App />);
    expect(wrapper.container.querySelectorAll('[disabled]').length).toBe(0);
    const App2 = () => <Form disabled>{renderComps()}</Form>;

    const wrapper2 = render(<App2 />);
    // 时间范围组件中会有两个 input 框,Upload 为叠加
    // 因此虽然上述只有 18 个组件,但实际有 20 个 带有 disabled 属性的表单组件
    expect(wrapper2.container.querySelectorAll('[disabled]').length).toBe(20);

    const App3 = () => <Form disabled>{renderComps(true)}</Form>;

    const wrapper3 = render(<App3 />);

    expect(wrapper3.container.querySelectorAll('[disabled]').length).toBe(20);

    const App4 = () => <Form>{renderComps(true)}</Form>;

    const wrapper4 = render(<App4 />);

    expect(wrapper4.container.querySelectorAll('[disabled]').length).toBe(20);

    const App5 = () => <Form>{renderComps()}</Form>;

    const wrapper5 = render(<App5 />);

    expect(wrapper5.container.querySelectorAll('[disabled]').length).toBe(0);
  });

  it('success feedback should display when pass hasFeedback prop and current value is valid value', async () => {
    const App = ({ trigger = false }: { trigger?: boolean }) => {
      const form = useRef<FormInstance<any>>(null);

      useEffect(() => {
        if (!trigger) {
          return;
        }
        form.current?.validateFields();
      }, [trigger]);

      return (
        <Form ref={form}>
          <Form.Item
            label="Success"
            name="name1"
            hasFeedback
            initialValue="test@qq.com"
            rules={[
              {
                type: 'email',
                message: 'Please input your e-mail',
              },
              {
                required: true,
                message: 'Please input your value',
              },
            ]}
          >
            <Input />
          </Form.Item>
          <Form.Item
            label="Success"
            name="name2"
            initialValue="test@qq.com"
            rules={[
              {
                type: 'email',
                message: 'Please input your e-mail',
              },
              {
                required: true,
                message: 'Please input your value',
              },
            ]}
          >
            <Input />
          </Form.Item>
        </Form>
      );
    };
    const { container, rerender } = render(<App />);

    expect(container.querySelectorAll('.ant-form-item-has-feedback').length).toBe(0);
    expect(container.querySelectorAll('.ant-form-item-has-success').length).toBe(0);

    rerender(<App trigger />);
    await waitFakeTimer();

    expect(container.querySelectorAll('.ant-form-item-has-feedback').length).toBe(1);
    expect(container.querySelectorAll('.ant-form-item-has-success').length).toBe(1);
  });

  it('feedback should automatically derive the correct state', async () => {
    const Demo: React.FC = () => {
      const [form] = Form.useForm();

      return (
        <Form form={form}>
          <Form.Item name="success" initialValue="test" hasFeedback rules={[{ required: true }]}>
            <Input />
          </Form.Item>
          <Form.Item
            name="validating"
            hasFeedback
            rules={[
              {
                validator: () =>
                  new Promise((resolve) => {
                    setTimeout(() => resolve(true), 2000);
                  }),
              },
            ]}
          >
            <Input />
          </Form.Item>
          <Form.Item name="warning" hasFeedback rules={[{ required: true, warningOnly: true }]}>
            <Input />
          </Form.Item>
          <Form.Item name="error" hasFeedback rules={[{ required: true }]}>
            <Input />
          </Form.Item>
          <Button onClick={() => form.submit()} className="submit-button">
            Submit
          </Button>
        </Form>
      );
    };
    const { container } = render(<Demo />);

    fireEvent.click(container.querySelector('.submit-button')!);

    await waitFakeTimer(50);

    expect(container.querySelector('.ant-form-item-has-success')).toBeTruthy();
    expect(container.querySelector('.ant-form-item-is-validating')).toBeTruthy();
    expect(container.querySelector('.ant-form-item-has-warning')).toBeTruthy();
    expect(container.querySelector('.ant-form-item-has-error')).toBeTruthy();
  });

  it('custom feedback icons should display when pass hasFeedback prop', async () => {
    const App = ({ trigger = false }: { trigger?: boolean }) => {
      const form = useRef<FormInstance<any>>(null);

      useEffect(() => {
        if (!trigger) {
          return;
        }
        form.current?.validateFields();
      }, [trigger]);

      return (
        <Form
          ref={form}
          feedbackIcons={() => ({
            error: <AlertFilled id="custom-error-icon" />,
          })}
        >
          <Form.Item
            label="Success"
            name="name1"
            hasFeedback
            rules={[
              {
                required: true,
                message: 'Please input your value',
              },
            ]}
          >
            <Input />
          </Form.Item>
          <Form.Item
            label="Success"
            name="name1"
            hasFeedback={{
              icons: () => ({
                error: <AlertFilled id="custom-error-icon2" />,
              }),
            }}
            rules={[
              {
                required: true,
                message: 'Please input your value 3',
              },
            ]}
          >
            <Input />
          </Form.Item>
        </Form>
      );
    };
    const { container, rerender } = render(<App />);

    expect(container.querySelectorAll('.ant-form-item-has-feedback').length).toBe(0);

    rerender(<App trigger />);
    await waitFakeTimer();

    expect(container.querySelectorAll('.ant-form-item-has-feedback').length).toBe(2);
    expect(container.querySelectorAll('#custom-error-icon, #custom-error-icon2').length).toBe(2);
  });

  // https://github.com/ant-design/ant-design/issues/41621
  it('should not override value when pass `undefined` to require', async () => {
    // When require is `undefined`, the `isRequire` calculation logic should be preserved
    const { container } = render(
      <Form>
        <Form.Item label="test" name="success" required={undefined} rules={[{ required: true }]}>
          <Input />
        </Form.Item>
      </Form>,
    );

    expect(container.querySelector('.ant-form-item-required')).toBeTruthy();
  });

  it('validate status should be change in order', async () => {
    const onChange = jest.fn();

    const CustomInput = (props: any) => {
      const { status } = Form.Item.useStatus();
      useEffect(() => {
        onChange(status);
      }, [status]);
      return <Input {...props} />;
    };

    const App: React.FC = () => (
      <Form>
        <Form.Item>
          <Form.Item name="test" label="test" rules={[{ len: 3, message: 'error.' }]}>
            <CustomInput />
          </Form.Item>
        </Form.Item>
      </Form>
    );

    render(<App />);
    await waitFakeTimer();

    // initial validate
    const initTriggerTime = ReactVersion.startsWith('18') || ReactVersion.startsWith('19') ? 2 : 1;
    expect(onChange).toHaveBeenCalledTimes(initTriggerTime);
    let idx = 1;
    expect(onChange).toHaveBeenNthCalledWith(idx++, '');
    if (initTriggerTime === 2) {
      expect(onChange).toHaveBeenNthCalledWith(idx++, '');
    }

    // change trigger
    await changeValue(0, '1');
    expect(onChange).toHaveBeenCalledTimes(initTriggerTime + 2);
    expect(onChange).toHaveBeenNthCalledWith(idx++, 'validating');
    expect(onChange).toHaveBeenNthCalledWith(idx++, 'error');
    await changeValue(0, '11');
    expect(onChange).toHaveBeenCalledTimes(initTriggerTime + 4);
    expect(onChange).toHaveBeenNthCalledWith(idx++, 'validating');
    expect(onChange).toHaveBeenNthCalledWith(idx++, 'error');
    await changeValue(0, '111');
    expect(onChange).toHaveBeenCalledTimes(initTriggerTime + 6);
    expect(onChange).toHaveBeenNthCalledWith(idx++, 'validating');
    expect(onChange).toHaveBeenNthCalledWith(idx++, 'success');
  });

  describe('requiredMark', () => {
    // https://user-images.githubusercontent.com/32004925/230819163-464fe90d-422d-4a6d-9e35-44a25d4c64f1.png
    it('should not render `requiredMark` when Form.Item has no required prop', () => {
      // Escaping TypeScript error
      const genProps = (value: any) => ({ ...value });

      const { container } = render(
        <Form name="basic" requiredMark="optional">
          <Form.Item
            label="First Name"
            name="firstName"
            required
            {...genProps({ requiredMark: false })}
          >
            <Input />
          </Form.Item>
          <Form.Item
            label="Last Name"
            name="lastName"
            required
            {...genProps({ requiredMark: true })}
          >
            <Input />
          </Form.Item>
        </Form>,
      );

      expect(container.querySelectorAll('.ant-form-item-required')).toHaveLength(2);
      expect(container.querySelectorAll('.ant-form-item-required-mark-optional')).toHaveLength(2);
    });

    it('customize logic', () => {
      const { container } = render(
        <Form name="basic" requiredMark={(label, info) => `${label}: ${info.required}`}>
          <Form.Item label="Required" required>
            <Input />
          </Form.Item>
          <Form.Item label="Optional">
            <Input />
          </Form.Item>
        </Form>,
      );

      expect(container.querySelectorAll('.ant-form-item-label')[0].textContent).toEqual(
        'Required: true',
      );
      expect(container.querySelectorAll('.ant-form-item-label')[1].textContent).toEqual(
        'Optional: false',
      );
    });
  });

  it('children support comment', () => {
    resetWarned();

    const { container } = render(
      <Form initialValues={{ name: 'bamboo', age: '14' }}>
        <Form.Item name="name">
          {/* Comment here */}
          <Input />
        </Form.Item>
        <Form.Item name="age">{[null, <Input key="input" />]}</Form.Item>
      </Form>,
    );

    expect(container.querySelectorAll('input')[0].value).toEqual('bamboo');
    expect(container.querySelectorAll('input')[1].value).toEqual('14');
    expect(errorSpy).not.toHaveBeenCalled();
  });

  it('duplicated form name', () => {
    resetWarned();

    render(
      <>
        <Form name="same" />
        <Form name="same" />
      </>,
    );

    expect(errorSpy).toHaveBeenCalledWith(
      'Warning: [antd: Form] There exist multiple Form with same `name`.',
    );
  });

  // https://github.com/ant-design/ant-design/issues/43044
  it('should not pass disabled to modal footer button', () => {
    render(
      // <FormDemo formProps={{ disabled: true }} modalProps={{ open: true }} />,
      <Form disabled>
        <Form.Item label="label">
          <Modal open />
        </Form.Item>
      </Form>,
    );

    const footerBts = document.querySelectorAll('.ant-modal-footer > button');
    expect(footerBts).toBeTruthy();

    footerBts.forEach((bt) => {
      expect(bt).not.toHaveAttribute('disabled');
    });
  });

  it('InputNumber with hasFeedback should keep dom stable', () => {
    const Demo = () => (
      <Form>
        <Form.Item
          name="light"
          hasFeedback
          rules={[{ required: true, message: 'Please input a entry price' }]}
        >
          <InputNumber />
        </Form.Item>
      </Form>
    );
    const { container } = render(<Demo />);

    const input = container.querySelector('input')!;

    expect(container.querySelector('.ant-input-number-suffix')).toBeTruthy();

    fireEvent.focus(input);

    expect(container.querySelector('.ant-input-number-focused')).toBeTruthy();

    fireEvent.change(input, {
      target: { value: '1' },
    });

    expect(container.querySelector('.ant-input-number-suffix')).toBeTruthy();
    expect(container.querySelector('.ant-input-number-focused')).toBeTruthy();
  });

  // https://github.com/ant-design/ant-design/issues/20803#issuecomment-601626759
  it('without explicitly passing `valuePropName`', async () => {
    const submit = jest.fn();
    const Demo = () => (
      <Form
        initialValues={{
          foo: true,
        }}
        onFinish={submit}
      >
        <Form.Item label="Switch" name="foo">
          <Switch />
        </Form.Item>
        <button type="submit">Submit</button>
      </Form>
    );

    const { getByRole } = render(<Demo />);

    await waitFakeTimer();

    const switchNode = getByRole('switch');

    expect(switchNode).toBeTruthy();
    expect(switchNode).toBeChecked();

    fireEvent.click(switchNode);
    expect(switchNode).not.toBeChecked();

    const submitButton = getByRole('button');
    expect(submitButton).toBeTruthy();
    fireEvent.click(submitButton);

    await waitFakeTimer();

    expect(submit).toHaveBeenCalledWith({
      foo: false,
    });
  });

  it('getValueProps should trigger update', () => {
    const { container } = render(
      <Form>
        <Form.Item
          name="remember"
          getValueProps={(val) => ({ checked: val })}
          getValueFromEvent={(e) => e.target.checked}
        >
          <Checkbox />
        </Form.Item>
      </Form>,
    );

    expect(container.querySelector('input')?.checked).toBeFalsy();

    fireEvent.click(container.querySelector('input')!);
    expect(container.querySelector('input')?.checked).toBeTruthy();
  });

  it('not warning for react key', async () => {
    const MockInput = (props: { onChange?: (value: number[]) => void }) => (
      <Input
        onChange={({ target: { value } }) => {
          props.onChange?.(value.split(',').map(Number));
        }}
      />
    );

    const { container } = render(
      <Form>
        <Form.Item>
          <Form.Item
            name="test"
            rules={[
              {
                type: 'array',
                defaultField: {
                  type: 'number',
                  min: 10,
                  message: 'LESS_THAN_10',
                },
              },
            ]}
          >
            <MockInput />
          </Form.Item>
        </Form.Item>
      </Form>,
    );

    function expectErrors(errors: string[]) {
      expect(container.querySelectorAll('.ant-form-item-explain-error')).toHaveLength(
        errors.length,
      );
      errors.forEach((error, index) => {
        expect(container.querySelectorAll('.ant-form-item-explain-error')[index]).toHaveTextContent(
          error,
        );
      });
    }

    // user type something and clear
    await changeValue(0, '1');
    expectErrors(['LESS_THAN_10']);

    await changeValue(0, '1,1');
    expectErrors(['LESS_THAN_10', 'LESS_THAN_10']);

    await changeValue(0, '1');
    expectErrors(['LESS_THAN_10']);

    await changeValue(0, '100');
    expectErrors([]);
  });
});