1212import dayjs from 'dayjs' ;
1313
1414describe ( 'MM-T4064 Status expiry visibility' , ( ) => {
15- before ( ( ) => {
16- cy . apiUpdateConfig ( { TeamSettings : { EnableCustomUserStatuses : true } } ) ;
15+ const waitingTime = 60 ; //minutes
16+ let expiresAt = dayjs ( ) ;
17+ const expiryTimeFormat = 'h:mm A' ;
18+
19+ beforeEach ( ( ) => {
20+ cy . apiAdminLogin ( ) . apiUpdateConfig ( { TeamSettings : { EnableCustomUserStatuses : true } } ) ;
1721
1822 // # Login as test user and visit channel
1923 cy . apiInitSetup ( { loginAfter : true } ) . then ( ( { channelUrl} ) => {
2024 cy . visit ( channelUrl ) ;
25+
26+ // # Post a message in the channel
27+ cy . postMessage ( 'Hello World!' ) ;
2128 } ) ;
2229 } ) ;
23- const waitingTime = 60 ; //minutes
24- let expiresAt = dayjs ( ) ;
25- const expiryTimeFormat = 'h:mm A' ;
2630
27- it . skip ( 'MM-T4064_6 should show expiry time in the tooltip of custom status emoji in the post header' , ( ) => {
31+ it ( 'MM-T4064_6 should show expiry time in the tooltip of custom status emoji in the post header' , ( ) => {
2832 // # Open the user account menu
2933 cy . uiOpenUserMenu ( 'Set custom status' ) ;
3034
@@ -44,9 +48,6 @@ describe('MM-T4064 Status expiry visibility', () => {
4448 // # Note that we need to be flexible around accepted values, as this calculation and the server-side one may differ slightly
4549 expiresAt = dayjs ( ) . add ( waitingTime , 'minute' ) ;
4650
47- // # Post a message in the channel
48- cy . postMessage ( 'Hello World!' ) ;
49-
5051 // # Get the last post
5152 cy . getLastPostId ( ) . then ( ( postId ) => {
5253 // # Hover on the custom status emoji present in the post header
@@ -59,7 +60,37 @@ describe('MM-T4064 Status expiry visibility', () => {
5960 } ) ;
6061 } ) ;
6162
62- it . skip ( 'MM-T4064_7 should show custom status expiry time in the user popover' , ( ) => {
63+ it ( 'MM-T4064_7 should show custom status expiry time in the user popover' , ( ) => {
64+ // # Open the user account menu
65+ cy . uiOpenUserMenu ( 'Set custom status' ) ;
66+
67+ // * Verify that the custom status modal opens
68+ cy . findByRole ( 'dialog' , { name : 'Set a status' } ) . should ( 'exist' ) . within ( ( ) => {
69+ // # Select a custom status from the suggestions
70+ cy . get ( '.statusSuggestion__row' ) . first ( ) . click ( ) ;
71+
72+ // # Click on the Set Status button
73+ cy . findByText ( 'Set Status' ) . click ( ) ;
74+ } ) ;
75+
76+ // * Modal should be closed
77+ cy . get ( '#custom_status_modal' ) . should ( 'not.exist' ) ;
78+
79+ // # Setting the time at which the custom status should be expired
80+ // # Note that we need to be flexible around accepted values, as this calculation and the server-side one may differ slightly
81+ expiresAt = dayjs ( ) . add ( waitingTime , 'minute' ) ;
82+
83+ // # Get the last post
84+ cy . getLastPostId ( ) . then ( ( postId ) => {
85+ // # Hover on the custom status emoji present in the post header
86+ cy . get ( `#post_${ postId } ` ) . find ( '.emoticon' ) . should ( 'exist' ) . trigger ( 'mouseenter' ) ;
87+
88+ // * Custom status tooltip should be visible and contain the correct custom status expiry time
89+ cy . findByRole ( 'tooltip' ) . should ( 'exist' ) . and ( 'contain.text' , expiresAt . format ( expiryTimeFormat ) ) ;
90+
91+ cy . get ( `#post_${ postId } ` ) . find ( '.emoticon' ) . trigger ( 'mouseleave' ) ;
92+ } ) ;
93+
6394 // # Click on the post header of the last post by the current user and open profile popover
6495 cy . get ( '.post.current--user .post__header .user-popover' ) . first ( ) . click ( ) ;
6596 cy . get ( 'div.user-profile-popover' ) . should ( 'exist' ) ;
0 commit comments