@@ -8,11 +8,11 @@ interface TestCompProptypes extends ActionSheetPropTypes {
8
8
}
9
9
10
10
const TestComp = ( props : TestCompProptypes ) => {
11
- const { onBtnClick, open, children } = props ;
11
+ const { onBtnClick, open = true , children, ... rest } = props ;
12
12
return (
13
13
< >
14
14
< button id = "opener" > Opener</ button >
15
- < ActionSheet className = "myCustomClass" open = { open } opener = "opener" >
15
+ < ActionSheet className = "myCustomClass" open = { open } opener = "opener" { ... rest } >
16
16
{ children || (
17
17
< >
18
18
< Button onClick = { onBtnClick } > Accept</ Button >
@@ -28,7 +28,7 @@ const TestComp = (props: TestCompProptypes) => {
28
28
describe ( 'ActionSheet' , ( ) => {
29
29
it ( 'Click Action' , ( ) => {
30
30
const onBtnClick = cy . spy ( ) . as ( 'onBtnClick' ) ;
31
- cy . mount ( < TestComp onBtnClick = { onBtnClick } open /> ) ;
31
+ cy . mount ( < TestComp onBtnClick = { onBtnClick } /> ) ;
32
32
33
33
cy . get ( '[ui5-responsive-popover]' ) . should ( 'be.visible' ) ;
34
34
@@ -39,10 +39,55 @@ describe('ActionSheet', () => {
39
39
40
40
it ( 'does not crash with other component' , ( ) => {
41
41
cy . mount (
42
- < TestComp open >
42
+ < TestComp >
43
43
< Label > I should not crash</ Label >
44
44
</ TestComp >
45
45
) ;
46
46
cy . findByText ( 'I should not crash' ) . should ( 'be.visible' ) ;
47
47
} ) ;
48
+
49
+ it ( 'keyboard navigation' , ( ) => {
50
+ cy . mount (
51
+ < TestComp >
52
+ { new Array ( 15 ) . fill ( 'O.o' ) . map ( ( _ , index ) => (
53
+ < Button key = { index } > { `Button${ index } ` } </ Button >
54
+ ) ) }
55
+ </ TestComp >
56
+ ) ;
57
+ cy . focused ( ) . should ( 'have.text' , 'Button0' ) ;
58
+ cy . realPress ( 'ArrowDown' ) ;
59
+ cy . focused ( ) . should ( 'have.text' , 'Button1' ) ;
60
+ cy . realPress ( 'ArrowRight' ) ;
61
+ cy . realPress ( 'ArrowRight' ) ;
62
+ cy . focused ( ) . should ( 'have.text' , 'Button3' ) ;
63
+ cy . realPress ( 'PageUp' ) ;
64
+ cy . focused ( ) . should ( 'have.text' , 'Button0' ) ;
65
+ cy . realPress ( 'PageDown' ) ;
66
+ cy . focused ( ) . should ( 'have.text' , 'Button5' ) ;
67
+ cy . realPress ( 'End' ) ;
68
+ cy . focused ( ) . should ( 'have.text' , 'Button14' ) ;
69
+ cy . realPress ( 'ArrowUp' ) ;
70
+ cy . focused ( ) . should ( 'have.text' , 'Button13' ) ;
71
+ cy . realPress ( 'ArrowLeft' ) ;
72
+ cy . realPress ( 'ArrowLeft' ) ;
73
+ cy . focused ( ) . should ( 'have.text' , 'Button11' ) ;
74
+ cy . realPress ( 'PageDown' ) ;
75
+ cy . focused ( ) . should ( 'have.text' , 'Button14' ) ;
76
+ cy . realPress ( 'Home' ) ;
77
+ cy . focused ( ) . should ( 'have.text' , 'Button0' ) ;
78
+
79
+ // todo: rtl detection of wcr and ui5wc doesn't work for some reason in cypress
80
+ // cy.mount(
81
+ // <TestComp dir="rtl">
82
+ // {new Array(15).fill('O.o').map((_, index) => (
83
+ // <Button key={index}>{`Button${index}`}</Button>
84
+ // ))}
85
+ // </TestComp>
86
+ // );
87
+ // cy.focused().should('have.text', 'Button0');
88
+ // cy.realPress('ArrowLeft');
89
+ // cy.focused().should('have.text', 'Button1');
90
+ // cy.realPress('ArrowRight');
91
+ // cy.focused().should('have.text', 'Button0');
92
+ } ) ;
48
93
} ) ;
0 commit comments