11import { AppDataVisibility , Context , PermissionLevel } from '@graasp/sdk' ;
22
33import {
4- PLAYER_VIEW_CY ,
54 buildCommentContainerDataCy ,
65 buildDataCy ,
76} from '../../../src/config/selectors' ;
@@ -24,7 +23,7 @@ const defaultAppData = [
2423] ;
2524
2625describe ( 'Player View' , ( ) => {
27- beforeEach ( ( ) => {
26+ it ( 'Show messages and write a new one' , ( ) => {
2827 cy . setUpApi (
2928 {
3029 appData : defaultAppData ,
@@ -36,10 +35,6 @@ describe('Player View', () => {
3635 } ,
3736 ) ;
3837 cy . visit ( '/' ) ;
39- } ) ;
40-
41- it ( 'Show messages and write a new one' , ( ) => {
42- cy . get ( buildDataCy ( PLAYER_VIEW_CY ) ) . should ( 'be.visible' ) ;
4338
4439 // expect previously saved app data
4540 const previousAppData = defaultAppData [ 0 ] ;
@@ -65,4 +60,82 @@ describe('Player View', () => {
6560 'i am a bot' , // default return value of the mocked chatbot
6661 ) ;
6762 } ) ;
63+
64+ it ( 'Show cue and write a message' , ( ) => {
65+ cy . setUpApi (
66+ {
67+ appData : [ ] ,
68+ appSettings : [ MOCK_APP_SETTING ] ,
69+ } ,
70+ {
71+ context : Context . Player ,
72+ permission : PermissionLevel . Write ,
73+ } ,
74+ ) ;
75+ cy . visit ( '/' ) ;
76+
77+ // expect cue
78+ cy . get ( buildDataCy ( buildCommentContainerDataCy ( 'cue' ) ) ) . should (
79+ 'contain' ,
80+ MOCK_APP_SETTING . data . chatbotCue ,
81+ ) ;
82+
83+ // type and send message
84+ const message = 'My message' ;
85+ cy . get ( '[role="textbox"]' ) . type ( message ) ;
86+ cy . get ( '[name="send"]' ) . click ( ) ;
87+
88+ // expect user message
89+ cy . get ( buildDataCy ( buildCommentContainerDataCy ( '2' ) ) ) . should (
90+ 'contain' ,
91+ message ,
92+ ) ;
93+
94+ // expect chatbot message
95+ cy . get ( buildDataCy ( buildCommentContainerDataCy ( '3' ) ) ) . should (
96+ 'contain' ,
97+ 'i am a bot' , // default return value of the mocked chatbot
98+ ) ;
99+ } ) ;
100+
101+ it ( 'Show dates' , ( ) => {
102+ cy . setUpApi (
103+ {
104+ appData : [
105+ {
106+ account : CURRENT_MEMBER ,
107+ createdAt : '2025-11-18T16:35:22.010Z' ,
108+ creator : CURRENT_MEMBER ,
109+ data : { content : 'A previously saved message' } ,
110+ id : '0' ,
111+ item : MOCK_SERVER_ITEM ,
112+ type : 'comment' ,
113+ updatedAt : '2025-11-18T16:35:22.010Z' ,
114+ visibility : AppDataVisibility . Member ,
115+ } ,
116+ {
117+ account : CURRENT_MEMBER ,
118+ createdAt : '2024-11-18T16:35:22.010Z' ,
119+ creator : CURRENT_MEMBER ,
120+ data : { content : 'A previously saved message' } ,
121+ id : '1' ,
122+ item : MOCK_SERVER_ITEM ,
123+ type : 'comment' ,
124+ updatedAt : '2025-11-18T16:35:22.010Z' ,
125+ visibility : AppDataVisibility . Member ,
126+ } ,
127+ ] ,
128+ appSettings : [ MOCK_APP_SETTING ] ,
129+ } ,
130+ {
131+ context : Context . Player ,
132+ permission : PermissionLevel . Write ,
133+ } ,
134+ ) ;
135+ cy . visit ( '/' ) ;
136+
137+ // expect dates
138+ cy . get ( '#root' ) . should ( 'contain' , 'November 18, 2024' ) ;
139+ cy . get ( '#root' ) . should ( 'contain' , 'November 18, 2025' ) ;
140+ } ) ;
68141} ) ;
0 commit comments