@@ -4,6 +4,7 @@ import { Link } from '@ui5/webcomponents-react';
44import { useRef } from 'react' ;
55import { MessageItem } from './MessageItem' ;
66import { MessageView } from './index.js' ;
7+ import { Dialog } from '../../webComponents/Dialog/index.js' ;
78
89describe ( 'MessageView' , ( ) => {
910 it ( 'default & grouped' , ( ) => {
@@ -80,54 +81,64 @@ describe('MessageView', () => {
8081 getAllTextsVisible ( ) ;
8182 } ) ;
8283
83- it ( 'select & nav back' , ( ) => {
84- const select = cy . spy ( ) . as ( 'select' ) ;
85- const TestComp = ( ) => {
86- const ref = useRef ( null ) ;
87- return (
88- < >
89- < button
90- onClick = { ( ) => {
91- ref . current . navigateBack ( ) ;
92- } }
93- >
94- nav back
95- </ button >
96- < MessageView onItemSelect = { select } ref = { ref } showDetailsPageHeader >
97- < MessageItem titleText = "Error" type = { ValueState . Negative } groupName = "Group1" >
98- Error Message
99- </ MessageItem >
100- < MessageItem titleText = "Warning" type = { ValueState . Critical } groupName = "Group1" >
101- Warning
102- </ MessageItem >
103- < MessageItem titleText = "Success" type = { ValueState . Positive } >
104- Success
105- </ MessageItem >
106- < MessageItem titleText = "Information" type = { ValueState . Information } >
107- Information Message
108- </ MessageItem >
109- < MessageItem titleText = "None" type = { ValueState . None } groupName = "Group2" >
110- None
111- </ MessageItem >
112- </ MessageView >
113- </ >
114- ) ;
115- } ;
116- cy . mount ( < TestComp /> ) ;
117- cy . findByText ( 'Error' ) . click ( ) ;
118- cy . findAllByText ( 'Error' ) . should ( 'have.length' , 1 ) ;
119- cy . findByText ( 'Error Message' ) . should ( 'be.visible' ) ;
120- cy . get ( '[ui5-button]' ) . click ( ) ;
121- cy . findAllByText ( 'Error' ) . should ( 'have.length' , 1 ) ;
122- cy . findByText ( 'Error Message' ) . should ( 'not.exist' ) ;
123- cy . get ( '@select' ) . should ( 'have.been.calledOnce' ) ;
124- cy . findByText ( 'Information' ) . click ( ) ;
125- cy . findAllByText ( 'Information' ) . should ( 'have.length' , 1 ) ;
126- cy . findByText ( 'Information Message' ) . should ( 'be.visible' ) ;
127- cy . findByText ( 'nav back' ) . click ( ) ;
128- cy . findAllByText ( 'Information' ) . should ( 'have.length' , 1 ) ;
129- cy . findByText ( 'Information Message' ) . should ( 'not.exist' ) ;
130- cy . get ( '@select' ) . should ( 'have.been.calledTwice' ) ;
84+ [ false , true ] . forEach ( ( inDialog ) => {
85+ [ 'ltr' , 'rtl' ] . forEach ( ( dir ) => {
86+ it ( `select & nav back ${ inDialog ? 'in Dialog' : '' } (${ dir } )` , ( ) => {
87+ const select = cy . spy ( ) . as ( 'select' ) ;
88+ const TestComp = ( ) => {
89+ const ref = useRef ( null ) ;
90+ const Parent = inDialog ? Dialog : 'div' ;
91+ return (
92+ < Parent dir = { dir } open style = { { width : '400px' } } >
93+ < button
94+ slot = "header"
95+ onClick = { ( ) => {
96+ ref . current . navigateBack ( ) ;
97+ } }
98+ >
99+ nav back
100+ </ button >
101+ < MessageView onItemSelect = { select } ref = { ref } showDetailsPageHeader = { ! inDialog } >
102+ < MessageItem titleText = "Error" type = { ValueState . Negative } groupName = "Group1" >
103+ Error Message
104+ </ MessageItem >
105+ < MessageItem titleText = "Warning" type = { ValueState . Critical } groupName = "Group1" >
106+ Warning
107+ </ MessageItem >
108+ < MessageItem titleText = "Success" type = { ValueState . Positive } >
109+ Success
110+ </ MessageItem >
111+ < MessageItem titleText = "Information" type = { ValueState . Information } >
112+ Information Message
113+ </ MessageItem >
114+ < MessageItem titleText = "None" type = { ValueState . None } groupName = "Group2" >
115+ None
116+ </ MessageItem >
117+ </ MessageView >
118+ </ Parent >
119+ ) ;
120+ } ;
121+ cy . mount ( < TestComp /> ) ;
122+ cy . findByText ( 'Error' ) . click ( ) ;
123+ cy . findAllByText ( 'Error' ) . should ( 'have.length' , 1 ) ;
124+ cy . findByText ( 'Error Message' ) . should ( 'be.visible' ) ;
125+ if ( inDialog ) {
126+ cy . findByText ( 'nav back' ) . click ( ) ;
127+ } else {
128+ cy . get ( '[ui5-button]' ) . click ( ) ;
129+ }
130+ cy . findAllByText ( 'Error' ) . should ( 'have.length' , 1 ) ;
131+ cy . findByText ( 'Error Message' ) . should ( 'not.exist' ) ;
132+ cy . get ( '@select' ) . should ( 'have.been.calledOnce' ) ;
133+ cy . findByText ( 'Information' ) . click ( ) ;
134+ cy . findAllByText ( 'Information' ) . should ( 'have.length' , 1 ) ;
135+ cy . findByText ( 'Information Message' ) . should ( 'be.visible' ) ;
136+ cy . findByText ( 'nav back' ) . click ( ) ;
137+ cy . findAllByText ( 'Information' ) . should ( 'have.length' , 1 ) ;
138+ cy . findByText ( 'Information Message' ) . should ( 'not.exist' ) ;
139+ cy . get ( '@select' ) . should ( 'have.been.calledTwice' ) ;
140+ } ) ;
141+ } ) ;
131142 } ) ;
132143
133144 it ( 'one/no message-type/item' , ( ) => {
0 commit comments