@@ -6,39 +6,6 @@ context ('Play', function () {
66 cy . window ( ) . its ( 'Monogatari.default' ) . as ( 'monogatari' ) ;
77 } ) ;
88
9- it ( 'Plays music correctly' , function ( ) {
10- this . monogatari . setting ( 'TypeAnimation' , false ) ;
11- this . monogatari . script ( {
12- 'Start' : [
13- 'Zero' ,
14- 'play music theme' ,
15- 'One' ,
16- ]
17- } ) ;
18-
19- cy . start ( ) ;
20-
21- cy . wrap ( this . monogatari ) . invoke ( 'state' , 'music' ) . should ( 'be.empty' ) ;
22- cy . wrap ( this . monogatari ) . invoke ( 'history' , 'music' ) . should ( 'be.empty' ) ;
23- cy . wrap ( this . monogatari ) . invoke ( 'mediaPlayers' , 'music' ) . should ( 'have.length' , 0 ) ;
24-
25- cy . get ( 'text-box' ) . contains ( 'Zero' ) ;
26-
27- cy . proceed ( ) ;
28-
29- cy . wrap ( this . monogatari ) . invoke ( 'state' , 'music' ) . should ( 'deep.equal' , [ { statement : 'play music theme' , paused : false } ] ) ;
30- cy . wrap ( this . monogatari ) . invoke ( 'history' , 'music' ) . should ( 'deep.equal' , [ 'play music theme' ] ) ;
31- cy . wrap ( this . monogatari ) . invoke ( 'mediaPlayers' , 'music' ) . should ( 'have.length' , 1 ) ;
32- cy . wrap ( this . monogatari . mediaPlayers ( 'music' , true ) ) . its ( 'theme.paused' ) . should ( 'equal' , false ) ;
33-
34- cy . get ( 'text-box' ) . contains ( 'One' ) ;
35- cy . rollback ( ) ;
36-
37- cy . wrap ( this . monogatari ) . invoke ( 'state' , 'music' ) . should ( 'be.empty' ) ;
38- cy . wrap ( this . monogatari ) . invoke ( 'history' , 'music' ) . should ( 'be.empty' ) ;
39- cy . wrap ( this . monogatari ) . invoke ( 'mediaPlayers' , 'music' ) . should ( 'have.length' , 0 ) ;
40- } ) ;
41-
429 it ( 'Plays all music correctly' , function ( ) {
4310 this . monogatari . setting ( 'TypeAnimation' , false ) ;
4411 this . monogatari . script ( {
@@ -63,6 +30,7 @@ context ('Play', function () {
6330 cy . get ( 'text-box' ) . contains ( 'Zero' ) ;
6431
6532 cy . proceed ( ) ;
33+ cy . wait ( 100 ) ; // Add a small delay to ensure async operations complete
6634
6735 cy . wrap ( this . monogatari ) . invoke ( 'state' , 'music' ) . should ( 'deep.equal' , [ { statement : 'play music theme loop' , paused : false } , { statement : 'play music subspace loop' , paused : false } ] ) ;
6836 cy . wrap ( this . monogatari ) . invoke ( 'history' , 'music' ) . should ( 'deep.equal' , [ 'play music theme loop' , 'play music subspace loop' ] ) ;
@@ -73,7 +41,16 @@ context ('Play', function () {
7341 cy . get ( 'text-box' ) . contains ( 'One' ) ;
7442
7543 cy . proceed ( ) ;
76- cy . wrap ( this . monogatari ) . invoke ( 'state' , 'music' ) . should ( 'deep.equal' , [ { statement : 'play music theme loop' , paused : true } , { statement : 'play music subspace loop' , paused : true } ] ) ;
44+ cy . wait ( 100 ) ;
45+ cy . wrap ( this . monogatari ) . invoke ( 'history' , 'music' ) . should ( 'have.length' , 2 ) ;
46+ cy . wrap ( this . monogatari ) . invoke ( 'history' , 'music' ) . should ( 'deep.equal' , [
47+ 'play music theme loop' ,
48+ 'play music subspace loop'
49+ ] ) ;
50+ cy . wrap ( this . monogatari ) . invoke ( 'state' , 'music' ) . should ( 'deep.equal' , [
51+ { statement : 'play music theme loop' , paused : true } ,
52+ { statement : 'play music subspace loop' , paused : true }
53+ ] ) ;
7754 cy . wrap ( this . monogatari ) . invoke ( 'history' , 'music' ) . should ( 'deep.equal' , [ 'play music theme loop' , 'play music subspace loop' ] ) ;
7855 cy . wrap ( this . monogatari ) . invoke ( 'mediaPlayers' , 'music' ) . should ( 'have.length' , 2 ) ;
7956 cy . wrap ( this . monogatari . mediaPlayers ( 'music' , true ) ) . its ( 'theme.paused' ) . should ( 'equal' , true ) ;
@@ -175,8 +152,8 @@ context ('Play', function () {
175152 cy . start ( ) ;
176153
177154 cy . wrap ( this . monogatari ) . invoke ( 'mediaPlayers' , 'music' ) . should ( 'have.length' , 2 ) ;
178- cy . wrap ( this . monogatari . mediaPlayers ( 'music' , true ) ) . its ( 'theme.volume' ) . should ( 'equal ' , 0.25 ) ;
179- cy . wrap ( this . monogatari . mediaPlayers ( 'music' , true ) ) . its ( 'subspace.volume' ) . should ( 'equal ' , 0.075 ) ;
155+ cy . wrap ( this . monogatari . mediaPlayers ( 'music' , true ) ) . its ( 'theme.volume' ) . should ( 'be.closeTo ' , 0.25 , 0.001 ) ;
156+ cy . wrap ( this . monogatari . mediaPlayers ( 'music' , true ) ) . its ( 'subspace.volume' ) . should ( 'be.closeTo ' , 0.075 , 0.001 ) ;
180157
181158 cy . get ( 'text-box' ) . contains ( 'One' ) ;
182159 } ) ;
@@ -196,17 +173,17 @@ context ('Play', function () {
196173 cy . start ( ) ;
197174
198175 cy . wrap ( this . monogatari ) . invoke ( 'mediaPlayers' , 'music' ) . should ( 'have.length' , 2 ) ;
199- cy . wrap ( this . monogatari . mediaPlayers ( 'music' , true ) ) . its ( 'theme.volume' ) . should ( 'equal ' , 0.25 ) ;
200- cy . wrap ( this . monogatari . mediaPlayers ( 'music' , true ) ) . its ( 'subspace.volume' ) . should ( 'equal ' , 0.075 ) ;
176+ cy . wrap ( this . monogatari . mediaPlayers ( 'music' , true ) ) . its ( 'theme.volume' ) . should ( 'be.closeTo ' , 0.25 , 0.001 ) ;
177+ cy . wrap ( this . monogatari . mediaPlayers ( 'music' , true ) ) . its ( 'subspace.volume' ) . should ( 'be.closeTo ' , 0.075 , 0.001 ) ;
201178
202179 cy . get ( 'text-box' ) . contains ( 'One' ) ;
203180
204181 cy . get ( '[data-component="quick-menu"] [data-open="settings"]' ) . click ( ) ;
205182 cy . get ( 'settings-screen' ) . should ( 'be.visible' ) ;
206183
207184 cy . get ( '[data-action="set-volume"][data-target="music"]' ) . as ( 'range' ) . invoke ( 'val' , 0.7 ) . trigger ( 'mouseover' ) ;
208- cy . wrap ( this . monogatari . mediaPlayers ( 'music' , true ) ) . its ( 'theme.volume' ) . should ( 'equal ' , 0.7 ) ;
209- cy . wrap ( this . monogatari . mediaPlayers ( 'music' , true ) ) . its ( 'subspace.volume' ) . should ( 'equal ' , 0.21 ) ;
185+ cy . wrap ( this . monogatari . mediaPlayers ( 'music' , true ) ) . its ( 'theme.volume' ) . should ( 'be.closeTo ' , 0.7 , 0.001 ) ;
186+ cy . wrap ( this . monogatari . mediaPlayers ( 'music' , true ) ) . its ( 'subspace.volume' ) . should ( 'be.closeTo ' , 0.21 , 0.001 ) ;
210187 } ) ;
211188
212189} ) ;
0 commit comments